diff options
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r-- | src/asm2wasm.h | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 857145937..2d0d1300e 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -1478,8 +1478,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { out = getNextId("while-out"); in = getNextId("while-in"); } - ret->out = out; - ret->in = in; + ret->name = in; breakStack.push_back(out); continueStack.push_back(in); if (forever) { @@ -1497,9 +1496,9 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { ret->body = body; } // loops do not automatically loop, add a branch back - Block* block = blockify(ret->body); + Block* block = builder.blockifyWithName(ret->body, out); auto continuer = allocator.alloc<Break>(); - continuer->name = ret->in; + continuer->name = ret->name; block->list.push_back(continuer); ret->body = block; continueStack.pop_back(); @@ -1536,13 +1535,12 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { } else { auto loop = allocator.alloc<Loop>(); loop->body = child; - loop->out = stop; - loop->in = more; - return loop; + loop->name = more; + return builder.blockifyWithName(loop, stop); } } // general do-while loop - auto ret = allocator.alloc<Loop>(); + auto loop = allocator.alloc<Loop>(); IString out, in; if (!parentLabel.isNull()) { out = getBreakLabelName(parentLabel); @@ -1552,20 +1550,18 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { out = getNextId("do-out"); in = getNextId("do-in"); } - ret->out = out; - ret->in = in; + loop->name = in; breakStack.push_back(out); continueStack.push_back(in); - ret->body = process(ast[2]); + loop->body = process(ast[2]); continueStack.pop_back(); breakStack.pop_back(); Break *continuer = allocator.alloc<Break>(); continuer->name = in; continuer->condition = process(ast[1]); - Block *block = blockify(ret->body); - block->list.push_back(continuer); - ret->body = block; - return ret; + Block *block = builder.blockifyWithName(loop->body, out, continuer); + loop->body = block; + return loop; } else if (what == FOR) { Ref finit = ast[1], fcond = ast[2], @@ -1581,8 +1577,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { out = getNextId("for-out"); in = getNextId("for-in"); } - ret->out = out; - ret->in = in; + ret->name = in; breakStack.push_back(out); continueStack.push_back(in); Break *breakOut = allocator.alloc<Break>(); @@ -1597,10 +1592,9 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { body->finalize(); ret->body = body; // loops do not automatically loop, add a branch back - Block* block = blockify(ret->body); auto continuer = allocator.alloc<Break>(); - continuer->name = ret->in; - block->list.push_back(continuer); + continuer->name = ret->name; + Block* block = builder.blockifyWithName(ret->body, out, continuer); ret->body = block; continueStack.pop_back(); breakStack.pop_back(); |