mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
working codegen
This commit is contained in:
parent
e7f9ff8b51
commit
8c99cdf817
5 changed files with 103 additions and 68 deletions
|
@ -267,7 +267,6 @@ macro_rules! assert_evals_to {
|
|||
};
|
||||
($src:expr, $expected:expr, $ty:ty, $transform:expr, $leak:expr, $lazy_literals:expr) => {
|
||||
use bumpalo::Bump;
|
||||
use roc_gen_dev::run_jit_function_raw;
|
||||
|
||||
let arena = Bump::new();
|
||||
let (main_fn_name, errors, lib) =
|
||||
|
@ -279,7 +278,29 @@ macro_rules! assert_evals_to {
|
|||
let given = $transform(success);
|
||||
assert_eq!(&given, &expected);
|
||||
};
|
||||
run_jit_function_raw!(lib, main_fn_name, $ty, transform, errors)
|
||||
|
||||
unsafe {
|
||||
let main: libloading::Symbol<unsafe extern "C" fn() -> $ty> = lib
|
||||
.get(main_fn_name.as_bytes())
|
||||
.ok()
|
||||
.ok_or(format!("Unable to JIT compile `{}`", main_fn_name))
|
||||
.expect("errored");
|
||||
|
||||
let result = main();
|
||||
|
||||
if !errors.is_empty() {
|
||||
dbg!(&errors);
|
||||
|
||||
assert_eq!(
|
||||
errors,
|
||||
std::vec::Vec::new(),
|
||||
"Encountered errors: {:?}",
|
||||
errors
|
||||
);
|
||||
}
|
||||
|
||||
transform(result)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue