diff options
author | Thomas Lively <tlively@google.com> | 2024-02-06 13:06:28 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-06 13:06:28 -0800 |
commit | 41b365e99ffd68f427b561121c364028f2c2d2f9 (patch) | |
tree | f1d28d8564686e7381cb4c1cfcb2872da8cadddf /src/wasm/wasm-s-parser.cpp | |
parent | 3db60dfeb4cb07b239e7f3210b20af547a6554fc (diff) | |
download | binaryen-41b365e99ffd68f427b561121c364028f2c2d2f9.tar.gz binaryen-41b365e99ffd68f427b561121c364028f2c2d2f9.tar.bz2 binaryen-41b365e99ffd68f427b561121c364028f2c2d2f9.zip |
Make `array.new_fixed` length annotations mandatory (#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.
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 26af9ee00..957956044 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -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); } |