Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/compiler/qv4compileddata_p.h |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
5 | ** | - | ||||||||||||
6 | ** This file is part of the QtQml module of the Qt Toolkit. | - | ||||||||||||
7 | ** | - | ||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||
16 | ** | - | ||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
24 | ** | - | ||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
35 | ** | - | ||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||
37 | ** | - | ||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||
39 | #ifndef QV4COMPILEDDATA_P_H | - | ||||||||||||
40 | #define QV4COMPILEDDATA_P_H | - | ||||||||||||
41 | - | |||||||||||||
42 | // | - | ||||||||||||
43 | // W A R N I N G | - | ||||||||||||
44 | // ------------- | - | ||||||||||||
45 | // | - | ||||||||||||
46 | // This file is not part of the Qt API. It exists purely as an | - | ||||||||||||
47 | // implementation detail. This header file may change from version to | - | ||||||||||||
48 | // version without notice, or even be removed. | - | ||||||||||||
49 | // | - | ||||||||||||
50 | // We mean it. | - | ||||||||||||
51 | // | - | ||||||||||||
52 | - | |||||||||||||
53 | #include <QtCore/qstring.h> | - | ||||||||||||
54 | #include <QVector> | - | ||||||||||||
55 | #include <QStringList> | - | ||||||||||||
56 | #include <QHash> | - | ||||||||||||
57 | #include <QUrl> | - | ||||||||||||
58 | - | |||||||||||||
59 | #include <private/qv4value_p.h> | - | ||||||||||||
60 | #include <private/qv4executableallocator_p.h> | - | ||||||||||||
61 | #include <private/qqmlrefcount_p.h> | - | ||||||||||||
62 | #include <private/qqmlnullablevalue_p.h> | - | ||||||||||||
63 | #include <private/qv4identifier_p.h> | - | ||||||||||||
64 | #include <private/qflagpointer_p.h> | - | ||||||||||||
65 | #include <private/qendian_p.h> | - | ||||||||||||
66 | #ifndef V4_BOOTSTRAP | - | ||||||||||||
67 | #include <private/qqmltypenamecache_p.h> | - | ||||||||||||
68 | #include <private/qqmlpropertycache_p.h> | - | ||||||||||||
69 | #include "private/qintrusivelist_p.h" | - | ||||||||||||
70 | #endif | - | ||||||||||||
71 | - | |||||||||||||
72 | QT_BEGIN_NAMESPACE | - | ||||||||||||
73 | - | |||||||||||||
74 | // Bump this whenever the compiler data structures change in an incompatible way. | - | ||||||||||||
75 | #define QV4_DATA_STRUCTURE_VERSION 0x19 | - | ||||||||||||
76 | - | |||||||||||||
77 | class QIODevice; | - | ||||||||||||
78 | class QQmlPropertyCache; | - | ||||||||||||
79 | class QQmlPropertyData; | - | ||||||||||||
80 | class QQmlTypeNameCache; | - | ||||||||||||
81 | class QQmlScriptData; | - | ||||||||||||
82 | class QQmlType; | - | ||||||||||||
83 | class QQmlEngine; | - | ||||||||||||
84 | - | |||||||||||||
85 | namespace QmlIR { | - | ||||||||||||
86 | struct Document; | - | ||||||||||||
87 | } | - | ||||||||||||
88 | - | |||||||||||||
89 | namespace QV4 { | - | ||||||||||||
90 | - | |||||||||||||
91 | struct Function; | - | ||||||||||||
92 | class EvalISelFactory; | - | ||||||||||||
93 | class CompilationUnitMapper; | - | ||||||||||||
94 | - | |||||||||||||
95 | namespace CompiledData { | - | ||||||||||||
96 | - | |||||||||||||
97 | struct String; | - | ||||||||||||
98 | struct Function; | - | ||||||||||||
99 | struct Lookup; | - | ||||||||||||
100 | struct RegExp; | - | ||||||||||||
101 | struct Unit; | - | ||||||||||||
102 | - | |||||||||||||
103 | template <typename ItemType, typename Container, const ItemType *(Container::*IndexedGetter)(int index) const> | - | ||||||||||||
104 | struct TableIterator | - | ||||||||||||
105 | { | - | ||||||||||||
106 | TableIterator(const Container *container, int index) : container(container), index(index) {} executed 27228 times by 90 tests: end of block Executed by:
| 27228 | ||||||||||||
107 | const Container *container; | - | ||||||||||||
108 | int index; | - | ||||||||||||
109 | - | |||||||||||||
110 | const ItemType *operator->() { return (container->*IndexedGetter)(index); } executed 490 times by 14 tests: return (container->*IndexedGetter)(index); Executed by:
| 490 | ||||||||||||
111 | void operator++() { ++index; } executed 221 times by 14 tests: end of block Executed by:
| 221 | ||||||||||||
112 | bool operator==(const TableIterator &rhs) const { return index == rhs.index; } never executed: return index == rhs.index; | 0 | ||||||||||||
113 | bool operator!=(const TableIterator &rhs) const { return index != rhs.index; } executed 13835 times by 90 tests: return index != rhs.index; Executed by:
| 13835 | ||||||||||||
114 | }; | - | ||||||||||||
115 | - | |||||||||||||
116 | struct Location | - | ||||||||||||
117 | { | - | ||||||||||||
118 | union { | - | ||||||||||||
119 | quint32 _dummy; | - | ||||||||||||
120 | quint32_le_bitfield<0, 20> line; | - | ||||||||||||
121 | quint32_le_bitfield<20, 12> column; | - | ||||||||||||
122 | }; | - | ||||||||||||
123 | - | |||||||||||||
124 | Location() : _dummy(0) { } executed 574326 times by 142 tests: end of block Executed by:
| 574326 | ||||||||||||
125 | - | |||||||||||||
126 | inline bool operator<(const Location &other) const { | - | ||||||||||||
127 | return line < other.line || executed 2 times by 1 test: return line < other.line || (line == other.line && column < other.column); Executed by:
| 2 | ||||||||||||
128 | (line == other.line && column < other.column); executed 2 times by 1 test: return line < other.line || (line == other.line && column < other.column); Executed by:
| 2 | ||||||||||||
129 | } | - | ||||||||||||
130 | }; | - | ||||||||||||
131 | static_assert(sizeof(Location) == 4, "Location structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
132 | - | |||||||||||||
133 | struct RegExp | - | ||||||||||||
134 | { | - | ||||||||||||
135 | enum Flags : unsigned int { | - | ||||||||||||
136 | RegExp_Global = 0x01, | - | ||||||||||||
137 | RegExp_IgnoreCase = 0x02, | - | ||||||||||||
138 | RegExp_Multiline = 0x04 | - | ||||||||||||
139 | }; | - | ||||||||||||
140 | union { | - | ||||||||||||
141 | quint32 _dummy; | - | ||||||||||||
142 | quint32_le_bitfield<0, 4> flags; | - | ||||||||||||
143 | quint32_le_bitfield<4, 28> stringIndex; | - | ||||||||||||
144 | }; | - | ||||||||||||
145 | - | |||||||||||||
146 | RegExp() : _dummy(0) { } executed 1054971 times by 8 tests: end of block Executed by:
| 1054971 | ||||||||||||
147 | }; | - | ||||||||||||
148 | static_assert(sizeof(RegExp) == 4, "RegExp structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
149 | - | |||||||||||||
150 | struct Lookup | - | ||||||||||||
151 | { | - | ||||||||||||
152 | enum Type : unsigned int { | - | ||||||||||||
153 | Type_Getter = 0x0, | - | ||||||||||||
154 | Type_Setter = 0x1, | - | ||||||||||||
155 | Type_GlobalGetter = 2 | - | ||||||||||||
156 | }; | - | ||||||||||||
157 | - | |||||||||||||
158 | union { | - | ||||||||||||
159 | quint32 _dummy; | - | ||||||||||||
160 | quint32_le_bitfield<0, 4> type_and_flags; | - | ||||||||||||
161 | quint32_le_bitfield<4, 28> nameIndex; | - | ||||||||||||
162 | }; | - | ||||||||||||
163 | - | |||||||||||||
164 | Lookup() : _dummy(0) { } executed 5881206 times by 8 tests: end of block Executed by:
| 5881206 | ||||||||||||
165 | }; | - | ||||||||||||
166 | static_assert(sizeof(Lookup) == 4, "Lookup structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
167 | - | |||||||||||||
168 | struct JSClassMember | - | ||||||||||||
169 | { | - | ||||||||||||
170 | union { | - | ||||||||||||
171 | quint32 _dummy; | - | ||||||||||||
172 | quint32_le_bitfield<0, 31> nameOffset; | - | ||||||||||||
173 | quint32_le_bitfield<31, 1> isAccessor; | - | ||||||||||||
174 | }; | - | ||||||||||||
175 | - | |||||||||||||
176 | JSClassMember() : _dummy(0) { } never executed: end of block | 0 | ||||||||||||
177 | }; | - | ||||||||||||
178 | static_assert(sizeof(JSClassMember) == 4, "JSClassMember structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
179 | - | |||||||||||||
180 | struct JSClass | - | ||||||||||||
181 | { | - | ||||||||||||
182 | quint32_le nMembers; | - | ||||||||||||
183 | // JSClassMember[nMembers] | - | ||||||||||||
184 | - | |||||||||||||
185 | static int calculateSize(int nMembers) { return (sizeof(JSClass) + nMembers * sizeof(JSClassMember) + 7) & ~7; } executed 71520 times by 36 tests: return (sizeof(JSClass) + nMembers * sizeof(JSClassMember) + 7) & ~7; Executed by:
| 71520 | ||||||||||||
186 | }; | - | ||||||||||||
187 | static_assert(sizeof(JSClass) == 4, "JSClass structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
188 | - | |||||||||||||
189 | // This data structure is intended to be binary compatible with QStringData/QStaticStringData on | - | ||||||||||||
190 | // 64-bit and 32-bit little-endian architectures, in all directions. So the same structure mapped | - | ||||||||||||
191 | // from a file must be castable to a QStringData regardless of the pointer size. With the first | - | ||||||||||||
192 | // few fields that's easy, they're always 32-bit. However the offset field of QArrayData is a | - | ||||||||||||
193 | // ptrdiff_t and thus variable in size. | - | ||||||||||||
194 | // On 64-bit systems compilers enforce an 8-byte alignment and thus place it at offset 16, while | - | ||||||||||||
195 | // on 32-bit systems offset 12 is sufficient. Therefore the two values don't overlap and contain | - | ||||||||||||
196 | // the same value. | - | ||||||||||||
197 | struct String | - | ||||||||||||
198 | { | - | ||||||||||||
199 | qint32_le refcount; // -1 | - | ||||||||||||
200 | qint32_le size; | - | ||||||||||||
201 | quint32_le allocAndCapacityReservedFlag; // 0 | - | ||||||||||||
202 | quint32_le offsetOn32Bit; | - | ||||||||||||
203 | quint64_le offsetOn64Bit; | - | ||||||||||||
204 | // uint16 strdata[] | - | ||||||||||||
205 | - | |||||||||||||
206 | static int calculateSize(const QString &str) { | - | ||||||||||||
207 | return (sizeof(String) + (str.length() + 1) * sizeof(quint16) + 7) & ~0x7; executed 27171099 times by 147 tests: return (sizeof(String) + (str.length() + 1) * sizeof(quint16) + 7) & ~0x7; Executed by:
| 27171099 | ||||||||||||
208 | } | - | ||||||||||||
209 | }; | - | ||||||||||||
210 | static_assert(sizeof(String) == 24, "String structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
211 | - | |||||||||||||
212 | // Ensure compatibility with QString | - | ||||||||||||
213 | static_assert(offsetof(QArrayData, ref) == offsetof(String, refcount), "refcount must be at the same location"); | - | ||||||||||||
214 | static_assert(offsetof(QArrayData, size) == offsetof(String, size), "size must be at the same location"); | - | ||||||||||||
215 | static_assert(offsetof(String, offsetOn64Bit) == 16, "offset must be at 8-byte aligned location"); | - | ||||||||||||
216 | static_assert(offsetof(String, offsetOn32Bit) == 12, "offset must be at 4-byte aligned location"); | - | ||||||||||||
217 | #if QT_POINTER_SIZE == 8 | - | ||||||||||||
218 | static_assert(offsetof(QArrayData, offset) == offsetof(String, offsetOn64Bit), "offset must be at the same location"); | - | ||||||||||||
219 | #else | - | ||||||||||||
220 | static_assert(offsetof(QArrayData, offset) == offsetof(String, offsetOn32Bit), "offset must be at the same location"); | - | ||||||||||||
221 | #endif | - | ||||||||||||
222 | - | |||||||||||||
223 | struct CodeOffsetToLine { | - | ||||||||||||
224 | quint32_le codeOffset; | - | ||||||||||||
225 | quint32_le line; | - | ||||||||||||
226 | }; | - | ||||||||||||
227 | - | |||||||||||||
228 | struct Block | - | ||||||||||||
229 | { | - | ||||||||||||
230 | quint32_le nLocals; | - | ||||||||||||
231 | quint32_le localsOffset; | - | ||||||||||||
232 | - | |||||||||||||
233 | const quint32_le *localsTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + localsOffset); } executed 339681 times by 39 tests: return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + localsOffset); Executed by:
| 339681 | ||||||||||||
234 | - | |||||||||||||
235 | static int calculateSize(int nLocals) { | - | ||||||||||||
236 | int trailingData = nLocals*sizeof (quint32); | - | ||||||||||||
237 | size_t size = align(align(sizeof(Block)) + size_t(trailingData)); | - | ||||||||||||
238 | Q_ASSERT(size < INT_MAX); | - | ||||||||||||
239 | return int(size); executed 345730 times by 40 tests: return int(size); Executed by:
| 345730 | ||||||||||||
240 | } | - | ||||||||||||
241 | - | |||||||||||||
242 | static size_t align(size_t a) { | - | ||||||||||||
243 | return (a + 7) & ~size_t(7); executed 689763 times by 40 tests: return (a + 7) & ~size_t(7); Executed by:
| 689763 | ||||||||||||
244 | } | - | ||||||||||||
245 | }; | - | ||||||||||||
246 | - | |||||||||||||
247 | // Function is aligned on an 8-byte boundary to make sure there are no bus errors or penalties | - | ||||||||||||
248 | // for unaligned access. The ordering of the fields is also from largest to smallest. | - | ||||||||||||
249 | struct Function | - | ||||||||||||
250 | { | - | ||||||||||||
251 | enum Flags : unsigned int { | - | ||||||||||||
252 | IsStrict = 0x1, | - | ||||||||||||
253 | IsArrowFunction = 0x2, | - | ||||||||||||
254 | IsGenerator = 0x4 | - | ||||||||||||
255 | }; | - | ||||||||||||
256 | - | |||||||||||||
257 | // Absolute offset into file where the code for this function is located. | - | ||||||||||||
258 | quint32_le codeOffset; | - | ||||||||||||
259 | quint32_le codeSize; | - | ||||||||||||
260 | - | |||||||||||||
261 | quint32_le nameIndex; | - | ||||||||||||
262 | quint32_le length; | - | ||||||||||||
263 | quint32_le nFormals; | - | ||||||||||||
264 | quint32_le formalsOffset; | - | ||||||||||||
265 | quint32_le nLocals; | - | ||||||||||||
266 | quint32_le localsOffset; | - | ||||||||||||
267 | quint32_le nLineNumbers; | - | ||||||||||||
268 | quint32_le lineNumberOffset; | - | ||||||||||||
269 | quint32_le nestedFunctionIndex; // for functions that only return a single closure, used in signal handlers | - | ||||||||||||
270 | quint32_le nRegisters; | - | ||||||||||||
271 | Location location; | - | ||||||||||||
272 | - | |||||||||||||
273 | // Qml Extensions Begin | - | ||||||||||||
274 | quint32_le nDependingIdObjects; | - | ||||||||||||
275 | quint32_le dependingIdObjectsOffset; // Array of resolved ID objects | - | ||||||||||||
276 | quint32_le nDependingContextProperties; | - | ||||||||||||
277 | quint32_le dependingContextPropertiesOffset; // Array of int pairs (property index and notify index) | - | ||||||||||||
278 | quint32_le nDependingScopeProperties; | - | ||||||||||||
279 | quint32_le dependingScopePropertiesOffset; // Array of int pairs (property index and notify index) | - | ||||||||||||
280 | // Qml Extensions End | - | ||||||||||||
281 | - | |||||||||||||
282 | // Keep all unaligned data at the end | - | ||||||||||||
283 | quint8 flags; | - | ||||||||||||
284 | quint8 padding1; | - | ||||||||||||
285 | quint16_le padding2; | - | ||||||||||||
286 | - | |||||||||||||
287 | // quint32 formalsIndex[nFormals] | - | ||||||||||||
288 | // quint32 localsIndex[nLocals] | - | ||||||||||||
289 | - | |||||||||||||
290 | const quint32_le *formalsTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + formalsOffset); } executed 3453673 times by 138 tests: return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + formalsOffset); Executed by:
| 3453673 | ||||||||||||
291 | const quint32_le *localsTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + localsOffset); } executed 3439731 times by 138 tests: return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + localsOffset); Executed by:
| 3439731 | ||||||||||||
292 | const CodeOffsetToLine *lineNumberTable() const { return reinterpret_cast<const CodeOffsetToLine *>(reinterpret_cast<const char *>(this) + lineNumberOffset); } executed 4577045 times by 40 tests: return reinterpret_cast<const CodeOffsetToLine *>(reinterpret_cast<const char *>(this) + lineNumberOffset); Executed by:
| 4577045 | ||||||||||||
293 | const quint32_le *qmlIdObjectDependencyTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingIdObjectsOffset); } executed 99145 times by 67 tests: return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingIdObjectsOffset); Executed by:
| 99145 | ||||||||||||
294 | const quint32_le *qmlContextPropertiesDependencyTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingContextPropertiesOffset); } executed 99145 times by 67 tests: return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingContextPropertiesOffset); Executed by:
| 99145 | ||||||||||||
295 | const quint32_le *qmlScopePropertiesDependencyTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingScopePropertiesOffset); } executed 99145 times by 67 tests: return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingScopePropertiesOffset); Executed by:
| 99145 | ||||||||||||
296 | - | |||||||||||||
297 | // --- QQmlPropertyCacheCreator interface | - | ||||||||||||
298 | const quint32_le *formalsBegin() const { return formalsTable(); } executed 6563 times by 51 tests: return formalsTable(); Executed by:
| 6563 | ||||||||||||
299 | const quint32_le *formalsEnd() const { return formalsTable() + nFormals; } executed 6563 times by 51 tests: return formalsTable() + nFormals; Executed by:
| 6563 | ||||||||||||
300 | // --- | - | ||||||||||||
301 | - | |||||||||||||
302 | const char *code() const { return reinterpret_cast<const char *>(this) + codeOffset; } executed 3441641 times by 138 tests: return reinterpret_cast<const char *>(this) + codeOffset; Executed by:
| 3441641 | ||||||||||||
303 | - | |||||||||||||
304 | inline bool hasQmlDependencies() const { return nDependingIdObjects > 0 || nDependingContextProperties > 0 || nDependingScopeProperties > 0; } executed 3716387 times by 138 tests: return nDependingIdObjects > 0 || nDependingContextProperties > 0 || nDependingScopeProperties > 0; Executed by:
| 3716387 | ||||||||||||
305 | - | |||||||||||||
306 | static int calculateSize(int nFormals, int nLocals, int nLines, int nInnerfunctions, int nIdObjectDependencies, int nPropertyDependencies, int codeSize) { | - | ||||||||||||
307 | int trailingData = (nFormals + nLocals + nInnerfunctions + nIdObjectDependencies + | - | ||||||||||||
308 | 2 * nPropertyDependencies)*sizeof (quint32) + nLines*sizeof(CodeOffsetToLine); | - | ||||||||||||
309 | size_t size = align(align(sizeof(Function)) + size_t(trailingData)) + align(codeSize); | - | ||||||||||||
310 | Q_ASSERT(size < INT_MAX); | - | ||||||||||||
311 | return int(size); executed 3398978 times by 140 tests: return int(size); Executed by:
| 3398978 | ||||||||||||
312 | } | - | ||||||||||||
313 | - | |||||||||||||
314 | static size_t align(size_t a) { | - | ||||||||||||
315 | return (a + 7) & ~size_t(7); executed 10194110 times by 140 tests: return (a + 7) & ~size_t(7); Executed by:
| 10194110 | ||||||||||||
316 | } | - | ||||||||||||
317 | }; | - | ||||||||||||
318 | static_assert(sizeof(Function) == 80, "Function structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
319 | - | |||||||||||||
320 | struct Method { | - | ||||||||||||
321 | enum Type { | - | ||||||||||||
322 | Regular, | - | ||||||||||||
323 | Getter, | - | ||||||||||||
324 | Setter | - | ||||||||||||
325 | }; | - | ||||||||||||
326 | - | |||||||||||||
327 | quint32_le name; | - | ||||||||||||
328 | quint32_le type; | - | ||||||||||||
329 | quint32_le function; | - | ||||||||||||
330 | }; | - | ||||||||||||
331 | - | |||||||||||||
332 | struct Class | - | ||||||||||||
333 | { | - | ||||||||||||
334 | quint32_le nameIndex; | - | ||||||||||||
335 | quint32_le scopeIndex; | - | ||||||||||||
336 | quint32_le constructorFunction; | - | ||||||||||||
337 | quint32_le nStaticMethods; | - | ||||||||||||
338 | quint32_le nMethods; | - | ||||||||||||
339 | quint32_le methodTableOffset; | - | ||||||||||||
340 | - | |||||||||||||
341 | const Method *methodTable() const { return reinterpret_cast<const Method *>(reinterpret_cast<const char *>(this) + methodTableOffset); } executed 9008 times by 1 test: return reinterpret_cast<const Method *>(reinterpret_cast<const char *>(this) + methodTableOffset); Executed by:
| 9008 | ||||||||||||
342 | - | |||||||||||||
343 | static int calculateSize(int nStaticMethods, int nMethods) { | - | ||||||||||||
344 | int trailingData = (nStaticMethods + nMethods) * sizeof(Method); | - | ||||||||||||
345 | size_t size = align(sizeof(Class) + trailingData); | - | ||||||||||||
346 | Q_ASSERT(size < INT_MAX); | - | ||||||||||||
347 | return int(size); executed 9292 times by 1 test: return int(size); Executed by:
| 9292 | ||||||||||||
348 | } | - | ||||||||||||
349 | - | |||||||||||||
350 | static size_t align(size_t a) { | - | ||||||||||||
351 | return (a + 7) & ~size_t(7); executed 9292 times by 1 test: return (a + 7) & ~size_t(7); Executed by:
| 9292 | ||||||||||||
352 | } | - | ||||||||||||
353 | }; | - | ||||||||||||
354 | static_assert(sizeof(Class) == 24, "Function structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
355 | - | |||||||||||||
356 | - | |||||||||||||
357 | // Qml data structures | - | ||||||||||||
358 | - | |||||||||||||
359 | struct Q_QML_EXPORT TranslationData { | - | ||||||||||||
360 | quint32_le commentIndex; | - | ||||||||||||
361 | qint32_le number; | - | ||||||||||||
362 | }; | - | ||||||||||||
363 | static_assert(sizeof(TranslationData) == 8, "TranslationData structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
364 | - | |||||||||||||
365 | struct Q_QML_PRIVATE_EXPORT Binding | - | ||||||||||||
366 | { | - | ||||||||||||
367 | quint32_le propertyNameIndex; | - | ||||||||||||
368 | - | |||||||||||||
369 | enum ValueType : unsigned int { | - | ||||||||||||
370 | Type_Invalid, | - | ||||||||||||
371 | Type_Boolean, | - | ||||||||||||
372 | Type_Number, | - | ||||||||||||
373 | Type_String, | - | ||||||||||||
374 | Type_Translation, | - | ||||||||||||
375 | Type_TranslationById, | - | ||||||||||||
376 | Type_Script, | - | ||||||||||||
377 | Type_Object, | - | ||||||||||||
378 | Type_AttachedProperty, | - | ||||||||||||
379 | Type_GroupProperty | - | ||||||||||||
380 | }; | - | ||||||||||||
381 | - | |||||||||||||
382 | enum Flags : unsigned int { | - | ||||||||||||
383 | IsSignalHandlerExpression = 0x1, | - | ||||||||||||
384 | IsSignalHandlerObject = 0x2, | - | ||||||||||||
385 | IsOnAssignment = 0x4, | - | ||||||||||||
386 | InitializerForReadOnlyDeclaration = 0x8, | - | ||||||||||||
387 | IsResolvedEnum = 0x10, | - | ||||||||||||
388 | IsListItem = 0x20, | - | ||||||||||||
389 | IsBindingToAlias = 0x40, | - | ||||||||||||
390 | IsDeferredBinding = 0x80, | - | ||||||||||||
391 | IsCustomParserBinding = 0x100, | - | ||||||||||||
392 | IsFunctionExpression = 0x200 | - | ||||||||||||
393 | }; | - | ||||||||||||
394 | - | |||||||||||||
395 | union { | - | ||||||||||||
396 | quint32_le_bitfield<0, 16> flags; | - | ||||||||||||
397 | quint32_le_bitfield<16, 16> type; | - | ||||||||||||
398 | }; | - | ||||||||||||
399 | union { | - | ||||||||||||
400 | bool b; | - | ||||||||||||
401 | quint64 doubleValue; // do not access directly, needs endian protected access | - | ||||||||||||
402 | quint32_le compiledScriptIndex; // used when Type_Script | - | ||||||||||||
403 | quint32_le objectIndex; | - | ||||||||||||
404 | TranslationData translationData; // used when Type_Translation | - | ||||||||||||
405 | } value; | - | ||||||||||||
406 | quint32_le stringIndex; // Set for Type_String, Type_Translation and Type_Script (the latter because of script strings) | - | ||||||||||||
407 | - | |||||||||||||
408 | Location location; | - | ||||||||||||
409 | Location valueLocation; | - | ||||||||||||
410 | - | |||||||||||||
411 | quint32_le padding; | - | ||||||||||||
412 | - | |||||||||||||
413 | bool isValueBinding() const | - | ||||||||||||
414 | { | - | ||||||||||||
415 | if (type == Type_AttachedProperty
| 991-119606 | ||||||||||||
416 | || type == Type_GroupProperty)
| 2910-116696 | ||||||||||||
417 | return false; executed 3901 times by 109 tests: return false; Executed by:
| 3901 | ||||||||||||
418 | if (flags & IsSignalHandlerExpression
| 1838-114858 | ||||||||||||
419 | || flags & IsSignalHandlerObject)
| 20-114838 | ||||||||||||
420 | return false; executed 1858 times by 82 tests: return false; Executed by:
| 1858 | ||||||||||||
421 | return true; executed 114838 times by 142 tests: return true; Executed by:
| 114838 | ||||||||||||
422 | } | - | ||||||||||||
423 | - | |||||||||||||
424 | bool isValueBindingNoAlias() const { return isValueBinding() && !(flags & IsBindingToAlias); } never executed: return isValueBinding() && !(flags & IsBindingToAlias); | 0 | ||||||||||||
425 | bool isValueBindingToAlias() const { return isValueBinding() && (flags & IsBindingToAlias); } never executed: return isValueBinding() && (flags & IsBindingToAlias); | 0 | ||||||||||||
426 | - | |||||||||||||
427 | bool isSignalHandler() const | - | ||||||||||||
428 | { | - | ||||||||||||
429 | if (flags & IsSignalHandlerExpression || flags & IsSignalHandlerObject) {
| 0 | ||||||||||||
430 | Q_ASSERT(!isValueBinding()); | - | ||||||||||||
431 | Q_ASSERT(!isAttachedProperty()); | - | ||||||||||||
432 | Q_ASSERT(!isGroupProperty()); | - | ||||||||||||
433 | return true; never executed: return true; | 0 | ||||||||||||
434 | } | - | ||||||||||||
435 | return false; never executed: return false; | 0 | ||||||||||||
436 | } | - | ||||||||||||
437 | - | |||||||||||||
438 | bool isAttachedProperty() const | - | ||||||||||||
439 | { | - | ||||||||||||
440 | if (type == Type_AttachedProperty) {
| 0 | ||||||||||||
441 | Q_ASSERT(!isValueBinding()); | - | ||||||||||||
442 | Q_ASSERT(!isSignalHandler()); | - | ||||||||||||
443 | Q_ASSERT(!isGroupProperty()); | - | ||||||||||||
444 | return true; never executed: return true; | 0 | ||||||||||||
445 | } | - | ||||||||||||
446 | return false; never executed: return false; | 0 | ||||||||||||
447 | } | - | ||||||||||||
448 | - | |||||||||||||
449 | bool isGroupProperty() const | - | ||||||||||||
450 | { | - | ||||||||||||
451 | if (type == Type_GroupProperty) {
| 0 | ||||||||||||
452 | Q_ASSERT(!isValueBinding()); | - | ||||||||||||
453 | Q_ASSERT(!isSignalHandler()); | - | ||||||||||||
454 | Q_ASSERT(!isAttachedProperty()); | - | ||||||||||||
455 | return true; never executed: return true; | 0 | ||||||||||||
456 | } | - | ||||||||||||
457 | return false; never executed: return false; | 0 | ||||||||||||
458 | } | - | ||||||||||||
459 | - | |||||||||||||
460 | bool isFunctionExpression() const { return (flags & IsFunctionExpression); } executed 190 times by 2 tests: return (flags & IsFunctionExpression); Executed by:
| 190 | ||||||||||||
461 | - | |||||||||||||
462 | static QString escapedString(const QString &string); | - | ||||||||||||
463 | - | |||||||||||||
464 | bool isTranslationBinding() const { return type == Type_Translation || type == Type_TranslationById; } executed 1773552 times by 140 tests: return type == Type_Translation || type == Type_TranslationById; Executed by:
| 1773552 | ||||||||||||
465 | bool evaluatesToString() const { return type == Type_String || isTranslationBinding(); } executed 248835 times by 111 tests: return type == Type_String || isTranslationBinding(); Executed by:
| 248835 | ||||||||||||
466 | - | |||||||||||||
467 | QString valueAsString(const Unit *unit) const; | - | ||||||||||||
468 | QString valueAsScriptString(const Unit *unit) const; | - | ||||||||||||
469 | double valueAsNumber() const | - | ||||||||||||
470 | { | - | ||||||||||||
471 | if (type != Type_Number)
| 4158-567351 | ||||||||||||
472 | return 0.0; executed 4158 times by 12 tests: return 0.0; Executed by:
| 4158 | ||||||||||||
473 | quint64 intval = qFromLittleEndian<quint64>(value.doubleValue); | - | ||||||||||||
474 | double d; | - | ||||||||||||
475 | memcpy(&d, &intval, sizeof(double)); | - | ||||||||||||
476 | return d; executed 567351 times by 121 tests: return d; Executed by:
| 567351 | ||||||||||||
477 | } | - | ||||||||||||
478 | void setNumberValueInternal(double d) | - | ||||||||||||
479 | { | - | ||||||||||||
480 | quint64 intval; | - | ||||||||||||
481 | memcpy(&intval, &d, sizeof(double)); | - | ||||||||||||
482 | value.doubleValue = qToLittleEndian<quint64>(intval); | - | ||||||||||||
483 | } executed 1344 times by 41 tests: end of block Executed by:
| 1344 | ||||||||||||
484 | - | |||||||||||||
485 | bool valueAsBoolean() const | - | ||||||||||||
486 | { | - | ||||||||||||
487 | if (type == Type_Boolean)
| 0-26170 | ||||||||||||
488 | return value.b; executed 26170 times by 98 tests: return value.b; Executed by:
| 26170 | ||||||||||||
489 | return false; never executed: return false; | 0 | ||||||||||||
490 | } | - | ||||||||||||
491 | - | |||||||||||||
492 | }; | - | ||||||||||||
493 | - | |||||||||||||
494 | static_assert(sizeof(Binding) == 32, "Binding structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
495 | - | |||||||||||||
496 | struct EnumValue | - | ||||||||||||
497 | { | - | ||||||||||||
498 | quint32_le nameIndex; | - | ||||||||||||
499 | qint32_le value; | - | ||||||||||||
500 | Location location; | - | ||||||||||||
501 | }; | - | ||||||||||||
502 | - | |||||||||||||
503 | struct Enum | - | ||||||||||||
504 | { | - | ||||||||||||
505 | quint32_le nameIndex; | - | ||||||||||||
506 | quint32_le nEnumValues; | - | ||||||||||||
507 | Location location; | - | ||||||||||||
508 | - | |||||||||||||
509 | const EnumValue *enumValueAt(int idx) const { | - | ||||||||||||
510 | return reinterpret_cast<const EnumValue*>(this + 1) + idx; never executed: return reinterpret_cast<const EnumValue*>(this + 1) + idx; | 0 | ||||||||||||
511 | } | - | ||||||||||||
512 | - | |||||||||||||
513 | static int calculateSize(int nEnumValues) { | - | ||||||||||||
514 | return (sizeof(Enum) never executed: return (sizeof(Enum) + nEnumValues * sizeof(EnumValue) + 7) & ~0x7; | 0 | ||||||||||||
515 | + nEnumValues * sizeof(EnumValue) never executed: return (sizeof(Enum) + nEnumValues * sizeof(EnumValue) + 7) & ~0x7; | 0 | ||||||||||||
516 | + 7) & ~0x7; never executed: return (sizeof(Enum) + nEnumValues * sizeof(EnumValue) + 7) & ~0x7; | 0 | ||||||||||||
517 | } | - | ||||||||||||
518 | - | |||||||||||||
519 | // --- QQmlPropertyCacheCreatorInterface | - | ||||||||||||
520 | const EnumValue *enumValuesBegin() const { return enumValueAt(0); } never executed: return enumValueAt(0); | 0 | ||||||||||||
521 | const EnumValue *enumValuesEnd() const { return enumValueAt(nEnumValues); } never executed: return enumValueAt(nEnumValues); | 0 | ||||||||||||
522 | int enumValueCount() const { return nEnumValues; } never executed: return nEnumValues; | 0 | ||||||||||||
523 | // --- | - | ||||||||||||
524 | }; | - | ||||||||||||
525 | - | |||||||||||||
526 | struct Parameter | - | ||||||||||||
527 | { | - | ||||||||||||
528 | quint32_le nameIndex; | - | ||||||||||||
529 | quint32_le type; | - | ||||||||||||
530 | quint32_le customTypeNameIndex; | - | ||||||||||||
531 | Location location; | - | ||||||||||||
532 | }; | - | ||||||||||||
533 | static_assert(sizeof(Parameter) == 16, "Parameter structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
534 | - | |||||||||||||
535 | struct Signal | - | ||||||||||||
536 | { | - | ||||||||||||
537 | quint32_le nameIndex; | - | ||||||||||||
538 | quint32_le nParameters; | - | ||||||||||||
539 | Location location; | - | ||||||||||||
540 | // Parameter parameters[1]; | - | ||||||||||||
541 | - | |||||||||||||
542 | const Parameter *parameterAt(int idx) const { | - | ||||||||||||
543 | return reinterpret_cast<const Parameter*>(this + 1) + idx; executed 48 times by 5 tests: return reinterpret_cast<const Parameter*>(this + 1) + idx; Executed by:
| 48 | ||||||||||||
544 | } | - | ||||||||||||
545 | - | |||||||||||||
546 | static int calculateSize(int nParameters) { | - | ||||||||||||
547 | return (sizeof(Signal) never executed: return (sizeof(Signal) + nParameters * sizeof(Parameter) + 7) & ~0x7; | 0 | ||||||||||||
548 | + nParameters * sizeof(Parameter) never executed: return (sizeof(Signal) + nParameters * sizeof(Parameter) + 7) & ~0x7; | 0 | ||||||||||||
549 | + 7) & ~0x7; never executed: return (sizeof(Signal) + nParameters * sizeof(Parameter) + 7) & ~0x7; | 0 | ||||||||||||
550 | } | - | ||||||||||||
551 | - | |||||||||||||
552 | // --- QQmlPropertyCacheCceatorInterface | - | ||||||||||||
553 | const Parameter *parametersBegin() const { return parameterAt(0); } executed 24 times by 5 tests: return parameterAt(0); Executed by:
| 24 | ||||||||||||
554 | const Parameter *parametersEnd() const { return parameterAt(nParameters); } executed 24 times by 5 tests: return parameterAt(nParameters); Executed by:
| 24 | ||||||||||||
555 | int parameterCount() const { return nParameters; } executed 221 times by 14 tests: return nParameters; Executed by:
| 221 | ||||||||||||
556 | // --- | - | ||||||||||||
557 | }; | - | ||||||||||||
558 | static_assert(sizeof(Signal) == 12, "Signal structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
559 | - | |||||||||||||
560 | struct Property | - | ||||||||||||
561 | { | - | ||||||||||||
562 | enum Type : unsigned int { Var = 0, Variant, Int, Bool, Real, String, Url, Color, | - | ||||||||||||
563 | Font, Time, Date, DateTime, Rect, Point, Size, | - | ||||||||||||
564 | Vector2D, Vector3D, Vector4D, Matrix4x4, Quaternion, | - | ||||||||||||
565 | Custom, CustomList }; | - | ||||||||||||
566 | - | |||||||||||||
567 | enum Flags : unsigned int { | - | ||||||||||||
568 | IsReadOnly = 0x1 | - | ||||||||||||
569 | }; | - | ||||||||||||
570 | - | |||||||||||||
571 | quint32_le nameIndex; | - | ||||||||||||
572 | union { | - | ||||||||||||
573 | quint32_le_bitfield<0, 31> type; | - | ||||||||||||
574 | quint32_le_bitfield<31, 1> flags; // readonly | - | ||||||||||||
575 | }; | - | ||||||||||||
576 | quint32_le customTypeNameIndex; // If type >= Custom | - | ||||||||||||
577 | Location location; | - | ||||||||||||
578 | }; | - | ||||||||||||
579 | static_assert(sizeof(Property) == 16, "Property structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
580 | - | |||||||||||||
581 | struct Alias { | - | ||||||||||||
582 | enum Flags : unsigned int { | - | ||||||||||||
583 | IsReadOnly = 0x1, | - | ||||||||||||
584 | Resolved = 0x2, | - | ||||||||||||
585 | AliasPointsToPointerObject = 0x4 | - | ||||||||||||
586 | }; | - | ||||||||||||
587 | union { | - | ||||||||||||
588 | quint32_le_bitfield<0, 29> nameIndex; | - | ||||||||||||
589 | quint32_le_bitfield<29, 3> flags; | - | ||||||||||||
590 | }; | - | ||||||||||||
591 | union { | - | ||||||||||||
592 | quint32_le idIndex; // string index | - | ||||||||||||
593 | quint32_le_bitfield<0, 31> targetObjectId; // object id index (in QQmlContextData::idValues) | - | ||||||||||||
594 | quint32_le_bitfield<31, 1> aliasToLocalAlias; | - | ||||||||||||
595 | }; | - | ||||||||||||
596 | union { | - | ||||||||||||
597 | quint32_le propertyNameIndex; // string index | - | ||||||||||||
598 | qint32_le encodedMetaPropertyIndex; | - | ||||||||||||
599 | quint32_le localAliasIndex; // index in list of aliases local to the object (if targetObjectId == objectId) | - | ||||||||||||
600 | }; | - | ||||||||||||
601 | Location location; | - | ||||||||||||
602 | Location referenceLocation; | - | ||||||||||||
603 | - | |||||||||||||
604 | bool isObjectAlias() const { | - | ||||||||||||
605 | Q_ASSERT(flags & Resolved); | - | ||||||||||||
606 | return encodedMetaPropertyIndex == -1; executed 6648 times by 30 tests: return encodedMetaPropertyIndex == -1; Executed by:
| 6648 | ||||||||||||
607 | } | - | ||||||||||||
608 | }; | - | ||||||||||||
609 | static_assert(sizeof(Alias) == 20, "Alias structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
610 | - | |||||||||||||
611 | struct Object | - | ||||||||||||
612 | { | - | ||||||||||||
613 | enum Flags : unsigned int { | - | ||||||||||||
614 | NoFlag = 0x0, | - | ||||||||||||
615 | IsComponent = 0x1, // object was identified to be an explicit or implicit component boundary | - | ||||||||||||
616 | HasDeferredBindings = 0x2, // any of the bindings are deferred | - | ||||||||||||
617 | HasCustomParserBindings = 0x4 | - | ||||||||||||
618 | }; | - | ||||||||||||
619 | - | |||||||||||||
620 | // Depending on the use, this may be the type name to instantiate before instantiating this | - | ||||||||||||
621 | // object. For grouped properties the type name will be empty and for attached properties | - | ||||||||||||
622 | // it will be the name of the attached type. | - | ||||||||||||
623 | quint32_le inheritedTypeNameIndex; | - | ||||||||||||
624 | quint32_le idNameIndex; | - | ||||||||||||
625 | union { | - | ||||||||||||
626 | quint32_le_bitfield<0, 15> flags; | - | ||||||||||||
627 | quint32_le_bitfield<15, 1> defaultPropertyIsAlias; | - | ||||||||||||
628 | qint32_le_bitfield<16, 16> id; | - | ||||||||||||
629 | }; | - | ||||||||||||
630 | qint32_le indexOfDefaultPropertyOrAlias; // -1 means no default property declared in this object | - | ||||||||||||
631 | quint32_le nFunctions; | - | ||||||||||||
632 | quint32_le offsetToFunctions; | - | ||||||||||||
633 | quint32_le nProperties; | - | ||||||||||||
634 | quint32_le offsetToProperties; | - | ||||||||||||
635 | quint32_le nAliases; | - | ||||||||||||
636 | quint32_le offsetToAliases; | - | ||||||||||||
637 | quint32_le nEnums; | - | ||||||||||||
638 | quint32_le offsetToEnums; // which in turn will be a table with offsets to variable-sized Enum objects | - | ||||||||||||
639 | quint32_le nSignals; | - | ||||||||||||
640 | quint32_le offsetToSignals; // which in turn will be a table with offsets to variable-sized Signal objects | - | ||||||||||||
641 | quint32_le nBindings; | - | ||||||||||||
642 | quint32_le offsetToBindings; | - | ||||||||||||
643 | quint32_le nNamedObjectsInComponent; | - | ||||||||||||
644 | quint32_le offsetToNamedObjectsInComponent; | - | ||||||||||||
645 | Location location; | - | ||||||||||||
646 | Location locationOfIdProperty; | - | ||||||||||||
647 | // Function[] | - | ||||||||||||
648 | // Property[] | - | ||||||||||||
649 | // Signal[] | - | ||||||||||||
650 | // Binding[] | - | ||||||||||||
651 | - | |||||||||||||
652 | static int calculateSizeExcludingSignalsAndEnums(int nFunctions, int nProperties, int nAliases, int nEnums, int nSignals, int nBindings, int nNamedObjectsInComponent) | - | ||||||||||||
653 | { | - | ||||||||||||
654 | return ( sizeof(Object) never executed: return ( sizeof(Object) + nFunctions * sizeof(quint32) + nProperties * sizeof(Property) + nAliases * sizeof(Alias) + nEnums * sizeof(quint32) + nSignals * sizeof(quint32) + nBindings * sizeof(Binding) + nNamedObjectsInComponent * sizeof(int) + 0x7 ) & ~0x7; | 0 | ||||||||||||
655 | + nFunctions * sizeof(quint32) never executed: return ( sizeof(Object) + nFunctions * sizeof(quint32) + nProperties * sizeof(Property) + nAliases * sizeof(Alias) + nEnums * sizeof(quint32) + nSignals * sizeof(quint32) + nBindings * sizeof(Binding) + nNamedObjectsInComponent * sizeof(int) + 0x7 ) & ~0x7; | 0 | ||||||||||||
656 | + nProperties * sizeof(Property) never executed: return ( sizeof(Object) + nFunctions * sizeof(quint32) + nProperties * sizeof(Property) + nAliases * sizeof(Alias) + nEnums * sizeof(quint32) + nSignals * sizeof(quint32) + nBindings * sizeof(Binding) + nNamedObjectsInComponent * sizeof(int) + 0x7 ) & ~0x7; | 0 | ||||||||||||
657 | + nAliases * sizeof(Alias) never executed: return ( sizeof(Object) + nFunctions * sizeof(quint32) + nProperties * sizeof(Property) + nAliases * sizeof(Alias) + nEnums * sizeof(quint32) + nSignals * sizeof(quint32) + nBindings * sizeof(Binding) + nNamedObjectsInComponent * sizeof(int) + 0x7 ) & ~0x7; | 0 | ||||||||||||
658 | + nEnums * sizeof(quint32) never executed: return ( sizeof(Object) + nFunctions * sizeof(quint32) + nProperties * sizeof(Property) + nAliases * sizeof(Alias) + nEnums * sizeof(quint32) + nSignals * sizeof(quint32) + nBindings * sizeof(Binding) + nNamedObjectsInComponent * sizeof(int) + 0x7 ) & ~0x7; | 0 | ||||||||||||
659 | + nSignals * sizeof(quint32) never executed: return ( sizeof(Object) + nFunctions * sizeof(quint32) + nProperties * sizeof(Property) + nAliases * sizeof(Alias) + nEnums * sizeof(quint32) + nSignals * sizeof(quint32) + nBindings * sizeof(Binding) + nNamedObjectsInComponent * sizeof(int) + 0x7 ) & ~0x7; | 0 | ||||||||||||
660 | + nBindings * sizeof(Binding) never executed: return ( sizeof(Object) + nFunctions * sizeof(quint32) + nProperties * sizeof(Property) + nAliases * sizeof(Alias) + nEnums * sizeof(quint32) + nSignals * sizeof(quint32) + nBindings * sizeof(Binding) + nNamedObjectsInComponent * sizeof(int) + 0x7 ) & ~0x7; | 0 | ||||||||||||
661 | + nNamedObjectsInComponent * sizeof(int) never executed: return ( sizeof(Object) + nFunctions * sizeof(quint32) + nProperties * sizeof(Property) + nAliases * sizeof(Alias) + nEnums * sizeof(quint32) + nSignals * sizeof(quint32) + nBindings * sizeof(Binding) + nNamedObjectsInComponent * sizeof(int) + 0x7 ) & ~0x7; | 0 | ||||||||||||
662 | + 0x7 never executed: return ( sizeof(Object) + nFunctions * sizeof(quint32) + nProperties * sizeof(Property) + nAliases * sizeof(Alias) + nEnums * sizeof(quint32) + nSignals * sizeof(quint32) + nBindings * sizeof(Binding) + nNamedObjectsInComponent * sizeof(int) + 0x7 ) & ~0x7; | 0 | ||||||||||||
663 | ) & ~0x7; never executed: return ( sizeof(Object) + nFunctions * sizeof(quint32) + nProperties * sizeof(Property) + nAliases * sizeof(Alias) + nEnums * sizeof(quint32) + nSignals * sizeof(quint32) + nBindings * sizeof(Binding) + nNamedObjectsInComponent * sizeof(int) + 0x7 ) & ~0x7; | 0 | ||||||||||||
664 | } | - | ||||||||||||
665 | - | |||||||||||||
666 | const quint32_le *functionOffsetTable() const | - | ||||||||||||
667 | { | - | ||||||||||||
668 | return reinterpret_cast<const quint32_le*>(reinterpret_cast<const char *>(this) + offsetToFunctions); executed 35377 times by 54 tests: return reinterpret_cast<const quint32_le*>(reinterpret_cast<const char *>(this) + offsetToFunctions); Executed by:
| 35377 | ||||||||||||
669 | } | - | ||||||||||||
670 | - | |||||||||||||
671 | const Property *propertyTable() const | - | ||||||||||||
672 | { | - | ||||||||||||
673 | return reinterpret_cast<const Property*>(reinterpret_cast<const char *>(this) + offsetToProperties); executed 527466 times by 134 tests: return reinterpret_cast<const Property*>(reinterpret_cast<const char *>(this) + offsetToProperties); Executed by:
| 527466 | ||||||||||||
674 | } | - | ||||||||||||
675 | - | |||||||||||||
676 | const Alias *aliasTable() const | - | ||||||||||||
677 | { | - | ||||||||||||
678 | return reinterpret_cast<const Alias*>(reinterpret_cast<const char *>(this) + offsetToAliases); executed 41244 times by 90 tests: return reinterpret_cast<const Alias*>(reinterpret_cast<const char *>(this) + offsetToAliases); Executed by:
| 41244 | ||||||||||||
679 | } | - | ||||||||||||
680 | - | |||||||||||||
681 | const Binding *bindingTable() const | - | ||||||||||||
682 | { | - | ||||||||||||
683 | return reinterpret_cast<const Binding*>(reinterpret_cast<const char *>(this) + offsetToBindings); executed 1406549 times by 142 tests: return reinterpret_cast<const Binding*>(reinterpret_cast<const char *>(this) + offsetToBindings); Executed by:
| 1406549 | ||||||||||||
684 | } | - | ||||||||||||
685 | - | |||||||||||||
686 | const Enum *enumAt(int idx) const | - | ||||||||||||
687 | { | - | ||||||||||||
688 | const quint32_le *offsetTable = reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToEnums); | - | ||||||||||||
689 | const quint32_le offset = offsetTable[idx]; | - | ||||||||||||
690 | return reinterpret_cast<const Enum*>(reinterpret_cast<const char*>(this) + offset); never executed: return reinterpret_cast<const Enum*>(reinterpret_cast<const char*>(this) + offset); | 0 | ||||||||||||
691 | } | - | ||||||||||||
692 | - | |||||||||||||
693 | const Signal *signalAt(int idx) const | - | ||||||||||||
694 | { | - | ||||||||||||
695 | const quint32_le *offsetTable = reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToSignals); | - | ||||||||||||
696 | const quint32_le offset = offsetTable[idx]; | - | ||||||||||||
697 | return reinterpret_cast<const Signal*>(reinterpret_cast<const char*>(this) + offset); executed 490 times by 14 tests: return reinterpret_cast<const Signal*>(reinterpret_cast<const char*>(this) + offset); Executed by:
| 490 | ||||||||||||
698 | } | - | ||||||||||||
699 | - | |||||||||||||
700 | const quint32_le *namedObjectsInComponentTable() const | - | ||||||||||||
701 | { | - | ||||||||||||
702 | return reinterpret_cast<const quint32_le*>(reinterpret_cast<const char *>(this) + offsetToNamedObjectsInComponent); executed 49432 times by 90 tests: return reinterpret_cast<const quint32_le*>(reinterpret_cast<const char *>(this) + offsetToNamedObjectsInComponent); Executed by:
| 49432 | ||||||||||||
703 | } | - | ||||||||||||
704 | - | |||||||||||||
705 | // --- QQmlPropertyCacheCreator interface | - | ||||||||||||
706 | int propertyCount() const { return nProperties; } executed 74254 times by 123 tests: return nProperties; Executed by:
| 74254 | ||||||||||||
707 | int aliasCount() const { return nAliases; } executed 122463 times by 123 tests: return nAliases; Executed by:
| 122463 | ||||||||||||
708 | int enumCount() const { return nEnums; } executed 54101 times by 123 tests: return nEnums; Executed by:
| 54101 | ||||||||||||
709 | int signalCount() const { return nSignals; } executed 61226 times by 123 tests: return nSignals; Executed by:
| 61226 | ||||||||||||
710 | int functionCount() const { return nFunctions; } executed 54400 times by 123 tests: return nFunctions; Executed by:
| 54400 | ||||||||||||
711 | - | |||||||||||||
712 | const Binding *bindingsBegin() const { return bindingTable(); } executed 212904 times by 124 tests: return bindingTable(); Executed by:
| 212904 | ||||||||||||
713 | const Binding *bindingsEnd() const { return bindingTable() + nBindings; } executed 211682 times by 124 tests: return bindingTable() + nBindings; Executed by:
| 211682 | ||||||||||||
714 | - | |||||||||||||
715 | const Property *propertiesBegin() const { return propertyTable(); } executed 77911 times by 124 tests: return propertyTable(); Executed by:
| 77911 | ||||||||||||
716 | const Property *propertiesEnd() const { return propertyTable() + nProperties; } executed 77911 times by 124 tests: return propertyTable() + nProperties; Executed by:
| 77911 | ||||||||||||
717 | - | |||||||||||||
718 | const Alias *aliasesBegin() const { return aliasTable(); } executed 14706 times by 90 tests: return aliasTable(); Executed by:
| 14706 | ||||||||||||
719 | const Alias *aliasesEnd() const { return aliasTable() + nAliases; } executed 14704 times by 90 tests: return aliasTable() + nAliases; Executed by:
| 14704 | ||||||||||||
720 | - | |||||||||||||
721 | typedef TableIterator<Enum, Object, &Object::enumAt> EnumIterator; | - | ||||||||||||
722 | EnumIterator enumsBegin() const { return EnumIterator(this, 0); } executed 6807 times by 90 tests: return EnumIterator(this, 0); Executed by:
| 6807 | ||||||||||||
723 | EnumIterator enumsEnd() const { return EnumIterator(this, nEnums); } executed 6807 times by 90 tests: return EnumIterator(this, nEnums); Executed by:
| 6807 | ||||||||||||
724 | - | |||||||||||||
725 | typedef TableIterator<Signal, Object, &Object::signalAt> SignalIterator; | - | ||||||||||||
726 | SignalIterator signalsBegin() const { return SignalIterator(this, 0); } executed 6807 times by 90 tests: return SignalIterator(this, 0); Executed by:
| 6807 | ||||||||||||
727 | SignalIterator signalsEnd() const { return SignalIterator(this, nSignals); } executed 6807 times by 90 tests: return SignalIterator(this, nSignals); Executed by:
| 6807 | ||||||||||||
728 | - | |||||||||||||
729 | int namedObjectsInComponentCount() const { return nNamedObjectsInComponent; } executed 2040 times by 35 tests: return nNamedObjectsInComponent; Executed by:
| 2040 | ||||||||||||
730 | // --- | - | ||||||||||||
731 | }; | - | ||||||||||||
732 | static_assert(sizeof(Object) == 80, "Object structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
733 | - | |||||||||||||
734 | struct Import | - | ||||||||||||
735 | { | - | ||||||||||||
736 | enum ImportType : unsigned int { | - | ||||||||||||
737 | ImportLibrary = 0x1, | - | ||||||||||||
738 | ImportFile = 0x2, | - | ||||||||||||
739 | ImportScript = 0x3 | - | ||||||||||||
740 | }; | - | ||||||||||||
741 | quint32_le type; | - | ||||||||||||
742 | - | |||||||||||||
743 | quint32_le uriIndex; | - | ||||||||||||
744 | quint32_le qualifierIndex; | - | ||||||||||||
745 | - | |||||||||||||
746 | qint32_le majorVersion; | - | ||||||||||||
747 | qint32_le minorVersion; | - | ||||||||||||
748 | - | |||||||||||||
749 | Location location; | - | ||||||||||||
750 | - | |||||||||||||
751 | Import() { type = 0; uriIndex = 0; qualifierIndex = 0; majorVersion = 0; minorVersion = 0; } executed 602 times by 36 tests: end of block Executed by:
| 602 | ||||||||||||
752 | }; | - | ||||||||||||
753 | static_assert(sizeof(Import) == 24, "Import structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
754 | - | |||||||||||||
755 | static const char magic_str[] = "qv4cdata"; | - | ||||||||||||
756 | - | |||||||||||||
757 | struct Unit | - | ||||||||||||
758 | { | - | ||||||||||||
759 | // DO NOT CHANGE THESE FIELDS EVER | - | ||||||||||||
760 | char magic[8]; | - | ||||||||||||
761 | quint32_le version; | - | ||||||||||||
762 | quint32_le qtVersion; | - | ||||||||||||
763 | qint64_le sourceTimeStamp; | - | ||||||||||||
764 | quint32_le unitSize; // Size of the Unit and any depending data. | - | ||||||||||||
765 | // END DO NOT CHANGE THESE FIELDS EVER | - | ||||||||||||
766 | - | |||||||||||||
767 | char libraryVersionHash[48]; | - | ||||||||||||
768 | - | |||||||||||||
769 | char md5Checksum[16]; // checksum of all bytes following this field. | - | ||||||||||||
770 | void generateChecksum(); | - | ||||||||||||
771 | - | |||||||||||||
772 | char dependencyMD5Checksum[16]; | - | ||||||||||||
773 | - | |||||||||||||
774 | enum : unsigned int { | - | ||||||||||||
775 | IsJavascript = 0x1, | - | ||||||||||||
776 | IsQml = 0x2, | - | ||||||||||||
777 | StaticData = 0x4, // Unit data persistent in memory? | - | ||||||||||||
778 | IsSingleton = 0x8, | - | ||||||||||||
779 | IsSharedLibrary = 0x10, // .pragma shared? | - | ||||||||||||
780 | PendingTypeCompilation = 0x20 // the QML data structures present are incomplete and require type compilation | - | ||||||||||||
781 | }; | - | ||||||||||||
782 | quint32_le flags; | - | ||||||||||||
783 | quint32_le stringTableSize; | - | ||||||||||||
784 | quint32_le offsetToStringTable; | - | ||||||||||||
785 | quint32_le functionTableSize; | - | ||||||||||||
786 | quint32_le offsetToFunctionTable; | - | ||||||||||||
787 | quint32_le classTableSize; | - | ||||||||||||
788 | quint32_le offsetToClassTable; | - | ||||||||||||
789 | quint32_le blockTableSize; | - | ||||||||||||
790 | quint32_le offsetToBlockTable; | - | ||||||||||||
791 | quint32_le lookupTableSize; | - | ||||||||||||
792 | quint32_le offsetToLookupTable; | - | ||||||||||||
793 | quint32_le regexpTableSize; | - | ||||||||||||
794 | quint32_le offsetToRegexpTable; | - | ||||||||||||
795 | quint32_le constantTableSize; | - | ||||||||||||
796 | quint32_le offsetToConstantTable; | - | ||||||||||||
797 | quint32_le jsClassTableSize; | - | ||||||||||||
798 | quint32_le offsetToJSClassTable; | - | ||||||||||||
799 | qint32_le indexOfRootFunction; | - | ||||||||||||
800 | quint32_le sourceFileIndex; | - | ||||||||||||
801 | quint32_le finalUrlIndex; | - | ||||||||||||
802 | - | |||||||||||||
803 | /* QML specific fields */ | - | ||||||||||||
804 | quint32_le nImports; | - | ||||||||||||
805 | quint32_le offsetToImports; | - | ||||||||||||
806 | quint32_le nObjects; | - | ||||||||||||
807 | quint32_le offsetToObjects; | - | ||||||||||||
808 | - | |||||||||||||
809 | quint32_le padding; | - | ||||||||||||
810 | - | |||||||||||||
811 | bool verifyHeader(QDateTime expectedSourceTimeStamp, QString *errorString) const; | - | ||||||||||||
812 | - | |||||||||||||
813 | const Import *importAt(int idx) const { | - | ||||||||||||
814 | return reinterpret_cast<const Import*>((reinterpret_cast<const char *>(this)) + offsetToImports + idx * sizeof(Import)); executed 10403 times by 126 tests: return reinterpret_cast<const Import*>((reinterpret_cast<const char *>(this)) + offsetToImports + idx * sizeof(Import)); Executed by:
| 10403 | ||||||||||||
815 | } | - | ||||||||||||
816 | - | |||||||||||||
817 | const Object *objectAt(int idx) const { | - | ||||||||||||
818 | const quint32_le *offsetTable = reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToObjects); | - | ||||||||||||
819 | const quint32_le offset = offsetTable[idx]; | - | ||||||||||||
820 | return reinterpret_cast<const Object*>(reinterpret_cast<const char*>(this) + offset); executed 2184583 times by 142 tests: return reinterpret_cast<const Object*>(reinterpret_cast<const char*>(this) + offset); Executed by:
| 2184583 | ||||||||||||
821 | } | - | ||||||||||||
822 | - | |||||||||||||
823 | bool isSingleton() const { | - | ||||||||||||
824 | return flags & Unit::IsSingleton; executed 1982 times by 39 tests: return flags & Unit::IsSingleton; Executed by:
| 1982 | ||||||||||||
825 | } | - | ||||||||||||
826 | /* end QML specific fields*/ | - | ||||||||||||
827 | - | |||||||||||||
828 | QString stringAt(int idx) const { | - | ||||||||||||
829 | const quint32_le *offsetTable = reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToStringTable); | - | ||||||||||||
830 | const quint32_le offset = offsetTable[idx]; | - | ||||||||||||
831 | const String *str = reinterpret_cast<const String*>(reinterpret_cast<const char *>(this) + offset); | - | ||||||||||||
832 | if (str->size == 0)
| 7150615-13127805 | ||||||||||||
833 | return QString(); executed 7145208 times by 146 tests: return QString(); Executed by:
| 7145208 | ||||||||||||
834 | #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN | - | ||||||||||||
835 | if (flags & StaticData) {
| 868539-12258759 | ||||||||||||
836 | const QStringDataPtr holder = { const_cast<QStringData *>(reinterpret_cast<const QStringData*>(str)) }; | - | ||||||||||||
837 | return QString(holder); executed 868539 times by 126 tests: return QString(holder); Executed by:
| 868539 | ||||||||||||
838 | } | - | ||||||||||||
839 | const QChar *characters = reinterpret_cast<const QChar *>(str + 1); | - | ||||||||||||
840 | return QString(characters, str->size); executed 12258619 times by 88 tests: return QString(characters, str->size); Executed by:
| 12258619 | ||||||||||||
841 | #else | - | ||||||||||||
842 | const quint16_le *characters = reinterpret_cast<const quint16_le *>(str + 1); | - | ||||||||||||
843 | QString qstr(str->size, Qt::Uninitialized); | - | ||||||||||||
844 | QChar *ch = qstr.data(); | - | ||||||||||||
845 | for (int i = 0; i < str->size; ++i) | - | ||||||||||||
846 | ch[i] = QChar(characters[i]); | - | ||||||||||||
847 | return qstr; | - | ||||||||||||
848 | #endif | - | ||||||||||||
849 | } | - | ||||||||||||
850 | - | |||||||||||||
851 | const quint32_le *functionOffsetTable() const { return reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToFunctionTable); } executed 3460110 times by 138 tests: return reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToFunctionTable); Executed by:
| 3460110 | ||||||||||||
852 | const quint32_le *classOffsetTable() const { return reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToClassTable); } executed 8999 times by 1 test: return reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToClassTable); Executed by:
| 8999 | ||||||||||||
853 | const quint32_le *blockOffsetTable() const { return reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToBlockTable); } executed 340032 times by 39 tests: return reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToBlockTable); Executed by:
| 340032 | ||||||||||||
854 | - | |||||||||||||
855 | const Function *functionAt(int idx) const { | - | ||||||||||||
856 | const quint32_le *offsetTable = functionOffsetTable(); | - | ||||||||||||
857 | const quint32_le offset = offsetTable[idx]; | - | ||||||||||||
858 | return reinterpret_cast<const Function*>(reinterpret_cast<const char *>(this) + offset); executed 3460525 times by 138 tests: return reinterpret_cast<const Function*>(reinterpret_cast<const char *>(this) + offset); Executed by:
| 3460525 | ||||||||||||
859 | } | - | ||||||||||||
860 | - | |||||||||||||
861 | const Class *classAt(int idx) const { | - | ||||||||||||
862 | const quint32_le *offsetTable = classOffsetTable(); | - | ||||||||||||
863 | const quint32_le offset = offsetTable[idx]; | - | ||||||||||||
864 | return reinterpret_cast<const Class *>(reinterpret_cast<const char *>(this) + offset); executed 9095 times by 1 test: return reinterpret_cast<const Class *>(reinterpret_cast<const char *>(this) + offset); Executed by:
| 9095 | ||||||||||||
865 | } | - | ||||||||||||
866 | - | |||||||||||||
867 | const Block *blockAt(int idx) const { | - | ||||||||||||
868 | const quint32_le *offsetTable = blockOffsetTable(); | - | ||||||||||||
869 | const quint32_le offset = offsetTable[idx]; | - | ||||||||||||
870 | return reinterpret_cast<const Block *>(reinterpret_cast<const char *>(this) + offset); executed 339700 times by 39 tests: return reinterpret_cast<const Block *>(reinterpret_cast<const char *>(this) + offset); Executed by:
| 339700 | ||||||||||||
871 | } | - | ||||||||||||
872 | - | |||||||||||||
873 | const Lookup *lookupTable() const { return reinterpret_cast<const Lookup*>(reinterpret_cast<const char *>(this) + offsetToLookupTable); } executed 84724 times by 8 tests: return reinterpret_cast<const Lookup*>(reinterpret_cast<const char *>(this) + offsetToLookupTable); Executed by:
| 84724 | ||||||||||||
874 | const RegExp *regexpAt(int index) const { | - | ||||||||||||
875 | return reinterpret_cast<const RegExp*>(reinterpret_cast<const char *>(this) + offsetToRegexpTable + index * sizeof(RegExp)); executed 1052209 times by 7 tests: return reinterpret_cast<const RegExp*>(reinterpret_cast<const char *>(this) + offsetToRegexpTable + index * sizeof(RegExp)); Executed by:
| 1052209 | ||||||||||||
876 | } | - | ||||||||||||
877 | const quint64_le *constants() const { | - | ||||||||||||
878 | return reinterpret_cast<const quint64_le*>(reinterpret_cast<const char *>(this) + offsetToConstantTable); executed 2342320 times by 145 tests: return reinterpret_cast<const quint64_le*>(reinterpret_cast<const char *>(this) + offsetToConstantTable); Executed by:
| 2342320 | ||||||||||||
879 | } | - | ||||||||||||
880 | - | |||||||||||||
881 | const JSClassMember *jsClassAt(int idx, int *nMembers) const { | - | ||||||||||||
882 | const quint32_le *offsetTable = reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + offsetToJSClassTable); | - | ||||||||||||
883 | const quint32_le offset = offsetTable[idx]; | - | ||||||||||||
884 | const char *ptr = reinterpret_cast<const char *>(this) + offset; | - | ||||||||||||
885 | const JSClass *klass = reinterpret_cast<const JSClass *>(ptr); | - | ||||||||||||
886 | *nMembers = klass->nMembers; | - | ||||||||||||
887 | return reinterpret_cast<const JSClassMember*>(ptr + sizeof(JSClass)); executed 72668 times by 36 tests: return reinterpret_cast<const JSClassMember*>(ptr + sizeof(JSClass)); Executed by:
| 72668 | ||||||||||||
888 | } | - | ||||||||||||
889 | }; | - | ||||||||||||
890 | - | |||||||||||||
891 | static_assert(sizeof(Unit) == 208, "Unit structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); | - | ||||||||||||
892 | - | |||||||||||||
893 | struct TypeReference | - | ||||||||||||
894 | { | - | ||||||||||||
895 | TypeReference(const Location &loc) | - | ||||||||||||
896 | : location(loc) | - | ||||||||||||
897 | , needsCreation(false) | - | ||||||||||||
898 | , errorWhenNotFound(false) | - | ||||||||||||
899 | {} executed 77725 times by 142 tests: end of block Executed by:
| 77725 | ||||||||||||
900 | Location location; // first use | - | ||||||||||||
901 | bool needsCreation : 1; // whether the type needs to be creatable or not | - | ||||||||||||
902 | bool errorWhenNotFound: 1; | - | ||||||||||||
903 | }; | - | ||||||||||||
904 | - | |||||||||||||
905 | // Map from name index to location of first use. | - | ||||||||||||
906 | struct TypeReferenceMap : QHash<int, TypeReference> | - | ||||||||||||
907 | { | - | ||||||||||||
908 | TypeReference &add(int nameIndex, const Location &loc) { | - | ||||||||||||
909 | Iterator it = find(nameIndex); | - | ||||||||||||
910 | if (it != end())
| 39495-77725 | ||||||||||||
911 | return *it; executed 39495 times by 93 tests: return *it; Executed by:
| 39495 | ||||||||||||
912 | return *insert(nameIndex, loc); executed 77725 times by 142 tests: return *insert(nameIndex, loc); Executed by:
| 77725 | ||||||||||||
913 | } | - | ||||||||||||
914 | - | |||||||||||||
915 | template <typename CompiledObject> | - | ||||||||||||
916 | void collectFromObject(const CompiledObject *obj) | - | ||||||||||||
917 | { | - | ||||||||||||
918 | if (obj->inheritedTypeNameIndex != 0) {
| 11496-113658 | ||||||||||||
919 | TypeReference &r = this->add(obj->inheritedTypeNameIndex, obj->location); | - | ||||||||||||
920 | r.needsCreation = true; | - | ||||||||||||
921 | r.errorWhenNotFound = true; | - | ||||||||||||
922 | } executed 113658 times by 142 tests: end of block Executed by:
| 113658 | ||||||||||||
923 | - | |||||||||||||
924 | auto prop = obj->propertiesBegin(); | - | ||||||||||||
925 | auto propEnd = obj->propertiesEnd(); | - | ||||||||||||
926 | for ( ; prop != propEnd; ++prop) {
| 22987-125154 | ||||||||||||
927 | if (prop->type >= QV4::CompiledData::Property::Custom) {
| 786-22201 | ||||||||||||
928 | TypeReference &r = this->add(prop->customTypeNameIndex, prop->location); | - | ||||||||||||
929 | r.errorWhenNotFound = true; | - | ||||||||||||
930 | } executed 786 times by 45 tests: end of block Executed by:
| 786 | ||||||||||||
931 | } executed 22987 times by 101 tests: end of block Executed by:
| 22987 | ||||||||||||
932 | - | |||||||||||||
933 | auto binding = obj->bindingsBegin(); | - | ||||||||||||
934 | auto bindingEnd = obj->bindingsEnd(); | - | ||||||||||||
935 | for ( ; binding != bindingEnd; ++binding) {
| 125154-291664 | ||||||||||||
936 | if (binding->type == QV4::CompiledData::Binding::Type_AttachedProperty)
| 2776-288888 | ||||||||||||
937 | this->add(binding->propertyNameIndex, binding->location); executed 2776 times by 65 tests: this->add(binding->propertyNameIndex, binding->location); Executed by:
| 2776 | ||||||||||||
938 | } executed 291664 times by 142 tests: end of block Executed by:
| 291664 | ||||||||||||
939 | } executed 125154 times by 142 tests: end of block Executed by:
| 125154 | ||||||||||||
940 | - | |||||||||||||
941 | template <typename Iterator> | - | ||||||||||||
942 | void collectFromObjects(Iterator it, Iterator end) | - | ||||||||||||
943 | { | - | ||||||||||||
944 | for (; it != end; ++it)
| 48282-67664 | ||||||||||||
945 | collectFromObject(*it); executed 67664 times by 142 tests: collectFromObject(*it); Executed by:
| 67664 | ||||||||||||
946 | } executed 48282 times by 142 tests: end of block Executed by:
| 48282 | ||||||||||||
947 | }; | - | ||||||||||||
948 | - | |||||||||||||
949 | #ifndef V4_BOOTSTRAP | - | ||||||||||||
950 | struct ResolvedTypeReference; | - | ||||||||||||
951 | // map from name index | - | ||||||||||||
952 | // While this could be a hash, a map is chosen here to provide a stable | - | ||||||||||||
953 | // order, which is used to calculating a check-sum on dependent meta-objects. | - | ||||||||||||
954 | struct ResolvedTypeReferenceMap: public QMap<int, ResolvedTypeReference*> | - | ||||||||||||
955 | { | - | ||||||||||||
956 | bool addToHash(QCryptographicHash *hash, QQmlEngine *engine) const; | - | ||||||||||||
957 | }; | - | ||||||||||||
958 | - | |||||||||||||
959 | using DependentTypesHasher = std::function<bool(QCryptographicHash *)>; | - | ||||||||||||
960 | #else | - | ||||||||||||
961 | struct DependentTypesHasher {}; | - | ||||||||||||
962 | #endif | - | ||||||||||||
963 | - | |||||||||||||
964 | // index is per-object binding index | - | ||||||||||||
965 | typedef QVector<QQmlPropertyData*> BindingPropertyData; | - | ||||||||||||
966 | - | |||||||||||||
967 | // This is how this hooks into the existing structures: | - | ||||||||||||
968 | - | |||||||||||||
969 | struct Q_QML_PRIVATE_EXPORT CompilationUnitBase | - | ||||||||||||
970 | { | - | ||||||||||||
971 | // pointers either to data->constants() or little-endian memory copy. | - | ||||||||||||
972 | QV4::Heap::String **runtimeStrings = nullptr; // Array | - | ||||||||||||
973 | const Value* constants = nullptr; | - | ||||||||||||
974 | QV4::Value *runtimeRegularExpressions = nullptr; | - | ||||||||||||
975 | const Unit *data = nullptr; | - | ||||||||||||
976 | QV4::Heap::InternalClass **runtimeClasses = nullptr; | - | ||||||||||||
977 | }; | - | ||||||||||||
978 | - | |||||||||||||
979 | Q_STATIC_ASSERT(std::is_standard_layout<CompilationUnitBase>::value); | - | ||||||||||||
980 | Q_STATIC_ASSERT(offsetof(CompilationUnitBase, runtimeStrings) == 0); | - | ||||||||||||
981 | Q_STATIC_ASSERT(offsetof(CompilationUnitBase, constants) == sizeof(QV4::Heap::String **)); | - | ||||||||||||
982 | Q_STATIC_ASSERT(offsetof(CompilationUnitBase, runtimeRegularExpressions) == offsetof(CompilationUnitBase, constants) + sizeof(const Value *)); | - | ||||||||||||
983 | - | |||||||||||||
984 | struct Q_QML_PRIVATE_EXPORT CompilationUnit final : public CompilationUnitBase | - | ||||||||||||
985 | { | - | ||||||||||||
986 | public: | - | ||||||||||||
987 | CompilationUnit(const Unit *unitData = nullptr); | - | ||||||||||||
988 | #ifdef V4_BOOTSTRAP | - | ||||||||||||
989 | ~CompilationUnit() {} | - | ||||||||||||
990 | #else | - | ||||||||||||
991 | ~CompilationUnit(); | - | ||||||||||||
992 | #endif | - | ||||||||||||
993 | - | |||||||||||||
994 | void addref() | - | ||||||||||||
995 | { | - | ||||||||||||
996 | Q_ASSERT(refCount.load() > 0); | - | ||||||||||||
997 | refCount.ref(); | - | ||||||||||||
998 | } executed 5838750 times by 146 tests: end of block Executed by:
| 5838750 | ||||||||||||
999 | - | |||||||||||||
1000 | void release() | - | ||||||||||||
1001 | { | - | ||||||||||||
1002 | Q_ASSERT(refCount.load() > 0); | - | ||||||||||||
1003 | if (!refCount.deref())
| 2351946-5642854 | ||||||||||||
1004 | destroy(); executed 2351935 times by 146 tests: destroy(); Executed by:
| 2351935 | ||||||||||||
1005 | } executed 7994685 times by 147 tests: end of block Executed by:
| 7994685 | ||||||||||||
1006 | int count() const | - | ||||||||||||
1007 | { | - | ||||||||||||
1008 | return refCount.load(); executed 3436 times by 2 tests: return refCount.load(); Executed by:
| 3436 | ||||||||||||
1009 | } | - | ||||||||||||
1010 | - | |||||||||||||
1011 | // Called only when building QML, when we build the header for JS first and append QML data | - | ||||||||||||
1012 | QV4::CompiledData::Unit *createUnitData(QmlIR::Document *irDocument); | - | ||||||||||||
1013 | - | |||||||||||||
1014 | #ifndef V4_BOOTSTRAP | - | ||||||||||||
1015 | QIntrusiveListNode nextCompilationUnit; | - | ||||||||||||
1016 | ExecutionEngine *engine = nullptr; | - | ||||||||||||
1017 | QQmlEnginePrivate *qmlEngine = nullptr; // only used in QML environment for composite types, not in plain QJSEngine case. | - | ||||||||||||
1018 | - | |||||||||||||
1019 | // url() and fileName() shall be used to load the actual QML/JS code or to show errors or | - | ||||||||||||
1020 | // warnings about that code. They include any potential URL interceptions and thus represent the | - | ||||||||||||
1021 | // "physical" location of the code. | - | ||||||||||||
1022 | // | - | ||||||||||||
1023 | // finalUrl() and finalUrlString() shall be used to resolve further URLs referred to in the code | - | ||||||||||||
1024 | // They are _not_ intercepted and thus represent the "logical" name for the code. | - | ||||||||||||
1025 | - | |||||||||||||
1026 | QString fileName() const { return data->stringAt(data->sourceFileIndex); } | - | ||||||||||||
1027 | QString finalUrlString() const { return data->stringAt(data->finalUrlIndex); } | - | ||||||||||||
1028 | QUrl url() const { if (m_url.isNull) m_url = QUrl(fileName()); return m_url; } | - | ||||||||||||
1029 | QUrl finalUrl() const | - | ||||||||||||
1030 | { | - | ||||||||||||
1031 | if (m_finalUrl.isNull) | - | ||||||||||||
1032 | m_finalUrl = QUrl(finalUrlString()); | - | ||||||||||||
1033 | return m_finalUrl; | - | ||||||||||||
1034 | } | - | ||||||||||||
1035 | - | |||||||||||||
1036 | QV4::Lookup *runtimeLookups = nullptr; | - | ||||||||||||
1037 | QVector<QV4::Function *> runtimeFunctions; | - | ||||||||||||
1038 | QVector<QV4::Heap::InternalClass *> runtimeBlocks; | - | ||||||||||||
1039 | mutable QQmlNullableValue<QUrl> m_url; | - | ||||||||||||
1040 | mutable QQmlNullableValue<QUrl> m_finalUrl; | - | ||||||||||||
1041 | - | |||||||||||||
1042 | // QML specific fields | - | ||||||||||||
1043 | QQmlPropertyCacheVector propertyCaches; | - | ||||||||||||
1044 | QQmlRefPointer<QQmlPropertyCache> rootPropertyCache() const { return propertyCaches.at(/*root object*/0); } | - | ||||||||||||
1045 | - | |||||||||||||
1046 | QQmlRefPointer<QQmlTypeNameCache> typeNameCache; | - | ||||||||||||
1047 | - | |||||||||||||
1048 | // index is object index. This allows fast access to the | - | ||||||||||||
1049 | // property data when initializing bindings, avoiding expensive | - | ||||||||||||
1050 | // lookups by string (property name). | - | ||||||||||||
1051 | QVector<BindingPropertyData> bindingPropertyDataPerObject; | - | ||||||||||||
1052 | - | |||||||||||||
1053 | // mapping from component object index (CompiledData::Unit object index that points to component) to identifier hash of named objects | - | ||||||||||||
1054 | // this is initialized on-demand by QQmlContextData | - | ||||||||||||
1055 | QHash<int, IdentifierHash> namedObjectsPerComponentCache; | - | ||||||||||||
1056 | inline IdentifierHash namedObjectsPerComponent(int componentObjectIndex); | - | ||||||||||||
1057 | - | |||||||||||||
1058 | void finalizeCompositeType(QQmlEnginePrivate *qmlEngine); | - | ||||||||||||
1059 | - | |||||||||||||
1060 | int totalBindingsCount = 0; // Number of bindings used in this type | - | ||||||||||||
1061 | int totalParserStatusCount = 0; // Number of instantiated types that are QQmlParserStatus subclasses | - | ||||||||||||
1062 | int totalObjectCount = 0; // Number of objects explicitly instantiated | - | ||||||||||||
1063 | - | |||||||||||||
1064 | QVector<QQmlRefPointer<QQmlScriptData>> dependentScripts; | - | ||||||||||||
1065 | ResolvedTypeReferenceMap resolvedTypes; | - | ||||||||||||
1066 | - | |||||||||||||
1067 | bool verifyChecksum(const DependentTypesHasher &dependencyHasher) const; | - | ||||||||||||
1068 | - | |||||||||||||
1069 | int metaTypeId = -1; | - | ||||||||||||
1070 | int listMetaTypeId = -1; | - | ||||||||||||
1071 | bool isRegisteredWithEngine = false; | - | ||||||||||||
1072 | - | |||||||||||||
1073 | QScopedPointer<CompilationUnitMapper> backingFile; | - | ||||||||||||
1074 | - | |||||||||||||
1075 | // --- interface for QQmlPropertyCacheCreator | - | ||||||||||||
1076 | typedef Object CompiledObject; | - | ||||||||||||
1077 | int objectCount() const { return data->nObjects; } | - | ||||||||||||
1078 | const Object *objectAt(int index) const { return data->objectAt(index); } | - | ||||||||||||
1079 | QString stringAt(int index) const { return data->stringAt(index); } | - | ||||||||||||
1080 | - | |||||||||||||
1081 | struct FunctionIterator | - | ||||||||||||
1082 | { | - | ||||||||||||
1083 | FunctionIterator(const Unit *unit, const Object *object, int index) : unit(unit), object(object), index(index) {} | - | ||||||||||||
1084 | const Unit *unit; | - | ||||||||||||
1085 | const Object *object; | - | ||||||||||||
1086 | int index; | - | ||||||||||||
1087 | - | |||||||||||||
1088 | const Function *operator->() const { return unit->functionAt(object->functionOffsetTable()[index]); } | - | ||||||||||||
1089 | void operator++() { ++index; } | - | ||||||||||||
1090 | bool operator==(const FunctionIterator &rhs) const { return index == rhs.index; } | - | ||||||||||||
1091 | bool operator!=(const FunctionIterator &rhs) const { return index != rhs.index; } | - | ||||||||||||
1092 | }; | - | ||||||||||||
1093 | FunctionIterator objectFunctionsBegin(const Object *object) const { return FunctionIterator(data, object, 0); } | - | ||||||||||||
1094 | FunctionIterator objectFunctionsEnd(const Object *object) const { return FunctionIterator(data, object, object->nFunctions); } | - | ||||||||||||
1095 | // --- | - | ||||||||||||
1096 | - | |||||||||||||
1097 | QV4::Function *linkToEngine(QV4::ExecutionEngine *engine); | - | ||||||||||||
1098 | void unlink(); | - | ||||||||||||
1099 | - | |||||||||||||
1100 | void markObjects(MarkStack *markStack); | - | ||||||||||||
1101 | - | |||||||||||||
1102 | bool loadFromDisk(const QUrl &url, const QDateTime &sourceTimeStamp, QString *errorString); | - | ||||||||||||
1103 | - | |||||||||||||
1104 | static QString localCacheFilePath(const QUrl &url); | - | ||||||||||||
1105 | - | |||||||||||||
1106 | protected: | - | ||||||||||||
1107 | void linkBackendToEngine(QV4::ExecutionEngine *engine); | - | ||||||||||||
1108 | #endif // V4_BOOTSTRAP | - | ||||||||||||
1109 | - | |||||||||||||
1110 | private: | - | ||||||||||||
1111 | void destroy(); | - | ||||||||||||
1112 | - | |||||||||||||
1113 | QAtomicInt refCount = 1; | - | ||||||||||||
1114 | - | |||||||||||||
1115 | Q_NEVER_INLINE IdentifierHash createNamedObjectsPerComponent(int componentObjectIndex); | - | ||||||||||||
1116 | - | |||||||||||||
1117 | public: | - | ||||||||||||
1118 | #if defined(V4_BOOTSTRAP) | - | ||||||||||||
1119 | bool saveToDisk(const QString &outputFileName, QString *errorString); | - | ||||||||||||
1120 | #else | - | ||||||||||||
1121 | bool saveToDisk(const QUrl &unitUrl, QString *errorString); | - | ||||||||||||
1122 | #endif | - | ||||||||||||
1123 | }; | - | ||||||||||||
1124 | - | |||||||||||||
1125 | #ifndef V4_BOOTSTRAP | - | ||||||||||||
1126 | struct ResolvedTypeReference | - | ||||||||||||
1127 | { | - | ||||||||||||
1128 | ResolvedTypeReference() | - | ||||||||||||
1129 | : majorVersion(0) | - | ||||||||||||
1130 | , minorVersion(0) | - | ||||||||||||
1131 | , isFullyDynamicType(false) | - | ||||||||||||
1132 | {} | - | ||||||||||||
1133 | - | |||||||||||||
1134 | QQmlType type; | - | ||||||||||||
1135 | QQmlRefPointer<QQmlPropertyCache> typePropertyCache; | - | ||||||||||||
1136 | QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit; | - | ||||||||||||
1137 | - | |||||||||||||
1138 | int majorVersion; | - | ||||||||||||
1139 | int minorVersion; | - | ||||||||||||
1140 | // Types such as QQmlPropertyMap can add properties dynamically at run-time and | - | ||||||||||||
1141 | // therefore cannot have a property cache installed when instantiated. | - | ||||||||||||
1142 | bool isFullyDynamicType; | - | ||||||||||||
1143 | - | |||||||||||||
1144 | QQmlRefPointer<QQmlPropertyCache> propertyCache() const; | - | ||||||||||||
1145 | QQmlRefPointer<QQmlPropertyCache> createPropertyCache(QQmlEngine *); | - | ||||||||||||
1146 | bool addToHash(QCryptographicHash *hash, QQmlEngine *engine); | - | ||||||||||||
1147 | - | |||||||||||||
1148 | void doDynamicTypeCheck(); | - | ||||||||||||
1149 | }; | - | ||||||||||||
1150 | - | |||||||||||||
1151 | IdentifierHash CompilationUnit::namedObjectsPerComponent(int componentObjectIndex) | - | ||||||||||||
1152 | { | - | ||||||||||||
1153 | auto it = namedObjectsPerComponentCache.find(componentObjectIndex); | - | ||||||||||||
1154 | if (Q_UNLIKELY(it == namedObjectsPerComponentCache.end())) | - | ||||||||||||
1155 | return createNamedObjectsPerComponent(componentObjectIndex); | - | ||||||||||||
1156 | return *it; | - | ||||||||||||
1157 | } | - | ||||||||||||
1158 | #endif // V4_BOOTSTRAP | - | ||||||||||||
1159 | - | |||||||||||||
1160 | } // CompiledData namespace | - | ||||||||||||
1161 | } // QV4 namespace | - | ||||||||||||
1162 | - | |||||||||||||
1163 | Q_DECLARE_TYPEINFO(QV4::CompiledData::JSClassMember, Q_PRIMITIVE_TYPE); | - | ||||||||||||
1164 | - | |||||||||||||
1165 | QT_END_NAMESPACE | - | ||||||||||||
1166 | - | |||||||||||||
1167 | #endif | - | ||||||||||||
Source code | Switch to Preprocessed file |