allow module environment to parse name section

This commit is contained in:
data-pup
2019-06-28 19:29:53 +00:00
committed by Benjamin Bouvier
parent 3293ca6b69
commit ac2ca6116b
5 changed files with 119 additions and 16 deletions

View File

@@ -4,10 +4,10 @@ use crate::environ::{ModuleEnvironment, WasmError, WasmResult};
use crate::sections_translator::{
parse_code_section, parse_data_section, parse_element_section, parse_export_section,
parse_function_section, parse_global_section, parse_import_section, parse_memory_section,
parse_start_section, parse_table_section, parse_type_section,
parse_name_section, parse_start_section, parse_table_section, parse_type_section,
};
use cranelift_codegen::timing;
use wasmparser::{ModuleReader, SectionCode};
use wasmparser::{CustomSectionKind, ModuleReader, SectionCode};
/// Translate a sequence of bytes forming a valid Wasm binary into a list of valid Cranelift IR
/// [`Function`](cranelift_codegen::ir::Function).
@@ -83,6 +83,14 @@ pub fn translate_module<'data>(
});
}
SectionCode::Custom {
kind: CustomSectionKind::Name,
name: _,
} => {
let names = section.get_name_section_reader()?;
parse_name_section(names, environ)?;
}
SectionCode::Custom { name, kind: _ } => {
let mut reader = section.get_binary_reader();
let len = reader.bytes_remaining();