aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compilercontext.cpp
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2018-10-05 14:17:05 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2018-11-01 15:07:01 +0000
commit8b418d9be73dafd25c9c528127274a3573f1a7e1 (patch)
treef5901f8cf6e9a23caadbf5ba6fc4c3329b9823c7 /src/qml/compiler/qv4compilercontext.cpp
parentfd3cf7a45ad5abf269aecc63dc164d9bd0f1b407 (diff)
Clone ContextType::Global as ContextType::ScriptImportedByQML
Add new enum value QV4::Compiler::ContextType::ScriptImportedByQML, which behaves exactly the same as ContextType::Global. A follow-up patch will change the behavior slightly. Task-number: QTBUG-69408 Change-Id: I20d27804fd1433f2229704546bcd78a0ac108c01 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compilercontext.cpp')
-rw-r--r--src/qml/compiler/qv4compilercontext.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/qml/compiler/qv4compilercontext.cpp b/src/qml/compiler/qv4compilercontext.cpp
index b423dcf0b7..572f24f148 100644
--- a/src/qml/compiler/qv4compilercontext.cpp
+++ b/src/qml/compiler/qv4compilercontext.cpp
@@ -207,7 +207,7 @@ void Context::emitBlockHeader(Codegen *codegen)
blockIndex = codegen->module()->blocks.count() - 1;
}
- if (contextType == ContextType::Global) {
+ if (contextType == ContextType::Global || contextType == ContextType::ScriptImportedByQML) {
Instruction::PushScriptContext scriptContext;
scriptContext.index = blockIndex;
bytecodeGenerator->addInstruction(scriptContext);
@@ -256,7 +256,7 @@ void Context::emitBlockHeader(Codegen *codegen)
r.storeConsumeAccumulator();
}
- if (contextType == ContextType::Global || (contextType == ContextType::Eval && !isStrict)) {
+ if (contextType == ContextType::Global || contextType == ContextType::ScriptImportedByQML || (contextType == ContextType::Eval && !isStrict)) {
// variables in global code are properties of the global context object, not locals as with other functions.
for (Context::MemberMap::const_iterator it = members.constBegin(), cend = members.constEnd(); it != cend; ++it) {
if (it->isLexicallyScoped())
@@ -316,7 +316,7 @@ void Context::emitBlockFooter(Codegen *codegen)
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") // the loads below are empty structs.
- if (contextType == ContextType::Global)
+ if (contextType == ContextType::Global || contextType == ContextType::ScriptImportedByQML)
bytecodeGenerator->addInstruction(Instruction::PopScriptContext());
else if (contextType != ContextType::ESModule)
bytecodeGenerator->addInstruction(Instruction::PopContext());
@@ -371,9 +371,10 @@ void Context::setupFunctionIndices(Moth::BytecodeGenerator *bytecodeGenerator)
break;
}
case ContextType::Global:
+ case ContextType::ScriptImportedByQML:
case ContextType::Eval:
for (Context::MemberMap::iterator it = members.begin(), end = members.end(); it != end; ++it) {
- if (!it->isLexicallyScoped() && (contextType == ContextType::Global || !isStrict))
+ if (!it->isLexicallyScoped() && (contextType == ContextType::Global || contextType == ContextType::ScriptImportedByQML || !isStrict))
continue;
if (it->canEscape)
registerLocal(it);