From 406bc7895a4ec274bc21e03d1ec2b90a085a5687 Mon Sep 17 00:00:00 2001 From: Peter Huene Date: Fri, 27 Sep 2019 05:50:54 -0700 Subject: [PATCH] Implement reading module table imports in API. (#387) This commit implements populating the table imports of a module from the API. It also allows for `anyref` in table types as per the reference types proposal. --- wasmtime-api/src/module.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wasmtime-api/src/module.rs b/wasmtime-api/src/module.rs index 4447127c77..0caed03b14 100644 --- a/wasmtime-api/src/module.rs +++ b/wasmtime-api/src/module.rs @@ -47,7 +47,9 @@ fn into_func_type(mt: wasmparser::FuncType) -> FuncType { } fn into_table_type(tt: wasmparser::TableType) -> TableType { - assert!(tt.element_type == wasmparser::Type::AnyFunc); + assert!( + tt.element_type == wasmparser::Type::AnyFunc || tt.element_type == wasmparser::Type::AnyRef + ); let ty = into_valtype(&tt.element_type); let limits = Limits::new( tt.limits.initial, @@ -118,8 +120,10 @@ fn read_imports_and_exports( let sig = &sigs[index as usize]; ExternType::ExternFunc(sig.clone()) } - ImportSectionEntryType::Table(_tt) => { - unimplemented!("ImportSectionEntryType::Table") + ImportSectionEntryType::Table(tt) => { + let table = into_table_type(tt); + tables.push(table.clone()); + ExternType::ExternTable(table) } ImportSectionEntryType::Memory(mt) => { let memory = into_memory_type(mt);