summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2018-05-14 18:52:49 -0700
committerGitHub <noreply@github.com>2018-05-14 18:52:49 -0700
commit4615f00d6fdc314e6ca08ad3abbd42bfed60737c (patch)
tree33f4a88d1c6c9d9f25dfa50e6013dc84581e05eb
parent689ca6b29a135b8eaa206d790f4a01562fbe5fe4 (diff)
downloadbinaryen-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.
-rw-r--r--src/passes/Print.cpp22
-rw-r--r--test/wasm2asm/i64-rotate.2asm.js3
2 files changed, 25 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) {
diff --git a/test/wasm2asm/i64-rotate.2asm.js b/test/wasm2asm/i64-rotate.2asm.js
index c76c41e39..2d30f3f40 100644
--- a/test/wasm2asm/i64-rotate.2asm.js
+++ b/test/wasm2asm/i64-rotate.2asm.js
@@ -14,6 +14,9 @@ function asmFunc(global, env, buffer) {
var Math_clz32 = global.Math.clz32;
var Math_min = global.Math.min;
var Math_max = global.Math.max;
+ var Math_floor = global.Math.floor;
+ var Math_ceil = global.Math.ceil;
+ var Math_sqrt = global.Math.sqrt;
var i64toi32_i32$HIGH_BITS = 0;
function dummy() {