summaryrefslogtreecommitdiff
path: root/src/passes/Print.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r--src/passes/Print.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 1392ccb6f..ef78bf582 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -1926,7 +1926,7 @@ struct PrintExpressionContents
// where if the ref is unreachable, we don't know what heap type to print),
// then print the children in a block, which is good enough as this
// instruction is never reached anyhow.
- printMedium(o, "block ");
+ printMedium(o, "block");
}
void printFieldName(HeapType type, Index index) {
processFieldName(wasm, type, index, [&](Name name) {
@@ -2346,6 +2346,33 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
o << " ;; end try";
}
}
+ void printUnreachableReplacement(Expression* curr) {
+ // See the parallel function in PrintExpressionContents for background.
+ //
+ // Emit a block with drops of the children.
+ o << "(block";
+ incIndent();
+ for (auto* child : ChildIterator(curr)) {
+ Drop drop;
+ drop.value = child;
+ printFullLine(&drop);
+ }
+ decIndent();
+ }
+ void visitStructSet(StructSet* curr) {
+ if (curr->ref->type == Type::unreachable) {
+ printUnreachableReplacement(curr);
+ return;
+ }
+ visitExpression(curr);
+ }
+ void visitStructGet(StructGet* curr) {
+ if (curr->ref->type == Type::unreachable) {
+ printUnreachableReplacement(curr);
+ return;
+ }
+ visitExpression(curr);
+ }
// Module-level visitors
void handleSignature(Signature curr, Name name = Name()) {
o << "(func";