summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-s-parser.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-06-29 09:34:26 -0700
committerGitHub <noreply@github.com>2022-06-29 09:34:26 -0700
commit7f75427f7671562874a22981c9dcc4a8e223f48b (patch)
treebd3237d5b43197127e7a17c63fec3b9f5102b5f9 /src/wasm/wasm-s-parser.cpp
parent9dbe45780d8c78dbb49c208fe4505cd1624a98ac (diff)
downloadbinaryen-7f75427f7671562874a22981c9dcc4a8e223f48b.tar.gz
binaryen-7f75427f7671562874a22981c9dcc4a8e223f48b.tar.bz2
binaryen-7f75427f7671562874a22981c9dcc4a8e223f48b.zip
[Strings] Add string proposal types (#4755)
This starts to implement the Wasm Strings proposal https://github.com/WebAssembly/stringref/blob/main/proposals/stringref/Overview.md This just adds the types.
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r--src/wasm/wasm-s-parser.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index b59319be2..22557a06d 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -1184,6 +1184,18 @@ Type SExpressionWasmBuilder::stringToType(const char* str,
if (strncmp(str, "dataref", 7) == 0 && (prefix || str[7] == 0)) {
return Type::dataref;
}
+ if (strncmp(str, "stringref", 9) == 0 && (prefix || str[9] == 0)) {
+ return Type(HeapType::string, Nullable);
+ }
+ if (strncmp(str, "stringview_wtf8", 15) == 0 && (prefix || str[15] == 0)) {
+ return Type(HeapType::stringview_wtf8, Nullable);
+ }
+ if (strncmp(str, "stringview_wtf16", 16) == 0 && (prefix || str[16] == 0)) {
+ return Type(HeapType::stringview_wtf16, Nullable);
+ }
+ if (strncmp(str, "stringview_iter", 15) == 0 && (prefix || str[15] == 0)) {
+ return Type(HeapType::stringview_iter, Nullable);
+ }
if (allowError) {
return Type::none;
}
@@ -1223,6 +1235,20 @@ HeapType SExpressionWasmBuilder::stringToHeapType(const char* str,
return HeapType::data;
}
}
+ if (str[0] == 's') {
+ if (strncmp(str, "string", 6) == 0 && (prefix || str[6] == 0)) {
+ return HeapType::string;
+ }
+ if (strncmp(str, "stringview_wtf8", 15) == 0 && (prefix || str[15] == 0)) {
+ return HeapType::stringview_wtf8;
+ }
+ if (strncmp(str, "stringview_wtf16", 16) == 0 && (prefix || str[16] == 0)) {
+ return HeapType::stringview_wtf16;
+ }
+ if (strncmp(str, "stringview_iter", 15) == 0 && (prefix || str[15] == 0)) {
+ return HeapType::stringview_iter;
+ }
+ }
throw ParseException(std::string("invalid wasm heap type: ") + str);
}