405 std::find_if(completions.cbegin(), completions.cend(), [&](
const Completion &c) {
406 return c.type == type && c.label == label;
408 const qsizetype index =
409 it == completions.cend() ? completions.size() : it - completions.cbegin();
410 if (it == completions.cend())
411 completions.append({ label, type });
413 target->linkLabel = unwindLabel;
425 if (!completions.isEmpty())
426 Reference::fromConst(cg, QV4::Encode(0)).storeOnStack(completionRegister);
431 Codegen::RegisterScope scope(cg);
434 int returnValueTemp = -1;
435 if (cg->requiresReturnValue) {
436 returnValueTemp = generator()->newRegister();
437 Instruction::MoveReg move;
438 move.srcReg = cg->_returnAddress;
439 move.destReg = returnValueTemp;
440 generator()->addInstruction(move);
442 int exceptionTemp = generator()->newRegister();
443 Instruction::GetException instr;
444 generator()->addInstruction(instr);
445 Reference::fromStackSlot(cg, exceptionTemp).storeConsumeAccumulator();
447 generator()->setUnwindHandler(parentUnwindHandler());
448 cg->statement(finally->statement);
451 if (cg->requiresReturnValue) {
452 Instruction::MoveReg move;
453 move.srcReg = returnValueTemp;
454 move.destReg = cg->_returnAddress;
455 generator()->addInstruction(move);
457 Reference::fromStackSlot(cg, exceptionTemp).loadInAccumulator();
458 Instruction::SetException setException;
459 generator()->addInstruction(setException);
466 for (qsizetype i = 0, end = completions.size(); i != end; ++i) {
467 const Completion &completion = completions.at(i);
468 BytecodeGenerator::Label next = generator()->newLabel();
469 Reference::fromConst(cg, QV4::Encode(
int(i) + 1)).loadInAccumulator();
470 generator()->jumpStrictNotEqual(Moth::StackSlot::createRegister(completionRegister),
472 const UnwindTarget target = unwindTarget(completion.type, completion.label);
473 Q_ASSERT(target.linkLabel.isValid());
477 insideFinally =
false;