From a5da7d604ba4ad8bcbb8dba2f85018c50c2e1e68 Mon Sep 17 00:00:00 2001 From: fro Date: Tue, 25 Jul 2017 14:31:17 +0300 Subject: [PATCH] global import breaks with Function("missing exports with name STACKTOP") --- src/interpreter/tests/basics.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/interpreter/tests/basics.rs b/src/interpreter/tests/basics.rs index f9bc24e..326b7b7 100644 --- a/src/interpreter/tests/basics.rs +++ b/src/interpreter/tests/basics.rs @@ -210,6 +210,39 @@ fn single_program_different_modules() { assert_eq!(executor.values, vec![7, 57, 42]); } +#[test] +fn import_global() { + // create new program + 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(¶ms.externals)).unwrap(); + } + +} + + #[test] fn env_native_export_entry_type_check() { let program = ProgramInstance::new().unwrap();