feat: C backend module import support, Int/Float.toString, Test.assertEqualMsg
The C backend can now compile programs that import user-defined modules. Module-qualified calls like `mymodule.func(args)` are resolved to prefixed C functions (e.g., `mymodule_func_lux`), with full support for transitive imports and effect-passing. Also adds Int.toString/Float.toString to type system, interpreter, and C backend, and Test.assertEqualMsg for labeled test assertions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
13
src/main.rs
13
src/main.rs
@@ -174,9 +174,14 @@ fn main() {
|
||||
.and_then(|s| s.parse::<u16>().ok())
|
||||
.unwrap_or(8080);
|
||||
|
||||
let dir = args.get(2)
|
||||
.filter(|a| !a.starts_with('-'))
|
||||
.map(|s| s.as_str())
|
||||
let port_value_idx = args.iter()
|
||||
.position(|a| a == "--port" || a == "-p")
|
||||
.map(|i| i + 1);
|
||||
let dir = args.iter().enumerate()
|
||||
.skip(2)
|
||||
.filter(|(i, a)| !a.starts_with('-') && Some(*i) != port_value_idx)
|
||||
.map(|(_, a)| a.as_str())
|
||||
.next()
|
||||
.unwrap_or(".");
|
||||
|
||||
serve_static_files(dir, port);
|
||||
@@ -842,7 +847,7 @@ fn compile_to_c(path: &str, output_path: Option<&str>, run_after: bool, emit_c:
|
||||
|
||||
// Generate C code
|
||||
let mut backend = CBackend::new();
|
||||
let c_code = match backend.generate(&program) {
|
||||
let c_code = match backend.generate(&program, loader.module_cache()) {
|
||||
Ok(code) => code,
|
||||
Err(e) => {
|
||||
eprintln!("{} C codegen: {}", c(colors::RED, "error:"), e);
|
||||
|
||||
Reference in New Issue
Block a user