Skip to content

Commit

Permalink
Make array.new_fixed length annotations mandatory (#6277)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tlively authored Feb 6, 2024
1 parent 3db60df commit 41b365e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 47 deletions.
16 changes: 5 additions & 11 deletions src/wasm/wasm-s-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3161,18 +3161,12 @@ Expression* SExpressionWasmBuilder::makeArrayNewElem(Element& s) {

Expression* SExpressionWasmBuilder::makeArrayNewFixed(Element& s) {
auto heapType = parseHeapType(*s[1]);
size_t i = 2;
std::vector<Expression*> values;
if (i < s.size() && s[i]->isStr()) {
// With the standard syntax one should specify explicitly the size
// of the array
if ((size_t)parseIndex(*s[i]) != s.size() - 3) {
throw SParseException("wrong number of elements in array", s);
}
i++;
if ((size_t)parseIndex(*s[2]) != s.size() - 3) {
throw SParseException("wrong number of elements in array", s);
}
while (i < s.size()) {
values.push_back(parseExpression(*s[i++]));
std::vector<Expression*> values;
for (size_t i = 3; i < s.size(); ++i) {
values.push_back(parseExpression(*s[i]));
}
return Builder(wasm).makeArrayNewFixed(heapType, values);
}
Expand Down
36 changes: 0 additions & 36 deletions test/lit/array-new-fixed.wast

This file was deleted.

0 comments on commit 41b365e

Please sign in to comment.