aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-04-28 10:04:55 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-04-28 18:46:43 +0200
commita63347100c74ea857d3595aa564d95e5e2416508 (patch)
tree560d8cf209a384813e64e8ac97aa8fa383234b61 /src
parentbb8163a53325555b28adbdc36e8b4372d292fc60 (diff)
QmlCompiler: Remove emptyListType
It was a stop-gap solution on the way to actual list type support. It creates problems because it's a sequence type but doesn't have a value type. Add an assert to catch related problems earlier in the future. Fixes: QTBUG-113265 Change-Id: Iae955ab6c5ca41113095b523a5d6b9bcfd4d2396 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qmlcompiler/qqmljsbasicblocks.cpp1
-rw-r--r--src/qmlcompiler/qqmljscodegenerator.cpp23
-rw-r--r--src/qmlcompiler/qqmljstypepropagator.cpp4
-rw-r--r--src/qmlcompiler/qqmljstyperesolver.cpp11
-rw-r--r--src/qmlcompiler/qqmljstyperesolver_p.h2
5 files changed, 4 insertions, 37 deletions
diff --git a/src/qmlcompiler/qqmljsbasicblocks.cpp b/src/qmlcompiler/qqmljsbasicblocks.cpp
index 4d8ab49367..506bed15b3 100644
--- a/src/qmlcompiler/qqmljsbasicblocks.cpp
+++ b/src/qmlcompiler/qqmljsbasicblocks.cpp
@@ -302,6 +302,7 @@ void QQmlJSBasicBlocks::populateReaderLocations()
if (!blockInstr->second.isRename && containsAny(
readIt->second.content.conversionOrigins(), access.trackedTypes)) {
Q_ASSERT(readIt->second.content.isConversion());
+ Q_ASSERT(readIt->second.content.conversionResult());
access.typeReaders[blockInstr.key()]
= readIt->second.content.conversionResult();
}
diff --git a/src/qmlcompiler/qqmljscodegenerator.cpp b/src/qmlcompiler/qqmljscodegenerator.cpp
index 327aeabfd9..55dc3867e6 100644
--- a/src/qmlcompiler/qqmljscodegenerator.cpp
+++ b/src/qmlcompiler/qqmljscodegenerator.cpp
@@ -44,7 +44,6 @@ static bool isTypeStorable(const QQmlJSTypeResolver *resolver, const QQmlJSScope
{
return !type.isNull()
&& !resolver->equals(type, resolver->nullType())
- && !resolver->equals(type, resolver->emptyListType())
&& !resolver->equals(type, resolver->voidType());
}
@@ -2047,14 +2046,6 @@ void QQmlJSCodeGenerator::generate_DefineArray(int argc, int args)
{
INJECT_TRACE_INFO(generate_DefineArray);
-
- if (argc == 0) {
- m_body += m_state.accumulatorVariableOut + u" = "_s;
- m_body += conversion(m_typeResolver->emptyListType(), m_state.accumulatorOut(), QString());
- m_body += u";\n"_s;
- return;
- }
-
const QQmlJSScope::ConstPtr stored = m_state.accumulatorOut().storedType();
if (stored->accessSemantics() != QQmlJSScope::AccessSemantics::Sequence) {
// This rejects any attempt to store the list into a QVariant.
@@ -2742,10 +2733,6 @@ void QQmlJSCodeGenerator::generateEqualityOperation(int lhs, const QString &func
m_body += conversion(m_typeResolver->boolType(), m_state.accumulatorOut(),
consumedRegisterVariable(lhs) + (invert ? u" != "_s : u" == "_s)
+ consumedAccumulatorVariableIn());
- } else if (m_typeResolver->equals(lhsType, m_typeResolver->emptyListType())) {
- // We cannot compare two empty lists, because we don't know whether it's
- // the same instance or not. "[] === []" is false, but "var a = []; a === a" is true;
- reject(u"comparison of two empty lists"_s);
} else {
// null === null and undefined === undefined
m_body += invert ? u"false"_s : u"true"_s;
@@ -3116,16 +3103,6 @@ QString QQmlJSCodeGenerator::convertStored(
reject(u"Conversion from null to %1"_s.arg(to->internalName()));
}
- if (m_typeResolver->equals(from, m_typeResolver->emptyListType())) {
- if (to->accessSemantics() == QQmlJSScope::AccessSemantics::Sequence)
- return castTargetName(to) + u"()"_s;
- if (m_typeResolver->equals(to, m_typeResolver->varType()))
- return u"QVariant(QVariantList())"_s;
- if (m_typeResolver->equals(from, to))
- return QString();
- reject(u"Conversion from empty list to %1"_s.arg(to->internalName()));
- }
-
if (m_typeResolver->equals(from, to))
return variable;
diff --git a/src/qmlcompiler/qqmljstypepropagator.cpp b/src/qmlcompiler/qqmljstypepropagator.cpp
index aa1b6880ec..674071f218 100644
--- a/src/qmlcompiler/qqmljstypepropagator.cpp
+++ b/src/qmlcompiler/qqmljstypepropagator.cpp
@@ -1670,9 +1670,7 @@ void QQmlJSTypePropagator::generate_DeclareVar(int varName, int isDeletable)
void QQmlJSTypePropagator::generate_DefineArray(int argc, int args)
{
- setAccumulator(m_typeResolver->globalType(argc == 0
- ? m_typeResolver->emptyListType()
- : m_typeResolver->variantListType()));
+ setAccumulator(m_typeResolver->globalType(m_typeResolver->variantListType()));
// Track all arguments as the same type.
const QQmlJSRegisterContent elementType
diff --git a/src/qmlcompiler/qqmljstyperesolver.cpp b/src/qmlcompiler/qqmljstyperesolver.cpp
index 3c4076b0a4..984df8cdaf 100644
--- a/src/qmlcompiler/qqmljstyperesolver.cpp
+++ b/src/qmlcompiler/qqmljstyperesolver.cpp
@@ -56,13 +56,6 @@ QQmlJSTypeResolver::QQmlJSTypeResolver(QQmlJSImporter *importer)
emptyType->setAccessSemantics(QQmlJSScope::AccessSemantics::None);
m_emptyType = emptyType;
- QQmlJSScope::Ptr emptyListType = QQmlJSScope::create();
- emptyListType->setInternalName(u"void*"_s);
- emptyListType->setAccessSemantics(QQmlJSScope::AccessSemantics::Sequence);
- QQmlJSScope::resolveTypes(emptyListType, builtinTypes);
- Q_ASSERT(!emptyListType->extensionType().scope.isNull());
- m_emptyListType = emptyListType;
-
QQmlJSScope::Ptr jsPrimitiveType = QQmlJSScope::create();
jsPrimitiveType->setInternalName(u"QJSPrimitiveValue"_s);
jsPrimitiveType->setFilePath(u"qjsprimitivevalue.h"_s);
@@ -812,7 +805,7 @@ QQmlJSScope::ConstPtr QQmlJSTypeResolver::genericType(
|| equals(type, m_dateTimeType) || equals(type, m_dateType) || equals(type, m_timeType)
|| equals(type, m_variantListType) || equals(type, m_variantMapType)
|| equals(type, m_varType) || equals(type, m_stringListType)
- || equals(type, m_emptyListType) || equals(type, m_byteArrayType)) {
+ || equals(type, m_byteArrayType)) {
return type;
}
@@ -1133,7 +1126,7 @@ bool QQmlJSTypeResolver::canPrimitivelyConvertFromTo(
if (equals(to, m_jsPrimitiveType))
return isPrimitive(from);
- if (equals(from, m_emptyListType) || equals(from, m_variantListType))
+ if (equals(from, m_variantListType))
return to->accessSemantics() == QQmlJSScope::AccessSemantics::Sequence;
const bool matchByName = !to->isComposite();
diff --git a/src/qmlcompiler/qqmljstyperesolver_p.h b/src/qmlcompiler/qqmljstyperesolver_p.h
index feeac52f6d..57020920d5 100644
--- a/src/qmlcompiler/qqmljstyperesolver_p.h
+++ b/src/qmlcompiler/qqmljstyperesolver_p.h
@@ -41,7 +41,6 @@ public:
QQmlJSScope::ConstPtr voidType() const { return m_voidType; }
QQmlJSScope::ConstPtr emptyType() const { return m_emptyType; }
- QQmlJSScope::ConstPtr emptyListType() const { return m_emptyListType; }
QQmlJSScope::ConstPtr nullType() const { return m_nullType; }
QQmlJSScope::ConstPtr realType() const { return m_realType; }
QQmlJSScope::ConstPtr floatType() const { return m_floatType; }
@@ -208,7 +207,6 @@ protected:
QQmlJSScope::ConstPtr m_voidType;
- QQmlJSScope::ConstPtr m_emptyListType;
QQmlJSScope::ConstPtr m_emptyType;
QQmlJSScope::ConstPtr m_nullType;
QQmlJSScope::ConstPtr m_numberPrototype;