diff options
-rw-r--r-- | src/wasm/wasm-binary.cpp | 2 | ||||
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 11 | ||||
-rw-r--r-- | test/lit/strings.wast | 2 |
3 files changed, 13 insertions, 2 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 5399be0b7..daefbc28c 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -7027,6 +7027,8 @@ bool WasmBinaryBuilder::maybeVisitStringNew(Expression*& out, uint32_t code) { start = popNonVoidExpression(); } else if (code == BinaryConsts::StringNewWTF16Array) { op = StringNewWTF16Array; + end = popNonVoidExpression(); + start = popNonVoidExpression(); } else { return false; } diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index c1285c647..382ca741d 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -2824,8 +2824,10 @@ Expression* SExpressionWasmBuilder::makeStringNew(Element& s, StringNewOp op) { throw ParseException("bad string.new op", s.line, s.col); } length = parseExpression(s[i + 1]); + return Builder(wasm).makeStringNew(op, parseExpression(s[i]), length); } else if (op == StringNewWTF16) { length = parseExpression(s[i + 1]); + return Builder(wasm).makeStringNew(op, parseExpression(s[i]), length); } else if (op == StringNewWTF8Array) { const char* str = s[i++]->c_str(); if (strncmp(str, "utf8", 4) == 0) { @@ -2840,8 +2842,13 @@ Expression* SExpressionWasmBuilder::makeStringNew(Element& s, StringNewOp op) { auto* start = parseExpression(s[i + 1]); auto* end = parseExpression(s[i + 2]); return Builder(wasm).makeStringNew(op, parseExpression(s[i]), start, end); + } else if (op == StringNewWTF16Array) { + auto* start = parseExpression(s[i + 1]); + auto* end = parseExpression(s[i + 2]); + return Builder(wasm).makeStringNew(op, parseExpression(s[i]), start, end); + } else { + throw ParseException("bad string.new op", s.line, s.col); } - return Builder(wasm).makeStringNew(op, parseExpression(s[i]), length); } Expression* SExpressionWasmBuilder::makeStringConst(Element& s) { @@ -2858,7 +2865,7 @@ Expression* SExpressionWasmBuilder::makeStringMeasure(Element& s, } else if (strncmp(str, "wtf8", 4) == 0) { op = StringMeasureWTF8; } else { - throw ParseException("bad string.new op", s.line, s.col); + throw ParseException("bad string.measure op", s.line, s.col); } } return Builder(wasm).makeStringMeasure(op, parseExpression(s[i])); diff --git a/test/lit/strings.wast b/test/lit/strings.wast index 4e9b87d39..0acfa50ed 100644 --- a/test/lit/strings.wast +++ b/test/lit/strings.wast @@ -465,6 +465,8 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (string.new_wtf16_array ;; CHECK-NEXT: (local.get $array) + ;; CHECK-NEXT: (i32.const 7) + ;; CHECK-NEXT: (i32.const 8) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) |