aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2011-11-21 15:51:54 +1000
committerQt by Nokia <qt-info@nokia.com>2011-11-23 22:31:45 +0100
commit9be39c62ff33248e40175610173bf49d06336a5e (patch)
treef99a85757c49c45762a2102352d630ee02404606 /src/declarative
parent625d0cfc269bed9fcf80046a66cdd419c092490a (diff)
Use the AST for binding rewriting when possible.
Change-Id: I1ac8bd39ea7e02f7c236c030ca233e1060746431 Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp6
-rw-r--r--src/declarative/qml/qdeclarativecompiler_p.h2
-rw-r--r--src/declarative/qml/qdeclarativecustomparser.cpp6
-rw-r--r--src/declarative/qml/qdeclarativecustomparser_p.h2
-rw-r--r--src/declarative/util/qdeclarativepropertychanges.cpp3
5 files changed, 9 insertions, 10 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index e7d9b80c35..a2eae79ff7 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -1170,7 +1170,7 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeScript::Object *obj)
ss.value = output->indexForString(script);
ss.scope = prop->scriptStringScope;
// ss.bindingId = rewriteBinding(script, prop->name());
- ss.bindingId = rewriteBinding(script, QString()); // XXX
+ ss.bindingId = rewriteBinding(prop->values.first()->value, QString()); // XXX
ss.line = prop->location.start.line;
output->addInstruction(ss);
}
@@ -2484,12 +2484,12 @@ const QMetaObject *QDeclarativeCompiler::resolveType(const QString& name) const
// similar to logic of completeComponentBuild, but also sticks data
// into primitives at the end
-int QDeclarativeCompiler::rewriteBinding(const QString& expression, const QString& name)
+int QDeclarativeCompiler::rewriteBinding(const QDeclarativeScript::Variant& value, const QString& name)
{
QDeclarativeRewrite::RewriteBinding rewriteBinding;
rewriteBinding.setName(QLatin1Char('$') + name.mid(name.lastIndexOf(QLatin1Char('.')) + 1));
- QString rewrite = rewriteBinding(expression, 0, 0);
+ QString rewrite = rewriteBinding(value.asAST(), value.asScript(), 0);
return output->indexForString(rewrite);
}
diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h
index f6229bc666..1ee5afbc41 100644
--- a/src/declarative/qml/qdeclarativecompiler_p.h
+++ b/src/declarative/qml/qdeclarativecompiler_p.h
@@ -279,7 +279,7 @@ public:
int evaluateEnum(const QByteArray& script) const; // for QDeclarativeCustomParser::evaluateEnum
const QMetaObject *resolveType(const QString& name) const; // for QDeclarativeCustomParser::resolveType
- int rewriteBinding(const QString& expression, const QString& name); // for QDeclarativeCustomParser::rewriteBinding
+ int rewriteBinding(const QDeclarativeScript::Variant& value, const QString& name); // for QDeclarativeCustomParser::rewriteBinding
private:
typedef QDeclarativeCompiledData::Instruction Instruction;
diff --git a/src/declarative/qml/qdeclarativecustomparser.cpp b/src/declarative/qml/qdeclarativecustomparser.cpp
index e783d3ac75..9d643d3129 100644
--- a/src/declarative/qml/qdeclarativecustomparser.cpp
+++ b/src/declarative/qml/qdeclarativecustomparser.cpp
@@ -298,13 +298,13 @@ const QMetaObject *QDeclarativeCustomParser::resolveType(const QString& name) co
}
/*!
- Rewrites \a expression and returns an identifier that can be
+ Rewrites \a value and returns an identifier that can be
used to construct the binding later. \a name
is used as the name of the rewritten function.
*/
-QDeclarativeBinding::Identifier QDeclarativeCustomParser::rewriteBinding(const QString& expression, const QString& name)
+QDeclarativeBinding::Identifier QDeclarativeCustomParser::rewriteBinding(const QDeclarativeScript::Variant &value, const QString& name)
{
- return compiler->rewriteBinding(expression, name);
+ return compiler->rewriteBinding(value, name);
}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecustomparser_p.h b/src/declarative/qml/qdeclarativecustomparser_p.h
index 94b68652f4..83e1319fd2 100644
--- a/src/declarative/qml/qdeclarativecustomparser_p.h
+++ b/src/declarative/qml/qdeclarativecustomparser_p.h
@@ -142,7 +142,7 @@ protected:
const QMetaObject *resolveType(const QString&) const;
- QDeclarativeBinding::Identifier rewriteBinding(const QString&, const QString&);
+ QDeclarativeBinding::Identifier rewriteBinding(const QDeclarativeScript::Variant&, const QString&);
private:
QList<QDeclarativeError> exceptions;
diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp
index 72add5621f..e9dc559d5e 100644
--- a/src/declarative/util/qdeclarativepropertychanges.cpp
+++ b/src/declarative/util/qdeclarativepropertychanges.cpp
@@ -298,8 +298,7 @@ QDeclarativePropertyChangesParser::compile(const QList<QDeclarativeCustomParserP
var = QVariant(v.asScript());
{
// Pre-rewrite the expression
- QString expression = v.asScript();
- id = rewriteBinding(expression, data.at(ii).first); //### recreates the AST, which is slow
+ id = rewriteBinding(v, data.at(ii).first);
}
break;
}