summaryrefslogtreecommitdiff
path: root/src/wasm2asm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm2asm.h')
-rw-r--r--src/wasm2asm.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/wasm2asm.h b/src/wasm2asm.h
index 3fd743dcf..8f4c54de3 100644
--- a/src/wasm2asm.h
+++ b/src/wasm2asm.h
@@ -448,8 +448,15 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) {
size_t size = curr->list.size();
int noResults = result == NO_RESULT ? size : size-1;
for (size_t i = 0; i < noResults; i++) {
- // TODO: flatten out, if we receive a block, just insert the elements
- ret[1]->push_back(ValueBuilder::makeStatement(visit(curr->list[i], NO_RESULT)));
+ // add to our return block. if we receive a block, can just flatten it out here
+ Ref ast = ValueBuilder::makeStatement(visit(curr->list[i], NO_RESULT));
+ if (ast[0] == BLOCK) {
+ for (int j = 0; j < ast[1]->size(); j++) {
+ ret[1]->push_back(ast[1][j]);
+ }
+ } else {
+ ret[1]->push_back(ast);
+ }
}
if (result != NO_RESULT) {
ret[1]->push_back(ValueBuilder::makeStatement(