mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-13 22:08:45 +00:00
Simplified polyfill
This commit is contained in:
@@ -7,14 +7,12 @@
|
|||||||
//! https://github.com/WebAssembly/js-types/blob/master/proposals/js-types/Overview.md
|
//! https://github.com/WebAssembly/js-types/blob/master/proposals/js-types/Overview.md
|
||||||
use core::convert::TryFrom;
|
use core::convert::TryFrom;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
use wasmer_types::entity::{EntityRef, PrimaryMap};
|
use wasmer_types::entity::EntityRef;
|
||||||
use wasmer_types::{
|
use wasmer_types::{
|
||||||
ExportIndex, ExportType, ExternType, FunctionIndex, FunctionType, GlobalIndex, GlobalType,
|
ExportIndex, FunctionIndex, FunctionType, GlobalIndex, GlobalType, ImportIndex, MemoryIndex,
|
||||||
ImportIndex, ImportType, MemoryIndex, MemoryType, ModuleInfo, Pages, SignatureIndex,
|
MemoryType, ModuleInfo, Pages, SignatureIndex, TableIndex, TableType, Type,
|
||||||
TableIndex, TableType, Type,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use indexmap::IndexMap;
|
|
||||||
use wasmparser::{
|
use wasmparser::{
|
||||||
self, BinaryReaderError, Export, ExportSectionReader, ExternalKind, FuncType as WPFunctionType,
|
self, BinaryReaderError, Export, ExportSectionReader, ExternalKind, FuncType as WPFunctionType,
|
||||||
FunctionSectionReader, GlobalSectionReader, GlobalType as WPGlobalType, ImportSectionEntryType,
|
FunctionSectionReader, GlobalSectionReader, GlobalType as WPGlobalType, ImportSectionEntryType,
|
||||||
@@ -27,9 +25,6 @@ pub type WasmResult<T> = Result<T, String>;
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct ModuleInfoPolyfill {
|
pub struct ModuleInfoPolyfill {
|
||||||
pub(crate) info: ModuleInfo,
|
pub(crate) info: ModuleInfo,
|
||||||
|
|
||||||
/// Number of total imports
|
|
||||||
total_imports: u32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ModuleInfoPolyfill {
|
impl ModuleInfoPolyfill {
|
||||||
@@ -48,7 +43,7 @@ impl ModuleInfoPolyfill {
|
|||||||
(
|
(
|
||||||
String::from(module),
|
String::from(module),
|
||||||
String::from(field),
|
String::from(field),
|
||||||
self.total_imports,
|
self.info.imports.len() as u32,
|
||||||
),
|
),
|
||||||
import,
|
import,
|
||||||
);
|
);
|
||||||
@@ -87,7 +82,6 @@ impl ModuleInfoPolyfill {
|
|||||||
)?;
|
)?;
|
||||||
self.info.functions.push(sig_index);
|
self.info.functions.push(sig_index);
|
||||||
self.info.num_imported_functions += 1;
|
self.info.num_imported_functions += 1;
|
||||||
self.total_imports += 1;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +103,6 @@ impl ModuleInfoPolyfill {
|
|||||||
)?;
|
)?;
|
||||||
self.info.tables.push(table);
|
self.info.tables.push(table);
|
||||||
self.info.num_imported_tables += 1;
|
self.info.num_imported_tables += 1;
|
||||||
self.total_imports += 1;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +124,6 @@ impl ModuleInfoPolyfill {
|
|||||||
)?;
|
)?;
|
||||||
self.info.memories.push(memory);
|
self.info.memories.push(memory);
|
||||||
self.info.num_imported_memories += 1;
|
self.info.num_imported_memories += 1;
|
||||||
self.total_imports += 1;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +145,6 @@ impl ModuleInfoPolyfill {
|
|||||||
)?;
|
)?;
|
||||||
self.info.globals.push(global);
|
self.info.globals.push(global);
|
||||||
self.info.num_imported_globals += 1;
|
self.info.num_imported_globals += 1;
|
||||||
self.total_imports += 1;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user