From 0e4712f8dbbc43c6c55041e2359f24aa42ae0fdb Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 26 Jan 2023 16:11:24 -0800 Subject: [Strings] Add experimental StringNew variants (#5459) string.from_code_point makes a string from an int code point. string.new_utf8*_try makes a utf8 string and returns null on a UTF8 encoding error rather than trap. --- src/wasm.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/wasm.h') diff --git a/src/wasm.h b/src/wasm.h index d5b52b315..779efe991 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -586,6 +586,8 @@ enum StringNewOp { StringNewWTF8Array, StringNewReplaceArray, StringNewWTF16Array, + // Other + StringNewFromCodePoint, }; enum StringMeasureOp { @@ -1684,7 +1686,7 @@ public: StringNewOp op; // In linear memory variations this is the pointer in linear memory. In the - // GC variations this is an Array. + // GC variations this is an Array. In from_codepoint this is the code point. Expression* ptr; // Used only in linear memory variations. @@ -1694,6 +1696,10 @@ public: Expression* start = nullptr; Expression* end = nullptr; + // The "try" variants will return null if an encoding error happens, rather + // than trap. + bool try_ = false; + void finalize(); }; -- cgit v1.2.3