diff options
author | Simon Hausmann <[email protected]> | 2014-01-27 16:55:49 +0100 |
---|---|---|
committer | The Qt Project <[email protected]> | 2014-01-29 10:08:50 +0100 |
commit | 3d3429f55bca1b09c1d2184ef719abae0e762a09 (patch) | |
tree | fbf79751ef8c18bfa594667c9c0d3c62d986e06b /src/qml/compiler/qv4compileddata_p.h | |
parent | 7cfd7ab2b1244681e384ec4640ee6e528881f4af (diff) |
[new compiler] Avoid uncreatable type errors for types that aren't created
QtQuick.Keys for example is not creatable, but it's also never created but
only used as attached properties. Therefore types used as attached properties
create the needCreation = false flag in the referenced types.
Change-Id: I6ca3a3ff677858bf3c55d3e08a0f0fc8ee9160fe
Reviewed-by: Lars Knoll <[email protected]>
Diffstat (limited to 'src/qml/compiler/qv4compileddata_p.h')
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 06361fbf85..29b6fd564e 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -74,13 +74,24 @@ struct Location qint32 column; }; +struct TypeReference +{ + TypeReference(const Location &loc) + : location(loc) + , needsCreation(false) + {} + Location location; // first use + bool needsCreation; // whether the type needs to be creatable or not +}; + // map from name index to location of first use -struct TypeReferenceMap : QHash<int, Location> +struct TypeReferenceMap : QHash<int, TypeReference> { - void add(int nameIndex, const Location &loc) { - if (contains(nameIndex)) - return; - insert(nameIndex, loc); + TypeReference &add(int nameIndex, const Location &loc) { + Iterator it = find(nameIndex); + if (it != end()) + return *it; + return *insert(nameIndex, loc); } }; |