diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-05-14 18:52:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-14 18:52:49 -0700 |
commit | 4615f00d6fdc314e6ca08ad3abbd42bfed60737c (patch) | |
tree | 33f4a88d1c6c9d9f25dfa50e6013dc84581e05eb /src/passes/Print.cpp | |
parent | 689ca6b29a135b8eaa206d790f4a01562fbe5fe4 (diff) | |
download | binaryen-4615f00d6fdc314e6ca08ad3abbd42bfed60737c.tar.gz binaryen-4615f00d6fdc314e6ca08ad3abbd42bfed60737c.tar.bz2 binaryen-4615f00d6fdc314e6ca08ad3abbd42bfed60737c.zip |
In full-printing mode, print comments for control flow endings, to help readability (#1552)
Like this:
(block $x
..
) ;; end block $x
Also fix some current breakage on master.
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 f894c0d36..fc07b23b9 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -157,6 +157,13 @@ struct PrintSExpression : public Visitor<PrintSExpression> { if (curr != top && i == 0) { // one of the block recursions we already handled decIndent(); + if (full) { + o << " ;; end block"; + auto* child = list[0]->cast<Block>(); + if (child->name.is()) { + o << ' ' << child->name; + } + } o << '\n'; continue; } @@ -164,6 +171,12 @@ struct PrintSExpression : public Visitor<PrintSExpression> { } } decIndent(); + if (full) { + o << " ;; end block"; + if (curr->name.is()) { + o << ' ' << curr->name; + } + } } void visitIf(If *curr) { printOpening(o, "if"); @@ -186,6 +199,9 @@ struct PrintSExpression : public Visitor<PrintSExpression> { } } decIndent(); + if (full) { + o << " ;; end if"; + } } void visitLoop(Loop *curr) { printOpening(o, "loop"); @@ -207,6 +223,12 @@ struct PrintSExpression : public Visitor<PrintSExpression> { printFullLine(curr->body); } decIndent(); + if (full) { + o << " ;; end loop"; + if (curr->name.is()) { + o << ' ' << curr->name; + } + } } void visitBreak(Break *curr) { if (curr->condition) { |