diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2021-11-19 14:17:44 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-11-26 11:58:02 +0100 |
| commit | 66a7ab6ac1ebde82f6f81d43a5ecb1e693a41fab (patch) | |
| tree | 50c422b91c5fde57fce3fe01dbc8c2fe04d8e1b2 | |
| parent | 17bfd9c69467f2e7e426674d8d9fc4b9112e852d (diff) | |
QmlCompiler: Document the compile passes
Task-number: QTBUG-98305
Change-Id: I910d48183c1d78edf6c9d5ca80ceca07d276c702
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
| -rw-r--r-- | src/qmlcompiler/qqmljsshadowcheck.cpp | 21 | ||||
| -rw-r--r-- | src/qmlcompiler/qqmljsstoragegeneralizer.cpp | 14 | ||||
| -rw-r--r-- | src/qmlcompiler/qqmljstypepropagator.cpp | 11 |
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) |
