From 7c18dcf79abbcc4de085e73ca7abe4eeeb7f140c Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 22 Mar 2016 14:49:21 +0100 Subject: 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 Reviewed-by: Simon Hausmann --- src/qml/compiler/qqmlirbuilder.cpp | 7 ++++++- src/qml/compiler/qv4ssa.cpp | 11 ++++++++++- 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(); + 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; } -- cgit v1.2.3