initial integration with ic10editor mod

This commit is contained in:
2025-11-28 17:11:08 -07:00
parent e274b33553
commit 9a9fa9517f
10 changed files with 175 additions and 71 deletions

View File

@@ -386,9 +386,9 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
[[package]]
name = "js-sys"
version = "0.3.82"
version = "0.3.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65"
checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8"
dependencies = [
"once_cell",
"wasm-bindgen",
@@ -967,9 +967,9 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]]
name = "wasm-bindgen"
version = "0.2.105"
version = "0.2.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60"
checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd"
dependencies = [
"cfg-if",
"once_cell",
@@ -980,9 +980,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.105"
version = "0.2.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2"
checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -990,9 +990,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.105"
version = "0.2.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc"
checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40"
dependencies = [
"bumpalo",
"proc-macro2",
@@ -1003,9 +1003,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.105"
version = "0.2.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76"
checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4"
dependencies = [
"unicode-ident",
]
@@ -1027,9 +1027,9 @@ dependencies = [
[[package]]
name = "winnow"
version = "0.7.13"
version = "0.7.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf"
checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829"
dependencies = [
"memchr",
]

View File

@@ -1125,9 +1125,7 @@ impl<'a, W: std::io::Write> Compiler<'a, W> {
}))
}
_ => {
todo!()
}
t => Err(Error::Unknown(format!("{t:?}\n\nNot yet implemented"))),
}
}

View File

@@ -1260,7 +1260,9 @@ impl<'a> Parser<'a> {
let arg = literal_or_variable!(invocation.arguments.first());
Ok(SysCall::Math(sys_call::Math::Trunc(arg)))
}
_ => todo!(),
_ => Err(Error::UnsupportedKeyword(token_from_option!(
self.current_token
))),
}
}
}

View File

@@ -457,7 +457,11 @@ impl<'a> Iterator for Tokenizer<'a> {
type Item = Result<Token, Error>;
fn next(&mut self) -> Option<Self::Item> {
todo!()
match self.next_token() {
Ok(Some(tok)) => Some(Ok(tok)),
Ok(None) => None,
Err(e) => Some(Err(e)),
}
}
}

View File

@@ -8,9 +8,9 @@ use tokenizer::{Error as TokenizerError, Tokenizer};
#[repr(C)]
pub struct FfiToken {
pub text: safer_ffi::String,
pub tooltip: Option<safer_ffi::String>,
pub error: Option<safer_ffi::String>,
pub status: Option<safer_ffi::String>,
pub tooltip: safer_ffi::String,
pub error: safer_ffi::String,
pub status: safer_ffi::String,
pub column: i32,
}
@@ -56,18 +56,18 @@ pub fn tokenize_line(input: safer_ffi::slice::Ref<'_, u16>) -> safer_ffi::Vec<Ff
tokens.push(FfiToken {
column: col as i32,
text: "".into(),
tooltip: None,
tooltip: "".into(),
// Safety: it's okay to unwrap the err here because we are matching on the `Err` variant
error: Some(token.unwrap_err().to_string().into()),
status: None,
error: token.unwrap_err().to_string().into(),
status: "".into(),
});
}
Err(_) => return safer_ffi::Vec::EMPTY,
Ok(token) => tokens.push(FfiToken {
text: token.token_type.to_string().into(),
tooltip: None,
error: None,
status: None,
tooltip: "".into(),
error: "".into(),
status: "".into(),
column: token.column as i32,
}),
}
@@ -88,8 +88,19 @@ pub fn free_string(s: safer_ffi::String) {
#[cfg(feature = "headers")]
pub fn generate_headers() -> std::io::Result<()> {
let file_name = "../csharp_mod/FfiGlue.cs";
::safer_ffi::headers::builder()
.with_language(safer_ffi::headers::Language::CSharp)
.to_file("../csharp_mod/FfiGlue.cs")?
.generate()
.to_file(file_name)?
.generate()?;
let content = std::fs::read_to_string(file_name)?;
let content = content.replace(
"private const string RustLib = \"slang\";",
"public const string RustLib = \"slang_compiler.dll\";",
);
std::fs::write(file_name, content)?;
Ok(())
}