jit works yay

This commit is contained in:
2023-12-27 10:27:18 -08:00
parent e5db6640f2
commit 5936f5a0d9
3 changed files with 77 additions and 233 deletions

View File

@@ -1,5 +1,6 @@
use clap::Parser;
use codespan_reporting::files::SimpleFiles;
use ngr::backend::Backend;
use ngr::eval::Value;
use ngr::syntax;
use ngr::type_infer::TypeInferenceResult;
@@ -70,5 +71,12 @@ fn main() -> Result<(), anyhow::Error> {
return Ok(());
}
unimplemented!();
}
let mut backend = Backend::jit(None)?;
let function_id = backend.compile_program("gogogo", ir)?;
backend.module.finalize_definitions()?;
let compiled_bytes = backend.bytes(function_id);
let compiled_function = unsafe { std::mem::transmute::<_, fn() -> ()>(compiled_bytes) };
compiled_function();
Ok(())
}