summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-s-parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r--src/wasm/wasm-s-parser.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index cd6c167c0..98ed64c2d 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -2957,6 +2957,22 @@ Expression* SExpressionWasmBuilder::makeStringConst(Element& s) {
return Builder(wasm).makeStringConst(s[1]->str());
}
+Expression* SExpressionWasmBuilder::makeStringMeasure(Element& s,
+ StringMeasureOp op) {
+ size_t i = 1;
+ if (op == StringMeasureWTF8) {
+ const char* str = s[i++]->c_str();
+ if (strncmp(str, "utf8", 4) == 0) {
+ op = StringMeasureUTF8;
+ } else if (strncmp(str, "wtf8", 4) == 0) {
+ op = StringMeasureWTF8;
+ } else {
+ throw ParseException("bad string.new op", s.line, s.col);
+ }
+ }
+ return Builder(wasm).makeStringMeasure(op, parseExpression(s[i]));
+}
+
// converts an s-expression string representing binary data into an output
// sequence of raw bytes this appends to data, which may already contain
// content.