4#ifndef QV4COMPILEDDATA_P_H
5#define QV4COMPILEDDATA_P_H
21#include <QtCore/qcryptographichash.h>
22#include <QtCore/qhash.h>
23#include <QtCore/qhashfunctions.h>
24#include <QtCore/qlocale.h>
25#include <QtCore/qscopeguard.h>
26#include <QtCore/qstring.h>
27#include <QtCore/qstringlist.h>
28#include <QtCore/qurl.h>
29#include <QtCore/qvector.h>
30#include <QtCore/qtyperevision.h>
31#include <QtCore/qxpfunctional.h>
33#if QT_CONFIG(temporaryfile)
34#include <QtCore/qsavefile.h>
37#include <private/qendian_p.h>
38#include <private/qqmlnullablevalue_p.h>
39#include <private/qqmlpropertycachevector_p.h>
40#include <private/qqmlrefcount_p.h>
41#include <private/qqmltype_p.h>
42#include <private/qv4compilationunitmapper_p.h>
43#include <private/qv4staticvalue_p.h>
58#define QV4_DATA_STRUCTURE_VERSION 0x56
61class QQmlTypeNameCache;
94 bool addToHash(QCryptographicHash *hash, QHash<quintptr, QByteArray> *checksums)
const;
104template <
typename ItemType,
typename Container,
const ItemType *(Container::*IndexedGetter)(
int index)
const>
140 m_data.set<LineField>(l);
141 m_data.set<ColumnField>(c);
142 Q_ASSERT(m_data.get<LineField>() == l);
143 Q_ASSERT(m_data.get<ColumnField>() == c);
147 return m_data.get<LineField>() < other.m_data.get<LineField>()
148 || (m_data.get<LineField>() == other.m_data.get<LineField>()
149 && m_data.get<ColumnField>() < other.m_data.get<ColumnField>());
154 return QT_PREPEND_NAMESPACE(qHash)(location.m_data.data(), seed);
159 return a.m_data.data()== b.m_data.data();
163 void set(quint32 line, quint32 column)
165 m_data.set<LineField>(line);
166 m_data.set<ColumnField>(column);
176 quint32_le_bitfield_union<LineField, ColumnField> m_data;
178static_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");
196 m_data.set<FlagsField>(flags);
197 m_data.set<StringIndexField>(stringIndex);
206 quint32_le_bitfield_union<FlagsField, StringIndexField> m_data;
208static_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");
231 m_data.set<TypeField>(type);
232 m_data.set<ModeField>(mode);
233 m_data.set<NameIndexField>(nameIndex);
241 quint32_le_bitfield_union<TypeField, ModeField, NameIndexField> m_data;
243static_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");
249 void set(quint32 nameOffset,
bool isAccessor)
251 m_data.set<NameOffsetField>(nameOffset);
252 m_data.set<IsAccessorField>(isAccessor ? 1 : 0);
256 bool isAccessor()
const {
return m_data.get<IsAccessorField>() != 0; }
261 quint32_le_bitfield_union<NameOffsetField, IsAccessorField> m_data;
263static_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");
272static_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");
281 return (
sizeof(String) + (
int(str.size()) + 1) *
sizeof(quint16) + 7) & ~0x7;
285static_assert (
sizeof (
String) == 4,
"String structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
292static_assert(
sizeof(
CodeOffsetToLineAndStatement) == 12,
"CodeOffsetToLineAndStatement structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
301 const quint32_le *
localsTable()
const {
return reinterpret_cast<
const quint32_le *>(
reinterpret_cast<
const char *>(
this) + localsOffset); }
304 int trailingData = nLocals*
sizeof (quint32);
305 size_t size = align(align(
sizeof(
Block)) + size_t(trailingData));
306 Q_ASSERT(size < INT_MAX);
311 return (a + 7) & ~size_t(7);
314static_assert(
sizeof(
Block) == 12,
"Block structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
348 void set(Flags flags, quint32 typeNameIndexOrCommonType)
350 m_data.set<IsListField>(flags.testFlag(List) ? 1 : 0);
351 m_data.set<IndexIsCommonTypeField>(flags.testFlag(Common) ? 1 : 0);
352 m_data.set<TypeNameIndexOrCommonTypeField>(typeNameIndexOrCommonType);
357 return m_data.get<IndexIsCommonTypeField>() != 0;
362 return m_data.get<IsListField>() != 0;
367 return m_data.get<TypeNameIndexOrCommonTypeField>();
374 quint32_le_bitfield_union<IndexIsCommonTypeField, IsListField, TypeNameIndexOrCommonTypeField> m_data;
376static_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");
383static_assert(
sizeof(
Parameter) == 8,
"Parameter structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
421 return lineAndStatementNumberOffset() + nLineAndStatementNumbers *
sizeof(CodeOffsetToLineAndStatement);
433 return reinterpret_cast<
const Parameter *>(
434 reinterpret_cast<
const char *>(
this) + formalsOffset);
438 return reinterpret_cast<
const quint32_le *>(
439 reinterpret_cast<
const char *>(
this) + localsOffset);
443 return reinterpret_cast<
const CodeOffsetToLineAndStatement *>(
444 reinterpret_cast<
const char *>(
this) + lineAndStatementNumberOffset());
452 const quint32_le *
labelInfoTable()
const {
return reinterpret_cast<
const quint32_le *>(
reinterpret_cast<
const char *>(
this) + labelInfosOffset()); }
454 const char *
code()
const {
return reinterpret_cast<
const char *>(
this) + codeOffset; }
457 int nFormals,
int nLocals,
int nLinesAndStatements,
int labelInfoSize,
int codeSize)
459 const size_t trailingData = nFormals *
sizeof(Parameter)
460 + (nLocals + labelInfoSize) *
sizeof (quint32)
461 + nLinesAndStatements *
sizeof(CodeOffsetToLineAndStatement);
462 size_t size = align(align(
sizeof(
Function)) + size_t(trailingData)) + align(codeSize);
463 Q_ASSERT(size < INT_MAX);
468 return (a + 7) & ~size_t(7);
471static_assert(
sizeof(
Function) == 56,
"Function structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
484static_assert(
sizeof(
Method) == 12,
"Method structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
495 const Method *
methodTable()
const {
return reinterpret_cast<
const Method *>(
reinterpret_cast<
const char *>(
this) + methodTableOffset); }
498 int trailingData = (nStaticMethods + nMethods) *
sizeof(
Method);
499 size_t size = align(
sizeof(
Class) + trailingData);
500 Q_ASSERT(size < INT_MAX);
505 return (a + 7) & ~size_t(7);
508static_assert(
sizeof(
Class) == 24,
"Class structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
515 int trailingData = 2 * size *
sizeof(quint32_le);
517 Q_ASSERT(s < INT_MAX);
522 return (a + 7) & ~size_t(7);
526 return reinterpret_cast<
const quint32_le *>(
reinterpret_cast<
const char *>(
this + 1));
530 return stringTable()[i];
533 return stringTable()[size + i];
536static_assert(
sizeof(
TemplateObject) == 4,
"Template object structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
546static_assert(
sizeof(
ExportEntry) == 20,
"ExportEntry structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
555static_assert(
sizeof(
ImportEntry) == 16,
"ImportEntry structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
567static_assert(
sizeof(
TranslationData) == 16,
"TranslationData structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
600 void setFlag(
Flag flag) { flagsAndType.set<FlagsField>(flagsAndType.get<FlagsField>() | flag); }
601 bool hasFlag(
Flag flag)
const {
return Flags(flagsAndType.get<FlagsField>()) & flag; }
602 Flags flags()
const {
return Flags(flagsAndType.get<FlagsField>()); }
605 Type type()
const {
return Type(flagsAndType.get<TypeField>()); }
609 quint32_le constantValueIndex;
610 quint32_le compiledScriptIndex;
611 quint32_le objectIndex;
612 quint32_le translationDataIndex;
628 QString tmp = QLatin1String(
"\"");
629 for (
int i = 0; i < string.size(); ++i) {
630 const QChar &c = string.at(i);
631 switch (c.unicode()) {
633 tmp += QLatin1String(
"\\b");
636 tmp += QLatin1String(
"\\t");
639 tmp += QLatin1String(
"\\n");
642 tmp += QLatin1String(
"\\v");
645 tmp += QLatin1String(
"\\f");
648 tmp += QLatin1String(
"\\r");
651 tmp += QLatin1String(
"\\\"");
654 tmp += QLatin1String(
"\\\'");
657 tmp += QLatin1String(
"\\\\");
664 tmp += QLatin1Char(
'\"');
679 if (type() == Type_Boolean)
685static_assert(
sizeof(
Binding) == 24,
"Binding structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
694static_assert(
sizeof(
InlineComponent) == 12,
"InlineComponent structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
701static_assert(
sizeof(
EnumValue) == 8,
"EnumValue structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
710 return reinterpret_cast<
const EnumValue*>(
this + 1) + idx;
725static_assert(
sizeof(
Enum) == 12,
"Enum structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
735 return reinterpret_cast<
const Parameter*>(
this + 1) + idx;
750static_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");
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
798 void setNameIndex(
int nameIndex) { nameIndexAndVirtSpecifiers.set<NameIndexField>(nameIndex); }
800 bool isVirtual()
const {
return nameIndexAndVirtSpecifiers.get<IsVirtualField>(); }
803 nameIndexAndVirtSpecifiers.set<IsVirtualField>(isVirtual ? 1 : 0);
806 bool isOverride()
const {
return nameIndexAndVirtSpecifiers.get<IsOverrideField>(); }
809 nameIndexAndVirtSpecifiers.set<IsOverrideField>(isOverride ? 1 : 0);
812 bool isFinal()
const {
return nameIndexAndVirtSpecifiers.get<IsFinalField>(); }
813 void setIsFinal(
bool isFinal) { nameIndexAndVirtSpecifiers.set<IsFinalField>(isFinal ? 1 : 0); }
817 data.set<CommonTypeOrTypeNameIndexField>(
static_cast<quint32>(t));
818 data.set<IsCommonTypeField>(
true);
823 return CommonType(data.get<CommonTypeOrTypeNameIndexField>());
829 data.set<CommonTypeOrTypeNameIndexField>(nameIndex);
830 data.set<IsCommonTypeField>(
false);
835 return data.get<IsCommonTypeField>() ? -1 : data.get<CommonTypeOrTypeNameIndexField>();
841 bool isList()
const {
return data.get<IsListField>(); }
842 void setIsList(
bool isList) { data.set<IsListField>(isList); }
844 bool isRequired()
const {
return data.get<IsRequiredField>(); }
845 void setIsRequired(
bool isRequired) { data.set<IsRequiredField>(isRequired); }
847 bool isReadOnly()
const {
return data.get<IsReadOnlyField>(); }
848 void setIsReadOnly(
bool isReadOnly) { data.set<IsReadOnlyField>(isReadOnly); }
850static_assert(
sizeof(
Property) == 12,
"Property structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
856static_assert (
sizeof(
RequiredPropertyExtraData) == 4,
"RequiredPropertyExtraData structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
860 bool isReadOnly()
const {
return m_nameIndexAndFlags.get<IsReadOnlyField>(); }
861 void setIsReadOnly(
bool isReadOnly) { m_nameIndexAndFlags.set<IsReadOnlyField>(isReadOnly); }
866 m_nameIndexAndFlags.set<NameIndexField>(nameIndex);
870 void setIdIndex(quint32 idIndex) { m_idIndexField = idIndex; }
875 m_propertyNameIndex = propertyNameIndex;
884 m_referenceLocation = referenceLocation;
891 quint32_le_bitfield_union<NameIndexField, IsReadOnlyField> m_nameIndexAndFlags;
892 quint32_le m_idIndexField;
893 quint32_le m_propertyNameIndex;
897static_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");
948 return Flags(flagsAndDefaultPropertyIsAlias.get<FlagsField>());
953 return flagsAndDefaultPropertyIsAlias.get<FlagsField>() & flag;
958 flagsAndDefaultPropertyIsAlias.set<FlagsField>(
959 flagsAndDefaultPropertyIsAlias.get<FlagsField>() | flag);
964 flagsAndDefaultPropertyIsAlias.set<FlagsField>(flags);
969 return flagsAndDefaultPropertyIsAlias.get<DefaultPropertyIsAliasField>();
974 flagsAndDefaultPropertyIsAlias.set<DefaultPropertyIsAliasField>(defaultAlias);
979 return (
sizeof(Object)
980 + nFunctions *
sizeof(quint32)
981 + nProperties *
sizeof(Property)
982 + nAliases *
sizeof(Alias)
983 + nEnums *
sizeof(quint32)
984 + nSignals *
sizeof(quint32)
985 + nBindings *
sizeof(Binding)
986 + nInlineComponents *
sizeof(InlineComponent)
987 + nRequiredPropertyExtraData *
sizeof(RequiredPropertyExtraData)
994 return reinterpret_cast<
const quint32_le*>(
reinterpret_cast<
const char *>(
this) + offsetToFunctions);
999 return reinterpret_cast<
const Property*>(
reinterpret_cast<
const char *>(
this) + offsetToProperties);
1004 return reinterpret_cast<
const Alias*>(
reinterpret_cast<
const char *>(
this) + offsetToAliases);
1009 return reinterpret_cast<
const Binding*>(
reinterpret_cast<
const char *>(
this) + offsetToBindings);
1014 const quint32_le *offsetTable =
reinterpret_cast<
const quint32_le*>((
reinterpret_cast<
const char *>(
this)) + offsetToEnums);
1015 const quint32_le offset = offsetTable[idx];
1016 return reinterpret_cast<
const Enum*>(
reinterpret_cast<
const char*>(
this) + offset);
1021 const quint32_le *offsetTable =
reinterpret_cast<
const quint32_le*>((
reinterpret_cast<
const char *>(
this)) + offsetToSignals);
1022 const quint32_le offset = offsetTable[idx];
1023 return reinterpret_cast<
const Signal*>(
reinterpret_cast<
const char*>(
this) + offset);
1033 return reinterpret_cast<
const InlineComponent*>(
reinterpret_cast<
const char *>(
this) + offsetToInlineComponents);
1043 return reinterpret_cast<
const RequiredPropertyExtraData*>(
reinterpret_cast<
const char *>(
this) + offsetToRequiredPropertyExtraData);
1080static_assert(
sizeof(
Object) == 76,
"Object structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
1101 type = 0; uriIndex = 0; qualifierIndex = 0; version = QTypeRevision::zero(); reserved = 0;
1104static_assert(
sizeof(
Import) == 20,
"Import structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
1114 return reinterpret_cast<
const Import*>((
reinterpret_cast<
const char *>(
this)) + offsetToImports + idx *
sizeof(Import));
1118 const quint32_le *offsetTable =
reinterpret_cast<
const quint32_le*>((
reinterpret_cast<
const char *>(
this)) + offsetToObjects);
1119 const quint32_le offset = offsetTable[idx];
1120 return reinterpret_cast<
const Object*>(
reinterpret_cast<
const char*>(
this) + offset);
1123static_assert(
sizeof(
QmlUnit) == 16,
"QmlUnit structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
1151 enum :
unsigned int {
1213 return reinterpret_cast<
const QmlUnit *>(
reinterpret_cast<
const char *>(
this) + offsetToQmlUnit);
1217 return reinterpret_cast<QmlUnit *>(
reinterpret_cast<
char *>(
this) + offsetToQmlUnit);
1222 return runtimeDataSize
1223 ?
reinterpret_cast<
const RuntimeDataBlock *>(
1224 reinterpret_cast<
const char *>(
this) + offsetToRuntimeData)
1229 return flags & Unit::IsSingleton;
1235 return (flags & Unit::ListPropertyAssignReplace) == Unit::ListPropertyAssignReplace;
1239 return flags & Unit::ListPropertyAssignReplaceIfNotDefault;
1244 Q_ASSERT(idx < stringTableSize);
1245 const quint32_le *offsetTable =
reinterpret_cast<
const quint32_le*>((
reinterpret_cast<
const char *>(
this)) + offsetToStringTable);
1246 const quint32_le offset = offsetTable[idx];
1247 const String *str =
reinterpret_cast<
const String*>(
reinterpret_cast<
const char *>(
this) + offset);
1248 Q_ASSERT(str->size >= 0);
1249#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
1250 const QChar *characters =
reinterpret_cast<
const QChar *>(str + 1);
1251 if (flags & StaticData)
1252 return QString::fromRawData(characters, str->size);
1253 return QString(characters, str->size);
1255 const quint16_le *characters =
reinterpret_cast<
const quint16_le *>(str + 1);
1256 QString qstr(str->size, Qt::Uninitialized);
1257 QChar *ch = qstr.data();
1258 for (
int i = 0; i < str->size; ++i)
1259 ch[i] = QChar(quint16(characters[i]));
1265 const quint32_le *
classOffsetTable()
const {
return reinterpret_cast<
const quint32_le*>((
reinterpret_cast<
const char *>(
this)) + offsetToClassTable); }
1267 const quint32_le *
blockOffsetTable()
const {
return reinterpret_cast<
const quint32_le*>((
reinterpret_cast<
const char *>(
this)) + offsetToBlockTable); }
1270 const quint32_le *offsetTable = functionOffsetTable();
1271 const quint32_le offset = offsetTable[idx];
1272 return reinterpret_cast<
const Function*>(
reinterpret_cast<
const char *>(
this) + offset);
1276 const quint32_le *offsetTable = classOffsetTable();
1277 const quint32_le offset = offsetTable[idx];
1278 return reinterpret_cast<
const Class *>(
reinterpret_cast<
const char *>(
this) + offset);
1282 const quint32_le *offsetTable = templateObjectOffsetTable();
1283 const quint32_le offset = offsetTable[idx];
1284 return reinterpret_cast<
const TemplateObject *>(
reinterpret_cast<
const char *>(
this) + offset);
1288 const quint32_le *offsetTable = blockOffsetTable();
1289 const quint32_le offset = offsetTable[idx];
1290 return reinterpret_cast<
const Block *>(
reinterpret_cast<
const char *>(
this) + offset);
1293 const Lookup *
lookupTable()
const {
return reinterpret_cast<
const Lookup*>(
reinterpret_cast<
const char *>(
this) + offsetToLookupTable); }
1295 return reinterpret_cast<
const RegExp*>(
reinterpret_cast<
const char *>(
this) + offsetToRegexpTable + index *
sizeof(RegExp));
1298 return reinterpret_cast<
const quint64_le*>(
reinterpret_cast<
const char *>(
this) + offsetToConstantTable);
1302 const quint32_le *offsetTable =
reinterpret_cast<
const quint32_le *>(
reinterpret_cast<
const char *>(
this) + offsetToJSClassTable);
1303 const quint32_le offset = offsetTable[idx];
1304 const char *ptr =
reinterpret_cast<
const char *>(
this) + offset;
1306 *nMembers = klass->nMembers;
1311 return reinterpret_cast<
const TranslationData *>(
reinterpret_cast<
const char *>(
this) + offsetToTranslationTable);
1315 if ( translationTableSize == 0)
1317 return reinterpret_cast<
const quint32_le*>((
reinterpret_cast<
const char *>(
this))
1318 + offsetToTranslationTable
1319 + translationTableSize *
sizeof(CompiledData::TranslationData)); }
1322 if ( translationTableSize == 0)
1324 return reinterpret_cast<quint32_le*>((
reinterpret_cast<
char *>(
this))
1325 + offsetToTranslationTable
1326 + translationTableSize *
sizeof(CompiledData::TranslationData)); }
1328 const ImportEntry *
importEntryTable()
const {
return reinterpret_cast<
const ImportEntry *>(
reinterpret_cast<
const char *>(
this) + offsetToImportEntryTable); }
1333 const quint32_le *
moduleRequestTable()
const {
return reinterpret_cast<
const quint32_le*>((
reinterpret_cast<
const char *>(
this)) + offsetToModuleRequestTable); }
1335 bool verifyHeader(QDateTime expectedSourceTimeStamp, QString *errorString)
const;
1338static_assert(
sizeof(
Unit) == 208,
1339 "Unit structure needs to have the expected size to be binary compatible on disk when "
1340 "generated by host compiler and loaded by target");
1360 "RuntimeBinding structure needs to have the expected size to be binary compatible on "
1361 "disk when generated by host compiler and loaded by target");
1383 reinterpret_cast<
const char *>(
this) +
sizeof(
RuntimeObject));
1394 return reinterpret_cast<
const RuntimeBindingIndex *>(
1395 reinterpret_cast<
const char *>(
this) + offsetToBindingOrder);
1400 return reinterpret_cast<RuntimeBindingIndex *>(
1401 reinterpret_cast<
char *>(
this) + offsetToBindingOrder);
1406 return reinterpret_cast<
const quint32_le *>(
1407 reinterpret_cast<
const char *>(
this) + offsetToNamedObjectsInComponent);
1412 return reinterpret_cast<quint32_le *>(
1413 reinterpret_cast<
char *>(
this) + offsetToNamedObjectsInComponent);
1417 "RuntimeObject structure needs to have the expected size to be binary compatible on "
1418 "disk when generated by host compiler and loaded by target");
1428 const quint32_le *offsetTable =
reinterpret_cast<
const quint32_le *>(
1431 reinterpret_cast<
const char *>(
this) + offsetTable[idx]);
1436 const quint32_le *offsetTable =
reinterpret_cast<
const quint32_le *>(
1439 reinterpret_cast<
char *>(
this) + offsetTable[idx]);
1442 bool verifyChecksum(
const CompiledData::DependentTypesHasher &dependencyHasher)
const;
1445 "RuntimeDataBlock structure needs to have the expected size to be binary compatible "
1446 "on disk when generated by host compiler and loaded by target");
1464 Iterator it = find(nameIndex);
1467 return *insert(nameIndex, loc);
1470 template <
typename CompiledObject>
1473 if (obj->inheritedTypeNameIndex != 0) {
1479 auto binding = obj->bindingsBegin();
1480 auto const bindingEnd = obj->bindingsEnd();
1481 for ( ; binding != bindingEnd; ++binding) {
1483 this->add(binding->propertyNameIndex
, binding->location
);
1486 auto ic = obj->inlineComponentsBegin();
1487 auto const icEnd = obj->inlineComponentsEnd();
1488 for (; ic != icEnd; ++ic) {
1489 this->add(ic->nameIndex
, ic->location
);
1493 template <
typename Iterator>
1496 for (; it != end; ++it)
1497 collectFromObject(*it);
1559 LookupValidationFn validateLookupSignatures,
1560 const QString &fileName = QString(),
1561 const QString &finalUrlString = QString())
1565 this->validateLookupSignatures = validateLookupSignatures;
1577 const QString &fileName = QString(),
const QString &finalUrlString = QString())
1581#if Q_BYTE_ORDER == Q_BIG_ENDIAN
1582 delete [] constants;
1584 constants =
nullptr;
1586 m_finalUrlString.clear();
1592#if Q_BYTE_ORDER == Q_BIG_ENDIAN
1593 StaticValue *bigEndianConstants =
new StaticValue[data->constantTableSize];
1594 const quint64_le *littleEndianConstants =
data->constants();
1595 for (uint i = 0; i <
data->constantTableSize; ++i)
1596 bigEndianConstants[i] = StaticValue::fromReturnedValue(littleEndianConstants[i]);
1597 constants = bigEndianConstants;
1599 constants =
reinterpret_cast<
const StaticValue*>(data->constants());
1602 m_fileName = !fileName.isEmpty() ? fileName : stringAt(data->sourceFileIndex);
1603 m_finalUrlString = !finalUrlString.isEmpty() ? finalUrlString : stringAt(data->finalUrlIndex);
1608 if (index <
data->stringTableSize)
1609 return data->stringAtInternal(index);
1611 const qsizetype dynamicIndex = index -
data->stringTableSize;
1612 Q_ASSERT(dynamicIndex < dynamicStrings.size());
1613 return dynamicStrings.at(dynamicIndex);
1623 case Binding::Type_Script:
1624 case Binding::Type_String:
1625 return stringAt(binding->stringIndex);
1627 return QStringLiteral(
"null");
1629 return binding->value.b ? QStringLiteral(
"true") : QStringLiteral(
"false");
1630 case Binding::Type_Number:
1631 return QString::number(bindingValueAsNumber(binding),
'g', QLocale::FloatingPointShortest);
1634 case Binding::Type_TranslationById:
1635 case Binding::Type_Translation:
1636 return stringAt(data->translations()[binding->value.translationDataIndex].stringIndex);
1646 ? CompiledData::Binding::escapedString(stringAt(binding->stringIndex))
1647 : bindingValueAsString(binding);
1654 return constants[binding->value.constantValueIndex].doubleValue();
1663 const QUrl &url,
const QDateTime &sourceTimeStamp,
1690 if (!m_url.isValid())
1691 m_url = QUrl(fileName());
1697 if (!m_finalUrl.isValid())
1698 m_finalUrl = QUrl(finalUrlString());
1707 return propertyCaches.isEmpty()
1708 ? QQmlPropertyCache::ConstPtr()
1709 : propertyCaches.at(0);
1721 Q_ASSERT(p && p->isComponentWrapper());
1722 return p->wrappedObjectIndex();
1804 return int(binding.enumValue);
1805 return std::nullopt;
1819 runtimeDataStorage.clear();
1826 return runtimeDataStorage.isEmpty()
1828 :
reinterpret_cast<RuntimeDataBlock *>(runtimeDataStorage.data());
1835 for (
int i =
objectCount(), end = propertyCaches.count(); i < end; ++i) {
1837 Q_ASSERT(p && p->isComponentWrapper());
1838 if (p->wrappedObjectIndex() == index)
1846 for (uint i = 0; i <
qmlData->nObjects; ++i) {
1848 for (
auto it = object->inlineComponentsBegin(), end = object->inlineComponentsEnd();
1850 if (stringAt(it->nameIndex) == inlineComponentName)
1851 return it->objectIndex;
1943 QString m_finalUrlString;
1945 mutable QQmlNullableValue<QUrl> m_url;
1946 mutable QQmlNullableValue<QUrl> m_finalUrl;
1961 template<
typename Char>
1964 const quint32_le oldFlags = mutableFlags();
1965 auto cleanup = qScopeGuard([
this, oldFlags]() { mutableFlags() = oldFlags; });
1966 mutableFlags() |= temporaryFlags;
1967 return writer(data<Char>(), size());
1970 static bool writeDataToFile(
const QString &outputFileName,
const char *data, quint32 size,
1971 QString *errorString)
1973 return writeDataToFile(outputFileName,
nullptr, 0, data, 0, size,
nullptr, size, 0,
1981 const char *head, quint32 headSize,
1982 const char *data, quint32 offset, quint32 size,
1983 const char *tail, quint32 tailOffset, quint32 tailSize,
1984 QString *errorString)
1986#if QT_CONFIG(temporaryfile)
1987 Q_ASSERT(headSize <= offset);
1988 Q_ASSERT(tailOffset >= offset + size);
1989 QSaveFile cacheFile(outputFileName);
1990 if (!cacheFile.open(QIODevice::WriteOnly | QIODevice::Truncate)
1991 || (headSize > 0 && cacheFile.write(head, headSize) != headSize)
1993 && ((offset > headSize
1994 && (cacheFile.write(QByteArray(offset - headSize,
'\0'))
1995 != offset - headSize))
1996 || cacheFile.write(data, size) != size))
1998 && ((tailOffset > (offset + size)
1999 && cacheFile.write(QByteArray(tailOffset - size - offset,
'\0'))
2000 != tailOffset - size - offset)
2001 || cacheFile.write(tail, tailSize) != tailSize))
2002 || !cacheFile.commit()) {
2003 *errorString = cacheFile.errorString();
2007 errorString->clear();
2010 Q_UNUSED(outputFileName);
2011 *errorString = QStringLiteral(
"features.temporaryfile is disabled.");
2018 quint32 temporaryFlags;
2020 quint32_le &mutableFlags()
const
2022 return const_cast<
Unit *>(unit)->flags;
2025 template<
typename Char>
2026 const Char *data()
const
2028 Q_STATIC_ASSERT(
sizeof(Char) == 1);
2029 const Char *dataPtr;
2030 memcpy(&dataPtr, &unit,
sizeof(dataPtr));
2034 quint32 size()
const
2036 return unit->unitSize;
static bool writeDataToFile(const QString &outputFileName, const char *head, quint32 headSize, const char *data, quint32 offset, quint32 size, const char *tail, quint32 tailOffset, quint32 tailSize, QString *errorString)
static bool writeDataToFile(const QString &outputFileName, const char *data, quint32 size, QString *errorString)
bool saveToDisk(const std::function< bool(const Char *, quint32)> &writer) const
Combined button and popup list for selecting options.
static quint32 alignedTo(quint32 size)
static const char magic_str[]
Q_DECLARE_TYPEINFO(QV4::CompiledData::JSClassMember, Q_PRIMITIVE_TYPE)
#define QV4_DATA_STRUCTURE_VERSION
Q_DECLARE_OPERATORS_FOR_FLAGS(QV4::CompiledData::ParameterType::Flags)
void setPropertyNameIndex(quint32 propertyNameIndex)
quint32 propertyNameIndex() const
void setIsReadOnly(bool isReadOnly)
Location location() const
void setReferenceLocation(Location referenceLocation)
void setNameIndex(quint32 nameIndex)
Location referenceLocation() const
void setIdIndex(quint32 idIndex)
void setLocation(Location location)
quint32 nameIndex() const
quint32_le propertyNameIndex
bool isNumberBinding() const
bool isFunctionExpression() const
bool evaluatesToString() const
bool isAttachedProperty() const
quint32_le_bitfield_union< FlagsField, TypeField > flagsAndType
bool hasFlag(Flag flag) const
bool isGroupedProperty() const
bool isTranslationBinding() const
bool valueAsBoolean() const
static QString escapedString(const QString &string)
Q_DECLARE_FLAGS(Flags, Flag)
@ InitializerForReadOnlyDeclaration
const quint32_le * localsTable() const
quint16_le sizeOfLocalTemporalDeadZone
static size_t align(size_t a)
static int calculateSize(int nLocals)
static int calculateSize(int nStaticMethods, int nMethods)
static size_t align(size_t a)
quint32_le methodTableOffset
const Method * methodTable() const
quint32_le nStaticMethods
quint32_le constructorFunction
const CompiledObject * object
const CompiledData::Unit * unit
bool operator!=(const FunctionIterator &rhs) const
bool operator==(const FunctionIterator &rhs) const
FunctionIterator(const CompiledData::Unit *unit, const CompiledObject *object, int index)
const CompiledFunction * operator->() const
QString stringAt(uint index) const
std::unique_ptr< CompilationUnitMapper > backingFile
QString bindingValueAsScriptString(const CompiledData::Binding *binding) const
QHash< QString, InlineComponentData > inlineComponentData
RuntimeDataBlock * runtimeDataForWrite()
Q_QML_EXPORT ~CompilationUnit()
QByteArray runtimeDataStorage
void setUnitData(const Unit *unitData, const QmlUnit *qmlUnit=nullptr, const QString &fileName=QString(), const QString &finalUrlString=QString())
int inlineComponentId(const QString &inlineComponentName) const
quint32 namedObjectCountInComponent(int objectIndex) const
QMetaType metaType() const
double bindingValueAsNumber(const CompiledData::Binding *binding) const
std::optional< int > bindingFoldedEnum(int objectIndex, int bindingIndex) const
bool bindingIsDeferred(int objectIndex, int bindingIndex) const
void finalizeCompositeType(const QQmlType &type)
QMap< int, int > IdToObjectMap
bool persistRuntimeData(const QUrl &unitUrl, QString *errorString)
ResolvedTypeReference * resolvedType(int id) const
const CompiledData::Function CompiledFunction
const QQmlPrivate::AOTCompiledFunction * aotCompiledFunctions
bool valueTypesAreAssertable() const
quint32_le * allocateNamedObjectsInComponent(int objectIndex, quint32 count)
bool bindingIsSignalHandlerExpression(int objectIndex, int bindingIndex) const
bool bindingIsPropertyObserver(int objectIndex, int bindingIndex) const
int objectId(int objectIndex) const
bool writeWithRuntimeData(const QUrl &unitUrl, Unit *header, QString *errorString) const
int implicitComponentForObject(int index) const
bool bindingIsCustomParser(int objectIndex, int bindingIndex) const
bool bindingIsSignalHandlerObject(int objectIndex, int bindingIndex) const
bool hasImmutableRuntimeData() const
ResolvedTypeReferenceMap resolvedTypes
bool objectHasCustomParserBindings(int objectIndex) const
bool isSharedLibrary() const
bool componentsAreBound() const
QList< BindingPropertyData > bindingPropertyDataPerObject
bool objectIsPopulatedByDeferredBinding(int objectIndex) const
QQmlType qmlTypeForComponent(const QString &inlineComponentName=QString()) const
FunctionIterator objectFunctionsBegin(const CompiledObject *object) const
QString finalUrlString() const
QQmlRefPointer< QQmlTypeNameCache > typeNameCache
Q_QML_EXPORT bool saveToDisk(const QUrl &unitUrl, qxp::function_ref< QByteArray() const > sourceChecksum, QString *errorString) const
const RuntimeObject * runtimeObjectAt(int index) const
FunctionIterator objectFunctionsEnd(const CompiledObject *object) const
bool nativeMethodsAcceptThisObjects() const
ListPropertyAssignBehavior listPropertyAssignBehavior() const
const Unit * unitData() const
ListPropertyAssignBehavior
const CompiledObject * objectAt(int index) const
int resolvedIndex(int index) const
bool valueTypesAreAddressable() const
const CompiledData::Object CompiledObject
void allocateRuntimeData()
LookupValidationFn validateLookupSignatures
bool ignoresFunctionSignature() const
bool valueTypesAreCopied() const
const CompiledData::Binding CompiledBinding
const RuntimeDataBlock * runtimeData
const CompiledData::Import * importAt(int index) const
QQmlPropertyCacheVector propertyCaches
bool objectIsComponent(int objectIndex) const
CompilationUnit(const Unit *unitData, const QQmlPrivate::AOTCompiledFunction *aotCompiledFunctions, LookupValidationFn validateLookupSignatures, const QString &fileName=QString(), const QString &finalUrlString=QString())
QList< QQmlRefPointer< QQmlScriptData > > dependentScripts
QStringList dynamicStrings
bool bindingIsSignalHandler(int objectIndex, int bindingIndex) const
QString bindingValueAsString(const CompiledData::Binding *binding) const
Q_QML_EXPORT bool loadFromDisk(const QUrl &url, const QDateTime &sourceTimeStamp, qxp::function_ref< QByteArray() const > sourceChecksum, QString *errorString)
QQmlPropertyCache::ConstPtr rootPropertyCache() const
bool objectHasDeferredBindings(int objectIndex) const
const StaticValue * constants
const RuntimeBindingIndex * bindingApplicationOrder(int objectIndex) const
const EnumValue * enumValueAt(int idx) const
const EnumValue * enumValuesEnd() const
const EnumValue * enumValuesBegin() const
static int calculateSize(int nEnumValues)
int enumValueCount() const
quint32_le nestedFunctionIndex
quint16_le firstTemporalDeadZoneRegister
size_t labelInfosOffset() const
const quint32_le * localsTable() const
static size_t align(size_t a)
const CodeOffsetToLineAndStatement * lineAndStatementNumberTable() const
quint16_le sizeOfRegisterTemporalDeadZone
quint16_le sizeOfLocalTemporalDeadZone
const char * code() const
size_t lineAndStatementNumberOffset() const
static int calculateSize(int nFormals, int nLocals, int nLinesAndStatements, int labelInfoSize, int codeSize)
const Parameter * formalsTable() const
const Parameter * formalsEnd() const
const Parameter * formalsBegin() const
const quint32_le * labelInfoTable() const
quint16_le nLineAndStatementNumbers
quint32_le qualifierIndex
InlineComponentData(const QQmlType &qmlType, int objectIndex, int nameIndex)
InlineComponentData()=default
void set(quint32 nameOffset, bool isAccessor)
quint32 nameOffset() const
static int calculateSize(int nMembers)
Location(quint32 l, quint32 c)
void set(quint32 line, quint32 column)
friend size_t qHash(const Location &location, size_t seed=0)
bool operator<(const Location &other) const
friend bool comparesEqual(const Location &a, const Location &b) noexcept
Lookup(Type type, Mode mode, quint32 nameIndex)
quint32 nameIndex() const
@ Type_QmlContextPropertyGetter
void setFlags(Flags flags)
quint32_le offsetToBindings
TableIterator< Enum, Object, &Object::enumAt > EnumIterator
EnumIterator enumsBegin() const
Q_DECLARE_FLAGS(Flags, Flag)
quint32_le offsetToAliases
quint32_le offsetToProperties
int propertyCount() const
quint32_le offsetToSignals
const RequiredPropertyExtraData * requiredPropertyExtraDataAt(int idx) const
EnumIterator enumsEnd() const
const Enum * enumAt(int idx) const
RequiredPropertyExtraDataIterator requiredPropertyExtraDataEnd() const
bool hasAliasAsDefaultProperty() const
quint32_le offsetToInlineComponents
const RequiredPropertyExtraData * requiredPropertyExtraDataTable() const
TableIterator< Signal, Object, &Object::signalAt > SignalIterator
const Binding * bindingsEnd() const
quint32_le inheritedTypeNameIndex
bool hasFlag(Flag flag) const
const Property * propertyTable() const
@ IsPartOfInlineComponent
SignalIterator signalsBegin() const
InlineComponentIterator inlineComponentsEnd() const
qint32_le indexOfDefaultPropertyOrAlias
int functionCount() const
const Alias * aliasTable() const
quint16_le nInlineComponents
static int calculateSizeExcludingSignalsAndEnums(int nFunctions, int nProperties, int nAliases, int nEnums, int nSignals, int nBindings, int nInlineComponents, int nRequiredPropertyExtraData)
quint32_le offsetToRequiredPropertyExtraData
const InlineComponent * inlineComponentAt(int idx) const
const Property * propertiesEnd() const
const Binding * bindingTable() const
quint16_le nRequiredPropertyExtraData
const Signal * signalAt(int idx) const
const Property * propertiesBegin() const
Location locationOfIdProperty
const quint32_le * functionOffsetTable() const
TableIterator< InlineComponent, Object, &Object::inlineComponentAt > InlineComponentIterator
const InlineComponent * inlineComponentTable() const
InlineComponentIterator inlineComponentsBegin() const
TableIterator< RequiredPropertyExtraData, Object, &Object::requiredPropertyExtraDataAt > RequiredPropertyExtraDataIterator
SignalIterator signalsEnd() const
quint32_le_bitfield_union< FlagsField, DefaultPropertyIsAliasField > flagsAndDefaultPropertyIsAlias
const Alias * aliasesEnd() const
quint32_le offsetToFunctions
const Binding * bindingsBegin() const
RequiredPropertyExtraDataIterator requiredPropertyExtraDataBegin() const
void setHasAliasAsDefaultProperty(bool defaultAlias)
int inlineComponentCount() const
const Alias * aliasesBegin() const
quint32 typeNameIndexOrCommonType() const
void set(Flags flags, quint32 typeNameIndexOrCommonType)
bool indexIsCommonType() const
Q_DECLARE_FLAGS(Flags, Flag)
void setNameIndex(int nameIndex)
void setIsList(bool isList)
void setIsReadOnly(bool isReadOnly)
bool isCommonType() const
void setTypeNameIndex(int nameIndex)
void setIsVirtual(bool isVirtual)
void setIsFinal(bool isFinal)
quint32 nameIndex() const
quint32_le_bitfield_union< CommonTypeOrTypeNameIndexField, IsRequiredField, IsCommonTypeField, IsListField, IsReadOnlyField > data
quint32_le_bitfield_union< NameIndexField, IsVirtualField, IsOverrideField, IsFinalField > nameIndexAndVirtSpecifiers
void setIsOverride(bool isOverride)
uint commonTypeOrTypeNameIndex() const
int typeNameIndex() const
void setIsRequired(bool isRequired)
void setCommonType(CommonType t)
CommonType commonType() const
quint32_le offsetToObjects
const Object * objectAt(int idx) const
const Import * importAt(int idx) const
quint32_le offsetToImports
quint32 stringIndex() const
RegExp(quint32 flags, quint32 stringIndex)
Q_DECLARE_FLAGS(Flags, Flag)
bool addToHash(QCryptographicHash *hash, QHash< quintptr, QByteArray > *checksums) const
@ IsSignalHandlerExpression
char dependencyMD5Checksum[16]
const RuntimeObject * objectAt(int idx) const
RuntimeObject * objectAt(int idx)
bool verifyChecksum(const CompiledData::DependentTypesHasher &dependencyHasher) const
const RuntimeBindingIndex * bindingOrder() const
quint32_le offsetToBindingOrder
@ PopulatedByDeferredBinding
@ HasCustomParserBindings
RuntimeBinding * bindingTable()
const RuntimeBinding * bindingTable() const
quint32_le offsetToNamedObjectsInComponent
RuntimeBindingIndex * bindingOrder()
quint32_le * namedObjectsInComponentTable()
const quint32_le * namedObjectsInComponentTable() const
quint32_le nNamedObjectsInComponent
int parameterCount() const
const Parameter * parametersBegin() const
static int calculateSize(int nParameters)
const Parameter * parametersEnd() const
const Parameter * parameterAt(int idx) const
static int calculateSize(const QString &str)
bool operator==(const TableIterator &rhs) const
ItemType operator*() const
TableIterator & operator++()
const Container * container
bool operator!=(const TableIterator &rhs) const
TableIterator(const Container *container, int index)
TableIterator operator+(int offset) const
const ItemType * operator->() const
TableIterator operator++(int)
int operator-(TableIterator other) const
TableIterator operator-(int offset) const
static int calculateSize(int size)
uint stringIndexAt(uint i) const
static size_t align(size_t a)
uint rawStringIndexAt(uint i) const
const quint32_le * stringTable() const
void collectFromObject(const CompiledObject *obj)
TypeReference & add(int nameIndex, const Location &loc)
void collectFromObjects(Iterator it, Iterator end)
TypeReference(const Location &loc)
quint32_le offsetToLookupTable
quint32_le offsetToIndirectExportEntryTable
quint32_le offsetToJSClassTable
quint32_le jsClassTableSize
quint32_le * translationContextIndex()
quint32_le offsetToTemplateObjectTable
quint32_le offsetToRuntimeData
quint32_le functionTableSize
const TranslationData * translations() const
quint32_le offsetToRegexpTable
quint32_le importEntryTableSize
const ExportEntry * indirectExportEntryTable() const
quint32_le runtimeDataSize
const quint64_le * constants() const
quint32_le starExportEntryTableSize
quint32_le lookupTableSize
qint32_le indexOfRootFunction
QString stringAtInternal(uint idx) const
quint32_le offsetToLocalExportEntryTable
const quint32_le * functionOffsetTable() const
bool isListPropertyAssignReplaceIfNotDefault() const
bool verifyHeader(QDateTime expectedSourceTimeStamp, QString *errorString) const
quint32_le offsetToClassTable
quint32_le classTableSize
quint32_le offsetToStringTable
quint32_le offsetToQmlUnit
const Function * functionAt(int idx) const
const TemplateObject * templateObjectAt(int idx) const
quint32_le offsetToFunctionTable
quint32_le offsetToStarExportEntryTable
const ExportEntry * starExportEntryTable() const
const Lookup * lookupTable() const
quint32_le offsetToModuleRequestTable
const RuntimeDataBlock * runtimeData() const
quint32_le translationTableSize
const RegExp * regexpAt(int index) const
const Block * blockAt(int idx) const
const ExportEntry * localExportEntryTable() const
const quint32_le * translationContextIndex() const
const quint32_le * classOffsetTable() const
@ ListPropertyAssignReplace
@ FunctionSignaturesIgnored
@ ListPropertyAssignReplaceIfDefault
@ ListPropertyAssignReplaceIfNotDefault
@ NativeMethodsAcceptThisObject
const quint32_le * moduleRequestTable() const
quint32_le sourceFileIndex
quint32_le moduleRequestTableSize
quint32_le offsetToTranslationTable
quint32_le blockTableSize
quint32_le templateObjectTableSize
quint32_le localExportEntryTableSize
bool isListPropertyAssignReplace() const
const Class * classAt(int idx) const
quint32_le regexpTableSize
quint32_le offsetToImportEntryTable
quint32_le stringTableSize
quint32_le constantTableSize
const ImportEntry * importEntryTable() const
qint64_le sourceTimeStamp
const QmlUnit * qmlUnit() const
quint32_le offsetToConstantTable
quint32_le offsetToBlockTable
const quint32_le * blockOffsetTable() const
quint32_le indirectExportEntryTableSize
const JSClassMember * jsClassAt(int idx, int *nMembers) const
const quint32_le * templateObjectOffsetTable() const