instantiate env module

This commit is contained in:
Svyatoslav Nikolsky
2017-07-25 15:26:31 +03:00
parent a5da7d604b
commit 2f73f02831
3 changed files with 32 additions and 55 deletions

View File

@ -211,38 +211,16 @@ fn single_program_different_modules() {
}
#[test]
fn import_global() {
// create new program
fn import_env_mutable_global() {
let program = ProgramInstance::new().unwrap();
// => env module is created
let env_instance = program.module("env").unwrap();
// => linear memory is created
let env_memory = env_instance.memory(ItemIndex::Internal(0)).unwrap();
// create native env module executor
let mut executor = FunctionExecutor {
memory: env_memory.clone(),
values: Vec::new(),
};
{
let functions: UserFunctions = UserFunctions {
executor: &mut executor,
functions: ::std::borrow::Cow::from(SIGNATURES),
};
let native_env_instance = Arc::new(env_native_module(env_instance, functions).unwrap());
let params = ExecutionParams::with_external("env".into(), native_env_instance);
let module = module()
.with_import(ImportEntry::new("env".into(), "STACKTOP".into(), External::Global(GlobalType::new(ValueType::I32, false))))
.build();
// load module
program.add_module("main", module, Some(&params.externals)).unwrap();
}
let module = module()
.with_import(ImportEntry::new("env".into(), "STACKTOP".into(), External::Global(GlobalType::new(ValueType::I32, false))))
.build();
program.add_module("main", module, None).unwrap();
}
#[test]
fn env_native_export_entry_type_check() {
let program = ProgramInstance::new().unwrap();