summaryrefslogtreecommitdiff
path: root/src/wasm.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-01-23 11:03:08 -0800
committerAlon Zakai <alonzakai@gmail.com>2016-01-23 11:03:08 -0800
commit0e6ba7b1ee49bacd2a5ff4ae1b01982f624463f6 (patch)
treedcb8c523d13bc26363be3a8e1fcbc85641391a61 /src/wasm.h
parent627b4f16433739136dc9f51a7dc9db93ce0384a1 (diff)
downloadbinaryen-0e6ba7b1ee49bacd2a5ff4ae1b01982f624463f6.tar.gz
binaryen-0e6ba7b1ee49bacd2a5ff4ae1b01982f624463f6.tar.bz2
binaryen-0e6ba7b1ee49bacd2a5ff4ae1b01982f624463f6.zip
avoid emitting a block in a loop when the .wast format allows doing so #139
Diffstat (limited to 'src/wasm.h')
-rw-r--r--src/wasm.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/wasm.h b/src/wasm.h
index 5a8d57fd1..7c6ff85e7 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -412,7 +412,16 @@ public:
o << ' ' << in;
}
incIndent(o, indent);
- printFullLine(o, indent, body);
+ auto block = body->dyn_cast<Block>();
+ if (block && block->name.isNull()) {
+ // wasm spec has loops containing children directly, while our ast
+ // has a single child for simplicity. print out the optimal form.
+ for (auto expression : block->list) {
+ printFullLine(o, indent, expression);
+ }
+ } else {
+ printFullLine(o, indent, body);
+ }
return decIndent(o, indent);
}
};