From fd0f8a894a0e760d79f2d5ff890dd5a536ae2540 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 10 Aug 2022 12:43:02 -0700 Subject: [Strings] Fix string.new_wtf16_array (#4894) Like the 8-bit array variants, it takes 3 parameters. --- src/wasm/wasm-s-parser.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/wasm/wasm-s-parser.cpp') 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])); -- cgit v1.2.3