mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-21 12:41:32 +00:00
Refactor func_count in parser
This commit is contained in:
@ -92,7 +92,8 @@ pub fn read_module<
|
||||
|
||||
let mut namespace_builder = Some(StringTableBuilder::new());
|
||||
let mut name_builder = Some(StringTableBuilder::new());
|
||||
let mut func_count: usize = ::std::usize::MAX;
|
||||
let mut func_count: usize = 0;
|
||||
let mut mcg_info_fed = false;
|
||||
|
||||
loop {
|
||||
use wasmparser::ParserState;
|
||||
@ -196,9 +197,9 @@ pub fn read_module<
|
||||
info.write().unwrap().start_func = Some(FuncIndex::new(start_index as usize));
|
||||
}
|
||||
ParserState::BeginFunctionBody { .. } => {
|
||||
let id = func_count.wrapping_add(1);
|
||||
func_count = id;
|
||||
if func_count == 0 {
|
||||
let id = func_count;
|
||||
if !mcg_info_fed {
|
||||
mcg_info_fed = true;
|
||||
info.write().unwrap().namespace_table =
|
||||
namespace_builder.take().unwrap().finish();
|
||||
info.write().unwrap().name_table = name_builder.take().unwrap().finish();
|
||||
@ -279,6 +280,7 @@ pub fn read_module<
|
||||
.map_err(|x| LoadError::Codegen(x))?;
|
||||
fcg.finalize()
|
||||
.map_err(|x| LoadError::Codegen(format!("{:?}", x)))?;
|
||||
func_count = func_count.wrapping_add(1);
|
||||
}
|
||||
ParserState::BeginActiveElementSectionEntry(table_index) => {
|
||||
let table_index = TableIndex::new(table_index as usize);
|
||||
@ -370,7 +372,7 @@ pub fn read_module<
|
||||
}
|
||||
ParserState::EndWasm => {
|
||||
// TODO Consolidate with BeginFunction body if possible
|
||||
if func_count == ::std::usize::MAX {
|
||||
if !mcg_info_fed {
|
||||
info.write().unwrap().namespace_table =
|
||||
namespace_builder.take().unwrap().finish();
|
||||
info.write().unwrap().name_table = name_builder.take().unwrap().finish();
|
||||
|
Reference in New Issue
Block a user