LibWasm: Improve element validation and instantiation

This commit is contained in:
Diego
2024-06-16 06:42:00 -07:00
committed by Ali Mohammad Pur
parent 4c3071c7c2
commit 3225e6fad2
3 changed files with 13 additions and 7 deletions

View File

@@ -1281,10 +1281,10 @@ ParseResult<ElementSection::Element> ElementSection::Element::parse(Stream& stre
Vector<Expression> items;
if (!has_exprs) {
auto indices = TRY(parse_vector<GenericIndexParser<FunctionIndex>>(stream));
Vector<Instruction> instructions;
for (auto& index : indices)
instructions.empend(Instructions::ref_func, index);
items = { Expression { move(instructions) } };
for (auto& index : indices) {
Vector<Instruction> instructions { Instruction(Instructions::ref_func, index) };
items.empend(move(instructions));
}
} else {
items = TRY(parse_vector<Expression>(stream));
}