mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 14:37:43 +00:00
LibWasm: Execute the start function, if one exists
This commit is contained in:
parent
d9ed3b504e
commit
3402381d7a
1 changed files with 8 additions and 3 deletions
|
@ -170,9 +170,14 @@ InstantiationResult AbstractMachine::instantiate(const Module& module, Vector<Ex
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
module.for_each_section_of_type<StartSection>([&](auto&) {
|
module.for_each_section_of_type<StartSection>([&](const StartSection& section) {
|
||||||
instantiation_result = InstantiationError { "Start section not yet implemented" };
|
auto& functions = m_module_instance.functions();
|
||||||
// FIXME: Invoke the start function.
|
auto index = section.function().index();
|
||||||
|
if (functions.size() <= index.value()) {
|
||||||
|
instantiation_result = InstantiationError { String::formatted("Start section function referenced invalid index {} of max {} entries", index.value(), functions.size()) };
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
invoke(functions[index.value()], {});
|
||||||
});
|
});
|
||||||
|
|
||||||
return instantiation_result.value_or({});
|
return instantiation_result.value_or({});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue