diff options
-rw-r--r-- | src/wat-writer.cc | 4 | ||||
-rw-r--r-- | test/roundtrip/fold-block-labels.txt | 89 |
2 files changed, 93 insertions, 0 deletions
diff --git a/src/wat-writer.cc b/src/wat-writer.cc index cdea3b1b..0c051f83 100644 --- a/src/wat-writer.cc +++ b/src/wat-writer.cc @@ -1078,6 +1078,7 @@ void WatWriter::FlushExprTree(const ExprTree& expr_tree) { WriteFoldedExprList(cast<BlockExpr>(expr_tree.expr)->block.exprs); FlushExprTreeStack(); WriteCloseNewline(); + EndBlock(); break; case ExprType::Loop: @@ -1087,6 +1088,7 @@ void WatWriter::FlushExprTree(const ExprTree& expr_tree) { WriteFoldedExprList(cast<LoopExpr>(expr_tree.expr)->block.exprs); FlushExprTreeStack(); WriteCloseNewline(); + EndBlock(); break; case ExprType::If: { @@ -1106,6 +1108,7 @@ void WatWriter::FlushExprTree(const ExprTree& expr_tree) { WriteCloseNewline(); } WriteCloseNewline(); + EndBlock(); break; } @@ -1154,6 +1157,7 @@ void WatWriter::FlushExprTree(const ExprTree& expr_tree) { break; } WriteCloseNewline(); + EndBlock(); break; } diff --git a/test/roundtrip/fold-block-labels.txt b/test/roundtrip/fold-block-labels.txt new file mode 100644 index 00000000..c58a1f9b --- /dev/null +++ b/test/roundtrip/fold-block-labels.txt @@ -0,0 +1,89 @@ +;;; TOOL: run-roundtrip +;;; ARGS: --stdout --fold-exprs --enable-exceptions --debug-names +(module + (func + block + br 0 + end + block + br 0 + end) + + (func + block + br 0 + block + br 0 + end + end + block + br 0 + end) + + (func + (i32.const 0) + if + br 0 + end + (i32.const 0) + if + br 0 + end) + + (func + loop + br 0 + end + loop + br 0 + end) + + (func + try + br 0 + catch_all + end + try + br 0 + catch_all + end) + ) +(;; STDOUT ;;; +(module + (type (;0;) (func)) + (func (;0;) (type 0) + (block ;; label = @1 + (br 0 (;@1;))) + (block ;; label = @1 + (br 0 (;@1;)))) + (func (;1;) (type 0) + (block ;; label = @1 + (br 0 (;@1;)) + (block ;; label = @2 + (br 0 (;@2;)))) + (block ;; label = @1 + (br 0 (;@1;)))) + (func (;2;) (type 0) + (if ;; label = @1 + (i32.const 0) + (then + (br 0 (;@1;)))) + (if ;; label = @1 + (i32.const 0) + (then + (br 0 (;@1;))))) + (func (;3;) (type 0) + (loop ;; label = @1 + (br 0 (;@1;))) + (loop ;; label = @1 + (br 0 (;@1;)))) + (func (;4;) (type 0) + (try ;; label = @1 + (do + (br 0 (;@1;))) + (catch_all)) + (try ;; label = @1 + (do + (br 0 (;@1;))) + (catch_all)))) +;;; STDOUT ;;) |