10#include <private/qv4value_p.h>
12#include <private/qduplicatetracker_p.h>
14#include <QtCore/qloggingcategory.h>
23 : m_imports(importer->builtinInternalNames()),
135 qCDebug(lcTypeResolver()).nospace()
155 if (!
type->typeArgument)
157 if (typeId == u
"list"_s) {
159 return typeArgument->listType();
167 if (
value.isUndefined())
173 if (
value.isBoolean())
176 if (
value.isDouble())
325 return container.
type();
345 Q_UNREACHABLE_RETURN({});
382 enumeration.
setType((this->*op)(enumeration.
type()));
407 Q_UNREACHABLE_RETURN({});
412 bool hasObjectModulePrefix)
const
418 if (
type->isSingleton())
422 if (
type->isScript())
426 if (
const auto attached =
type->attachedType()) {
428 m_logger->
log(u
"Cannot resolve generic base of attached %1"_s.arg(
429 attached->internalName()),
432 }
else if (
type->accessSemantics() != QQmlJSScope::AccessSemantics::Reference) {
433 m_logger->
log(u
"Cannot retrieve attached object for non-reference type %1"_s.arg(
434 type->internalName()),
443 hasObjectModulePrefix
449 switch (
type->accessSemantics()) {
450 case QQmlJSScope::AccessSemantics::None:
451 case QQmlJSScope::AccessSemantics::Reference:
458 case QQmlJSScope::AccessSemantics::Sequence:
459 case QQmlJSScope::AccessSemantics::Value:
552 it->original = conversion;
570 bool useFancyName)
const
612 if (toTypeName == u
"QPoint"_s || toTypeName == u
"QPointF"_s
613 || toTypeName == u
"QSize"_s || toTypeName == u
"QSizeF"_s
614 || toTypeName == u
"QRect"_s || toTypeName == u
"QRectF"_s) {
638 if (
a.isConversion())
639 origins.append(
a.conversionOrigins());
643 if (
b.isConversion())
644 origins.append(
b.conversionOrigins());
653 merge(
a.storedType(),
b.storedType()),
657 merge(
a.scopeType(),
b.scopeType()));
669 const auto commonBaseType = [
this](
694 if (isInt32Compatible(
a) && isInt32Compatible(
b))
701 if (isUInt32Compatible(
a) && isUInt32Compatible(
b))
712 if (isStringCompatible(
a) && isStringCompatible(
b))
718 if (
auto commonBase = commonBaseType(
a,
b))
733 if (
equals(container, contained)
743 return contained->
accessSemantics() == QQmlJSScope::AccessSemantics::Sequence;
746 if (contained->
accessSemantics() != QQmlJSScope::AccessSemantics::Sequence)
749 return value->isReferenceType();
787 for (
const auto &origin :
origins) {
788 if (canBeUndefined(origin))
799 if (
type->isScript())
805 if (
type->accessSemantics() == QQmlJSScope::AccessSemantics::Reference) {
806 QString unresolvedBaseTypeName;
813 if (
base->internalName() == u
"QObject"_s) {
816 &&
base->internalName() == u
"QQmlComponent"_s) {
820 if (
auto baseBase =
base->baseType()) {
823 unresolvedBaseTypeName =
base->baseTypeName();
828 m_logger->
log(u
"Object type %1 is not derived from QObject or QQmlComponent. "
829 "You may need to fully qualify all names in C++ so that moc can see them. "
830 "You may also need to add qt_extract_metatypes(<target containing %2>)."_s
831 .
arg(
type->internalName(), unresolvedBaseTypeName),
839 if (
type->isListProperty())
902 return typeRevision.
isValid() && typeRevision >= revision;
910 const QString defaultPropertyName =
parent->defaultPropertyName();
911 if (defaultPropertyName.
isEmpty())
915 parent->propertyBindings(defaultPropertyName);
937 QQmlJSMetaProperty prop = found->ownProperty(name);
938 if (!isRevisionAllowed(prop.revision(), scope))
940 if (m_parentMode == UseDocumentParent
941 && name == base->parentPropertyName()) {
942 QQmlJSScope::ConstPtr baseParent = base->parentScope();
943 if (baseParent && baseParent->inherits(prop.type())
944 && isAssignedToDefaultProperty(baseParent, base)) {
945 prop.setType(baseParent);
955 auto methods = found->ownMethods(name);
956 for (auto it = methods.begin(); it != methods.end();) {
957 if (!isRevisionAllowed(it->revision(), scope))
958 it = methods.erase(it);
982 if (m_jsGlobalObject->hasProperty(
name)) {
986 }
else if (m_jsGlobalObject->hasMethod(
name)) {
1000 if (
name.isEmpty() || !
name.at(0).isUpper())
1003 const bool inExtension =
1007 for (
const auto &enumeration : enums) {
1008 if (enumeration.name() ==
name) {
1017 if (enumeration.hasKey(
name)) {
1032 bool *isExtension)
const
1040 ||
type->accessSemantics() != QQmlJSScope::AccessSemantics::Value
1041 || !
type->isStructured()) {
1046 *isExtension = !
type->extensionType().scope.isNull();
1053 bool *isExtension)
const
1059 ||
type->accessSemantics() != QQmlJSScope::AccessSemantics::Value
1060 || !
type->isCreatable()) {
1067 const auto ownMethods =
type->ownMethods();
1069 if (!
method.isConstructor())
1075 const auto methodArguments =
method.parameters();
1076 if (methodArguments.size() != 1)
1081 if (
equals(passedArgumentType, methodArgumentType))
1099 *isExtension =
true;
1105 *isExtension =
false;
1107 return doSelectConstructor(
type);
1118 for (
const auto eq : equivalentLists) {
1129 if (
type->isReferenceType())
1164 if (from->
accessSemantics() == QQmlJSScope::AccessSemantics::Reference
1175 return to->
scopeType() != QQmlJSScope::ScopeType::EnumScope;
1196 for (
const auto &originType :
types) {
1197 if (!
equals(from, originType))
1200 for (
const auto &targetType :
types) {
1201 if (
equals(to, targetType))
1209 && to->
accessSemantics() == QQmlJSScope::AccessSemantics::Reference) {
1222 return to->
accessSemantics() == QQmlJSScope::AccessSemantics::Sequence;
1226 for (
auto baseType = from; baseType; baseType = baseType->
baseType()) {
1227 if (
equals(baseType, to))
1229 if (matchByName && baseType->internalName() == to->
internalName())
1294 ||
type->accessSemantics() == QQmlJSScope::AccessSemantics::Sequence)
1295 &&
name == u
"length"_s) {
1324 if (std::optional<QQmlJSScope::JavaScriptIdentifier> identifier =
1326 identifier.has_value()) {
1348 m_logger->
log(u
"Cannot resolve generic base of attached %1"_s.arg(
1349 attached->internalName()),
1352 }
else if (
type->accessSemantics() != QQmlJSScope::AccessSemantics::Reference) {
1353 m_logger->
log(u
"Cannot retrieve attached object for non-reference type %1"_s.arg(
1354 type->internalName()),
1386 if (
type.isType()) {
1396 if (
type.isProperty())
1398 if (
type.isEnumeration()) {
1399 const auto enumeration =
type.enumeration();
1400 if (!
type.enumMember().isEmpty() || !enumeration.hasKey(
name))
1405 if (
type.isMethod()) {
1414 if (
type.isImportNamespace()) {
1415 if (
type.scopeType()->accessSemantics() != QQmlJSScope::AccessSemantics::Reference) {
1416 m_logger->
log(u
"Cannot use a non-QObject type %1 to access prefixed import"_s.arg(
1417 type.scopeType()->internalName()),
1426 if (
type.isConversion()) {
1440 return equals(origin, m_voidType);
1449 Q_UNREACHABLE_RETURN({});
1458 if (scope->
accessSemantics() == QQmlJSScope::AccessSemantics::Sequence)
1467 if (
list.isType()) {
1468 scope =
list.type();
1470 }
else if (
list.isConversion()) {
1472 }
else if (
list.isProperty()) {
1473 const auto prop =
list.property();
1474 scope = prop.type();
1482 property.setPropertyName(u
"[]"_s);
1483 property.setTypeName(
value->internalName());
1484 property.setType(
value);
1527 if (
type->isScript())
1529 if (
type->isComposite()) {
1531 return nonComposite;
1536 if (
type->filePath().isEmpty())
1579 return it->replacement ?
it->replacement :
it->original;
static JNINativeMethod methods[]
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
QQmlJSImporter::ImportedTypes imports() const
const QQmlJSLogger * logger() const
QQmlJSScopesById addressableScopes() const
QHash< QQmlJS::SourceLocation, QQmlJSMetaSignalHandler > signalHandlers() const
QHash< QV4::CompiledData::Location, QQmlJSScope::ConstPtr > scopesBylocation() const
QQmlJSScope::ConstPtr jsGlobalObject() const
void log(const QString &message, QQmlJS::LoggerWarningId id, const QQmlJS::SourceLocation &srcLocation, bool showContext=true, bool showFileName=true, const std::optional< QQmlJSFixSuggestion > &suggestion={}, const QString overrideFileName=QString())
QQmlJSScope::ConstPtr conversionResult() const
QQmlJSMetaProperty property() const
QQmlJSScope::ConstPtr scopeType() const
uint importNamespace() const
bool isConversion() const
static QQmlJSRegisterContent create(const QQmlJSScope::ConstPtr &storedType, const QQmlJSScope::ConstPtr &type, ContentVariant variant, const QQmlJSScope::ConstPtr &scope={})
QList< QQmlJSScope::ConstPtr > conversionOrigins() const
bool isImportNamespace() const
ContentVariant variant() const
QQmlJSScope::ConstPtr type() const
QQmlJSScope::ConstPtr storedType() const
QQmlJSMetaEnum enumeration() const
@ ExtensionObjectProperty
QString enumMember() const
bool isEnumeration() const
QList< QQmlJSMetaMethod > method() const
Tracks the types for the QmlCompiler.
QQmlJSMetaProperty ownProperty(const QString &name) const
static QQmlJSScope::Ptr create()
void setAccessSemantics(AccessSemantics semantics)
QHash< QString, QQmlJSMetaEnum > ownEnumerations() const
ScopeType scopeType() const
void setInternalName(const QString &internalName)
QString internalName() const
bool isReferenceType() const
static QQmlJSScope::ConstPtr nonCompositeBaseType(const QQmlJSScope::ConstPtr &type)
AccessSemantics accessSemantics() const
bool isListProperty() const
QQmlJSScope::ConstPtr listType() const
static QTypeRevision nonCompositeBaseRevision(const ImportedScope< QQmlJSScope::ConstPtr > &scope)
QQmlJSScope::ConstPtr attachedType() const
static QQmlJSScope::Ptr clone(const QQmlJSScope::ConstPtr &origin)
QDeferredSharedPointer< const QQmlJSScope > ConstPtr
std::optional< JavaScriptIdentifier > findJSIdentifier(const QString &id) const
static QString prettyName(QAnyStringView name)
bool hasOwnProperty(const QString &name) const
QQmlJSScope::ConstPtr baseType() const
static QQmlJSScope::ConstPtr findCurrentQMLScope(const QQmlJSScope::ConstPtr &scope)
void setFilePath(const QString &file)
QMultiHash< QString, QQmlJSMetaMethod > ownMethods() const
QTypeRevision baseTypeRevision() const
QQmlJSScope::ConstPtr valueType() const
bool hasOwnMethod(const QString &name) const
QString id(const QQmlJSScope::ConstPtr &scope, const QQmlJSScope::ConstPtr &referrer) const
QQmlJSScope::ConstPtr scope(const QString &id, const QQmlJSScope::ConstPtr &referrer) const
bool equals(const QQmlJSScope::ConstPtr &a, const QQmlJSScope::ConstPtr &b) const
QQmlJSRegisterContent original(const QQmlJSRegisterContent &type) const
QQmlJSScope::ConstPtr m_int8Type
QQmlJSScope::ConstPtr trackedContainedType(const QQmlJSRegisterContent &container) const
QQmlJSRegisterContent merge(const QQmlJSRegisterContent &a, const QQmlJSRegisterContent &b) const
QQmlJSRegisterContent memberType(const QQmlJSRegisterContent &type, const QString &name) const
QQmlJSMetaMethod selectConstructor(const QQmlJSScope::ConstPtr &type, const QQmlJSScope::ConstPtr &argument, bool *isExtension) const
QString idForScope(const QQmlJSScope::ConstPtr &scope, const QQmlJSScope::ConstPtr &referrer) const
QQmlJSScope::ConstPtr m_stringListType
QQmlJSScope::ConstPtr m_arrayPrototype
QQmlJSImporter::ImportedTypes m_imports
QQmlJSScope::ConstPtr stringType() const
QQmlJSScope::ConstPtr m_realType
QQmlJSScope::ConstPtr m_int64Type
QQmlJSScope::ConstPtr m_uint16Type
QQmlJSScope::ConstPtr storedType(const QQmlJSScope::ConstPtr &type) const
QQmlJSScope::ConstPtr nullType() const
QQmlJSRegisterContent memberEnumType(const QQmlJSScope::ConstPtr &type, const QString &name) const
QQmlJSScope::ConstPtr m_voidType
QQmlJSRegisterContent tracked(const QQmlJSRegisterContent &type) const
QQmlJSScope::ConstPtr genericType(const QQmlJSScope::ConstPtr &type, ComponentIsGeneric allowComponent=ComponentIsGeneric::No) const
bool areEquivalentLists(const QQmlJSScope::ConstPtr &a, const QQmlJSScope::ConstPtr &b) const
QQmlJSScope::ConstPtr emptyType() const
bool registerIsStoredIn(const QQmlJSRegisterContent ®, const QQmlJSScope::ConstPtr &type) const
bool canPopulate(const QQmlJSScope::ConstPtr &type, const QQmlJSScope::ConstPtr &argument, bool *isExtension) const
QQmlJSScope::ConstPtr containedType(const QQmlJSRegisterContent &container) const
QQmlJSScope::ConstPtr jsPrimitiveType() const
QQmlJSRegisterContent typeForArithmeticUnaryOperation(UnaryOperator op, const QQmlJSRegisterContent &operand) const
QQmlJSScope::ConstPtr m_jsValueType
bool isNumeric(const QQmlJSRegisterContent &type) const
QQmlJSScope::ConstPtr m_int16Type
QQmlJSScope::ConstPtr scopeForId(const QString &id, const QQmlJSScope::ConstPtr &referrer) const
QQmlJSRegisterContent lengthProperty(bool isWritable, const QQmlJSScope::ConstPtr &scope) const
QQmlJSScope::ConstPtr boolType() const
QQmlJSScope::ConstPtr trackedType(const QQmlJSScope::ConstPtr &type) const
QQmlJSScope::ConstPtr m_jsPrimitiveType
QQmlJSScopesById m_objectsById
bool adjustTrackedType(const QQmlJSScope::ConstPtr &tracked, const QQmlJSScope::ConstPtr &conversion) const
QQmlJSScope::ConstPtr m_qObjectListType
QQmlJSScope::ConstPtr m_varType
bool canPrimitivelyConvertFromTo(const QQmlJSScope::ConstPtr &from, const QQmlJSScope::ConstPtr &to) const
QQmlJSScope::ConstPtr m_byteArrayType
bool registerContains(const QQmlJSRegisterContent ®, const QQmlJSScope::ConstPtr &type) const
bool isIntegral(const QQmlJSRegisterContent &type) const
bool canHold(const QQmlJSScope::ConstPtr &container, const QQmlJSScope::ConstPtr &contained) const
bool isPrimitive(const QQmlJSRegisterContent &type) const
QQmlJSRegisterContent builtinType(const QQmlJSScope::ConstPtr &type) const
QQmlJSRegisterContent returnType(const QQmlJSScope::ConstPtr &type, QQmlJSRegisterContent::ContentVariant variant, const QQmlJSScope::ConstPtr &scope) const
bool canConvertFromTo(const QQmlJSScope::ConstPtr &from, const QQmlJSScope::ConstPtr &to) const
QQmlJSScope::ConstPtr m_qObjectType
QString containedTypeName(const QQmlJSRegisterContent &container, bool useFancyName=false) const
QQmlJSScope::ConstPtr jsValueType() const
QQmlJSRegisterContent globalType(const QQmlJSScope::ConstPtr &type) const
QQmlJSRegisterContent convert(const QQmlJSRegisterContent &from, const QQmlJSRegisterContent &to) const
QQmlJSScope::ConstPtr originalType(const QQmlJSScope::ConstPtr &type) const
bool canHoldUndefined(const QQmlJSRegisterContent &content) const
void adjustOriginalType(const QQmlJSScope::ConstPtr &tracked, const QQmlJSScope::ConstPtr &conversion) const
QQmlJSRegisterContent valueType(const QQmlJSRegisterContent &list) const
QHash< QV4::CompiledData::Location, QQmlJSScope::ConstPtr > m_objectsByLocation
QQmlJSScope::ConstPtr originalContainedType(const QQmlJSRegisterContent &container) const
QQmlJSScope::ConstPtr uint32Type() const
QQmlJSScope::ConstPtr comparableType(const QQmlJSScope::ConstPtr &type) const
bool checkEnums(const QQmlJSScope::ConstPtr &scope, const QString &name, QQmlJSRegisterContent *result, QQmlJSScope::ExtensionKind mode) const
bool isTriviallyCopyable(const QQmlJSScope::ConstPtr &type) const
QQmlJSScope::ConstPtr m_urlType
QQmlJSScope::ConstPtr m_uint32Type
QQmlJSScope::ConstPtr int32Type() const
QQmlJSScope::ConstPtr m_numberPrototype
QQmlJSScope::ConstPtr m_functionType
QQmlJSScope::ConstPtr m_listPropertyType
QQmlJSScope::ConstPtr m_variantMapType
QQmlJSScope::ConstPtr m_stringType
QQmlJSScope::ConstPtr m_nullType
QQmlJSScope::ConstPtr voidType() const
QQmlJSScope::ConstPtr m_dateTimeType
QQmlJSScope::ConstPtr typeFromAST(QQmlJS::AST::Type *type) const
QQmlJSRegisterContent registerContentForName(const QString &name, const QQmlJSScope::ConstPtr &scopeType=QQmlJSScope::ConstPtr(), bool hasObjectModuelPrefix=false) const
QQmlJSScope::ConstPtr m_floatType
QHash< QQmlJS::SourceLocation, QQmlJSMetaSignalHandler > m_signalHandlers
QQmlJSTypeResolver(QQmlJSImporter *importer)
QQmlJSScope::ConstPtr m_timeType
QQmlJSScope::ConstPtr m_boolType
QQmlJSScope::ConstPtr metaObjectType() const
QQmlJSScope::ConstPtr m_metaObjectType
QQmlJSScope::ConstPtr realType() const
QQmlJSScope::ConstPtr m_jsGlobalObject
void init(QQmlJSImportVisitor *visitor, QQmlJS::AST::Node *program)
void generalizeType(const QQmlJSScope::ConstPtr &type) const
QQmlJSScope::ConstPtr m_int32Type
bool isUnsignedInteger(const QQmlJSScope::ConstPtr &type) const
QQmlJSScope::ConstPtr scopeForLocation(const QV4::CompiledData::Location &location) const
QQmlJSScope::ConstPtr m_uint64Type
QQmlJSScope::ConstPtr m_emptyType
QQmlJSScope::ConstPtr typeForConst(QV4::ReturnedValue rv) const
bool canAddressValueTypes() const
bool isSignedInteger(const QQmlJSScope::ConstPtr &type) const
QQmlJSRegisterContent transformed(const QQmlJSRegisterContent &origin, QQmlJSScope::ConstPtr(QQmlJSTypeResolver::*op)(const QQmlJSScope::ConstPtr &) const) const
std::unique_ptr< QHash< QQmlJSScope::ConstPtr, TrackedType > > m_trackedTypes
QQmlJSScope::ConstPtr m_uint8Type
QQmlJSScope::ConstPtr m_variantListType
QQmlJSScope::ConstPtr typeForName(const QString &name) const
QQmlJSRegisterContent scopedType(const QQmlJSScope::ConstPtr &scope, const QString &name) const
QQmlJSScope::ConstPtr varType() const
QQmlJSRegisterContent typeForBinaryOperation(QSOperator::Op oper, const QQmlJSRegisterContent &left, const QQmlJSRegisterContent &right) const
QQmlJSScope::ConstPtr m_dateType
QQmlJSScope::ConstPtr variantMapType() const
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static constexpr QTypeRevision fromEncodedVersion(Integer value)
Produces a QTypeRevision from the given value.
static constexpr QTypeRevision zero()
Produces a QTypeRevision with major and minor version {0}.
constexpr bool isValid() const
Returns true if the major version or the minor version is known, otherwise false.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
qsizetype erase(QByteArray &ba, const T &t)
static const QCssKnownValue origins[NumKnownOrigins - 1]
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLsizei GLenum GLenum * types
const QQmlJS::LoggerWarningId qmlPrefixedImportType
const QQmlJS::LoggerWarningId qmlCompiler
static bool isRevisionAllowed(int memberRevision, const QQmlJSScope::ConstPtr &scope)
static QQmlJSRegisterContent::ContentVariant scopeContentVariant(QQmlJSScope::ExtensionKind mode, bool isMethod)
static QQmlJSRegisterContent::ContentVariant mergeVariants(QQmlJSRegisterContent::ContentVariant a, QQmlJSRegisterContent::ContentVariant b)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
if(qFloatDistance(a, b)<(1<< 7))
[0]
ImportedScope< ConstPtr > type(const QString &name) const
static bool searchBaseAndExtensionTypes(QQmlJSScopePtr type, const Action &check)
static constexpr Value fromReturnedValue(ReturnedValue val)
static QString asString(QQmlJS::AST::UiQualifiedId *node)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent