summaryrefslogtreecommitdiff
path: root/src/asm2wasm.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-08-03 12:12:24 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-09-07 09:54:53 -0700
commitf30d9f6cde023b29409f73aba68f472c06c3b11c (patch)
tree79f6744bdc406bb0b076fe0f4a1ec52ee5f575eb /src/asm2wasm.h
parent72616971b2a35cbc37ea974e47c870556ef8ef4d (diff)
downloadbinaryen-f30d9f6cde023b29409f73aba68f472c06c3b11c.tar.gz
binaryen-f30d9f6cde023b29409f73aba68f472c06c3b11c.tar.bz2
binaryen-f30d9f6cde023b29409f73aba68f472c06c3b11c.zip
loops no longer have an out label and other upstream loop updates
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r--src/asm2wasm.h34
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();