aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljscodegenerator.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-01-17 11:40:44 +0100
committerUlf Hermann <ulf.hermann@qt.io>2022-01-18 12:51:38 +0100
commit6a54c6013d9037f5c75d47f5e03d6871591e53b2 (patch)
tree182beb64c826e5e30ff782ee7196ad22a7ff0f93 /src/qmlcompiler/qqmljscodegenerator.cpp
parent3833e9291186ccd944e8b7c8c90116d1c2596f77 (diff)
QmlCompiler: Handle context push/pop in dead code
Otherwise we end up with unmatched curly braces in the generated code. Pick-to: 6.2 6.3 Change-Id: I4c24d4062a8ed54cd6a9ecb43dfd2b5d0a26c9e1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljscodegenerator.cpp')
-rw-r--r--src/qmlcompiler/qqmljscodegenerator.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/qmlcompiler/qqmljscodegenerator.cpp b/src/qmlcompiler/qqmljscodegenerator.cpp
index 28057d067c..a2f5d64aa5 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;
}