diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-01-17 11:40:44 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-01-18 21:07:33 +0000 |
commit | 83b22abcacb5704b94f5003d6242e42417b5c901 (patch) | |
tree | dc7076d3d48744ff4604d015294b61bf24e245ee /src/qmlcompiler | |
parent | 838ad1a8d0e9ea4eb62c2428d57b54df4d860c32 (diff) |
QmlCompiler: Handle context push/pop in dead code
Otherwise we end up with unmatched curly braces in the generated code.
Change-Id: I4c24d4062a8ed54cd6a9ecb43dfd2b5d0a26c9e1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
(cherry picked from commit 6a54c6013d9037f5c75d47f5e03d6871591e53b2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/qmlcompiler')
-rw-r--r-- | src/qmlcompiler/qqmljscodegenerator.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/qmlcompiler/qqmljscodegenerator.cpp b/src/qmlcompiler/qqmljscodegenerator.cpp index b2d6e9432f..3e3a20d14c 100644 --- a/src/qmlcompiler/qqmljscodegenerator.cpp +++ b/src/qmlcompiler/qqmljscodegenerator.cpp @@ -2188,7 +2188,33 @@ void QQmlJSCodeGenerator::generate_GetTemplateObject(int index) BYTECODE_UNIMPLEMENTED(); } -QV4::Moth::ByteCodeHandler::Verdict QQmlJSCodeGenerator::startInstruction(QV4::Moth::Instr::Type) +static bool instructionManipulatesContext(QV4::Moth::Instr::Type type) +{ + using Type = QV4::Moth::Instr::Type; + switch (type) { + case Type::PopContext: + case Type::PopScriptContext: + case Type::CreateCallContext: + case Type::CreateCallContext_Wide: + case Type::PushCatchContext: + case Type::PushCatchContext_Wide: + case Type::PushWithContext: + case Type::PushWithContext_Wide: + case Type::PushBlockContext: + case Type::PushBlockContext_Wide: + case Type::CloneBlockContext: + case Type::CloneBlockContext_Wide: + case Type::PushScriptContext: + case Type::PushScriptContext_Wide: + return true; + default: + break; + } + return false; +} + +QV4::Moth::ByteCodeHandler::Verdict QQmlJSCodeGenerator::startInstruction( + QV4::Moth::Instr::Type type) { m_state.State::operator=(nextStateFromAnnotations(m_state, *m_annotations)); m_state.accumulatorVariableIn = m_registerVariables.value(Accumulator) @@ -2202,7 +2228,7 @@ QV4::Moth::ByteCodeHandler::Verdict QQmlJSCodeGenerator::startInstruction(QV4::M m_body.setLabel(*labelIt); m_body += *labelIt + u":;\n"_qs; m_skipUntilNextLabel = false; - } else if (m_skipUntilNextLabel) { + } else if (m_skipUntilNextLabel && !instructionManipulatesContext(type)) { return SkipInstruction; } |