aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4jsir_p.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-12-05 14:53:58 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-05 22:05:31 +0100
commite6415cc21768a0ade96d449f6d84a26037d563af (patch)
tree88de062498b42f066f1a253d6b0f53d463ed3db5 /src/qml/compiler/qv4jsir_p.h
parent7a344ef2b7796731a69a4f36e13ca9cf6f3b1ee9 (diff)
Clean up property dependency data structures
As a follow-up to the previous commit, this patch cleans up the data structures used to track dependencies of QML binding expressions and functions to context and scope properties, determined at compile time. Instead of "collecting" these depending properties upfront (codegen time), we propagate the information that a property is a context or scope property into the IR at codegen time and later in the isel collect these properties and their notify signal index in a hash in the IR functions. The CompileData structure generator then can read these hashes directly when writing out the dependency information. Change-Id: I32134706e2d24bf63d1b1abad0259ab072460173 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4jsir_p.h')
-rw-r--r--src/qml/compiler/qv4jsir_p.h63
1 files changed, 33 insertions, 30 deletions
diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h
index b0ca4c0478..2eba3405fe 100644
--- a/src/qml/compiler/qv4jsir_p.h
+++ b/src/qml/compiler/qv4jsir_p.h
@@ -554,42 +554,49 @@ struct Subscript: Expr {
};
struct Member: Expr {
+ // Used for property dependency tracking
+ enum MemberKind {
+ UnspecifiedMember,
+ MemberOfEnum,
+ MemberOfQmlScopeObject,
+ MemberOfQmlContextObject
+ };
+
Expr *base;
const QString *name;
QQmlPropertyData *property;
- int attachedPropertiesId;
- int enumValue;
- bool memberIsEnum : 1;
- bool freeOfSideEffects : 1;
+ int attachedPropertiesIdOrEnumValue; // depending on kind
+ uchar memberIsEnum : 1;
+ uchar freeOfSideEffects : 1;
// This is set for example for for QObject properties. All sorts of extra behavior
// is defined when writing to them, for example resettable properties are reset
// when writing undefined to them, and an exception is thrown when they're missing
// a reset function. And then there's also Qt.binding().
- bool inhibitTypeConversionOnWrite: 1;
+ uchar inhibitTypeConversionOnWrite: 1;
- void init(Expr *base, const QString *name, QQmlPropertyData *property = 0, int attachedPropertiesId = 0)
+ uchar kind: 3; // MemberKind
+
+ void setEnumValue(int value) {
+ kind = MemberOfEnum;
+ attachedPropertiesIdOrEnumValue = value;
+ }
+
+ void setAttachedPropertiesId(int id) {
+ Q_ASSERT(kind != MemberOfEnum);
+ attachedPropertiesIdOrEnumValue = id;
+ }
+
+ void init(Expr *base, const QString *name, QQmlPropertyData *property = 0, uchar kind = UnspecifiedMember, int attachedPropertiesIdOrEnumValue = 0)
{
this->base = base;
this->name = name;
this->property = property;
- this->attachedPropertiesId = attachedPropertiesId;
- this->enumValue = 0;
+ this->attachedPropertiesIdOrEnumValue = attachedPropertiesIdOrEnumValue;
this->memberIsEnum = false;
this->freeOfSideEffects = false;
this->inhibitTypeConversionOnWrite = property != 0;
- }
-
- void init(Expr *base, const QString *name, int enumValue)
- {
- this->base = base;
- this->name = name;
- this->property = 0;
- this->attachedPropertiesId = 0;
- this->enumValue = enumValue;
- this->memberIsEnum = true;
- this->freeOfSideEffects = false;
- this->inhibitTypeConversionOnWrite = false;
+ this->kind = kind;
}
virtual void accept(ExprVisitor *v) { v->visitMember(this); }
@@ -752,6 +759,9 @@ struct Q_QML_EXPORT Module {
void setFileName(const QString &name);
};
+// Map from meta property index (existence implies dependency) to notify signal index
+typedef QHash<int, int> PropertyDependencyMap;
+
struct Function {
Module *module;
MemoryPool *pool;
@@ -782,14 +792,8 @@ struct Function {
// Qml extension:
QSet<int> idObjectDependencies;
- // Context/Scope properties discovered during identifier resolution
- QSet<QQmlPropertyData*> contextObjectDependencyCandidates;
- QSet<QQmlPropertyData*> scopeObjectDependencyCandidates;
- // Context/Scope properties actually being read from, not only written
- QSet<QQmlPropertyData*> contextObjectDependencies;
- QSet<QQmlPropertyData*> scopeObjectDependencies;
-
- bool hasQmlDependencies() const { return !idObjectDependencies.isEmpty() || !contextObjectDependencies.isEmpty() || !scopeObjectDependencies.isEmpty(); }
+ PropertyDependencyMap contextObjectPropertyDependencies;
+ PropertyDependencyMap scopeObjectPropertyDependencies;
template <typename _Tp> _Tp *New() { return new (pool->allocate(sizeof(_Tp))) _Tp(); }
@@ -899,8 +903,7 @@ struct BasicBlock {
Expr *CALL(Expr *base, ExprList *args = 0);
Expr *NEW(Expr *base, ExprList *args = 0);
Expr *SUBSCRIPT(Expr *base, Expr *index);
- Expr *MEMBER(Expr *base, const QString *name, QQmlPropertyData *property = 0, int attachedPropertiesId = 0);
- Expr *MEMBER(Expr *base, const QString *name, int enumValue);
+ Expr *MEMBER(Expr *base, const QString *name, QQmlPropertyData *property = 0, uchar kind = Member::UnspecifiedMember, int attachedPropertiesIdOrEnumValue = 0);
Stmt *EXP(Expr *expr);