Fix tests.

This commit is contained in:
Sergey Pepyakin 2017-12-01 20:27:33 +03:00
parent 29613aef9c
commit 7ea00b975b
4 changed files with 9 additions and 4 deletions

View File

@ -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![

View File

@ -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();

View File

@ -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;

View File

@ -127,6 +127,11 @@ fn prepare_context(module: &Module) -> Result<ModuleContext, Error> {
}
// 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()?;