aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmlcodegenerator_p.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-10-23 16:24:58 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-29 21:56:07 +0100
commitba6fc15d729304c136447242de2410fbf4f020cd (patch)
tree3ad8a9575de295c9102eae125f64246bec854852 /src/qml/compiler/qqmlcodegenerator_p.h
parentc32265bfc562db23b7c894306ec61fd22111a7b1 (diff)
Speed up id object lookups
We can resolve lookups for objects referenced by id at QML compile time and use a run-time helper to extract the id object out of the QML context data by index instead of name. Dependencies to id objects are also tracked at compile time and registered separately before entering the generated function code. The lookup of id objects is encoded in the IR as special member lookups. Members will also then in the future be used to for property lookups in context and scope properties, as well as any other property lookups in QObjects where we can determine the meta-object. Change-Id: I36cf3ceb11b51a983da6cad5b61c3bf574acc20a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qqmlcodegenerator_p.h')
-rw-r--r--src/qml/compiler/qqmlcodegenerator_p.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator_p.h b/src/qml/compiler/qqmlcodegenerator_p.h
index 1830b62772..0f4c2b145a 100644
--- a/src/qml/compiler/qqmlcodegenerator_p.h
+++ b/src/qml/compiler/qqmlcodegenerator_p.h
@@ -349,24 +349,24 @@ struct Q_QML_EXPORT JSCodeGen : public QQmlJS::Codegen
: QQmlJS::Codegen(/*strict mode*/false)
{}
+ struct IdMapping
+ {
+ QString name;
+ int idIndex;
+ };
+ typedef QVector<IdMapping> ObjectIdMapping;
+
// Returns mapping from input functions to index in V4IR::Module::functions / compiledData->runtimeFunctions
QVector<int> generateJSCodeForFunctionsAndBindings(const QString &fileName, ParsedQML *output);
QVector<int> generateJSCodeForFunctionsAndBindings(const QString &fileName, const QString &sourceCode, V4IR::Module *jsModule,
- QQmlJS::Engine *jsEngine, AST::UiProgram *qmlRoot, const QList<AST::Node*> &functions);
-
-private:
- struct QmlScanner : public ScanFunctions
- {
- QmlScanner(JSCodeGen *cg, const QString &sourceCode)
- : ScanFunctions(cg, sourceCode, /*default program mode*/GlobalCode)
- , codeGen(cg)
- {}
+ QQmlJS::Engine *jsEngine, AST::UiProgram *qmlRoot, AST::Node *contextRoot, const QList<AST::Node*> &functions,
+ const ObjectIdMapping &objectIds = ObjectIdMapping());
- void begin(AST::Node *rootNode, CompilationMode compilationMode);
- void end();
+protected:
+ virtual V4IR::Expr *fallbackNameLookup(const QString &name, int line, int col) const;
- JSCodeGen *codeGen;
- };
+private:
+ ObjectIdMapping idObjects;
};
} // namespace QtQml