aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compilercontrolflow_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-06-02 21:58:35 +0200
committerLars Knoll <lars.knoll@qt.io>2018-06-21 13:30:19 +0000
commit4b7d56f65dcb29718a0aee33863e7687b1cb6e5f (patch)
tree1ac32832a108dd4e8ab4d5f5c42b8c63a9dac003 /src/qml/compiler/qv4compilercontrolflow_p.h
parent27fe56d3e7eedb2f8c45746880689c1e9e9b56b4 (diff)
Fix some of the finer details with regards to Completions
JS completion records have some finer details that can only be seen when using eval(), where the value of the completion record becomes important. Fix most of those cases to be compliant with the spec. Change-Id: I0c8105a8e778de7be3aea151d1bd64243aea067c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compilercontrolflow_p.h')
-rw-r--r--src/qml/compiler/qv4compilercontrolflow_p.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4compilercontrolflow_p.h b/src/qml/compiler/qv4compilercontrolflow_p.h
index 9ab581f015..415a112ec5 100644
--- a/src/qml/compiler/qv4compilercontrolflow_p.h
+++ b/src/qml/compiler/qv4compilercontrolflow_p.h
@@ -119,6 +119,16 @@ struct ControlFlow {
virtual QString label() const { return QString(); }
+ bool hasLoop() const {
+ const ControlFlow *flow = this;
+ while (flow) {
+ if (flow->type == Loop)
+ return true;
+ flow = flow->parent;
+ }
+ return false;
+ }
+
protected:
virtual BytecodeGenerator::Label getUnwindTarget(UnwindType, const QString & = QString()) {
return BytecodeGenerator::Label();
@@ -355,7 +365,6 @@ struct ControlFlowFinally : public ControlFlowUnwind
{
AST::Finally *finally;
bool insideFinally = false;
- int exceptionTemp = -1;
ControlFlowFinally(Codegen *cg, AST::Finally *finally)
: ControlFlowUnwind(cg, Finally), finally(finally)
@@ -380,9 +389,17 @@ struct ControlFlowFinally : public ControlFlowUnwind
Codegen::RegisterScope scope(cg);
insideFinally = true;
- exceptionTemp = generator()->newRegister();
+ int exceptionTemp = generator()->newRegister();
Instruction::GetException instr;
generator()->addInstruction(instr);
+ int returnValueTemp = -1;
+ if (cg->requiresReturnValue) {
+ returnValueTemp = generator()->newRegister();
+ Instruction::MoveReg move;
+ move.srcReg = cg->_returnAddress;
+ move.destReg = returnValueTemp;
+ generator()->addInstruction(move);
+ }
Reference::fromStackSlot(cg, exceptionTemp).storeConsumeAccumulator();
generator()->setUnwindHandler(parentUnwindHandler());
@@ -391,6 +408,12 @@ struct ControlFlowFinally : public ControlFlowUnwind
Reference::fromStackSlot(cg, exceptionTemp).loadInAccumulator();
+ if (cg->requiresReturnValue) {
+ Instruction::MoveReg move;
+ move.srcReg = returnValueTemp;
+ move.destReg = cg->_returnAddress;
+ generator()->addInstruction(move);
+ }
Instruction::SetException setException;
generator()->addInstruction(setException);