Compare commits
No commits in common. "77107ef95e27a7ad5ccb9e1a901ccde1f9d01785" and "8d8d6ac336c0ce6b255a7715d48da46b63c6f99b" have entirely different histories.
77107ef95e
...
8d8d6ac336
302
Cargo.lock
generated
302
Cargo.lock
generated
@ -17,59 +17,12 @@ version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
||||
|
||||
[[package]]
|
||||
name = "android-tzdata"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
|
||||
|
||||
[[package]]
|
||||
name = "android_system_properties"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.98"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"
|
||||
|
||||
[[package]]
|
||||
name = "argh"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34ff18325c8a36b82f992e533ece1ec9f9a9db446bd1c14d4f936bac88fcd240"
|
||||
dependencies = [
|
||||
"argh_derive",
|
||||
"argh_shared",
|
||||
"rust-fuzzy-search",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "argh_derive"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adb7b2b83a50d329d5d8ccc620f5c7064028828538bdf5646acd60dc1f767803"
|
||||
dependencies = [
|
||||
"argh_shared",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "argh_shared"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a464143cc82dedcdc3928737445362466b7674b5db4e2eb8e869846d6d84f4f6"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.88"
|
||||
@ -125,12 +78,6 @@ version = "2.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.10.1"
|
||||
@ -152,20 +99,6 @@ version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d"
|
||||
dependencies = [
|
||||
"android-tzdata",
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"wasm-bindgen",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "colored"
|
||||
version = "3.0.0"
|
||||
@ -175,12 +108,6 @@ dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.21"
|
||||
@ -323,42 +250,12 @@ version = "0.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c"
|
||||
|
||||
[[package]]
|
||||
name = "httparse"
|
||||
version = "1.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"core-foundation-sys",
|
||||
"iana-time-zone-haiku",
|
||||
"js-sys",
|
||||
"log",
|
||||
"wasm-bindgen",
|
||||
"windows-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone-haiku"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_collections"
|
||||
version = "2.0.0"
|
||||
@ -477,33 +374,12 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is-terminal"
|
||||
version = "0.4.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.77"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
@ -546,12 +422,6 @@ dependencies = [
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
||||
|
||||
[[package]]
|
||||
name = "lsp-types"
|
||||
version = "0.94.1"
|
||||
@ -786,11 +656,8 @@ checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a"
|
||||
name = "reid"
|
||||
version = "1.0.0-beta.4"
|
||||
dependencies = [
|
||||
"argh",
|
||||
"colored",
|
||||
"log",
|
||||
"reid-lib",
|
||||
"stderrlog",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
@ -815,24 +682,12 @@ dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-fuzzy-search"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a157657054ffe556d8858504af8a672a054a6e0bd9e8ee531059100c0fa11bb2"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace"
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.20"
|
||||
@ -947,19 +802,6 @@ version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
|
||||
[[package]]
|
||||
name = "stderrlog"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61c910772f992ab17d32d6760e167d2353f4130ed50e796752689556af07dc6b"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"is-terminal",
|
||||
"log",
|
||||
"termcolor",
|
||||
"thread_local",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.104"
|
||||
@ -982,15 +824,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.69"
|
||||
@ -1011,15 +844,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinystr"
|
||||
version = "0.8.1"
|
||||
@ -1195,132 +1019,6 @@ version = "0.11.1+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"rustversion",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.61.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"
|
||||
dependencies = [
|
||||
"windows-implement",
|
||||
"windows-interface",
|
||||
"windows-link",
|
||||
"windows-result",
|
||||
"windows-strings",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-implement"
|
||||
version = "0.60.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-interface"
|
||||
version = "0.59.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"
|
||||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-strings"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
|
@ -16,7 +16,7 @@ BINARY="$(echo $1 | cut -d'.' -f1)"".out"
|
||||
|
||||
echo $1
|
||||
|
||||
cargo run -p reid $@ && \
|
||||
cargo run --example cli $@ && \
|
||||
./$BINARY ; echo "Return value: ""$?"
|
||||
|
||||
## Command from: clang -v hello.o -o test
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
use llvm_sys::core::LLVMBuildIsNull;
|
||||
|
||||
use crate::{
|
||||
Block, BlockData, CompileResult, ConstValueKind, CustomTypeKind, ErrorKind, FunctionData, Instr, InstructionData,
|
||||
ModuleData, NamedStruct, TerminatorKind, Type, TypeCategory, TypeData,
|
||||
|
@ -74,19 +74,5 @@
|
||||
"indentationRules": {
|
||||
"increaseIndentPattern": "^((?!\\/\\/).)*(\\{[^}\"'`]*|\\([^)\"'`]*|\\[[^\\]\"'`]*)$",
|
||||
"decreaseIndentPattern": "^((?!.*?\\/\\*).*\\*/)?\\s*[\\)\\}\\]].*$"
|
||||
},
|
||||
"colorizedBracketPairs": [
|
||||
[
|
||||
"(",
|
||||
")"
|
||||
],
|
||||
[
|
||||
"[",
|
||||
"]"
|
||||
],
|
||||
[
|
||||
"{",
|
||||
"}"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
@ -2,15 +2,16 @@ use std::{collections::HashMap, hash::Hash, path::PathBuf};
|
||||
|
||||
use reid::{
|
||||
ast::{
|
||||
ReturnType,
|
||||
lexer::{FullToken, Token},
|
||||
token_stream::TokenRange,
|
||||
},
|
||||
codegen::intrinsics::get_intrinsic_assoc_functions,
|
||||
codegen::intrinsics::{self, get_intrinsic_assoc_functions},
|
||||
compile_module,
|
||||
error_raporting::{ErrorModules, ReidError},
|
||||
mir::{
|
||||
self, Context, CustomTypeKey, FunctionCall, FunctionParam, IfExpression, Metadata, SourceModuleId, StructType,
|
||||
TypeKind, WhileStatement, typecheck::typerefs::TypeRefs,
|
||||
self, Context, CustomTypeKey, FunctionCall, FunctionDefinitionKind, FunctionParam, IfExpression, Metadata,
|
||||
SourceModuleId, StructType, TypeKind, WhileStatement, typecheck::typerefs::TypeRefs,
|
||||
},
|
||||
perform_all_passes,
|
||||
};
|
||||
@ -199,6 +200,26 @@ impl AnalysisState {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_documentation(&mut self, token_idx: usize, documentation: Option<String>) {
|
||||
if let Some(documentation) = documentation {
|
||||
if let Some(token) = self.map.get_mut(&token_idx) {
|
||||
token.hover.documentation = Some(documentation);
|
||||
} else {
|
||||
self.map.insert(
|
||||
token_idx,
|
||||
SemanticToken {
|
||||
hover: Hover {
|
||||
documentation: Some(documentation),
|
||||
kind: None,
|
||||
},
|
||||
autocomplete: Vec::new(),
|
||||
symbol: Default::default(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_symbol(&mut self, idx: usize, symbol: SymbolId) {
|
||||
self.symbol_to_token.insert(symbol, idx);
|
||||
if let Some(token) = self.map.get_mut(&idx) {
|
||||
@ -696,7 +717,7 @@ pub fn analyze_context(
|
||||
|
||||
let mut inner_scope = scope.inner();
|
||||
|
||||
analyze_function_parameters(module, function, &mut inner_scope);
|
||||
analyze_function_parameters(context, module, function, &mut inner_scope);
|
||||
|
||||
match &function.kind {
|
||||
mir::FunctionDefinitionKind::Local(block, _) => analyze_block(context, module, block, &mut inner_scope),
|
||||
@ -758,7 +779,7 @@ pub fn analyze_context(
|
||||
|
||||
let mut inner_scope = scope.inner();
|
||||
|
||||
analyze_function_parameters(module, function, &mut inner_scope);
|
||||
analyze_function_parameters(context, module, function, &mut inner_scope);
|
||||
|
||||
match &function.kind {
|
||||
mir::FunctionDefinitionKind::Local(block, _) => analyze_block(context, module, block, &mut inner_scope),
|
||||
@ -851,6 +872,7 @@ pub fn analyze_context(
|
||||
}
|
||||
|
||||
pub fn analyze_function_parameters(
|
||||
context: &mir::Context,
|
||||
module: &mir::Module,
|
||||
function: &mir::FunctionDefinition,
|
||||
scope: &mut AnalysisScope,
|
||||
|
@ -9,15 +9,15 @@ use reid::parse_module;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::sync::Mutex;
|
||||
use tower_lsp::lsp_types::{
|
||||
self, CompletionItem, CompletionOptions, CompletionParams, CompletionResponse, Diagnostic, DiagnosticSeverity,
|
||||
DidChangeTextDocumentParams, DidOpenTextDocumentParams, DidSaveTextDocumentParams, DocumentFilter,
|
||||
GotoDefinitionParams, GotoDefinitionResponse, Hover, HoverContents, HoverParams, HoverProviderCapability,
|
||||
InitializeParams, InitializeResult, InitializedParams, Location, MarkedString, MarkupContent, MarkupKind,
|
||||
MessageType, OneOf, Range, ReferenceParams, RenameParams, SemanticToken, SemanticTokensLegend,
|
||||
SemanticTokensOptions, SemanticTokensParams, SemanticTokensResult, SemanticTokensServerCapabilities,
|
||||
ServerCapabilities, TextDocumentItem, TextDocumentRegistrationOptions, TextDocumentSyncCapability,
|
||||
TextDocumentSyncKind, TextDocumentSyncOptions, TextDocumentSyncSaveOptions, TextEdit, Url, WorkspaceEdit,
|
||||
WorkspaceFoldersServerCapabilities, WorkspaceServerCapabilities,
|
||||
self, CompletionItem, CompletionItemKind, CompletionOptions, CompletionParams, CompletionResponse, Diagnostic,
|
||||
DiagnosticSeverity, DidChangeTextDocumentParams, DidOpenTextDocumentParams, DidSaveTextDocumentParams,
|
||||
DocumentFilter, GotoDefinitionParams, GotoDefinitionResponse, Hover, HoverContents, HoverParams,
|
||||
HoverProviderCapability, InitializeParams, InitializeResult, InitializedParams, Location, MarkedString,
|
||||
MarkupContent, MarkupKind, MessageType, OneOf, Range, ReferenceParams, RenameParams, SemanticToken,
|
||||
SemanticTokensLegend, SemanticTokensOptions, SemanticTokensParams, SemanticTokensResult,
|
||||
SemanticTokensServerCapabilities, ServerCapabilities, TextDocumentItem, TextDocumentRegistrationOptions,
|
||||
TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions, TextDocumentSyncSaveOptions, TextEdit,
|
||||
Url, WorkspaceEdit, WorkspaceFoldersServerCapabilities, WorkspaceServerCapabilities,
|
||||
};
|
||||
use tower_lsp::{Client, LanguageServer, LspService, Server, jsonrpc};
|
||||
|
||||
@ -65,7 +65,7 @@ impl LanguageServer for Backend {
|
||||
completion_item: Some(lsp_types::CompletionOptionsCompletionItem {
|
||||
label_details_support: Some(true),
|
||||
}),
|
||||
resolve_provider: Some(false),
|
||||
resolve_provider: Some(true),
|
||||
work_done_progress_options: lsp_types::WorkDoneProgressOptions {
|
||||
work_done_progress: Some(true),
|
||||
},
|
||||
@ -172,6 +172,20 @@ impl LanguageServer for Backend {
|
||||
Ok(Some(CompletionResponse::Array(list)))
|
||||
}
|
||||
|
||||
async fn completion_resolve(&self, params: CompletionItem) -> jsonrpc::Result<CompletionItem> {
|
||||
let data: Option<CompletionData> = if let Some(data) = ¶ms.data {
|
||||
serde_json::from_value(data.clone()).ok()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
if let Some(data) = data {
|
||||
let analysis = self.analysis.get(&data.path).unwrap();
|
||||
let token = analysis.tokens.get(data.token_idx).unwrap();
|
||||
if let Some(token_analysis) = analysis.state.map.get(&data.token_idx) {}
|
||||
}
|
||||
Ok(params)
|
||||
}
|
||||
|
||||
async fn hover(&self, params: HoverParams) -> jsonrpc::Result<Option<Hover>> {
|
||||
let path = PathBuf::from(params.text_document_position_params.text_document.uri.path());
|
||||
let analysis = self.analysis.get(&path);
|
||||
|
@ -7,17 +7,15 @@ edition = "2021"
|
||||
|
||||
|
||||
[features]
|
||||
default = ["color", "cli"]
|
||||
default = ["color"]
|
||||
|
||||
color = ["colored"]
|
||||
cli = ["argh", "stderrlog"]
|
||||
log_output = []
|
||||
context_debug = []
|
||||
|
||||
[dependencies]
|
||||
## Make it easier to generate errors
|
||||
thiserror = "1.0.44"
|
||||
reid-lib = { path = "../reid-llvm-lib", version = "1.0.0-beta.4", registry="gitea-teascade" }
|
||||
|
||||
argh = { version = "0.1.13", optional = true }
|
||||
stderrlog = { version = "0.6.0", optional = true }
|
||||
log = "*"
|
||||
colored = { version = "3.0.0", optional = true }
|
||||
colored = {version = "3.0.0", optional = true}
|
@ -37,13 +37,16 @@ fn main() -> Result<(), std::io::Error> {
|
||||
},
|
||||
CustomIRs { llir, mir },
|
||||
)) => {
|
||||
log::trace!("{}", _llvm_ir);
|
||||
log::debug!("Compiled with triple: {}\n", &_triple);
|
||||
log::debug!("Output LLVM IR to {:?}", llvm_ir_path);
|
||||
log::debug!("Output Assembly to {:?}", asm_path);
|
||||
log::debug!("Output Object-file to {:?}\n", object_path);
|
||||
log::debug!("Output LLIR-file to {:?}\n", llir_path);
|
||||
log::debug!("Output MIR-file to {:?}\n", mir_path);
|
||||
#[cfg(feature = "log_output")]
|
||||
{
|
||||
println!("{}", _llvm_ir);
|
||||
println!("Compiled with triple: {}\n", &_triple);
|
||||
println!("Output LLVM IR to {:?}", llvm_ir_path);
|
||||
println!("Output Assembly to {:?}", asm_path);
|
||||
println!("Output Object-file to {:?}\n", object_path);
|
||||
println!("Output LLIR-file to {:?}\n", llir_path);
|
||||
println!("Output MIR-file to {:?}\n", mir_path);
|
||||
}
|
||||
|
||||
fs::write(&llvm_ir_path, &_llvm_ir).expect("Could not write LLVM IR -file!");
|
||||
fs::write(&asm_path, &assembly).expect("Could not write Assembly-file!");
|
||||
@ -68,7 +71,8 @@ fn main() -> Result<(), std::io::Error> {
|
||||
Err(e) => panic!("{}", e),
|
||||
};
|
||||
} else {
|
||||
log::error!("Please input compiled file path!")
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("Please input compiled file path!")
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ impl LDRunner {
|
||||
let dyn_linker_path = find_objectfile(&self.dynamic_linker);
|
||||
let crt1_path = find_objectfile("crt1.o");
|
||||
|
||||
log::debug!("LDRunner: Using dynamic linker at: {:?}", dyn_linker_path);
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("LDRunner: Using dynamic linker at: {:?}", dyn_linker_path);
|
||||
|
||||
let mut ld = Command::new(&self.command);
|
||||
ld.arg("-dynamic-linker").arg(dyn_linker_path).arg(crt1_path);
|
||||
@ -39,36 +40,21 @@ impl LDRunner {
|
||||
.arg("-o")
|
||||
.arg(out_path.to_str().unwrap());
|
||||
|
||||
log::debug!(
|
||||
#[cfg(feature = "log_output")]
|
||||
println!(
|
||||
"LDRunner: Executing linker to objfile at {:?} => {:?}",
|
||||
input_path,
|
||||
out_path
|
||||
input_path, out_path
|
||||
);
|
||||
#[cfg(feature = "log_output")]
|
||||
dbg!(&ld);
|
||||
|
||||
let ld_output = ld.output().expect("Unable to execute ld!");
|
||||
if !ld_output.status.success() {
|
||||
let code = ld_output.status.code().unwrap_or(255);
|
||||
log::error!("LD exited with code {code}");
|
||||
println!("{}", unsafe { String::from_utf8_unchecked(ld_output.stderr) });
|
||||
return;
|
||||
}
|
||||
ld.spawn().expect("Unable to execute ld!");
|
||||
|
||||
thread::sleep(Duration::from_millis(100));
|
||||
|
||||
log::debug!("Setting executable bit to {:?}..", out_path);
|
||||
|
||||
let chmod_output = Command::new("chmod")
|
||||
.arg("+x")
|
||||
.arg(out_path)
|
||||
.output()
|
||||
.expect("Unable to execute ld!");
|
||||
|
||||
if !chmod_output.status.success() {
|
||||
let code = chmod_output.status.code().unwrap_or(255);
|
||||
log::error!("chmod exited with code {code}");
|
||||
println!("{}", unsafe { String::from_utf8_unchecked(chmod_output.stderr) });
|
||||
return;
|
||||
}
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("Setting executable bit to {:?}..", out_path);
|
||||
Command::new("chmod").arg("+x").arg(out_path).spawn().unwrap();
|
||||
thread::sleep(Duration::from_millis(100));
|
||||
}
|
||||
}
|
||||
@ -78,12 +64,6 @@ fn find_objectfile(name: &str) -> String {
|
||||
.arg(&name)
|
||||
.output()
|
||||
.expect("Unable to execute whereis");
|
||||
if !whereis.status.success() {
|
||||
let code = whereis.status.code().unwrap_or(255);
|
||||
log::error!("whereis exited with code {code}");
|
||||
println!("{}", unsafe { String::from_utf8_unchecked(whereis.stderr) });
|
||||
panic!();
|
||||
}
|
||||
let whereis_output = String::from_utf8(whereis.stdout).unwrap();
|
||||
|
||||
whereis_output
|
||||
|
@ -98,7 +98,8 @@ pub fn parse_module<'map, T: Into<String>>(
|
||||
map.set_tokens(id, tokens.clone());
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:#?}", &tokens);
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("{:#?}", &tokens);
|
||||
|
||||
Ok((id, tokens))
|
||||
}
|
||||
@ -157,7 +158,8 @@ pub fn compile_module<'map>(
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:#?}", &ast_module);
|
||||
#[cfg(feature = "log_output")]
|
||||
dbg!(&ast_module);
|
||||
|
||||
Ok(Ok(ast_module.process(module_id)))
|
||||
}
|
||||
@ -167,10 +169,12 @@ pub fn perform_all_passes<'map>(
|
||||
module_map: &'map mut ErrorModules,
|
||||
) -> Result<(), ReidError> {
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:#?}", &context);
|
||||
#[cfg(feature = "log_output")]
|
||||
dbg!(&context);
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:#}", &context);
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("{:#}", &context);
|
||||
|
||||
let state = context.pass(&mut LinkerPass {
|
||||
module_map,
|
||||
@ -184,11 +188,14 @@ pub fn perform_all_passes<'map>(
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:-^100}", "LINKER OUTPUT");
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("{:-^100}", "LINKER OUTPUT");
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:#}", &context);
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("{:#}", &context);
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:#?}", &state);
|
||||
#[cfg(feature = "log_output")]
|
||||
dbg!(&state);
|
||||
|
||||
if !state.errors.is_empty() {
|
||||
return Err(ReidError::from_kind(
|
||||
@ -209,11 +216,14 @@ pub fn perform_all_passes<'map>(
|
||||
let state = context.pass(&mut macro_pass)?;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:-^100}", "MACRO OUTPUT");
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("{:-^100}", "MACRO OUTPUT");
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:#}", &context);
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("{:#}", &context);
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:#?}", &state);
|
||||
#[cfg(feature = "log_output")]
|
||||
dbg!(&state);
|
||||
|
||||
if !state.errors.is_empty() {
|
||||
return Err(ReidError::from_kind(
|
||||
@ -247,13 +257,17 @@ pub fn perform_all_passes<'map>(
|
||||
let state = context.pass(&mut TypeInference { refs: &mut refs })?;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:-^70}", "TYPE INFERRER OUTPUT");
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("{:-^100}", "TYPE INFERRER OUTPUT");
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{}", &refs);
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("{}", &refs);
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:#}", &context);
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("{:#}", &context);
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:#?}", &state);
|
||||
#[cfg(feature = "log_output")]
|
||||
dbg!(&state);
|
||||
|
||||
if !state.errors.is_empty() {
|
||||
return Err(ReidError::from_kind(
|
||||
@ -269,11 +283,14 @@ pub fn perform_all_passes<'map>(
|
||||
let state = context.pass(&mut TypeCheck { refs: &refs })?;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:-^100}", "TYPECHECKER OUTPUT");
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("{:-^100}", "TYPECHECKER OUTPUT");
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:#}", &context);
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("{:#}", &context);
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:#?}", &state);
|
||||
#[cfg(feature = "log_output")]
|
||||
dbg!(&state);
|
||||
|
||||
if !state.errors.is_empty() {
|
||||
return Err(ReidError::from_kind(
|
||||
@ -286,6 +303,9 @@ pub fn perform_all_passes<'map>(
|
||||
));
|
||||
}
|
||||
|
||||
#[cfg(feature = "context_debug")]
|
||||
dbg!(&context);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -310,9 +330,11 @@ pub fn compile_and_pass<'map>(
|
||||
perform_all_passes(&mut mir_context, module_map)?;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:-^100}", "FINAL OUTPUT");
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("{:-^100}", "FINAL OUTPUT");
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{:#}", &mir_context);
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("{:#}", &mir_context);
|
||||
|
||||
let mut context = Context::new(format!("Reid ({})", env!("CARGO_PKG_VERSION")));
|
||||
let codegen_modules = match mir_context.codegen(&mut context) {
|
||||
@ -321,7 +343,8 @@ pub fn compile_and_pass<'map>(
|
||||
};
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("{}", &codegen_modules.context);
|
||||
#[cfg(feature = "log_output")]
|
||||
println!("{}", &codegen_modules.context);
|
||||
|
||||
let compiled = codegen_modules.compile(cpu, features);
|
||||
Ok((
|
||||
|
120
reid/src/main.rs
120
reid/src/main.rs
@ -1,120 +0,0 @@
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
use argh::FromArgs;
|
||||
use log::*;
|
||||
use reid::{compile_simple, ld::LDRunner, CustomIRs};
|
||||
use reid_lib::compile::CompileOutput;
|
||||
|
||||
#[derive(FromArgs, PartialEq, Debug)]
|
||||
/// Compile or run a Reid (.reid) file
|
||||
#[argh(help_triggers("-h", "--help", "help"))]
|
||||
struct Options {
|
||||
#[argh(option, short = 'l', default = "log::Level::Info")]
|
||||
/// log level
|
||||
log_level: log::Level,
|
||||
#[argh(switch, short = 't')]
|
||||
/// should logs be timestamped
|
||||
timestamps: bool,
|
||||
#[argh(subcommand)]
|
||||
command: Command,
|
||||
}
|
||||
|
||||
#[derive(FromArgs, PartialEq, Debug)]
|
||||
#[argh(subcommand)]
|
||||
enum Command {
|
||||
Build(BuildOpts),
|
||||
}
|
||||
|
||||
#[derive(FromArgs, PartialEq, Debug)]
|
||||
/// Build an executable file without running it
|
||||
#[argh(subcommand, name = "build")]
|
||||
struct BuildOpts {
|
||||
#[argh(option, long = "lib", short = 'l')]
|
||||
/// additional libraries to link against (with ld)
|
||||
libraries: Vec<String>,
|
||||
#[argh(positional)]
|
||||
path: PathBuf,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let options: Options = argh::from_env();
|
||||
let mut errlog = stderrlog::new();
|
||||
errlog.module(module_path!()).verbosity(options.log_level);
|
||||
if options.timestamps {
|
||||
errlog.timestamp(stderrlog::Timestamp::Second);
|
||||
}
|
||||
errlog.init().unwrap();
|
||||
|
||||
match options.command {
|
||||
Command::Build(build) => {
|
||||
let cpu = std::env::var("CPU").unwrap_or("generic".to_owned());
|
||||
let features = std::env::var("REIDFLAGS").unwrap_or("".to_owned());
|
||||
|
||||
let path = match build.path.canonicalize() {
|
||||
Ok(path) => path,
|
||||
Err(e) => {
|
||||
error!("{e}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let parent = path.with_extension("");
|
||||
let llvm_ir_path = parent.with_extension("ll");
|
||||
let object_path = parent.with_extension("o");
|
||||
let llir_path = parent.with_extension("llir");
|
||||
let mir_path = parent.with_extension("mir");
|
||||
let asm_path = parent.with_extension("asm");
|
||||
|
||||
let before = std::time::SystemTime::now();
|
||||
|
||||
let text = match fs::read_to_string(&path) {
|
||||
Ok(text) => text,
|
||||
Err(e) => {
|
||||
error!("Could not read file: {e}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
match compile_simple(&text, PathBuf::from(&path), Some(cpu), vec![features]) {
|
||||
Ok((
|
||||
CompileOutput {
|
||||
triple: _triple,
|
||||
assembly,
|
||||
obj_buffer,
|
||||
llvm_ir: _llvm_ir,
|
||||
},
|
||||
CustomIRs { llir, mir },
|
||||
)) => {
|
||||
log::trace!("{}", _llvm_ir);
|
||||
log::debug!("Compiled with triple: {}\n", &_triple);
|
||||
log::debug!("Output LLVM IR to {:?}", llvm_ir_path);
|
||||
log::debug!("Output Assembly to {:?}", asm_path);
|
||||
log::debug!("Output Object-file to {:?}\n", object_path);
|
||||
log::debug!("Output LLIR-file to {:?}\n", llir_path);
|
||||
log::debug!("Output MIR-file to {:?}\n", mir_path);
|
||||
|
||||
fs::write(&llvm_ir_path, &_llvm_ir).expect("Could not write LLVM IR -file!");
|
||||
fs::write(&asm_path, &assembly).expect("Could not write Assembly-file!");
|
||||
fs::write(&object_path, &obj_buffer).expect("Could not write Object-file!");
|
||||
fs::write(&llir_path, &llir).expect("Could not write LLIR-file!");
|
||||
fs::write(&mir_path, &mir).expect("Could not write MIR-file!");
|
||||
let after = std::time::SystemTime::now();
|
||||
log::info!(
|
||||
"Compilation took: {:.2}ms\n",
|
||||
(after.duration_since(before).unwrap().as_micros() as f32) / 1000.
|
||||
);
|
||||
|
||||
log::info!("Linking {:?}", &object_path);
|
||||
|
||||
let linker = std::env::var("LD").unwrap_or("ld".to_owned());
|
||||
let mut linker = LDRunner::from_command(&linker).with_library("c").with_library("m");
|
||||
for library in build.libraries {
|
||||
linker = linker.with_library(&library);
|
||||
}
|
||||
linker.invoke(&object_path, &object_path.with_extension("out"));
|
||||
}
|
||||
Err(e) => panic!("{}", e),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user