summaryrefslogtreecommitdiff
path: root/src/wasm/wasm.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-07-14 17:10:15 -0700
committerGitHub <noreply@github.com>2022-07-15 00:10:15 +0000
commit2b31aeb98a0fc8a5a505b3998d44990ed14e8c38 (patch)
treeb7e28f6ad6e3f77222e724afdb6d8668054410ea /src/wasm/wasm.cpp
parentc0151e99996a7b51d3d135fd5018c69e146b5c02 (diff)
downloadbinaryen-2b31aeb98a0fc8a5a505b3998d44990ed14e8c38.tar.gz
binaryen-2b31aeb98a0fc8a5a505b3998d44990ed14e8c38.tar.bz2
binaryen-2b31aeb98a0fc8a5a505b3998d44990ed14e8c38.zip
[Strings] stringview_*.slice (#4805)
Unfortunately one slice is the same as python [start:end], using 2 params, and the other slice is one param, [CURR:CURR+num] (where CURR is implied by the current state in the iter). So we can't use a single class here. Perhaps a different name would be good, like slice vs substring (like JS does), but I picked names to match the current spec.
Diffstat (limited to 'src/wasm/wasm.cpp')
-rw-r--r--src/wasm/wasm.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index c4a5f362a..0a3ca1929 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -1269,6 +1269,23 @@ void StringIterMove::finalize() {
}
}
+void StringSliceWTF::finalize() {
+ if (ref->type == Type::unreachable || start->type == Type::unreachable ||
+ end->type == Type::unreachable) {
+ type = Type::unreachable;
+ } else {
+ type = Type(HeapType::string, NonNullable);
+ }
+}
+
+void StringSliceIter::finalize() {
+ if (ref->type == Type::unreachable || num->type == Type::unreachable) {
+ type = Type::unreachable;
+ } else {
+ type = Type(HeapType::string, NonNullable);
+ }
+}
+
size_t Function::getNumParams() { return getParams().size(); }
size_t Function::getNumVars() { return vars.size(); }