diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2019-02-06 10:32:31 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2019-02-06 14:44:24 +0000 |
commit | 0282b89ec672e25a465a8e51bc74c7fd58a624b1 (patch) | |
tree | 6ad5ad340224a860ee0797b9251f3854697fc895 /src/qml/compiler/qv4codegen.cpp | |
parent | 9927bd00de613cd2edd00fa469fad31c10b44b47 (diff) |
V4: Add label for loop in spread in ArrayPattern
This patch also rotates the loop back so that the condition is at the
top of the loop.
Change-Id: I410792c0bdaf87af6fec86a256ea39947721daec
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index c3b6ab0b77..75212b841c 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -1207,7 +1207,6 @@ bool Codegen::visit(ArrayPattern *ast) BytecodeGenerator::Label in = bytecodeGenerator->newLabel(); BytecodeGenerator::Label end = bytecodeGenerator->newLabel(); - BytecodeGenerator::Label done = bytecodeGenerator->newLabel(); { auto cleanup = [this, iterator, iteratorDone]() { @@ -1217,26 +1216,21 @@ bool Codegen::visit(ArrayPattern *ast) bytecodeGenerator->addInstruction(close); }; ControlFlowLoop flow(this, &end, &in, cleanup); - bytecodeGenerator->jump().link(in); - - BytecodeGenerator::Label body = bytecodeGenerator->label(); - - lhsValue.loadInAccumulator(); - pushAccumulator(); - in.link(); + bytecodeGenerator->addLoopStart(in); iterator.loadInAccumulator(); Instruction::IteratorNext next; next.value = lhsValue.stackSlot(); next.done = iteratorDone.stackSlot(); bytecodeGenerator->addInstruction(next); - bytecodeGenerator->addTracingJumpInstruction(Instruction::JumpFalse()).link(body); - bytecodeGenerator->jump().link(done); + bytecodeGenerator->addTracingJumpInstruction(Instruction::JumpTrue()).link(end); + lhsValue.loadInAccumulator(); + pushAccumulator(); + + bytecodeGenerator->jump().link(in); end.link(); } - - done.link(); } else { RegisterScope innerScope(this); Reference expr = expression(it->element->initializer); |