diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-01-05 10:08:03 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-01-05 10:08:03 -0800 |
commit | 618c1737be20acd60a2653dfd0d65bfed5990480 (patch) | |
tree | d0166cc1767d024ce1ed942edec73597dc37246e /src | |
parent | 4c9e463f2c2012f72d701d96f62f1c4e03a27595 (diff) | |
download | binaryen-618c1737be20acd60a2653dfd0d65bfed5990480.tar.gz binaryen-618c1737be20acd60a2653dfd0d65bfed5990480.tar.bz2 binaryen-618c1737be20acd60a2653dfd0d65bfed5990480.zip |
do not print a toplevel block in functions if we don't need one #32
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/wasm.h b/src/wasm.h index 86aca1fd3..37e79dddb 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -912,7 +912,16 @@ public: doIndent(o, indent); printMinorOpening(o, "local ") << local.name << ' ' << printWasmType(local.type) << ")\n"; } - Expression::printFullLine(o, indent, body); + // It is ok to emit a block here, as a function can directly contain a list, even if our + // ast avoids that for simplicity. We can just do that optimization here.. + if (body->is<Block>() && body->cast<Block>()->name.isNull()) { + Block* block = body->cast<Block>(); + for (auto item : block->list) { + Expression::printFullLine(o, indent, item); + } + } else { + Expression::printFullLine(o, indent, body); + } return decIndent(o, indent); } }; |