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

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