aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativecompiler_p.h
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-12-21 16:34:36 +0000
committerQt by Nokia <qt-info@nokia.com>2011-12-21 18:42:48 +0100
commitb6c8497cdf070c8404a1f3784c4ee6df191bd546 (patch)
tree029a5ce39adbad2c9eb1213e57d38fecdd9e6041 /src/declarative/qml/qdeclarativecompiler_p.h
parent8249c72213bc7d212c05aa086b3145a5742706a3 (diff)
Detect and optimize qsTr() and qsTrId() bindings
As these two are frequently used with constants, we can detect them in the compiler, and run the appropriate C++ functions directly in the VME. This saves pointlessly creating and running bindings. Change-Id: I148a150400c13fda7955949453405202f18b1a6b Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'src/declarative/qml/qdeclarativecompiler_p.h')
-rw-r--r--src/declarative/qml/qdeclarativecompiler_p.h37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h
index 77f5b860dc..c592fd9a63 100644
--- a/src/declarative/qml/qdeclarativecompiler_p.h
+++ b/src/declarative/qml/qdeclarativecompiler_p.h
@@ -179,23 +179,36 @@ namespace QDeclarativeCompilerTypes {
QDeclarativeScript::Object *object;
};
- struct BindingReference : public QDeclarativePool::Class
+ struct BindingReference
{
- BindingReference() : nextReference(0) {}
+ enum DataType { QtScript, V4, V8,
+ Tr, TrId };
+ DataType dataType;
+ };
+
+ struct JSBindingReference : public QDeclarativePool::Class,
+ public BindingReference
+ {
+ JSBindingReference() : nextReference(0) {}
QDeclarativeScript::Variant expression;
QDeclarativeScript::Property *property;
QDeclarativeScript::Value *value;
- enum DataType { QtScript, V4, V8 };
- DataType dataType;
-
int compiledIndex;
QString rewrittenExpression;
BindingContext bindingContext;
- BindingReference *nextReference;
+ JSBindingReference *nextReference;
+ };
+
+ struct TrBindingReference : public QDeclarativePool::POD,
+ public BindingReference
+ {
+ QStringRef text;
+ QStringRef comment;
+ int n;
};
struct IdList : public QFieldList<QDeclarativeScript::Object,
@@ -250,9 +263,9 @@ namespace QDeclarativeCompilerTypes {
DepthStack objectDepth;
DepthStack listDepth;
- typedef QDeclarativeCompilerTypes::BindingReference B;
- typedef QFieldList<B, &B::nextReference> BindingReferenceList;
- BindingReferenceList bindings;
+ typedef QDeclarativeCompilerTypes::JSBindingReference B;
+ typedef QFieldList<B, &B::nextReference> JSBindingReferenceList;
+ JSBindingReferenceList bindings;
typedef QDeclarativeScript::Object O;
typedef QFieldList<O, &O::nextAliasingObject> AliasingObjectsList;
AliasingObjectsList aliasingObjects;
@@ -347,6 +360,8 @@ private:
bool checkDynamicMeta(QDeclarativeScript::Object *obj);
bool buildBinding(QDeclarativeScript::Value *, QDeclarativeScript::Property *prop,
const QDeclarativeCompilerTypes::BindingContext &ctxt);
+ bool buildLiteralBinding(QDeclarativeScript::Value *, QDeclarativeScript::Property *prop,
+ const QDeclarativeCompilerTypes::BindingContext &ctxt);
bool buildComponentFromRoot(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &);
bool compileAlias(QFastMetaBuilder &,
QByteArray &data,
@@ -378,6 +393,7 @@ private:
QDeclarativeScript::Property *valueTypeProp);
int componentTypeRef();
+ int translationContextIndex();
static QDeclarativeType *toQmlType(QDeclarativeScript::Object *from);
bool canCoerce(int to, QDeclarativeScript::Object *from);
@@ -399,7 +415,7 @@ private:
void dumpStats();
- void addBindingReference(QDeclarativeCompilerTypes::BindingReference *);
+ void addBindingReference(QDeclarativeCompilerTypes::JSBindingReference *);
QDeclarativeCompilerTypes::ComponentCompileState *compileState;
@@ -415,6 +431,7 @@ private:
QDeclarativeScript::Object *unitRoot;
QDeclarativeTypeData *unit;
int cachedComponentTypeRef;
+ int cachedTranslationContextIndex;
// Compiler component statistics. Only collected if QML_COMPILER_STATS=1
struct ComponentStat