Factor out creating wasmparser::ValidatingParserConfig to its own function.

This commit is contained in:
Nick Lewycky 2019-06-20 14:51:31 -07:00
parent b2db9238af
commit acbface4be
2 changed files with 17 additions and 14 deletions

View File

@ -137,8 +137,22 @@ impl<
}
}
pub fn default_validating_parser_config() -> wasmparser::ValidatingParserConfig {
wasmparser::ValidatingParserConfig {
operator_config: wasmparser::OperatorValidatorConfig {
enable_threads: false,
enable_reference_types: false,
enable_simd: false,
enable_bulk_memory: false,
enable_multi_value: false,
},
mutable_global_imports: false,
}
}
fn validate(bytes: &[u8]) -> CompileResult<()> {
let mut parser = wasmparser::ValidatingParser::new(bytes, None);
let mut parser =
wasmparser::ValidatingParser::new(bytes, Some(default_validating_parser_config()));
loop {
let state = parser.read();
match *state {

View File

@ -85,19 +85,8 @@ pub fn read_module<
custom_sections: HashMap::new(),
}));
let mut parser = wasmparser::ValidatingParser::new(
wasm,
Some(wasmparser::ValidatingParserConfig {
operator_config: wasmparser::OperatorValidatorConfig {
enable_threads: false,
enable_reference_types: false,
enable_simd: false,
enable_bulk_memory: false,
enable_multi_value: false,
},
mutable_global_imports: false,
}),
);
let mut parser =
wasmparser::ValidatingParser::new(wasm, Some(default_validating_parser_config()));
let mut namespace_builder = Some(StringTableBuilder::new());
let mut name_builder = Some(StringTableBuilder::new());