Upgrade wasmparser to 0.58.0 (#1942)
* Upgrade wasmparser to 0.58.0 * Enable more spec tests
This commit is contained in:
@@ -26,7 +26,7 @@ use wasmparser::{
|
||||
ElementKind, ElementSectionReader, Export, ExportSectionReader, ExternalKind,
|
||||
FunctionSectionReader, GlobalSectionReader, GlobalType, ImportSectionEntryType,
|
||||
ImportSectionReader, MemorySectionReader, MemoryType, NameSectionReader, Naming, NamingReader,
|
||||
Operator, TableSectionReader, Type, TypeSectionReader,
|
||||
Operator, TableSectionReader, Type, TypeDef, TypeSectionReader,
|
||||
};
|
||||
|
||||
/// Parses the Type section of the wasm module.
|
||||
@@ -40,22 +40,26 @@ pub fn parse_type_section(
|
||||
environ.reserve_signatures(count)?;
|
||||
|
||||
for entry in types {
|
||||
let wasm_func_ty = entry?;
|
||||
let mut sig = Signature::new(ModuleEnvironment::target_config(environ).default_call_conv);
|
||||
sig.params.extend(wasm_func_ty.params.iter().map(|ty| {
|
||||
let cret_arg: ir::Type = type_to_type(*ty, environ)
|
||||
.expect("only numeric types are supported in function signatures");
|
||||
AbiParam::new(cret_arg)
|
||||
}));
|
||||
sig.returns.extend(wasm_func_ty.returns.iter().map(|ty| {
|
||||
let cret_arg: ir::Type = type_to_type(*ty, environ)
|
||||
.expect("only numeric types are supported in function signatures");
|
||||
AbiParam::new(cret_arg)
|
||||
}));
|
||||
environ.declare_signature(&wasm_func_ty, sig)?;
|
||||
module_translation_state
|
||||
.wasm_types
|
||||
.push((wasm_func_ty.params, wasm_func_ty.returns));
|
||||
if let Ok(TypeDef::Func(wasm_func_ty)) = entry {
|
||||
let mut sig =
|
||||
Signature::new(ModuleEnvironment::target_config(environ).default_call_conv);
|
||||
sig.params.extend(wasm_func_ty.params.iter().map(|ty| {
|
||||
let cret_arg: ir::Type = type_to_type(*ty, environ)
|
||||
.expect("only numeric types are supported in function signatures");
|
||||
AbiParam::new(cret_arg)
|
||||
}));
|
||||
sig.returns.extend(wasm_func_ty.returns.iter().map(|ty| {
|
||||
let cret_arg: ir::Type = type_to_type(*ty, environ)
|
||||
.expect("only numeric types are supported in function signatures");
|
||||
AbiParam::new(cret_arg)
|
||||
}));
|
||||
environ.declare_signature(&wasm_func_ty, sig)?;
|
||||
module_translation_state
|
||||
.wasm_types
|
||||
.push((wasm_func_ty.params, wasm_func_ty.returns));
|
||||
} else {
|
||||
unimplemented!("module linking not implemented yet")
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -70,7 +74,7 @@ pub fn parse_import_section<'data>(
|
||||
for entry in imports {
|
||||
let import = entry?;
|
||||
let module_name = import.module;
|
||||
let field_name = import.field;
|
||||
let field_name = import.field.unwrap(); // TODO Handle error when module linking is implemented.
|
||||
|
||||
match import.ty {
|
||||
ImportSectionEntryType::Function(sig) => {
|
||||
@@ -80,6 +84,9 @@ pub fn parse_import_section<'data>(
|
||||
field_name,
|
||||
)?;
|
||||
}
|
||||
ImportSectionEntryType::Module(_sig) | ImportSectionEntryType::Instance(_sig) => {
|
||||
unimplemented!("module linking not implemented yet")
|
||||
}
|
||||
ImportSectionEntryType::Memory(MemoryType {
|
||||
limits: ref memlimits,
|
||||
shared,
|
||||
@@ -268,6 +275,9 @@ pub fn parse_export_section<'data>(
|
||||
ExternalKind::Global => {
|
||||
environ.declare_global_export(GlobalIndex::new(index), field)?
|
||||
}
|
||||
ExternalKind::Type | ExternalKind::Module | ExternalKind::Instance => {
|
||||
unimplemented!("module linking not implemented yet")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user