aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmltc
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-17 11:15:14 +0200
commit530d3749c59971e9ec3a8a333c6783842ebb288e (patch)
tree1fccf496d7852eebcaee6de703eb7b9c112d2293 /tools/qmltc
parent8b03ab373660a6ff3df7bcdfc64e0acf6ca10b97 (diff)
QML: Port QV4::CompiledData::Binding to new special integer bitfield
Task-number: QTBUG-99545 Change-Id: I9f8bc5fa45c61f77ee95b055a3d8de001da8f8c5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 36ebee4e69182f0e44d87691d4740b271e1dcf38)
Diffstat (limited to 'tools/qmltc')
-rw-r--r--tools/qmltc/prototype/codegenerator.cpp34
-rw-r--r--tools/qmltc/prototype/qml2cppdefaultpasses.cpp25
2 files changed, 34 insertions, 25 deletions
diff --git a/tools/qmltc/prototype/codegenerator.cpp b/tools/qmltc/prototype/codegenerator.cpp
index 5ee1d980d5..34d059c836 100644
--- a/tools/qmltc/prototype/codegenerator.cpp
+++ b/tools/qmltc/prototype/codegenerator.cpp
@@ -167,11 +167,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()];
}
};
@@ -758,7 +758,7 @@ void CodeGenerator::compileObjectElements(QQmlJSAotObject &compiled, const CodeG
// 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)
compileBinding(compiled, **it, object, { object.type, u"this"_qs, u""_qs, false });
@@ -1183,8 +1183,8 @@ void CodeGenerator::compileBinding(QQmlJSAotObject &current, const QmlIR::Bindin
// Note: unlike QQmlObjectCreator, we don't have to do a complicated
// deferral logic for bindings: if a binding is deferred, it is not compiled
// (potentially, with all the bindings inside of it), period.
- if (binding.flags & QV4::CompiledData::Binding::IsDeferredBinding) {
- if (binding.type == QmlIR::Binding::Type_GroupProperty) {
+ if (binding.flags() & QV4::CompiledData::Binding::IsDeferredBinding) {
+ 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 "
@@ -1234,7 +1234,7 @@ void CodeGenerator::compileBinding(QQmlJSAotObject &current, const QmlIR::Bindin
}
};
- switch (binding.type) {
+ switch (binding.type()) {
case QmlIR::Binding::Type_Boolean: {
addPropertyLine(propertyName, p, binding.value.b ? u"true"_qs : u"false"_qs);
break;
@@ -1295,7 +1295,7 @@ void CodeGenerator::compileBinding(QQmlJSAotObject &current, const QmlIR::Bindin
const QString qobjectParent = u"this"_qs;
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)) {
@@ -1331,7 +1331,7 @@ void CodeGenerator::compileBinding(QQmlJSAotObject &current, const QmlIR::Bindin
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)) {
@@ -1345,7 +1345,7 @@ void CodeGenerator::compileBinding(QQmlJSAotObject &current, const QmlIR::Bindin
}
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 {
@@ -1417,7 +1417,7 @@ void CodeGenerator::compileBinding(QQmlJSAotObject &current, const QmlIR::Bindin
// 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));
};
@@ -1485,7 +1485,13 @@ void CodeGenerator::compileBinding(QQmlJSAotObject &current, const QmlIR::Bindin
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(),
@@ -1518,10 +1524,10 @@ void CodeGenerator::compileBinding(QQmlJSAotObject &current, const QmlIR::Bindin
// 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);
}
@@ -1541,7 +1547,7 @@ void CodeGenerator::compileBinding(QQmlJSAotObject &current, const QmlIR::Bindin
// 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 611c317490..8eda649441 100644
--- a/tools/qmltc/prototype/qml2cppdefaultpasses.cpp
+++ b/tools/qmltc/prototype/qml2cppdefaultpasses.cpp
@@ -287,7 +287,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,
@@ -312,8 +312,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"'");
}
@@ -888,7 +888,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;
@@ -994,12 +994,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);
});
}
@@ -1096,14 +1099,14 @@ static void setDeferred(const Qml2CppContext &context, qsizetype objectIndex,
}
const auto setRecursive = [&](QmlIR::Binding &binding) {
- if (binding.type >= QmlIR::Binding::Type_Object)
+ if (binding.type() >= QmlIR::Binding::Type_Object)
setDeferred(context, binding.value.objectIndex, objects); // Note: recursive call here!
const QString propName = findPropertyName(context, o.type, binding);
Q_ASSERT(!propName.isEmpty());
if (o.type->isNameDeferred(propName)) {
- binding.flags |= QV4::CompiledData::Binding::IsDeferredBinding;
+ binding.setFlag(QV4::CompiledData::Binding::IsDeferredBinding);
o.irObject->flags |= QV4::CompiledData::Object::HasDeferredBindings;
}
};