diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-01 15:31:00 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-01 15:31:00 -0800 |
commit | 44e83f2fb039a38b0764a172aa7c64ec3290d8c5 (patch) | |
tree | 888f217d7df089525bf368849f22cf6a7505f1f2 /src/asm2wasm.h | |
parent | b25e59d51d828f6a818141a715e9008f05e7063f (diff) | |
download | binaryen-44e83f2fb039a38b0764a172aa7c64ec3290d8c5.tar.gz binaryen-44e83f2fb039a38b0764a172aa7c64ec3290d8c5.tar.bz2 binaryen-44e83f2fb039a38b0764a172aa7c64ec3290d8c5.zip |
remove condition from break
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r-- | src/asm2wasm.h | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 356077460..3a8d3d579 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -836,7 +836,6 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { needTopmost = true; auto ret = allocator.alloc<Break>(); ret->name = TOPMOST; - ret->condition = nullptr; ret->value = !!ast[1] ? process(ast[1]) : nullptr; return ret; } else if (what == BLOCK) { @@ -845,14 +844,12 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { auto ret = allocator.alloc<Break>(); assert(breakStack.size() > 0); ret->name = !!ast[1] ? getBreakLabelName(ast[1]->getIString()) : breakStack.back(); - ret->condition = nullptr; ret->value = nullptr; return ret; } else if (what == CONTINUE) { auto ret = allocator.alloc<Break>(); assert(continueStack.size() > 0); ret->name = !!ast[1] ? getContinueLabelName(ast[1]->getIString()) : continueStack.back(); - ret->condition = nullptr; ret->value = nullptr; return ret; } else if (what == WHILE) { @@ -874,12 +871,15 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { if (forever) { ret->body = process(ast[2]); } else { - Break *continueWhile = allocator.alloc<Break>(); - continueWhile->name = in; - continueWhile->condition = process(ast[1]); - continueWhile->value = nullptr; + Break *breakOut = allocator.alloc<Break>(); + breakOut->name = in; + breakOut->value = nullptr; + If *condition = allocator.alloc<If>(); + condition->condition = process(ast[1]); + condition->ifTrue = breakOut; + condition->ifFalse = nullptr; auto body = allocator.alloc<Block>(); - body->list.push_back(continueWhile); + body->list.push_back(condition); body->list.push_back(process(ast[2])); ret->body = body; } @@ -923,16 +923,19 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { ret->body = process(ast[2]); continueStack.pop_back(); breakStack.pop_back(); - Break *continueIf = allocator.alloc<Break>(); - continueIf->name = in; - continueIf->condition = process(ast[1]); - continueIf->value = nullptr; + Break *continueIn = allocator.alloc<Break>(); + continueIn->name = in; + continueIn->value = nullptr; + If *condition = allocator.alloc<If>(); + condition->condition = process(ast[1]); + condition->ifTrue = continueIn; + condition->ifFalse = nullptr; if (Block *block = ret->body->dyn_cast<Block>()) { - block->list.push_back(continueIf); + block->list.push_back(condition); } else { auto newBody = allocator.alloc<Block>(); newBody->list.push_back(ret->body); - newBody->list.push_back(continueIf); + newBody->list.push_back(condition); ret->body = newBody; } return ret; @@ -1054,7 +1057,6 @@ void Asm2WasmBuilder::optimize() { // look in the child's children to see if there are more uses of this name BreakSeeker breakSeeker(curr->name); - breakSeeker.walk(child->condition); breakSeeker.walk(child->value); if (breakSeeker.found == 0) return child->value; |