diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-04-06 10:20:08 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-02 14:17:51 +0000 |
commit | 922e6f42b4fa9b9fa87246c577c13bb945bd4bc4 (patch) | |
tree | 182cf430b7340c4f34c0cb350af1c15fd41b6648 /src/qml/compiler/qv4compilercontrolflow_p.h | |
parent | 20d30b6b3a253eebedc927dbb91685bbec52cfee (diff) |
Rework catch context handling
Remove the need for a specialized catch context, instead
use a regular block context, that also captures the
catched variable.
This also removes the need to do lookups by name inside
a catch expression.
Change-Id: I8b037add7f423922e2a76b4c0da646ca7e25813a
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.h | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/qml/compiler/qv4compilercontrolflow_p.h b/src/qml/compiler/qv4compilercontrolflow_p.h index c02168c1b6..6f524bb366 100644 --- a/src/qml/compiler/qv4compilercontrolflow_p.h +++ b/src/qml/compiler/qv4compilercontrolflow_p.h @@ -409,32 +409,33 @@ struct ControlFlowCatch : public ControlFlowUnwind ~ControlFlowCatch() { // emit code for unwinding - - cg->_context->forceLookupByName = true; insideCatch = true; Codegen::RegisterScope scope(cg); // exceptions inside the try block go here exceptionLabel.link(); - Moth::StackSlot savedContextReg = Moth::StackSlot::createRegister(generator()->newRegister()); - Instruction::PushCatchContext pushCatch; - pushCatch.name = cg->registerString(catchExpression->name.toString()); - pushCatch.reg = savedContextReg; - generator()->addInstruction(pushCatch); + + cg->enterContext(catchExpression); + Context *block = cg->currentContext(); + cg->_module->blocks.append(block); + block->blockIndex = cg->_module->blocks.count() - 1; + + int savedContextReg = block->emitBlockHeader(cg); + // clear the unwind temp for exceptions, we want to resume normal code flow afterwards Reference::storeConstOnStack(cg, QV4::Encode::undefined(), controlFlowTemp); generator()->setExceptionHandler(&catchUnwindLabel); - cg->statement(catchExpression->statement); + cg->statementList(catchExpression->statement->statements); insideCatch = false; // exceptions inside catch and break/return statements go here catchUnwindLabel.link(); - Instruction::PopContext pop; - pop.reg = savedContextReg; - generator()->addInstruction(pop); + block->emitBlockFooter(cg, savedContextReg); + + cg->leaveContext(); // break/continue/return statements in try go here unwindLabel.link(); |