diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-07-04 09:58:43 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-07-04 10:22:34 +0000 |
commit | d5ab38b606fa63e6da1425b6fa607f55b3877007 (patch) | |
tree | 31372304cc0106680d37304875d611a530c0b7da | |
parent | 968033e33ba2d7d9dd614994ecfca8b68f972032 (diff) |
Properly save/restore the QML temps between functions
This only worked by chance before, as they always for the
same temp indices.
Change-Id: Ib2c8b912fa1dee8b1f12c8f9d895bc023bc265d3
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
-rw-r--r-- | src/qml/compiler/qqmlirbuilder.cpp | 15 | ||||
-rw-r--r-- | src/qml/compiler/qqmlirbuilder_p.h | 4 | ||||
-rw-r--r-- | src/qml/compiler/qv4codegen_p.h | 6 |
3 files changed, 22 insertions, 3 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 312ddd753b..f34a797508 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -1650,6 +1650,21 @@ QVector<int> JSCodeGen::generateJSCodeForFunctionsAndBindings(const QList<Compil return runtimeFunctionIndices; } +int JSCodeGen::defineFunction(const QString &name, AST::Node *ast, AST::FormalParameterList *formals, AST::SourceElements *body) +{ + int qmlContextTemp = -1; + int importedScriptsTemp = -1; + qSwap(_qmlContextTemp, qmlContextTemp); + qSwap(_importedScriptsTemp, importedScriptsTemp); + + int result = Codegen::defineFunction(name, ast, formals, body); + + qSwap(_importedScriptsTemp, importedScriptsTemp); + qSwap(_qmlContextTemp, qmlContextTemp); + + return result; +} + #ifndef V4_BOOTSTRAP QQmlPropertyData *JSCodeGen::lookupQmlCompliantProperty(QQmlPropertyCache *cache, const QString &name) { diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h index cba26bf50a..0aaf5aa624 100644 --- a/src/qml/compiler/qqmlirbuilder_p.h +++ b/src/qml/compiler/qqmlirbuilder_p.h @@ -601,6 +601,10 @@ struct Q_QML_PRIVATE_EXPORT JSCodeGen : public QV4::Compiler::Codegen // Returns mapping from input functions to index in IR::Module::functions / compiledData->runtimeFunctions QVector<int> generateJSCodeForFunctionsAndBindings(const QList<CompiledFunctionOrExpression> &functions); + int defineFunction(const QString &name, AST::Node *ast, + AST::FormalParameterList *formals, + AST::SourceElements *body) override; + protected: void beginFunctionBodyHook() override; Reference fallbackNameLookup(const QString &name) override; diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h index 93d3ad85c2..4170001954 100644 --- a/src/qml/compiler/qv4codegen_p.h +++ b/src/qml/compiler/qv4codegen_p.h @@ -345,9 +345,9 @@ protected: uint registerGlobalGetterLookup(int nameIndex) { return jsUnitGenerator->registerGlobalGetterLookup(nameIndex); } // Returns index in _module->functions - int defineFunction(const QString &name, AST::Node *ast, - AST::FormalParameterList *formals, - AST::SourceElements *body); + virtual int defineFunction(const QString &name, AST::Node *ast, + AST::FormalParameterList *formals, + AST::SourceElements *body); void statement(AST::Statement *ast); void statement(AST::ExpressionNode *ast); |