diff options
author | Heejin Ahn <aheejin@gmail.com> | 2019-12-30 17:55:20 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-30 17:55:20 -0800 |
commit | bcc76146fed433cbc8ba01a9f568d979c145110b (patch) | |
tree | ab70ad24afc257b73513c3e62f3aab9938d05944 /src/passes/Print.cpp | |
parent | a30f1df5696ccb3490e2eaa3a9ed5e7e487c7b0e (diff) | |
download | binaryen-bcc76146fed433cbc8ba01a9f568d979c145110b.tar.gz binaryen-bcc76146fed433cbc8ba01a9f568d979c145110b.tar.bz2 binaryen-bcc76146fed433cbc8ba01a9f568d979c145110b.zip |
Add support for reference types proposal (#2451)
This adds support for the reference type proposal. This includes support
for all reference types (`anyref`, `funcref`(=`anyfunc`), and `nullref`)
and four new instructions: `ref.null`, `ref.is_null`, `ref.func`, and
new typed `select`. This also adds subtype relationship support between
reference types.
This does not include table instructions yet. This also does not include
wasm2js support.
Fixes #2444 and fixes #2447.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 5efd1fd28..51e78c8a7 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -1333,7 +1333,12 @@ struct PrintExpressionContents } restoreNormalColor(o); } - void visitSelect(Select* curr) { prepareColor(o) << "select"; } + void visitSelect(Select* curr) { + prepareColor(o) << "select"; + if (curr->type.isRef()) { + o << " (result " << curr->type << ')'; + } + } void visitDrop(Drop* curr) { printMedium(o, "drop"); } void visitReturn(Return* curr) { printMedium(o, "return"); } void visitHost(Host* curr) { @@ -1346,6 +1351,12 @@ struct PrintExpressionContents break; } } + void visitRefNull(RefNull* curr) { printMedium(o, "ref.null"); } + void visitRefIsNull(RefIsNull* curr) { printMedium(o, "ref.is_null"); } + void visitRefFunc(RefFunc* curr) { + printMedium(o, "ref.func "); + printName(curr->func, o); + } void visitTry(Try* curr) { printMedium(o, "try"); if (curr->type.isConcrete()) { @@ -1852,6 +1863,23 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> { } } } + void visitRefNull(RefNull* curr) { + o << '('; + PrintExpressionContents(currFunction, o).visit(curr); + o << ')'; + } + void visitRefIsNull(RefIsNull* curr) { + o << '('; + PrintExpressionContents(currFunction, o).visit(curr); + incIndent(); + printFullLine(curr->value); + decIndent(); + } + void visitRefFunc(RefFunc* curr) { + o << '('; + PrintExpressionContents(currFunction, o).visit(curr); + o << ')'; + } // try-catch-end is written in the folded wat format as // (try // ... @@ -2434,13 +2462,15 @@ WasmPrinter::printStackInst(StackInst* inst, std::ostream& o, Function* func) { } case StackInst::BlockBegin: case StackInst::IfBegin: - case StackInst::LoopBegin: { + case StackInst::LoopBegin: + case StackInst::TryBegin: { o << getExpressionName(inst->origin); break; } case StackInst::BlockEnd: case StackInst::IfEnd: - case StackInst::LoopEnd: { + case StackInst::LoopEnd: + case StackInst::TryEnd: { o << "end (" << inst->type << ')'; break; } @@ -2448,6 +2478,10 @@ WasmPrinter::printStackInst(StackInst* inst, std::ostream& o, Function* func) { o << "else"; break; } + case StackInst::Catch: { + o << "catch"; + break; + } default: WASM_UNREACHABLE("unexpeted op"); } |