aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmlcompiler')
-rw-r--r--src/qmlcompiler/qqmljsshadowcheck.cpp21
-rw-r--r--src/qmlcompiler/qqmljsstoragegeneralizer.cpp14
-rw-r--r--src/qmlcompiler/qqmljstypepropagator.cpp11
3 files changed, 46 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljsshadowcheck.cpp b/src/qmlcompiler/qqmljsshadowcheck.cpp
index 1d16d7dad5..e1b98deda0 100644
--- a/src/qmlcompiler/qqmljsshadowcheck.cpp
+++ b/src/qmlcompiler/qqmljsshadowcheck.cpp
@@ -30,6 +30,27 @@
QT_BEGIN_NAMESPACE
+/*!
+ * \internal
+ * \class QQmlJSShadowCheck
+ *
+ * This pass looks for possible shadowing when accessing members of QML-exposed
+ * types. A member can be shadowed if a non-final property is re-declared in a
+ * derived class. As the QML engine will always pick up the most derived variant
+ * of that property, we cannot rely on any property of a type to be actually
+ * accessible, unless one of a few special cases holds:
+ *
+ * 1. We are dealing with a direct scope lookup, without an intermediate object.
+ * Such lookups are protected from shadowing. For example "property int a: b"
+ * always works.
+ * 2. The object we are retrieving the property from is identified by an ID, or
+ * an attached property or a singleton. Such objects cannot be replaced.
+ * Therefore we can be sure to see all the type information at compile time.
+ * 3. The property is declared final.
+ * 4. The object we are retrieving the property from is a value type. Value
+ * types cannot be used polymorphically.
+ */
+
void QQmlJSShadowCheck::run(
const InstructionAnnotations *annotations, const Function *function,
QQmlJS::DiagnosticMessage *error)
diff --git a/src/qmlcompiler/qqmljsstoragegeneralizer.cpp b/src/qmlcompiler/qqmljsstoragegeneralizer.cpp
index 2b0938c96f..4512d596e1 100644
--- a/src/qmlcompiler/qqmljsstoragegeneralizer.cpp
+++ b/src/qmlcompiler/qqmljsstoragegeneralizer.cpp
@@ -30,6 +30,20 @@
QT_BEGIN_NAMESPACE
+/*!
+ * \internal
+ * \class QQmlJSStorageGeneralizer
+ *
+ * The QQmlJSStorageGeneralizer is a compile pass that changes all type
+ * annotations and the function signature to use a generic storage type like
+ * QVariant or QObject*. This is necessary if we cannot rely on the original
+ * type to be immediately accessible, for example because we cannot include its
+ * header.
+ *
+ * QQmlJSStorageGeneralizer does not have to use the byte code at all but
+ * operates only on the annotations and the function description.
+ */
+
QQmlJSCompilePass::InstructionAnnotations QQmlJSStorageGeneralizer::run(
InstructionAnnotations annotations, Function *function,
QQmlJS::DiagnosticMessage *error)
diff --git a/src/qmlcompiler/qqmljstypepropagator.cpp b/src/qmlcompiler/qqmljstypepropagator.cpp
index 430762cbe1..4946270205 100644
--- a/src/qmlcompiler/qqmljstypepropagator.cpp
+++ b/src/qmlcompiler/qqmljstypepropagator.cpp
@@ -31,6 +31,17 @@
QT_BEGIN_NAMESPACE
+/*!
+ * \internal
+ * \class QQmlJSTypePropagator
+ *
+ * QQmlJSTypePropagator is the initial pass that performs the type inference and
+ * annotates every register in use at any instruction with the possible types it
+ * may hold. This includes information on how and in what scope the values are
+ * retrieved. These annotations may be used by further compile passes for
+ * refinement or code generation.
+ */
+
QQmlJSTypePropagator::QQmlJSTypePropagator(const QV4::Compiler::JSUnitGenerator *unitGenerator,
QQmlJSTypeResolver *typeResolver, QQmlJSLogger *logger,
QQmlJSTypeInfo *typeInfo)