diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-05-14 12:36:16 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-14 19:32:34 +0000 |
commit | d8eade23bc4fdd7040204f4374ef26975b94ea0a (patch) | |
tree | 19542aa2a8ddf285a80f3fe528913cd630a7f601 /src/qml/compiler/qv4codegen.cpp | |
parent | 16288498cf0e1eb389ac3acdce86eb74cc69e67a (diff) |
Refactor InteratorNext instruction
The instruction now writes the value into a stack slot,
and returns the done state in the accumulator. This should
make it easier to implement the IteratorClose functionality
required by the spec.
Change-Id: I8cc497c54b0d044bd3c68a5a1b774eea8b2740ef
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index f00a0fafdc..99c45d19fa 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -477,6 +477,7 @@ void Codegen::destructureElementList(const Codegen::Reference &array, PatternEle RegisterScope scope(this); Reference iterator = Reference::fromStackSlot(this); + Reference iteratorValue = Reference::fromStackSlot(this); array.loadInAccumulator(); Instruction::GetIterator iteratorObjInstr; @@ -490,7 +491,7 @@ void Codegen::destructureElementList(const Codegen::Reference &array, PatternEle for (Elision *elision = p->elision; elision; elision = elision->next) { iterator.loadInAccumulator(); Instruction::IteratorNext next; - next.returnUndefinedWhenDone = true; + next.value = iteratorValue.stackSlot(); bytecodeGenerator->addInstruction(next); } @@ -503,12 +504,12 @@ void Codegen::destructureElementList(const Codegen::Reference &array, PatternEle initializeAndDestructureBindingElement(e, Reference::fromAccumulator(this)); } else { Instruction::IteratorNext next; - next.returnUndefinedWhenDone = true; + next.value = iteratorValue.stackSlot(); bytecodeGenerator->addInstruction(next); if (!e) continue; if (e->type != PatternElement::RestElement) { - initializeAndDestructureBindingElement(e, Reference::fromAccumulator(this)); + initializeAndDestructureBindingElement(e, iteratorValue); if (hasError) { end.link(); return; @@ -2686,11 +2687,9 @@ bool Codegen::visit(ForEachStatement *ast) in.link(); iterator.loadInAccumulator(); Instruction::IteratorNext next; - next.returnUndefinedWhenDone = false; + next.value = lhsValue.stackSlot(); bytecodeGenerator->addInstruction(next); - Instruction::JumpEmpty jump; - BytecodeGenerator::Jump done = bytecodeGenerator->addJumpInstruction(jump); - lhsValue.storeConsumeAccumulator(); + BytecodeGenerator::Jump done = bytecodeGenerator->addJumpInstruction(Instruction::JumpTrue()); bytecodeGenerator->jump().link(body); done.link(); |