diff options
author | Alon Zakai <azakai@google.com> | 2021-01-27 17:46:31 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-27 09:46:31 -0800 |
commit | 2bdc4841b680ee44e132bbb07f5167eaa7226f99 (patch) | |
tree | 170585bbb9c74022201efeeee91962fdb5f0a1f1 /src/passes/Print.cpp | |
parent | f82e94363a231bf570fbe3d7dc49259c8668206f (diff) | |
download | binaryen-2bdc4841b680ee44e132bbb07f5167eaa7226f99.tar.gz binaryen-2bdc4841b680ee44e132bbb07f5167eaa7226f99.tar.bz2 binaryen-2bdc4841b680ee44e132bbb07f5167eaa7226f99.zip |
[GC] ref.as_* (#3520)
These are similar to is, but instead of returning an i32 answer, they trap on
an invalid value, and return it otherwise.
These could in theory be in a single RefDoThing, with opcodes for both As
and Is, but as the return values are different, that would be a little odd, and
the name would be less clear.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index ba1371d9e..a6efd5f1f 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -1856,6 +1856,21 @@ struct PrintExpressionContents printMedium(o, "array.len "); printHeapTypeName(o, curr->ref->type.getHeapType()); } + void visitRefAs(RefAs* curr) { + switch (curr->op) { + case RefAsFunc: + printMedium(o, "ref.as_func"); + break; + case RefAsData: + printMedium(o, "ref.as_data"); + break; + case RefAsI31: + printMedium(o, "ref.as_i31"); + break; + default: + WASM_UNREACHABLE("invalid ref.is_*"); + } + } }; // Prints an expression in s-expr format, including both the @@ -2603,6 +2618,13 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> { printFullLine(curr->ref); decIndent(); } + void visitRefAs(RefAs* curr) { + o << '('; + PrintExpressionContents(currFunction, o).visit(curr); + incIndent(); + printFullLine(curr->value); + decIndent(); + } // Module-level visitors void handleSignature(Signature curr, Name name = Name()) { o << "(func"; |