diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-05-23 13:48:50 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-23 13:18:58 +0000 |
commit | 3e6d5d9cd1de1373f67f2ff31373a59c37f7b576 (patch) | |
tree | cbf317a1ebbf9674e5f1a79d95411a534298713c /src/qml/compiler/qqmlirbuilder.cpp | |
parent | 20b376b64a11b4bda18aa1abda543586f04688e8 (diff) |
Set the name of the context as early as possible
We used to set the name later on when calling
Codegen::defineFunction(), but this is too late in some
cases, especially when using the name to determine if
this function could be a QML signal handler.
Change-Id: Ie620a65ac8f17906cd9eba338cbdd3563004375d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qqmlirbuilder.cpp')
-rw-r--r-- | src/qml/compiler/qqmlirbuilder.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 6b75f8b8b7..fcd535905b 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -1810,6 +1810,12 @@ void JSCodeGen::beginObjectScope(QQmlPropertyCache *scopeObject) QVector<int> JSCodeGen::generateJSCodeForFunctionsAndBindings(const QList<CompiledFunctionOrExpression> &functions) { + auto qmlName = [&](const CompiledFunctionOrExpression &c) { + if (c.nameIndex != 0) + return stringPool->stringForIndex(c.nameIndex); + else + return QStringLiteral("%qml-expression-entry"); + }; QVector<int> runtimeFunctionIndices(functions.size()); QV4::Compiler::ScanFunctions scan(this, sourceCode, QV4::Compiler::ContextType::Global); @@ -1823,7 +1829,7 @@ QVector<int> JSCodeGen::generateJSCodeForFunctionsAndBindings(const QList<Compil scan.enterQmlFunction(function); } else { Q_ASSERT(f.node != f.parentNode); - scan.enterEnvironment(f.parentNode, QV4::Compiler::ContextType::Binding); + scan.enterEnvironment(f.parentNode, QV4::Compiler::ContextType::Binding, qmlName(f)); } scan(function ? function->body : f.node); @@ -1846,10 +1852,8 @@ QVector<int> JSCodeGen::generateJSCodeForFunctionsAndBindings(const QList<Compil QString name; if (function) name = function->name.toString(); - else if (qmlFunction.nameIndex != 0) - name = stringPool->stringForIndex(qmlFunction.nameIndex); else - name = QStringLiteral("%qml-expression-entry"); + name = qmlName(qmlFunction); QQmlJS::AST::StatementList *body; if (function) { |