wasm_interp: implement WASI random_get & refactor default imports

This commit is contained in:
Brian Carroll 2022-12-14 23:35:57 +00:00
parent eaa3f14fb0
commit b7fef386ee
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0
8 changed files with 112 additions and 31 deletions

View file

@ -1,7 +1,7 @@
#![cfg(test)]
use super::{const_value, create_exported_function_no_locals, default_state};
use crate::{instance::Action, ImportDispatcher, Instance, ValueStack, DEFAULT_IMPORTS};
use crate::{instance::Action, DefaultImportDispatcher, ImportDispatcher, Instance, ValueStack};
use bumpalo::{collections::Vec, Bump};
use roc_wasm_module::sections::{Import, ImportDesc};
use roc_wasm_module::{
@ -623,7 +623,8 @@ fn test_call_return_no_args() {
println!("Wrote to {}", filename);
}
let mut inst = Instance::for_module(&arena, &module, DEFAULT_IMPORTS, true).unwrap();
let mut inst =
Instance::for_module(&arena, &module, DefaultImportDispatcher::default(), true).unwrap();
let return_val = inst
.call_export(&module, start_fn_name, [])
@ -762,7 +763,13 @@ fn test_call_indirect_help(table_index: u32, elem_index: u32) -> Value {
.unwrap();
}
let mut inst = Instance::for_module(&arena, &module, DEFAULT_IMPORTS, is_debug_mode).unwrap();
let mut inst = Instance::for_module(
&arena,
&module,
DefaultImportDispatcher::default(),
is_debug_mode,
)
.unwrap();
inst.call_export(&module, start_fn_name, [])
.unwrap()
.unwrap()