From 2bdc4841b680ee44e132bbb07f5167eaa7226f99 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 27 Jan 2021 17:46:31 +0000 Subject: [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. --- src/passes/Print.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/passes/Print.cpp') 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 { 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"; -- cgit v1.2.3