Handle same-named imports with different signatures

This commit fixes the `wasmtime::Instance` instantiation API when
imports have the same name but might be imported under different types.
This is handled in the API by listing imports as a list instead of as a
name map, but they were interpreted as a name map under the hood causing
collisions.

This commit now keeps track of the index used to define each import, and
the index is passed through in the `Resolver`. Existing implementaitons
of `Resolver` all ignore this, but the API now uses it exclusivley to
match up `Extern` definitions to imports.
This commit is contained in:
Alex Crichton
2019-12-05 15:45:57 -08:00
committed by Dan Gohman
parent e22d93f750
commit 41780fb1a6
8 changed files with 128 additions and 50 deletions

View File

@@ -136,17 +136,18 @@ pub struct Module {
/// Unprocessed signatures exactly as provided by `declare_signature()`.
pub signatures: PrimaryMap<SignatureIndex, ir::Signature>,
/// Names of imported functions.
pub imported_funcs: PrimaryMap<FuncIndex, (String, String)>,
/// Names of imported functions, as well as the index of the import that
/// performed this import.
pub imported_funcs: PrimaryMap<FuncIndex, (String, String, u32)>,
/// Names of imported tables.
pub imported_tables: PrimaryMap<TableIndex, (String, String)>,
pub imported_tables: PrimaryMap<TableIndex, (String, String, u32)>,
/// Names of imported memories.
pub imported_memories: PrimaryMap<MemoryIndex, (String, String)>,
pub imported_memories: PrimaryMap<MemoryIndex, (String, String, u32)>,
/// Names of imported globals.
pub imported_globals: PrimaryMap<GlobalIndex, (String, String)>,
pub imported_globals: PrimaryMap<GlobalIndex, (String, String, u32)>,
/// Types of functions, imported and local.
pub functions: PrimaryMap<FuncIndex, SignatureIndex>,