aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmltypecompiler_p.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-03-31 15:07:18 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-02 14:03:54 +0200
commit59ff5cd1f607eca41d7ef87364a0d6a112dca214 (patch)
tree5cf2d996b133a0d1ecf103f0ddfaac8cee2c8527 /src/qml/compiler/qqmltypecompiler_p.h
parent73074002c84ed8d6e9f913402cc6806629e0a030 (diff)
Fix compilation of script strings
The right hand side of script string properties can be evaluated in entirely dynamic scopes, due to QQmlExpressions' public API of allowing construction from a QQmlScriptString and a variable scope/context. Nevertheless we should compile these bindings at type compile time, as long as we make sure that the compiled code doesn't try to do any compile time determined property lookups and type resolution. This is implemented using a separate compilation pass that ensures the disableAcceleratedLookups flag is set. A few minor cleanups come with this patch: * Ensure that the property caches array is always symmetric to the list of compiled QML objects, as that allows the use of at() instead of value(). * The code for creating a QML callable function object for a given run-time function is now centralized in a static function QmlBindingWrapper, used for script strings and bindings from custom parsers. The provided unit test verifies the successful execution of the same script string with two different scope objects. Change-Id: Ica2cea46dd9e47263b4d494d922d3cc9664b08ae Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qqmltypecompiler_p.h')
-rw-r--r--src/qml/compiler/qqmltypecompiler_p.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/qml/compiler/qqmltypecompiler_p.h b/src/qml/compiler/qqmltypecompiler_p.h
index d54bc1b37b..3b449bf9bd 100644
--- a/src/qml/compiler/qqmltypecompiler_p.h
+++ b/src/qml/compiler/qqmltypecompiler_p.h
@@ -207,6 +207,18 @@ private:
const QVector<QQmlPropertyCache *> propertyCaches;
};
+class QQmlScriptStringScanner : public QQmlCompilePass
+{
+public:
+ QQmlScriptStringScanner(QQmlTypeCompiler *typeCompiler);
+
+ void scan();
+
+private:
+ const QList<QmlIR::Object*> &qmlObjects;
+ const QVector<QQmlPropertyCache *> propertyCaches;
+};
+
class QQmlComponentAndAliasResolver : public QQmlCompilePass
{
Q_DECLARE_TR_FUNCTIONS(QQmlAnonymousComponentResolver)
@@ -238,7 +250,7 @@ protected:
QList<int> _objectsWithAliases;
QHash<int, QQmlCompiledData::TypeReference*> *resolvedTypes;
- const QVector<QQmlPropertyCache *> propertyCaches;
+ QVector<QQmlPropertyCache *> propertyCaches;
QVector<QByteArray> *vmeMetaObjectData;
QHash<int, int> *objectIndexToIdForRoot;
QHash<int, QHash<int, int> > *objectIndexToIdPerComponent;