diff --git a/src/webassembly/instance.rs b/src/webassembly/instance.rs index dd6565b23..e6cb70e7c 100644 --- a/src/webassembly/instance.rs +++ b/src/webassembly/instance.rs @@ -22,7 +22,7 @@ use super::super::common::slice::{BoundedSlice, UncheckedSlice}; use super::errors::ErrorKind; use super::import_object::{ImportObject, ImportValue}; use super::memory::LinearMemory; -use super::module::{Export, Exportable, Module}; +use super::module::{Export, ImportableExportable, Module}; use super::relocation::{Reloc, RelocSink, RelocationType}; use super::math_intrinsics; @@ -305,7 +305,7 @@ impl Instance { }; for (i, global) in module.info.globals.iter().enumerate() { - let Exportable {entity, import_name, ..} = global; + let ImportableExportable {entity, import_name, ..} = global; let value: i64 = match entity.initializer { GlobalInit::I32Const(n) => n as _, GlobalInit::I64Const(n) => n, diff --git a/src/webassembly/module.rs b/src/webassembly/module.rs index 9323ee4dc..bd31b060b 100644 --- a/src/webassembly/module.rs +++ b/src/webassembly/module.rs @@ -71,9 +71,9 @@ fn get_func_name(func_index: FuncIndex) -> ir::ExternalName { ir::ExternalName::user(0, func_index.index() as u32) } -/// A collection of names under which a given entity is exported. +/// A collection of names under which a given entity is imported/exported. #[derive(Debug)] -pub struct Exportable { +pub struct ImportableExportable { /// An entity. pub entity: T, @@ -84,7 +84,7 @@ pub struct Exportable { pub import_name: Option<(String, String)>, } -impl Exportable { +impl ImportableExportable { pub fn new(entity: T, import_name: Option<(String, String)>) -> Self { Self { entity, @@ -124,7 +124,7 @@ pub struct ModuleInfo { pub signatures: Vec, /// Functions, imported and local. - pub functions: PrimaryMap>, + pub functions: PrimaryMap>, /// Function bodies. pub function_bodies: PrimaryMap, @@ -133,7 +133,7 @@ pub struct ModuleInfo { pub imported_funcs: Vec<(String, String)>, /// Tables as provided by `declare_table`. - pub tables: Vec>, + pub tables: Vec>, /// WebAssembly table initializers. pub table_elements: Vec, @@ -142,13 +142,13 @@ pub struct ModuleInfo { pub tables_base: Option, /// Memories as provided by `declare_memory`. - pub memories: Vec>, + pub memories: Vec>, /// The Cranelift global holding the base address of the globals vector. pub globals_base: Option, /// Globals as provided by `declare_global`. - pub globals: Vec>, + pub globals: Vec>, /// The start function. pub start_func: Option, @@ -158,7 +158,7 @@ pub struct ModuleInfo { /// Exported entities /// We use this in order to have a O(1) allocation of the exports - /// rather than iterating through the Exportable elements. + /// rather than iterating through the ImportableExportable elements. pub exports: HashMap, /// The external function declaration for implementing wasm's `current_memory`. @@ -712,7 +712,7 @@ impl<'data> ModuleEnvironment<'data> for Module { self.info.imported_funcs.len(), "Imported functions must be declared first" ); - self.info.functions.push(Exportable::new(sig_index, None)); + self.info.functions.push(ImportableExportable::new(sig_index, None)); self.info .imported_funcs .push((String::from(module), String::from(field))); @@ -723,7 +723,7 @@ impl<'data> ModuleEnvironment<'data> for Module { } fn declare_func_type(&mut self, sig_index: SignatureIndex) { - self.info.functions.push(Exportable::new(sig_index, None)); + self.info.functions.push(ImportableExportable::new(sig_index, None)); } fn get_func_type(&self, func_index: FuncIndex) -> SignatureIndex { @@ -731,7 +731,7 @@ impl<'data> ModuleEnvironment<'data> for Module { } fn declare_global(&mut self, global: Global) { - self.info.globals.push(Exportable::new(global, None)); + self.info.globals.push(ImportableExportable::new(global, None)); } fn declare_global_import( @@ -740,7 +740,7 @@ impl<'data> ModuleEnvironment<'data> for Module { module: &'data str, field: &'data str, ) { - self.info.globals.push(Exportable::new(global, Some((String::from(module), String::from(field))))); + self.info.globals.push(ImportableExportable::new(global, Some((String::from(module), String::from(field))))); } fn get_global(&self, global_index: GlobalIndex) -> &Global { @@ -748,7 +748,7 @@ impl<'data> ModuleEnvironment<'data> for Module { } fn declare_table(&mut self, table: Table) { - self.info.tables.push(Exportable::new(table, None)); + self.info.tables.push(ImportableExportable::new(table, None)); } fn declare_table_import( @@ -757,7 +757,7 @@ impl<'data> ModuleEnvironment<'data> for Module { module: &'data str, field: &'data str, ) { - self.info.tables.push(Exportable::new(table, Some((String::from(module), String::from(field))))); + self.info.tables.push(ImportableExportable::new(table, Some((String::from(module), String::from(field))))); } fn declare_table_elements( @@ -776,7 +776,7 @@ impl<'data> ModuleEnvironment<'data> for Module { } fn declare_memory(&mut self, memory: Memory) { - self.info.memories.push(Exportable::new(memory, None)); + self.info.memories.push(ImportableExportable::new(memory, None)); } fn declare_memory_import( @@ -785,7 +785,7 @@ impl<'data> ModuleEnvironment<'data> for Module { module: &'data str, field: &'data str, ) { - self.info.memories.push(Exportable::new(memory, Some((String::from(module), String::from(field))))); + self.info.memories.push(ImportableExportable::new(memory, Some((String::from(module), String::from(field))))); } fn declare_data_initialization(