aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktestutils/qml/qmlutils_p.h
diff options
context:
space:
mode:
authorDmitrii Akshintsev <dmitrii.akshintsev@qt.io>2025-10-28 15:34:45 +0100
committerDmitrii Akshintsev <dmitrii.akshintsev@qt.io>2025-12-04 21:01:19 +0100
commitd99c610674ada29c5280c07b45ebfab7bc4e3b11 (patch)
tree398bdeb4776c53702e7d84e449536cbefcbfb675 /src/quicktestutils/qml/qmlutils_p.h
parent87cac29f88b96241bfa5e3e0f65a57a0e9002450 (diff)
Qml IR: add support for virtual and override keywords
This patch adds two new fields, IsVirtual and IsOverride, to CompiledData::Property. These fields will later be used to populate QQmlPropertyData and to handle property override semantics. At a high level, this change focuses on the data flow from the AST to the IR, laying the groundwork for future semantic resolution. Also moves test helper Syntax namespace to the quicktestutils Task-number: QTBUG-98320 Change-Id: Ic2a2e28df08d53c8752c49304bd5f7ff46916d08 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/quicktestutils/qml/qmlutils_p.h')
-rw-r--r--src/quicktestutils/qml/qmlutils_p.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/quicktestutils/qml/qmlutils_p.h b/src/quicktestutils/qml/qmlutils_p.h
index d8d28256ac..d4fc83c270 100644
--- a/src/quicktestutils/qml/qmlutils_p.h
+++ b/src/quicktestutils/qml/qmlutils_p.h
@@ -22,6 +22,7 @@
#include <QtCore/QStringList>
#include <QtTest/QTest>
#include <QtCore/private/qglobal_p.h>
+#include <private/qqmljsgrammar_p.h>
QT_BEGIN_NAMESPACE
@@ -122,6 +123,59 @@ void gc(QV4::ExecutionEngine &engine, GCFlags flags = GCFlags::None);
bool gcDone(QQmlEngine *engine);
void gc(QQmlEngine &engine, GCFlags flags = GCFlags::None);
+namespace Syntax {
+using Token = QQmlJSGrammar::VariousConstants;
+// TODO(QTBUG-138020)
+constexpr auto spellFor(Token token) -> QLatin1StringView
+{
+ switch (token) {
+ case Token::T_COLON:
+ return QLatin1StringView(":");
+ case Token::T_LBRACE:
+ return QLatin1StringView("{");
+ case Token::T_RBRACE:
+ return QLatin1StringView("}");
+ case Token::T_VAR:
+ return QLatin1StringView("var");
+ case Token::T_PROPERTY:
+ return QLatin1StringView("property");
+ case Token::T_DEFAULT:
+ return QLatin1StringView("default");
+ case Token::T_READONLY:
+ return QLatin1StringView("readonly");
+ case Token::T_REQUIRED:
+ return QLatin1StringView("required");
+ case Token::T_FINAL:
+ return QLatin1StringView("final");
+ case Token::T_VIRTUAL:
+ return QLatin1StringView("virtual");
+ case Token::T_OVERRIDE:
+ return QLatin1StringView("override");
+ default:
+ break;
+ }
+ Q_UNREACHABLE_RETURN({});
+}
+
+using Word = std::variant<Token, QLatin1StringView>;
+auto stringView(const Word &word) -> QLatin1StringView;
+
+using Phrase = QList<Word>;
+auto toString(const Phrase &phrase) -> QString;
+
+// comfort
+auto operator+(const Word &word, const Phrase &phrase) -> Phrase;
+auto operator+(const Word &word1, const Word &word2) -> Phrase;
+
+// if such declaration generating functions start to grow it might be worth creating a dedicated
+// more optimized generator
+
+// can probably be generalized later to accept QList<Phrase> if needed
+auto objectDeclaration(Phrase &&objectMember = {},
+ QLatin1StringView objName = QLatin1StringView("QtObject")) -> Phrase;
+
+} // namespace Syntax
+
QT_END_NAMESPACE
#endif // QQMLTESTUTILS_P_H