diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2024-12-20 16:39:13 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2025-01-08 10:59:15 +0100 |
| commit | b79f02f05aca382174cd144ee2e5c52ed43ed7be (patch) | |
| tree | 84dedfcbe3979614d6392fbbc6676f3f35a13e7e | |
| parent | 24bb6cbfdfad3b40b0e36dc46f26cbed986e1522 (diff) | |
QmlCompiler: Do not regard 64bit integers as primitives
We cannot store them in QJSPrimitiveValue. This exposes that on
LoadElement, we need to create the AccumulatorConverter before using the
index register (since it changes by accumulator conversion).
Task-number: QTBUG-132345
Change-Id: I0a7b2735c1dc330cc768f9d9c11cec5573faf13c
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
(cherry picked from commit 1e570d022b2bd1a6a33c6afed3937741775a9202)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 8e11092d271f2b4ac3e72bd058282c3d32760b43)
| -rw-r--r-- | src/qmlcompiler/qqmljscodegenerator.cpp | 16 | ||||
| -rw-r--r-- | src/qmlcompiler/qqmljstyperesolver.cpp | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/qmlcompiler/qqmljscodegenerator.cpp b/src/qmlcompiler/qqmljscodegenerator.cpp index 4a87e2f5a3..61c152a02a 100644 --- a/src/qmlcompiler/qqmljscodegenerator.cpp +++ b/src/qmlcompiler/qqmljscodegenerator.cpp @@ -786,6 +786,8 @@ void QQmlJSCodeGenerator::generate_LoadElement(int base) conversion(m_typeResolver->globalType(m_typeResolver->voidType()), m_state.accumulatorOut(), QString()) + u";\n"_s; + AccumulatorConverter registers(this); + QString indexName = m_state.accumulatorVariableIn; QQmlJSScope::ConstPtr indexType; if (m_typeResolver->isNumeric(m_state.accumulatorIn())) { @@ -805,7 +807,6 @@ void QQmlJSCodeGenerator::generate_LoadElement(int base) } } - AccumulatorConverter registers(this); const QString baseName = registerVariable(base); if (!m_typeResolver->isNativeArrayIndex(indexType)) { @@ -1592,8 +1593,8 @@ void QQmlJSCodeGenerator::generate_SetLookup(int index, int baseReg) QQmlJSRegisterContent property = specific; if (!m_typeResolver->equals(specific.storedType(), valueType)) { if (m_typeResolver->isPrimitive(specific.storedType()) - && m_typeResolver->isPrimitive(valueType)) { - // Nothing to do here. We can store all primitive types as is. + || m_typeResolver->isNumeric(specific.storedType())) { + // Nothing to do here. We can store all primitive types and 64bit intergers as-is. } else { property = property.storedIn(m_typeResolver->merge(specific.storedType(), valueType)); } @@ -2768,9 +2769,10 @@ void QQmlJSCodeGenerator::generate_DefineObjectLiteral(int internalClassId, int // a, the type is expressible in C++ (since we can express argType) // b, the type can hold readType. const QQmlJSScope::ConstPtr readStored = readType.storedType(); - const QQmlJSRegisterContent propType = m_typeResolver->isPrimitive(readStored) - ? readType - : readType.storedIn(m_typeResolver->merge(readStored, argType.storedType())); + const QQmlJSRegisterContent propType + = (m_typeResolver->isPrimitive(readStored) || m_typeResolver->isNumeric(readStored)) + ? readType + : readType.storedIn(m_typeResolver->merge(readStored, argType.storedType())); const QQmlJSMetaProperty property = contained->property(propName); const QString consumedArg = consumedRegisterVariable(currentArg); @@ -3415,6 +3417,8 @@ void QQmlJSCodeGenerator::generateEqualityOperation( auto isComparable = [&]() { if (m_typeResolver->isPrimitive(lhsContent) && m_typeResolver->isPrimitive(rhsContent)) return true; + if (m_typeResolver->isNumeric(lhsContent) && m_typeResolver->isNumeric(rhsContent)) + return true; if (m_typeResolver->isNumeric(lhsContent) && rhsContent.isEnumeration()) return true; if (m_typeResolver->isNumeric(rhsContent) && lhsContent.isEnumeration()) diff --git a/src/qmlcompiler/qqmljstyperesolver.cpp b/src/qmlcompiler/qqmljstyperesolver.cpp index e4845b33fc..2efaa02bb2 100644 --- a/src/qmlcompiler/qqmljstyperesolver.cpp +++ b/src/qmlcompiler/qqmljstyperesolver.cpp @@ -345,7 +345,7 @@ bool QQmlJSTypeResolver::isIntegral(const QQmlJSScope::ConstPtr &type) const bool QQmlJSTypeResolver::isPrimitive(const QQmlJSScope::ConstPtr &type) const { - return isNumeric(type) + return (isNumeric(type) && !equals(type, m_int64Type) && !equals(type, m_uint64Type)) || equals(type, m_boolType) || equals(type, m_voidType) || equals(type, m_nullType) || equals(type, m_stringType) || equals(type, m_jsPrimitiveType); } |
