summaryrefslogtreecommitdiff
path: root/src/wasm/wasm.cpp
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2020-03-10 13:43:06 -0700
committerGitHub <noreply@github.com>2020-03-10 13:43:06 -0700
commit8f16059d3c29e285d4effed7f0c1f84c1f2f4d9d (patch)
treefaaee424f0b2b77d199c385abe103ea6044cae4e /src/wasm/wasm.cpp
parent49e31f2034d9532f29704be3039829aa201556a0 (diff)
downloadbinaryen-8f16059d3c29e285d4effed7f0c1f84c1f2f4d9d.tar.gz
binaryen-8f16059d3c29e285d4effed7f0c1f84c1f2f4d9d.tar.bz2
binaryen-8f16059d3c29e285d4effed7f0c1f84c1f2f4d9d.zip
Handle multivalue returns in the interpreter (#2684)
Updates the interpreter to properly flow vectors of values, including at function boundaries. Adds a small spec test for multivalue return.
Diffstat (limited to 'src/wasm/wasm.cpp')
-rw-r--r--src/wasm/wasm.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index 64bc5615f..4e4186d08 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -198,7 +198,7 @@ const char* getExpressionName(Expression* curr) {
WASM_UNREACHABLE("invalid expr id");
}
-Literal getLiteralFromConstExpression(Expression* curr) {
+Literal getSingleLiteralFromConstExpression(Expression* curr) {
if (auto* c = curr->dynCast<Const>()) {
return c->value;
} else if (curr->is<RefNull>()) {
@@ -210,6 +210,18 @@ Literal getLiteralFromConstExpression(Expression* curr) {
}
}
+Literals getLiteralsFromConstExpression(Expression* curr) {
+ if (auto* t = curr->dynCast<TupleMake>()) {
+ Literals values;
+ for (auto* operand : t->operands) {
+ values.push_back(getSingleLiteralFromConstExpression(operand));
+ }
+ return values;
+ } else {
+ return {getSingleLiteralFromConstExpression(curr)};
+ }
+}
+
// core AST type checking
struct TypeSeeker : public PostWalker<TypeSeeker> {