Move start_index out of TranslationResult and into the WasmRuntime.

This makes it more consistent with how all the rest of the content of
a wasm module is handled. And, now TranslationResult just has a Vec
of translated functions, which will make it easier to refactor further.
This commit is contained in:
Dan Gohman
2017-10-09 08:37:04 -07:00
parent ef5ad630c8
commit e74bc06380
4 changed files with 39 additions and 29 deletions

View File

@@ -154,6 +154,23 @@ pub fn parse_export_section(
Ok(exports)
}
/// Retrieves the start function index from the start section
pub fn parse_start_section(
parser: &mut Parser,
runtime: &mut WasmRuntime,
) -> Result<(), SectionParsingError> {
loop {
match *parser.read() {
ParserState::StartSectionEntry(index) => {
runtime.declare_start_func(index as FunctionIndex);
}
ParserState::EndSection => break,
ref s => return Err(SectionParsingError::WrongSectionContent(format!("{:?}", s))),
};
}
Ok(())
}
/// Retrieves the size and maximum fields of memories from the memory section
pub fn parse_memory_section(
parser: &mut Parser,