Skip to content

Commit f1875b2

Browse files
tlivelyradekdoulik
authored andcommitted
Make array.new_fixed length annotations mandatory (WebAssembly#6277)
They were previously optional to ease the transition to the standard text format, but now we can make them mandatory to match the spec. This will simplify the new text parser as well.
1 parent 4ac6709 commit f1875b2

File tree

2 files changed

+5
-47
lines changed

2 files changed

+5
-47
lines changed

src/wasm/wasm-s-parser.cpp

+5-11
Original file line numberDiff line numberDiff line change
@@ -3161,18 +3161,12 @@ Expression* SExpressionWasmBuilder::makeArrayNewElem(Element& s) {
31613161

31623162
Expression* SExpressionWasmBuilder::makeArrayNewFixed(Element& s) {
31633163
auto heapType = parseHeapType(*s[1]);
3164-
size_t i = 2;
3165-
std::vector<Expression*> values;
3166-
if (i < s.size() && s[i]->isStr()) {
3167-
// With the standard syntax one should specify explicitly the size
3168-
// of the array
3169-
if ((size_t)parseIndex(*s[i]) != s.size() - 3) {
3170-
throw SParseException("wrong number of elements in array", s);
3171-
}
3172-
i++;
3164+
if ((size_t)parseIndex(*s[2]) != s.size() - 3) {
3165+
throw SParseException("wrong number of elements in array", s);
31733166
}
3174-
while (i < s.size()) {
3175-
values.push_back(parseExpression(*s[i++]));
3167+
std::vector<Expression*> values;
3168+
for (size_t i = 3; i < s.size(); ++i) {
3169+
values.push_back(parseExpression(*s[i]));
31763170
}
31773171
return Builder(wasm).makeArrayNewFixed(heapType, values);
31783172
}

test/lit/array-new-fixed.wast

-36
This file was deleted.

0 commit comments

Comments
 (0)