diff options
Diffstat (limited to 'src/qml/compiler/qv4compileddata.cpp')
-rw-r--r-- | src/qml/compiler/qv4compileddata.cpp | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 7cf97e55dc..fa0c222397 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -56,6 +56,7 @@ #include <QScopedValueRollback> #include <QStandardPaths> #include <QDir> +#include <private/qv4identifiertable_p.h> #endif #include <private/qqmlirbuilder_p.h> #include <QCoreApplication> @@ -98,6 +99,7 @@ CompilationUnit::CompilationUnit() , runtimeLookups(0) , runtimeRegularExpressions(0) , runtimeClasses(0) + , constants(nullptr) , totalBindingsCount(0) , totalParserStatusCount(0) , totalObjectCount(0) @@ -125,7 +127,7 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine) // memset the strings to 0 in case a GC run happens while we're within the loop below memset(runtimeStrings, 0, data->stringTableSize * sizeof(QV4::Heap::String*)); for (uint i = 0; i < data->stringTableSize; ++i) - runtimeStrings[i] = engine->newIdentifier(data->stringAt(i)); + runtimeStrings[i] = engine->newString(data->stringAt(i)); runtimeRegularExpressions = new QV4::Value[data->regexpTableSize]; // memset the regexps to 0 in case a GC run happens while we're within the loop below @@ -166,7 +168,7 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine) const CompiledData::JSClassMember *member = data->jsClassAt(i, &memberCount); QV4::InternalClass *klass = engine->internalClasses[QV4::ExecutionEngine::Class_Object]; for (int j = 0; j < memberCount; ++j, ++member) - klass = klass->addMember(runtimeStrings[member->nameOffset]->identifier, member->isAccessor ? QV4::Attr_Accessor : QV4::Attr_Data); + klass = klass->addMember(engine->identifierTable->identifier(runtimeStrings[member->nameOffset]), member->isAccessor ? QV4::Attr_Accessor : QV4::Attr_Data); runtimeClasses[i] = klass; } @@ -174,7 +176,7 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine) #if Q_BYTE_ORDER == Q_BIG_ENDIAN Value *bigEndianConstants = new Value[data->constantTableSize]; - const LEUInt64 *littleEndianConstants = data->constants(); + const quint64_le *littleEndianConstants = data->constants(); for (uint i = 0; i < data->constantTableSize; ++i) bigEndianConstants[i] = Value::fromReturnedValue(littleEndianConstants[i]); constants = bigEndianConstants; @@ -210,8 +212,9 @@ void CompilationUnit::unlink() if (isRegisteredWithEngine) { Q_ASSERT(data && quint32(propertyCaches.count()) > data->indexOfRootObject && propertyCaches.at(data->indexOfRootObject)); - QQmlEnginePrivate *qmlEngine = QQmlEnginePrivate::get(propertyCaches.at(data->indexOfRootObject)->engine); - qmlEngine->unregisterInternalCompositeType(this); + if (engine) + QQmlEnginePrivate::get(engine)->unregisterInternalCompositeType(this); + QQmlMetaType::unregisterInternalCompositeType(this); isRegisteredWithEngine = false; } @@ -239,6 +242,7 @@ void CompilationUnit::unlink() runtimeFunctions.clear(); #if Q_BYTE_ORDER == Q_BIG_ENDIAN delete [] constants; + constants = nullptr; #endif } @@ -270,7 +274,7 @@ IdentifierHash<int> CompilationUnit::namedObjectsPerComponent(int componentObjec if (it == namedObjectsPerComponentCache.end()) { IdentifierHash<int> namedObjectCache(engine); const CompiledData::Object *component = data->objectAt(componentObjectIndex); - const LEUInt32 *namedObjectIndexPtr = component->namedObjectsInComponentTable(); + const quint32_le *namedObjectIndexPtr = component->namedObjectsInComponentTable(); for (quint32 i = 0; i < component->nNamedObjectsInComponent; ++i, ++namedObjectIndexPtr) { const CompiledData::Object *namedObject = data->objectAt(*namedObjectIndexPtr); namedObjectCache.add(runtimeStrings[namedObject->idNameIndex], namedObject->id); @@ -283,9 +287,10 @@ IdentifierHash<int> CompilationUnit::namedObjectsPerComponent(int componentObjec void CompilationUnit::finalize(QQmlEnginePrivate *engine) { // Add to type registry of composites - if (propertyCaches.needsVMEMetaObject(data->indexOfRootObject)) + if (propertyCaches.needsVMEMetaObject(data->indexOfRootObject)) { + QQmlMetaType::registerInternalCompositeType(this); engine->registerInternalCompositeType(this); - else { + } else { const QV4::CompiledData::Object *obj = objectAt(data->indexOfRootObject); auto *typeRef = resolvedTypes.value(obj->inheritedTypeNameIndex); Q_ASSERT(typeRef); @@ -293,8 +298,8 @@ void CompilationUnit::finalize(QQmlEnginePrivate *engine) metaTypeId = typeRef->compilationUnit->metaTypeId; listMetaTypeId = typeRef->compilationUnit->listMetaTypeId; } else { - metaTypeId = typeRef->type->typeId(); - listMetaTypeId = typeRef->type->qListTypeId(); + metaTypeId = typeRef->type.typeId(); + listMetaTypeId = typeRef->type.qListTypeId(); } } @@ -306,8 +311,8 @@ void CompilationUnit::finalize(QQmlEnginePrivate *engine) const QV4::CompiledData::Object *obj = data->objectAt(i); bindingCount += obj->nBindings; if (auto *typeRef = resolvedTypes.value(obj->inheritedTypeNameIndex)) { - if (QQmlType *qmlType = typeRef->type) { - if (qmlType->parserStatusCast() != -1) + if (typeRef->type.isValid()) { + if (typeRef->type.parserStatusCast() != -1) ++parserStatusCount; } ++objectCount; @@ -671,7 +676,7 @@ Returns the property cache, if one alread exists. The cache is not referenced. */ QQmlPropertyCache *ResolvedTypeReference::propertyCache() const { - if (type) + if (type.isValid()) return typePropertyCache; else return compilationUnit->rootPropertyCache(); @@ -684,8 +689,8 @@ QQmlPropertyCache *ResolvedTypeReference::createPropertyCache(QQmlEngine *engine { if (typePropertyCache) { return typePropertyCache; - } else if (type) { - typePropertyCache = QQmlEnginePrivate::get(engine)->cache(type->metaObject()); + } else if (type.isValid()) { + typePropertyCache = QQmlEnginePrivate::get(engine)->cache(type.metaObject()); return typePropertyCache; } else { return compilationUnit->rootPropertyCache(); @@ -694,7 +699,7 @@ QQmlPropertyCache *ResolvedTypeReference::createPropertyCache(QQmlEngine *engine bool ResolvedTypeReference::addToHash(QCryptographicHash *hash, QQmlEngine *engine) { - if (type) { + if (type.isValid()) { bool ok = false; hash->addData(createPropertyCache(engine)->checksum(&ok)); return ok; @@ -718,8 +723,8 @@ void ResolvedTypeReference::doDynamicTypeCheck() const QMetaObject *mo = 0; if (typePropertyCache) mo = typePropertyCache->firstCppMetaObject(); - else if (type) - mo = type->metaObject(); + else if (type.isValid()) + mo = type.metaObject(); else if (compilationUnit) mo = compilationUnit->rootPropertyCache()->firstCppMetaObject(); isFullyDynamicType = qtTypeInherits<QQmlPropertyMap>(mo); |