Update to wasmparser 0.9.3.

wasmparser's API is changing in anticipation of streaming decoding, so
it will now hand large data section initializers back in chunks rather
than all at once.
This commit is contained in:
Dan Gohman
2017-09-08 16:16:19 -07:00
parent 0c16f13c6b
commit 3775fa4867
2 changed files with 10 additions and 8 deletions

View File

@@ -11,6 +11,6 @@ license = "Apache-2.0"
name = "cton_wasm" name = "cton_wasm"
[dependencies] [dependencies]
wasmparser = "0.8.2" wasmparser = "0.9.3"
cretonne = { path = "../cretonne" } cretonne = { path = "../cretonne" }
cretonne-frontend = { path = "../frontend" } cretonne-frontend = { path = "../frontend" }

View File

@@ -250,7 +250,7 @@ pub fn parse_data_section(
ParserState::BeginInitExpressionBody => (), ParserState::BeginInitExpressionBody => (),
ref s => return Err(SectionParsingError::WrongSectionContent(format!("{:?}", s))), ref s => return Err(SectionParsingError::WrongSectionContent(format!("{:?}", s))),
}; };
let offset = match *parser.read() { let mut offset = match *parser.read() {
ParserState::InitExpressionOperator(Operator::I32Const { value }) => { ParserState::InitExpressionOperator(Operator::I32Const { value }) => {
if value < 0 { if value < 0 {
return Err(SectionParsingError::WrongSectionContent(String::from( return Err(SectionParsingError::WrongSectionContent(String::from(
@@ -288,20 +288,22 @@ pub fn parse_data_section(
ParserState::EndInitExpressionBody => (), ParserState::EndInitExpressionBody => (),
ref s => return Err(SectionParsingError::WrongSectionContent(format!("{:?}", s))), ref s => return Err(SectionParsingError::WrongSectionContent(format!("{:?}", s))),
}; };
{ match *parser.read() {
ParserState::BeginDataSectionEntryBody(_) => (),
ref s => return Err(SectionParsingError::WrongSectionContent(format!("{:?}", s))),
};
loop {
let data = match *parser.read() { let data = match *parser.read() {
ParserState::DataSectionEntryBody(data) => data, ParserState::DataSectionEntryBodyChunk(data) => data,
ParserState::EndDataSectionEntry => break,
ref s => return Err(SectionParsingError::WrongSectionContent(format!("{:?}", s))), ref s => return Err(SectionParsingError::WrongSectionContent(format!("{:?}", s))),
}; };
match runtime.declare_data_initialization(memory_index as MemoryIndex, offset, data) { match runtime.declare_data_initialization(memory_index as MemoryIndex, offset, data) {
Ok(()) => (), Ok(()) => (),
Err(s) => return Err(SectionParsingError::WrongSectionContent(s)), Err(s) => return Err(SectionParsingError::WrongSectionContent(s)),
}; };
offset += data.len();
} }
match *parser.read() {
ParserState::EndDataSectionEntry => (),
ref s => return Err(SectionParsingError::WrongSectionContent(format!("{:?}", s))),
};
} }
Ok(()) Ok(())
} }