mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 14:25:32 +00:00
Improved naming of Exportable to ImportableExportable
This commit is contained in:
parent
9f561db90b
commit
60b1520808
@ -22,7 +22,7 @@ use super::super::common::slice::{BoundedSlice, UncheckedSlice};
|
|||||||
use super::errors::ErrorKind;
|
use super::errors::ErrorKind;
|
||||||
use super::import_object::{ImportObject, ImportValue};
|
use super::import_object::{ImportObject, ImportValue};
|
||||||
use super::memory::LinearMemory;
|
use super::memory::LinearMemory;
|
||||||
use super::module::{Export, Exportable, Module};
|
use super::module::{Export, ImportableExportable, Module};
|
||||||
use super::relocation::{Reloc, RelocSink, RelocationType};
|
use super::relocation::{Reloc, RelocSink, RelocationType};
|
||||||
use super::math_intrinsics;
|
use super::math_intrinsics;
|
||||||
|
|
||||||
@ -305,7 +305,7 @@ impl Instance {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (i, global) in module.info.globals.iter().enumerate() {
|
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 {
|
let value: i64 = match entity.initializer {
|
||||||
GlobalInit::I32Const(n) => n as _,
|
GlobalInit::I32Const(n) => n as _,
|
||||||
GlobalInit::I64Const(n) => n,
|
GlobalInit::I64Const(n) => n,
|
||||||
|
@ -71,9 +71,9 @@ fn get_func_name(func_index: FuncIndex) -> ir::ExternalName {
|
|||||||
ir::ExternalName::user(0, func_index.index() as u32)
|
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)]
|
#[derive(Debug)]
|
||||||
pub struct Exportable<T> {
|
pub struct ImportableExportable<T> {
|
||||||
/// An entity.
|
/// An entity.
|
||||||
pub entity: T,
|
pub entity: T,
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ pub struct Exportable<T> {
|
|||||||
pub import_name: Option<(String, String)>,
|
pub import_name: Option<(String, String)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Exportable<T> {
|
impl<T> ImportableExportable<T> {
|
||||||
pub fn new(entity: T, import_name: Option<(String, String)>) -> Self {
|
pub fn new(entity: T, import_name: Option<(String, String)>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
entity,
|
entity,
|
||||||
@ -124,7 +124,7 @@ pub struct ModuleInfo {
|
|||||||
pub signatures: Vec<ir::Signature>,
|
pub signatures: Vec<ir::Signature>,
|
||||||
|
|
||||||
/// Functions, imported and local.
|
/// Functions, imported and local.
|
||||||
pub functions: PrimaryMap<FuncIndex, Exportable<SignatureIndex>>,
|
pub functions: PrimaryMap<FuncIndex, ImportableExportable<SignatureIndex>>,
|
||||||
|
|
||||||
/// Function bodies.
|
/// Function bodies.
|
||||||
pub function_bodies: PrimaryMap<DefinedFuncIndex, ir::Function>,
|
pub function_bodies: PrimaryMap<DefinedFuncIndex, ir::Function>,
|
||||||
@ -133,7 +133,7 @@ pub struct ModuleInfo {
|
|||||||
pub imported_funcs: Vec<(String, String)>,
|
pub imported_funcs: Vec<(String, String)>,
|
||||||
|
|
||||||
/// Tables as provided by `declare_table`.
|
/// Tables as provided by `declare_table`.
|
||||||
pub tables: Vec<Exportable<Table>>,
|
pub tables: Vec<ImportableExportable<Table>>,
|
||||||
|
|
||||||
/// WebAssembly table initializers.
|
/// WebAssembly table initializers.
|
||||||
pub table_elements: Vec<TableElements>,
|
pub table_elements: Vec<TableElements>,
|
||||||
@ -142,13 +142,13 @@ pub struct ModuleInfo {
|
|||||||
pub tables_base: Option<ir::GlobalValue>,
|
pub tables_base: Option<ir::GlobalValue>,
|
||||||
|
|
||||||
/// Memories as provided by `declare_memory`.
|
/// Memories as provided by `declare_memory`.
|
||||||
pub memories: Vec<Exportable<Memory>>,
|
pub memories: Vec<ImportableExportable<Memory>>,
|
||||||
|
|
||||||
/// The Cranelift global holding the base address of the globals vector.
|
/// The Cranelift global holding the base address of the globals vector.
|
||||||
pub globals_base: Option<ir::GlobalValue>,
|
pub globals_base: Option<ir::GlobalValue>,
|
||||||
|
|
||||||
/// Globals as provided by `declare_global`.
|
/// Globals as provided by `declare_global`.
|
||||||
pub globals: Vec<Exportable<Global>>,
|
pub globals: Vec<ImportableExportable<Global>>,
|
||||||
|
|
||||||
/// The start function.
|
/// The start function.
|
||||||
pub start_func: Option<FuncIndex>,
|
pub start_func: Option<FuncIndex>,
|
||||||
@ -158,7 +158,7 @@ pub struct ModuleInfo {
|
|||||||
|
|
||||||
/// Exported entities
|
/// Exported entities
|
||||||
/// We use this in order to have a O(1) allocation of the exports
|
/// 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<String, Export>,
|
pub exports: HashMap<String, Export>,
|
||||||
|
|
||||||
/// The external function declaration for implementing wasm's `current_memory`.
|
/// 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(),
|
self.info.imported_funcs.len(),
|
||||||
"Imported functions must be declared first"
|
"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
|
self.info
|
||||||
.imported_funcs
|
.imported_funcs
|
||||||
.push((String::from(module), String::from(field)));
|
.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) {
|
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 {
|
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) {
|
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(
|
fn declare_global_import(
|
||||||
@ -740,7 +740,7 @@ impl<'data> ModuleEnvironment<'data> for Module {
|
|||||||
module: &'data str,
|
module: &'data str,
|
||||||
field: &'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 {
|
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) {
|
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(
|
fn declare_table_import(
|
||||||
@ -757,7 +757,7 @@ impl<'data> ModuleEnvironment<'data> for Module {
|
|||||||
module: &'data str,
|
module: &'data str,
|
||||||
field: &'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(
|
fn declare_table_elements(
|
||||||
@ -776,7 +776,7 @@ impl<'data> ModuleEnvironment<'data> for Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn declare_memory(&mut self, memory: Memory) {
|
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(
|
fn declare_memory_import(
|
||||||
@ -785,7 +785,7 @@ impl<'data> ModuleEnvironment<'data> for Module {
|
|||||||
module: &'data str,
|
module: &'data str,
|
||||||
field: &'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(
|
fn declare_data_initialization(
|
||||||
|
Loading…
Reference in New Issue
Block a user