diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-12-02 13:56:20 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-12-15 17:47:58 +0100 |
commit | c4fc1167188cde9e89d44a8e5e02c5b1e04c61a7 (patch) | |
tree | 8d2ff74980203ce361e8a18dc7eb3a7de7d733c3 /src/qml/common | |
parent | b13e22f2745562d0549461c85cfee1bbada631ce (diff) |
QmlCompiler: Fix recognition of builtin list types
Previously all list types used as arguments or return types for methods
had to be looked up via the imports. However, builtin types are not part
of the imports at run time. Therefore, recognize list types already
early on, when generating the IR. This is the same way we do it for
property types and it allows us to easily identify lists of builtins.
Pick-to: 6.5
Fixes: QTBUG-109147
Change-Id: I91fa9c8fc99c1e0155cc5db5faddd928ca7fabbc
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/common')
-rw-r--r-- | src/qml/common/qv4compileddata_p.h | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/qml/common/qv4compileddata_p.h b/src/qml/common/qv4compileddata_p.h index 8a89c4ab28..8636fa4fbe 100644 --- a/src/qml/common/qv4compileddata_p.h +++ b/src/qml/common/qv4compileddata_p.h @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE // Also change the comment behind the number to describe the latest change. This has the added // benefit that if another patch changes the version too, it will result in a merge conflict, and // not get removed silently. -#define QV4_DATA_STRUCTURE_VERSION 0x3A // Dropped CallElement instruction +#define QV4_DATA_STRUCTURE_VERSION 0x3B // Add isList flag to method parameters and return types class QIODevice; class QQmlTypeNameCache; @@ -276,9 +276,17 @@ enum class BuiltinType : unsigned int { struct ParameterType { - void set(bool indexIsBuiltinType, quint32 typeNameIndexOrBuiltinType) + enum Flag { + NoFlag = 0x0, + Builtin = 0x1, + List = 0x2, + }; + Q_DECLARE_FLAGS(Flags, Flag); + + void set(Flags flags, quint32 typeNameIndexOrBuiltinType) { - m_data.set<IndexIsBuiltinTypeField>(indexIsBuiltinType ? 1 : 0); + m_data.set<IsListField>(flags.testFlag(List) ? 1 : 0); + m_data.set<IndexIsBuiltinTypeField>(flags.testFlag(Builtin) ? 1 : 0); m_data.set<TypeNameIndexOrBuiltinTypeField>(typeNameIndexOrBuiltinType); } @@ -287,6 +295,11 @@ struct ParameterType return m_data.get<IndexIsBuiltinTypeField>() != 0; } + bool isList() const + { + return m_data.get<IsListField>() != 0; + } + quint32 typeNameIndexOrBuiltinType() const { return m_data.get<TypeNameIndexOrBuiltinTypeField>(); @@ -294,8 +307,9 @@ struct ParameterType private: using IndexIsBuiltinTypeField = quint32_le_bitfield_member<0, 1>; - using TypeNameIndexOrBuiltinTypeField = quint32_le_bitfield_member<1, 31>; - quint32_le_bitfield_union<IndexIsBuiltinTypeField, TypeNameIndexOrBuiltinTypeField> m_data; + using IsListField = quint32_le_bitfield_member<1, 1>; + using TypeNameIndexOrBuiltinTypeField = quint32_le_bitfield_member<2, 30>; + quint32_le_bitfield_union<IndexIsBuiltinTypeField, IsListField, TypeNameIndexOrBuiltinTypeField> m_data; }; static_assert(sizeof(ParameterType) == 4, "ParameterType structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); @@ -1642,6 +1656,7 @@ private: } // CompiledData namespace } // QV4 namespace +Q_DECLARE_OPERATORS_FOR_FLAGS(QV4::CompiledData::ParameterType::Flags); Q_DECLARE_TYPEINFO(QV4::CompiledData::JSClassMember, Q_PRIMITIVE_TYPE); QT_END_NAMESPACE |