From 7ea00b975bd36ffc62ae40eda637909a57e8dab3 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Fri, 1 Dec 2017 20:27:33 +0300 Subject: [PATCH] Fix tests. --- src/interpreter/tests/basics.rs | 2 +- src/interpreter/tests/mod.rs | 4 ++-- src/validation/func.rs | 2 +- src/validation/mod.rs | 5 +++++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/interpreter/tests/basics.rs b/src/interpreter/tests/basics.rs index 333413a..3361182 100644 --- a/src/interpreter/tests/basics.rs +++ b/src/interpreter/tests/basics.rs @@ -82,7 +82,7 @@ fn wrong_import() { #[test] fn global_get_set() { let module = module() - .with_global(GlobalEntry::new(GlobalType::new(ValueType::I32, true), InitExpr::new(vec![Opcode::I32Const(42)]))) + .with_global(GlobalEntry::new(GlobalType::new(ValueType::I32, true), InitExpr::new(vec![Opcode::I32Const(42), Opcode::End]))) .function() .signature().return_type().i32().build() .body().with_opcodes(Opcodes::new(vec![ diff --git a/src/interpreter/tests/mod.rs b/src/interpreter/tests/mod.rs index 8842ad9..b2bf1dc 100644 --- a/src/interpreter/tests/mod.rs +++ b/src/interpreter/tests/mod.rs @@ -18,9 +18,9 @@ mod utils { .with_min(64) .build() .with_export(ExportEntry::new("table".into(), Internal::Table(0))) - .with_global(GlobalEntry::new(GlobalType::new(ValueType::I32, false), InitExpr::new(vec![Opcode::I32Const(0)]))) + .with_global(GlobalEntry::new(GlobalType::new(ValueType::I32, false), InitExpr::new(vec![Opcode::I32Const(0), Opcode::End]))) .with_export(ExportEntry::new("tableBase".into(), Internal::Global(0))) - .with_global(GlobalEntry::new(GlobalType::new(ValueType::I32, false), InitExpr::new(vec![Opcode::I32Const(0)]))) + .with_global(GlobalEntry::new(GlobalType::new(ValueType::I32, false), InitExpr::new(vec![Opcode::I32Const(0), Opcode::End]))) .with_export(ExportEntry::new("memoryBase".into(), Internal::Global(1))) .build(); program.add_module("env", env_module, None).unwrap(); diff --git a/src/validation/func.rs b/src/validation/func.rs index b713734..7c51d65 100644 --- a/src/validation/func.rs +++ b/src/validation/func.rs @@ -67,7 +67,7 @@ impl Validator { func: &Func, body: &FuncBody, ) -> Result<(), Error> { - let (params, result_ty) = module.require_function(func.type_ref())?; + let (params, result_ty) = module.require_function_type(func.type_ref())?; // locals = (params + vars) let mut locals = params; diff --git a/src/validation/mod.rs b/src/validation/mod.rs index 04fbacd..b0ed35d 100644 --- a/src/validation/mod.rs +++ b/src/validation/mod.rs @@ -127,6 +127,11 @@ fn prepare_context(module: &Module) -> Result { } // Concatenate elements with defined in the module. + if let Some(function_section) = module.function_section() { + for func_entry in function_section.entries() { + func_type_indexes.push(func_entry.type_ref()); + } + } if let Some(table_section) = module.table_section() { for table_entry in table_section.entries() { table_entry.validate()?;