mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
Fix wasm module
This commit is contained in:
parent
650d3e6321
commit
f2a42affd1
2 changed files with 18 additions and 10 deletions
|
@ -111,7 +111,7 @@ fn compile_roc_to_wasm_bytes<'a, T: Wasm32Result>(
|
|||
procedures,
|
||||
mut interns,
|
||||
exposed_to_host,
|
||||
layout_interner,
|
||||
mut layout_interner,
|
||||
..
|
||||
} = loaded;
|
||||
|
||||
|
@ -125,7 +125,6 @@ fn compile_roc_to_wasm_bytes<'a, T: Wasm32Result>(
|
|||
|
||||
let env = roc_gen_wasm::Env {
|
||||
arena,
|
||||
layout_interner: &layout_interner,
|
||||
module_id,
|
||||
exposed_to_host,
|
||||
stack_bytes: roc_gen_wasm::Env::DEFAULT_STACK_BYTES,
|
||||
|
@ -140,8 +139,13 @@ fn compile_roc_to_wasm_bytes<'a, T: Wasm32Result>(
|
|||
)
|
||||
});
|
||||
|
||||
let (mut module, mut called_fns, main_fn_index) =
|
||||
roc_gen_wasm::build_app_module(&env, &mut interns, host_module, procedures);
|
||||
let (mut module, mut called_fns, main_fn_index) = roc_gen_wasm::build_app_module(
|
||||
&env,
|
||||
&mut layout_interner,
|
||||
&mut interns,
|
||||
host_module,
|
||||
procedures,
|
||||
);
|
||||
|
||||
T::insert_wrapper(arena, &mut module, TEST_WRAPPER_NAME, main_fn_index);
|
||||
called_fns.push(true);
|
||||
|
|
|
@ -141,7 +141,7 @@ struct BackendInputs<'a> {
|
|||
}
|
||||
|
||||
impl<'a> BackendInputs<'a> {
|
||||
fn new(arena: &'a Bump, layout_interner: &'a STLayoutInterner<'a>) -> Self {
|
||||
fn new(arena: &'a Bump) -> Self {
|
||||
// Compile the host from an external source file
|
||||
let host_bytes = fs::read(LINKING_TEST_HOST_WASM).unwrap();
|
||||
let host_module: WasmModule = roc_gen_wasm::parse_host(arena, &host_bytes).unwrap();
|
||||
|
@ -159,7 +159,6 @@ impl<'a> BackendInputs<'a> {
|
|||
exposed_to_host.insert(roc_main_sym);
|
||||
let env = Env {
|
||||
arena,
|
||||
layout_interner,
|
||||
module_id,
|
||||
exposed_to_host,
|
||||
stack_bytes: Env::DEFAULT_STACK_BYTES,
|
||||
|
@ -263,22 +262,27 @@ fn test_help(
|
|||
dump_filename: &str,
|
||||
) {
|
||||
let arena = Bump::new();
|
||||
let layout_interner = STLayoutInterner::with_capacity(4);
|
||||
let mut layout_interner = STLayoutInterner::with_capacity(4);
|
||||
|
||||
let BackendInputs {
|
||||
env,
|
||||
mut interns,
|
||||
host_module,
|
||||
procedures,
|
||||
} = BackendInputs::new(&arena, &layout_interner);
|
||||
} = BackendInputs::new(&arena);
|
||||
|
||||
let host_import_names = Vec::from_iter(host_module.import.imports.iter().map(|imp| imp.name));
|
||||
assert_eq!(&host_import_names, expected_host_import_names);
|
||||
|
||||
assert!(&host_module.names.function_names.is_empty());
|
||||
|
||||
let (mut final_module, called_fns, _roc_main_index) =
|
||||
roc_gen_wasm::build_app_module(&env, &mut interns, host_module, procedures);
|
||||
let (mut final_module, called_fns, _roc_main_index) = roc_gen_wasm::build_app_module(
|
||||
&env,
|
||||
&mut layout_interner,
|
||||
&mut interns,
|
||||
host_module,
|
||||
procedures,
|
||||
);
|
||||
|
||||
if eliminate_dead_code {
|
||||
final_module.eliminate_dead_code(env.arena, called_fns);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue