Skip to content

Commit 4615f00

Browse files
authored
In full-printing mode, print comments for control flow endings, to help readability (WebAssembly#1552)
Like this: (block $x .. ) ;; end block $x Also fix some current breakage on master.
1 parent 689ca6b commit 4615f00

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/passes/Print.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,26 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
157157
if (curr != top && i == 0) {
158158
// one of the block recursions we already handled
159159
decIndent();
160+
if (full) {
161+
o << " ;; end block";
162+
auto* child = list[0]->cast<Block>();
163+
if (child->name.is()) {
164+
o << ' ' << child->name;
165+
}
166+
}
160167
o << '\n';
161168
continue;
162169
}
163170
printFullLine(list[i]);
164171
}
165172
}
166173
decIndent();
174+
if (full) {
175+
o << " ;; end block";
176+
if (curr->name.is()) {
177+
o << ' ' << curr->name;
178+
}
179+
}
167180
}
168181
void visitIf(If *curr) {
169182
printOpening(o, "if");
@@ -186,6 +199,9 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
186199
}
187200
}
188201
decIndent();
202+
if (full) {
203+
o << " ;; end if";
204+
}
189205
}
190206
void visitLoop(Loop *curr) {
191207
printOpening(o, "loop");
@@ -207,6 +223,12 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
207223
printFullLine(curr->body);
208224
}
209225
decIndent();
226+
if (full) {
227+
o << " ;; end loop";
228+
if (curr->name.is()) {
229+
o << ' ' << curr->name;
230+
}
231+
}
210232
}
211233
void visitBreak(Break *curr) {
212234
if (curr->condition) {

test/wasm2asm/i64-rotate.2asm.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ function asmFunc(global, env, buffer) {
1414
var Math_clz32 = global.Math.clz32;
1515
var Math_min = global.Math.min;
1616
var Math_max = global.Math.max;
17+
var Math_floor = global.Math.floor;
18+
var Math_ceil = global.Math.ceil;
19+
var Math_sqrt = global.Math.sqrt;
1720
var i64toi32_i32$HIGH_BITS = 0;
1821
function dummy() {
1922

0 commit comments

Comments
 (0)