From 4615f00d6fdc314e6ca08ad3abbd42bfed60737c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 14 May 2018 18:52:49 -0700 Subject: 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. --- 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 f894c0d36..fc07b23b9 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -157,6 +157,13 @@ struct PrintSExpression : public Visitor { if (curr != top && i == 0) { // one of the block recursions we already handled decIndent(); + if (full) { + o << " ;; end block"; + auto* child = list[0]->cast(); + if (child->name.is()) { + o << ' ' << child->name; + } + } o << '\n'; continue; } @@ -164,6 +171,12 @@ struct PrintSExpression : public Visitor { } } 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 { } } decIndent(); + if (full) { + o << " ;; end if"; + } } void visitLoop(Loop *curr) { printOpening(o, "loop"); @@ -207,6 +223,12 @@ struct PrintSExpression : public Visitor { printFullLine(curr->body); } decIndent(); + if (full) { + o << " ;; end loop"; + if (curr->name.is()) { + o << ' ' << curr->name; + } + } } void visitBreak(Break *curr) { if (curr->condition) { -- cgit v1.2.3