aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2016-03-22 14:49:21 +0100
committerErik Verbruggen <erik.verbruggen@theqtcompany.com>2016-04-05 08:09:19 +0000
commit7c18dcf79abbcc4de085e73ca7abe4eeeb7f140c (patch)
tree2517c9863549e3248aab0034a2ff4db6ba086322
parentfcbbedc3c21ff69d9251264dd708d6ca66c09359 (diff)
QML: add type info for the built-in qml context.
Previously, the type for the target temp would be 'var', which would subsequently be corrected to qobject through a member access. That resulted in typing the defining move again, which is unnecessary. Change-Id: Ife993a667331e69aea64ac2af0f64096a142a583 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp7
-rw-r--r--src/qml/compiler/qv4ssa.cpp11
2 files changed, 16 insertions, 2 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index 1960f1d65b..065e91109b 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -1790,7 +1790,12 @@ void JSCodeGen::beginFunctionBodyHook()
#ifndef V4_BOOTSTRAP
QV4::IR::Temp *temp = _block->TEMP(_qmlContextTemp);
- move(temp, _block->NAME(QV4::IR::Name::builtin_qml_context, 0, 0));
+ temp->type = QV4::IR::QObjectType;
+ temp->memberResolver = _function->New<QV4::IR::MemberExpressionResolver>();
+ initMetaObjectResolver(temp->memberResolver, _scopeObject);
+ auto name = _block->NAME(QV4::IR::Name::builtin_qml_context, 0, 0);
+ name->type = temp->type;
+ move(temp, name);
move(_block->TEMP(_importedScriptsTemp), _block->NAME(QV4::IR::Name::builtin_qml_imported_scripts_object, 0, 0));
#endif
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp
index 6a4c1c54d6..f7cdd1b0b5 100644
--- a/src/qml/compiler/qv4ssa.cpp
+++ b/src/qml/compiler/qv4ssa.cpp
@@ -2435,13 +2435,22 @@ protected:
virtual void visitExp(Exp *s) { _ty = run(s->expr); }
virtual void visitMove(Move *s) {
- TypingResult sourceTy = run(s->source);
if (Temp *t = s->target->asTemp()) {
+ if (Name *n = s->source->asName()) {
+ if (n->builtin == Name::builtin_qml_context) {
+ _ty = TypingResult(t->memberResolver);
+ setType(n, _ty.type);
+ setType(t, _ty.type);
+ return;
+ }
+ }
+ TypingResult sourceTy = run(s->source);
setType(t, sourceTy.type);
_ty = sourceTy;
return;
}
+ TypingResult sourceTy = run(s->source);
_ty = run(s->target);
_ty.fullyTyped &= sourceTy.fullyTyped;
}