aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-05-04 15:26:30 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-05-11 12:56:22 +0200
commit36ebee4e69182f0e44d87691d4740b271e1dcf38 (patch)
treec6f38a2fbef397775d3c8e0031e570fbacd302be /tools
parentdea6ba50377df75046625abb0128e0250c01b2c9 (diff)
QML: Port QV4::CompiledData::Binding to new special integer bitfield
Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I9f8bc5fa45c61f77ee95b055a3d8de001da8f8c5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmltc/prototype/codegenerator.cpp30
-rw-r--r--tools/qmltc/prototype/qml2cppdefaultpasses.cpp21
-rw-r--r--tools/qmltc/qmltccompiler.cpp2
3 files changed, 31 insertions, 22 deletions
diff --git a/tools/qmltc/prototype/codegenerator.cpp b/tools/qmltc/prototype/codegenerator.cpp
index 2981c6c395..27585b75f7 100644
--- a/tools/qmltc/prototype/codegenerator.cpp
+++ b/tools/qmltc/prototype/codegenerator.cpp
@@ -124,11 +124,11 @@ private:
public:
bool operator()(const I &x, const I &y) const
{
- return orderTable[x->type] < orderTable[y->type];
+ return orderTable[x->type()] < orderTable[y->type()];
}
bool operator()(const T &x, const T &y) const
{
- return orderTable[x.type] < orderTable[y.type];
+ return orderTable[x.type()] < orderTable[y.type()];
}
};
@@ -354,7 +354,7 @@ void CodeGenerator::compileBinding(QmltcType &current, const QmlIR::Binding &bin
// deferral logic for bindings: if a binding is deferred, it is not compiled
// (potentially, with all the bindings inside of it), period.
if (object.type->isNameDeferred(propertyName)) {
- if (binding.type == QmlIR::Binding::Type_GroupProperty) {
+ if (binding.type() == QmlIR::Binding::Type_GroupProperty) {
// TODO: we should warn about this in QmlCompiler library
qCWarning(lcCodeGenerator)
<< QStringLiteral("Binding at line %1 column %2 is not deferred as it is a "
@@ -392,7 +392,7 @@ void CodeGenerator::compileBinding(QmltcType &current, const QmlIR::Binding &bin
}
};
- switch (binding.type) {
+ switch (binding.type()) {
case QmlIR::Binding::Type_Boolean: {
addPropertyLine(propertyName, p, binding.value.b ? u"true"_s : u"false"_s);
break;
@@ -453,7 +453,7 @@ void CodeGenerator::compileBinding(QmltcType &current, const QmlIR::Binding &bin
const QString qobjectParent = u"this"_s;
const QString objectAddr = accessor.name;
- if (binding.flags & QmlIR::Binding::IsOnAssignment) {
+ if (binding.hasFlag(QmlIR::Binding::IsOnAssignment)) {
const QString onAssignmentName = u"onAssign_" + propertyName;
const auto uniqueId = UniqueStringId(current, onAssignmentName);
if (!m_onAssignmentObjectsCreated.contains(uniqueId)) {
@@ -490,7 +490,7 @@ void CodeGenerator::compileBinding(QmltcType &current, const QmlIR::Binding &bin
return;
}
- if (p.isList() || (binding.flags & QmlIR::Binding::IsListItem)) {
+ if (p.isList() || binding.hasFlag(QmlIR::Binding::IsListItem)) {
const QString refName = u"listref_" + propertyName;
const auto uniqueId = UniqueStringId(current, refName);
if (!m_listReferencesCreated.contains(uniqueId)) {
@@ -504,7 +504,7 @@ void CodeGenerator::compileBinding(QmltcType &current, const QmlIR::Binding &bin
}
const auto setObjectBinding = [&](const QString &value) {
- if (p.isList() || (binding.flags & QmlIR::Binding::IsListItem)) {
+ if (p.isList() || binding.hasFlag(QmlIR::Binding::IsListItem)) {
const QString refName = u"listref_" + propertyName;
current.endInit.body << refName + u".append(" + value + u");";
} else {
@@ -575,7 +575,7 @@ void CodeGenerator::compileBinding(QmltcType &current, const QmlIR::Binding &bin
// TODO: there's a special QQmlComponentAttached, which has to be
// called? c.f. qqmlobjectcreator.cpp's finalize()
const auto compileComponent = [&](const QmlIR::Binding &b) {
- Q_ASSERT(b.type == QmlIR::Binding::Type_Script);
+ Q_ASSERT(b.type() == QmlIR::Binding::Type_Script);
compileScriptBindingOfComponent(current, irObject, type, b,
m_doc->stringAt(b.propertyNameIndex));
};
@@ -643,7 +643,13 @@ void CodeGenerator::compileBinding(QmltcType &current, const QmlIR::Binding &bin
const auto isGroupAffectingBinding = [](const QmlIR::Binding &b) {
// script bindings do not require value type group property variable
// to actually be present.
- return b.type != QmlIR::Binding::Type_Invalid && b.type != QmlIR::Binding::Type_Script;
+ switch (b.type()) {
+ case QmlIR::Binding::Type_Invalid:
+ case QmlIR::Binding::Type_Script:
+ return false;
+ default:
+ return true;
+ }
};
const bool generateValueTypeCode = isValueType
&& std::any_of(irObject->bindingsBegin(), irObject->bindingsEnd(),
@@ -676,10 +682,10 @@ void CodeGenerator::compileBinding(QmltcType &current, const QmlIR::Binding &bin
// predicate
auto scriptBindingsBegin =
std::find_if(sortedBindings.cbegin(), sortedBindings.cend(),
- [](auto it) { return it->type == QmlIR::Binding::Type_Script; });
+ [](auto it) { return it->type() == QmlIR::Binding::Type_Script; });
auto it = sortedBindings.cbegin();
for (; it != scriptBindingsBegin; ++it) {
- Q_ASSERT((*it)->type != QmlIR::Binding::Type_Script);
+ Q_ASSERT((*it)->type() != QmlIR::Binding::Type_Script);
compile(*it);
}
@@ -699,7 +705,7 @@ void CodeGenerator::compileBinding(QmltcType &current, const QmlIR::Binding &bin
// once the value is written back, process the script bindings
for (; it != sortedBindings.cend(); ++it) {
- Q_ASSERT((*it)->type == QmlIR::Binding::Type_Script);
+ Q_ASSERT((*it)->type() == QmlIR::Binding::Type_Script);
compile(*it);
}
break;
diff --git a/tools/qmltc/prototype/qml2cppdefaultpasses.cpp b/tools/qmltc/prototype/qml2cppdefaultpasses.cpp
index 48b97d3ded..5933a4e510 100644
--- a/tools/qmltc/prototype/qml2cppdefaultpasses.cpp
+++ b/tools/qmltc/prototype/qml2cppdefaultpasses.cpp
@@ -303,7 +303,7 @@ void verifyTypes(const Qml2CppContext &context, QList<Qml2CppObject> &objects)
return;
// attached property is special
- if (binding.type == QmlIR::Binding::Type_AttachedProperty) {
+ if (binding.type() == QmlIR::Binding::Type_AttachedProperty) {
const auto [attachedObject, attachedType] = objects.at(binding.value.objectIndex);
if (!attachedObject || !attachedType) {
context.recordError(binding.location,
@@ -328,8 +328,8 @@ void verifyTypes(const Qml2CppContext &context, QList<Qml2CppObject> &objects)
// TODO: why isList() needed here?
if (!p.isWritable() && !p.isList()
- && !(binding.flags & QmlIR::Binding::InitializerForReadOnlyDeclaration)
- && binding.type != QmlIR::Binding::Type_GroupProperty) {
+ && !binding.hasFlag(QmlIR::Binding::InitializerForReadOnlyDeclaration)
+ && binding.type() != QmlIR::Binding::Type_GroupProperty) {
context.recordError(binding.location,
u"Binding on read-only property '" + propName + u"'");
}
@@ -906,7 +906,7 @@ static void updateImplicitComponents(const Qml2CppContext &context, Qml2CppObjec
QList<Qml2CppObject> &objects, Update update)
{
const auto checkAndUpdate = [&](const QmlIR::Binding &binding) {
- if (binding.type != QmlIR::Binding::Type_Object)
+ if (binding.type() != QmlIR::Binding::Type_Object)
return;
if (object.irObject->flags & QV4::CompiledData::Object::IsComponent) // already set
return;
@@ -1012,12 +1012,15 @@ static void setObjectId(const Qml2CppContext &context, const QList<Qml2CppObject
std::for_each(irObject->bindingsBegin(), irObject->bindingsEnd(),
[&](const QmlIR::Binding &binding) {
- if (binding.type != QV4::CompiledData::Binding::Type_Object
- && binding.type != QV4::CompiledData::Binding::Type_AttachedProperty
- && binding.type != QV4::CompiledData::Binding::Type_GroupProperty) {
- return;
+ switch (binding.type()) {
+ case QV4::CompiledData::Binding::Type_Object:
+ case QV4::CompiledData::Binding::Type_AttachedProperty:
+ case QV4::CompiledData::Binding::Type_GroupProperty:
+ setObjectId(context, objects, binding.value.objectIndex, idToObjectIndex);
+ break;
+ default:
+ break;
}
- setObjectId(context, objects, binding.value.objectIndex, idToObjectIndex);
});
}
diff --git a/tools/qmltc/qmltccompiler.cpp b/tools/qmltc/qmltccompiler.cpp
index 60d78434b5..95dabe7f5c 100644
--- a/tools/qmltc/qmltccompiler.cpp
+++ b/tools/qmltc/qmltccompiler.cpp
@@ -352,7 +352,7 @@ void QmltcCompiler::compileTypeElements(QmltcType &current, const QQmlJSScope::C
auto scriptBindingsBegin =
std::find_if(sortedBindings.cbegin(), sortedBindings.cend(),
- [](auto it) { return it->type == QmlIR::Binding::Type_Script; });
+ [](auto it) { return it->type() == QmlIR::Binding::Type_Script; });
auto it = sortedBindings.cbegin();
for (; it != scriptBindingsBegin; ++it) {
m_prototypeCodegen->compileBinding(current, **it, object,