diff options
Diffstat (limited to 'Userland/Libraries/LibWasm/Parser/Parser.cpp')
-rw-r--r-- | Userland/Libraries/LibWasm/Parser/Parser.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/Userland/Libraries/LibWasm/Parser/Parser.cpp b/Userland/Libraries/LibWasm/Parser/Parser.cpp index 797e9367dc..0335dc0a20 100644 --- a/Userland/Libraries/LibWasm/Parser/Parser.cpp +++ b/Userland/Libraries/LibWasm/Parser/Parser.cpp @@ -948,7 +948,7 @@ ParseResult<ElementSection::SegmentType0> ElementSection::SegmentType0::parse(In if (indices.is_error()) return indices.error(); - return SegmentType0 { ValueType(ValueType::FunctionReference), indices.release_value(), Active { 0, expression.release_value() } }; + return SegmentType0 { indices.release_value(), Active { 0, expression.release_value() } }; } ParseResult<ElementSection::SegmentType1> ElementSection::SegmentType1::parse(InputStream& stream) @@ -963,7 +963,7 @@ ParseResult<ElementSection::SegmentType1> ElementSection::SegmentType1::parse(In if (indices.is_error()) return indices.error(); - return SegmentType1 { ValueType(ValueType::FunctionReference), indices.release_value() }; + return SegmentType1 { indices.release_value() }; } ParseResult<ElementSection::SegmentType2> ElementSection::SegmentType2::parse(InputStream& stream) @@ -1008,7 +1008,7 @@ ParseResult<ElementSection::SegmentType7> ElementSection::SegmentType7::parse(In return ParseError::NotImplemented; } -ParseResult<ElementSection::AnyElementType> ElementSection::Element::parse(InputStream& stream) +ParseResult<ElementSection::Element> ElementSection::Element::parse(InputStream& stream) { ScopeLogger<WASM_BINPARSER_DEBUG> logger("Element"); u8 tag; @@ -1021,49 +1021,55 @@ ParseResult<ElementSection::AnyElementType> ElementSection::Element::parse(Input if (auto result = SegmentType0::parse(stream); result.is_error()) { return result.error(); } else { - return AnyElementType { result.release_value() }; + Vector<Instruction> instructions; + for (auto& index : result.value().function_indices) + instructions.empend(Instructions::ref_func, index); + return Element { ValueType(ValueType::FunctionReference), { Expression { move(instructions) } }, move(result.value().mode) }; } case 0x01: if (auto result = SegmentType1::parse(stream); result.is_error()) { return result.error(); } else { - return AnyElementType { result.release_value() }; + Vector<Instruction> instructions; + for (auto& index : result.value().function_indices) + instructions.empend(Instructions::ref_func, index); + return Element { ValueType(ValueType::FunctionReference), { Expression { move(instructions) } }, Passive {} }; } case 0x02: if (auto result = SegmentType2::parse(stream); result.is_error()) { return result.error(); } else { - return AnyElementType { result.release_value() }; + return ParseError::NotImplemented; } case 0x03: if (auto result = SegmentType3::parse(stream); result.is_error()) { return result.error(); } else { - return AnyElementType { result.release_value() }; + return ParseError::NotImplemented; } case 0x04: if (auto result = SegmentType4::parse(stream); result.is_error()) { return result.error(); } else { - return AnyElementType { result.release_value() }; + return ParseError::NotImplemented; } case 0x05: if (auto result = SegmentType5::parse(stream); result.is_error()) { return result.error(); } else { - return AnyElementType { result.release_value() }; + return ParseError::NotImplemented; } case 0x06: if (auto result = SegmentType6::parse(stream); result.is_error()) { return result.error(); } else { - return AnyElementType { result.release_value() }; + return ParseError::NotImplemented; } case 0x07: if (auto result = SegmentType7::parse(stream); result.is_error()) { return result.error(); } else { - return AnyElementType { result.release_value() }; + return ParseError::NotImplemented; } default: return ParseError::InvalidTag; |