diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm2js.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/wasm2js.h b/src/wasm2js.h index 3c868e8dd..927dbac24 100644 --- a/src/wasm2js.h +++ b/src/wasm2js.h @@ -973,6 +973,14 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, Function* func, IString resul return ValueBuilder::makeLabel(fromName(asmLabel, NameScope::Label), ret); } + Ref makeBreakOrContinue(Name name) { + if (continueLabels.count(name)) { + return ValueBuilder::makeContinue(fromName(name, NameScope::Label)); + } else { + return ValueBuilder::makeBreak(fromName(name, NameScope::Label)); + } + } + Ref visitBreak(Break* curr) { if (curr->condition) { // we need an equivalent to an if here, so use that code @@ -983,13 +991,7 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, Function* func, IString resul fakeIf.ifTrue = &fakeBreak; return visit(&fakeIf, result); } - Ref theBreak; - auto iter = continueLabels.find(curr->name); - if (iter == continueLabels.end()) { - theBreak = ValueBuilder::makeBreak(fromName(curr->name, NameScope::Label)); - } else { - theBreak = ValueBuilder::makeContinue(fromName(curr->name, NameScope::Label)); - } + Ref theBreak = makeBreakOrContinue(curr->name); if (!curr->value) return theBreak; // generate the value, including assigning to the result, and then do the break Ref ret = visitAndAssign(curr->value, breakResults[curr->name]); @@ -1016,10 +1018,10 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, Function* func, IString resul ret[1]->push_back(theSwitch); for (size_t i = 0; i < curr->targets.size(); i++) { ValueBuilder::appendCaseToSwitch(theSwitch, ValueBuilder::makeNum(i)); - ValueBuilder::appendCodeToSwitch(theSwitch, blockify(ValueBuilder::makeBreak(fromName(curr->targets[i], NameScope::Label))), false); + ValueBuilder::appendCodeToSwitch(theSwitch, blockify(makeBreakOrContinue(curr->targets[i])), false); } ValueBuilder::appendDefaultToSwitch(theSwitch); - ValueBuilder::appendCodeToSwitch(theSwitch, blockify(ValueBuilder::makeBreak(fromName(curr->default_, NameScope::Label))), false); + ValueBuilder::appendCodeToSwitch(theSwitch, blockify(makeBreakOrContinue(curr->default_)), false); return ret; } |