diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-12-04 15:25:25 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-12-04 15:25:25 -0800 |
commit | 016ba0d2f6d078b133dec713987c663c937f7de6 (patch) | |
tree | 872ae8fa7925aab7aa4649d7c28f28f7c8d90135 /src | |
parent | 15d52de57ac98e822abcef0fa5b06d58335d59ac (diff) | |
download | binaryen-016ba0d2f6d078b133dec713987c663c937f7de6.tar.gz binaryen-016ba0d2f6d078b133dec713987c663c937f7de6.tar.bz2 binaryen-016ba0d2f6d078b133dec713987c663c937f7de6.zip |
fix continue logic in wasm2asm
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm2asm.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/wasm2asm.h b/src/wasm2asm.h index 190f08b20..7b460a4c7 100644 --- a/src/wasm2asm.h +++ b/src/wasm2asm.h @@ -416,13 +416,7 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) { std::map<Name, IString> breakResults; // Breaks to the top of a loop should be emitted as continues, to that loop's main label - std::map<Name, Name> actualBreakLabel; - - Name getActualBreakLabel(Name name) { - auto iter = actualBreakLabel.find(name); - if (iter == actualBreakLabel.end()) return name; - return iter->second; - } + std::map<Name, Name> continueLabels; IString fromName(Name name) { return parent->fromName(name); @@ -461,7 +455,7 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) { } Ref visitLoop(Loop *curr) override { Name asmLabel = curr->out.is() ? curr->out : curr->in; // label using the outside, normal for breaks. if no outside, then inside - if (curr->in.is()) continues[curr->in] = asmLabel; + if (curr->in.is()) continueLabels[curr->in] = asmLabel; Ref body = visit(curr->body, result); if (asmLabel.is()) { body = ValueBuilder::makeLabel(fromName(asmLabel), body); @@ -481,7 +475,13 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) { fakeIf.ifTrue = fakeBreak; return visit(fake, result); } - Ref theBreak = ValueBuilder::makeBreak(fromName(getActualBreakLabel(curr->name))); + Ref theBreak; + Name iter = continueLabels.find(curr->name); + if (iter == continueLabels.end()) { + theBreak = ValueBuilder::makeBreak(fromName(curr->name)); + } else { + theBreak = ValueBuilder::makeContinue(fromName(iter.second)); + } if (!curr->value) return theBreak; // generate the value, including assigning to the result, and then do the break Ref ret = visitAndAssign(curr->value, result); |