aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmlirbuilder.cpp
Commit message (Collapse)AuthorAgeFilesLines
* qmllint: Also lint inner functionsOlivier De Cannière2025-11-051-38/+47
| | | | | | | | | | | | | | | | | | | We were only collecting the 'QML' functions that would be passed to the AOT compiler. Other function types were ignored. Also collect those and pass them to the compiler but only use them when linting. Defer invistigating whether it is a good idea to try to compile JS functions as well to a later point. Logic in a few places was adapted with this changing assumption. [ChangeLog][QML][qmllint] qmllint will now lint inner functions, defined in javascript, in addition to top-level functions and bindings. Fixes: QTBUG-138845 Pick-to: 6.10 6.8 6.5 Change-Id: If6f62aeace8739442b6a1f355fad95ce19c0643c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* IRBuilder: Drop pointless visit overridesOlivier De Cannière2025-10-141-30/+0
| | | | | | | | Overriding the function only to then call the base implementation and nothing else is not very productive. Change-Id: Ib3cba0d38de652c94689b0bac5e878f629e35bd3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Improve error message for invalid import qualifierDheerendra Purohit2025-08-081-1/+1
| | | | | | | | | | | | Previously, the error message for an invalid import qualifier did not show the qualifier name or explain what was wrong. This change adds the qualifier name to the message and says it must start with an uppercase letter. Pick-to: 6.10 Fixes: QTBUG-133313 Change-Id: I0bd4bb143f7b4cdc3b26cae73ab42a4fb05977b1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Revert "QtQml: Remove dependency hashing"Ulf Hermann2025-05-151-1/+9
| | | | | | | | | | | This reverts commit 18c421fe6159dc921643c72ae335cf189eb1cc3a. Removing the dependency hashing is not safe because there are various other bits covered by it, not only the alias target IDs. Task-number: QTBUG-136806 Change-Id: I4a8a57d810203a47945ce67916ee5b54ee7a603d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Remove dependency hashingUlf Hermann2025-05-131-9/+1
| | | | | | | | | Since we don't store any property indices in the compilation units anymore, we don't need to hash the dependencies anymore. Task-number: QTBUG-135286 Change-Id: I2ea05c920475749f2a2d6cf309d0956a74d6c688 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Add final property attributeOlivier De Cannière2025-03-061-0/+1
| | | | | | | | | This works the same as the FINAL attribute to Q_PROPERTY. Task-number: QTBUG-98320 Change-Id: Icc2cf1afb5354fd711770f7147ded853b74cd1da Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QV4: Reserve a bit in CompiledData::PropertyOlivier De Cannière2025-03-061-6/+6
| | | | | | | | | | | | The bit is taken from nameIndex. It should have more than enough capacity with 31 bits. The reserved bit will be used as a flag in subsequent commits. A more typed and centrally enforced aproach to the indexes will be necessary in the future. Change-Id: Ia7c686affba6d5320e674dd3f32b7c59b6321e22 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Fix assignment of fileName and URL during compilationUlf Hermann2025-02-041-2/+2
| | | | | | | | | | | We need to assign them right away when creating the module. If we do it later on, there are a lot of different code paths to cover and in fact we were missing some. Pick-to: 6.9 6.8 Task-number: QTBUG-133053 Change-Id: I57e381c787f504eb9bcd8c2041e41b4f1d1f8b53 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Generalize the global/illegal namesUlf Hermann2024-12-171-14/+12
| | | | | | | | | Instead of passing them around everywhere, use the ones we statically know and only validate them when creating a new engine. Task-number: QTBUG-131721 Change-Id: I7fb93d15eb6e4194c46249727bcf7a48f5dce730 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Deprecate coercion on type assertionsUlf Hermann2024-05-241-0/+13
| | | | | | | | | | | | | | | | | | | By using an "as" cast you want to check the type of the value, not coerce it. Previously, however, if you did this with a value type, it would create the value type instead of just checking for it. Add an attribute "Assertable" to the ValueTypeBehavior pragma that prevents this and enables the correct behavior. Also print a warning when coercing as part of an as-cast. [ChangeLog][QtQml] A new attribute "Assertable" has been added to the "ValueTypeBehavior" pragma. You should always use it if you want to type-check value types using "as". If you don't use it, an instance of the type is created as result of the "as" if the type doesn't match. Task-number: QTBUG-124662 Change-Id: I1d5a6ca0a6f97d7d48440330bed1f9f6472198aa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Make base CU a member of ExecutableCompilationUnitUlf Hermann2024-01-101-6/+10
| | | | | | | | | | | | We want to re-use the base compilation unit across engines. For that to work it cannot be a slice of the engine-specific ExecutableCompilationUnit. Since CompiledData::CompilationUnit is refcounted on its own now, make it unmovable. Change-Id: I8418c9754d7a07e5210c1e7a7fc69355e1d57807 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add pragma syntax to support translation contextLucie Gérard2023-10-261-0/+9
| | | | | | | | | | | | | Translator pragma can be used to set the translation context instead of having the file name used [ChangeLog][qml][translation][Important Behavior Changes] The context for the translation can now be controled in a given file using pragma Translator. Task-number: QTBUG-114528 Change-Id: I6d9d7fb81ea969a90d8637d7277bdbe96c102088 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Replace signal name manipulations with QQmlSignalNamesSami Shalayel2023-08-151-32/+0
| | | | | | | | | | | | | | | Remove custom implementations found in qqmljs* and use the static helper methods from qqmlsignalnames_p.h instead. This sometimes requires to move some code around to avoid bugs with property that do not have letters in their name. Add a warning in the JS implementation of the SignalSpy.qml that the used heuristic might fail on certain signal names. Add tests in in tst_qqmllanguage to see if the property change handlers work correctly for weird names. Change-Id: I4dc73c34df7f77f529511fa04ab5fcc5385b59fc Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Revert the default for enforcing function signaturesUlf Hermann2023-06-261-2/+1
| | | | | | | | | [ChangeLog][QtQml][Important Behavior Changes] Type annotations on function signatures are now enforced, no matter if the code in question is interpreted, JIT-compiled, or AOT-compiled. Previously, only AOT-compiled code enforced the signatures. Therefore you could produce divergent behavior by passing or returning values that violated the type annotations. Fixes: QTBUG-113527 Fixes: QTBUG-109221 Change-Id: Ie573b31f35813db37b75189e747c764d1b9bbe78 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Discern between named builtins and optimizations for common typesUlf Hermann2023-05-161-22/+24
| | | | | | | | | The named builtins include void and regexp. The optimizations for other types are useful, but should be a separate enum. Change-Id: I06220cf4a6d3449deca89a26c4f5db0e41d32765 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Add an "Addressable" value to ValueTypeBehaviorUlf Hermann2023-03-021-8/+25
| | | | | | | Task-number: QTBUG-94807 Change-Id: I8c78faa99fc4c4b2ffd8c89f1037fc7569212c73 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QML: Allow pragmas with multiple valuesUlf Hermann2023-02-221-48/+75
| | | | | | | | | This will be needed in follow-up changes. Task-number: QTBUG-94807 Change-Id: I6243ea31290251c30dd0aceaae878568bc1c0525 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix CMake Unity (Jumbo) builds on WindowsFriedemann Kleint2023-02-151-2/+2
| | | | | | | | | | Rename some variables to prevent clashes with the "interface" on Windows. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I54cd35c2d06b30c21cddd8650282687ec8ccf5ee Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Add a pragma for value type behaviorUlf Hermann2023-01-201-6/+33
| | | | | | | | | | | Unfortunately value types behave differently when compiled to C++. Document the difference and introduce a pragma to make them behave one way or the other. Pick-to: 6.5 Fixes: QTBUG-109221 Change-Id: Ib2685153c0b4ae209bafbea7a01229377fdb47dd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlIRBuilder: Clean up QStringView odditiesFabian Kosmale2023-01-171-3/+3
| | | | | | | | | | The port from QStringRef to QStringView created a few odd constructs, like locals of type const QStringView & and explicitly creating a QStringView from a QString before passing it to a function taking a QSV. Clean them up. Change-Id: I92293198266530f8ab8b9c858a0f0a96e31d7680 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qqmlirbuilder: Remove dead codeFabian Kosmale2023-01-171-4/+0
| | | | | | | | Whatever CONST was, it no longer seems to be defined, and we also have no member called CONST anymore, so we can just remove the code block. Change-Id: I4fa9fb6f17460cc610fbcc3fb3d6e7d3db3df927 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QObjectWrapper: Fix calling attached methods on different objectsUlf Hermann2023-01-021-0/+25
| | | | | | | | | | | | | You can generally store a method in a value and call it on a different object. However, since we've ignored the thisObject basically forever, we cannot just accept it right away. Add an opt-in mechanism via a pragma that allows you to pass (implicitly via context or explicitly via call()) specific thisObjects to QObject methods. Fixes: QTBUG-109585 Pick-to: 6.5 Change-Id: I4c81b8ecf6317af55104ac9ebb62d98862ff24e7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Fix recognition of builtin list typesUlf Hermann2022-12-151-26/+24
| | | | | | | | | | | | | Previously all list types used as arguments or return types for methods had to be looked up via the imports. However, builtin types are not part of the imports at run time. Therefore, recognize list types already early on, when generating the IR. This is the same way we do it for property types and it allows us to easily identify lists of builtins. Pick-to: 6.5 Fixes: QTBUG-109147 Change-Id: I91fa9c8fc99c1e0155cc5db5faddd928ca7fabbc Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port to new Q_UNREACHABLE_RETURN()Marc Mutz2022-10-201-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator to convert sequences of Q_UNREACHABLE() + return into Q_UNREACHABLE_RETURN(), newly added to qtbase. const std::string unr = "unr", val = "val", ret = "ret"; auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(", ifBound(val, cat(node(val)), cat("")), ")"); auto ignoringSwitchCases = [](auto stmt) { return anyOf(stmt, switchCase(subStmt(stmt))); }; makeRule(stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)), nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))), {changeTo(node(unr), cat(makeUnreachableReturn, ";")), // TODO: why is the ; lost w/o this? changeTo(node(ret), cat(""))}, cat("use ", makeUnreachableReturn)); a.k.a qt-use-unreachable-return. subStmt() and nextStmt() are non-standard matchers. There was one false positive, suppressed it with NOLINTNEXTLINE. It's not really a false positiive, it's just that Clang sees the world in one way and if conditonal compilation (#if) differs for other compilers, Clang doesn't know better. This is an artifact of matching two consecutive statements. Change-Id: I3855b2dc8523db1ea860f72ad9818738162495c6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add option to enforce function signaturesUlf Hermann2022-10-141-0/+26
| | | | | | | | | | | | | | | | | | | | | By default, the QML engine does not enforce signatures given as type annotations to functions. By passing different types than the function declares, you can get different behavior between the interpreter/JIT and the AOT-compiled code. In addition, in interpreted or JIT'ed mode, we pass all non-primitive value types as references. This means, if you modify them within the called function, the modifications are propagated back to the place where the value was loaded from. Enforcing the signature prevents all of this, at a run time cost. Since we have to coerce all arguments to the desired types, the function call overhead grows. This change introduces a pragma "FunctionSignatureBehavior" which you can set to "Ignored" or "Enforced" to choose one way or the other as universal way of handling type annotations. Fixes: QTBUG-106819 Change-Id: I50e9b2bd6702907da44974cd9e05b48a96bb609e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Qml: Analyze qsTranslate at compile timeUlf Hermann2022-10-131-6/+14
| | | | | | | | | | We generate translation bindings for all the other translation functions already. We can just as well generate a translation binding for this one, too. Fixes: QTBUG-107536 Change-Id: I851f03c26510b6d450aa78f5d7a1f0142d3a81aa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-071-4/+4
| | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: I601bf70f020f511019ed28731ba53b14b765dbf0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-12/+12
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlIRBuilder: Introduce a more extensible Pragma parserUlf Hermann2022-09-291-42/+100
| | | | | | | | We're going to get more pragmas. Change-Id: I4c9ec1845763f0f6ffc3f94442a0a4fd7e4903a1 Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Qml: Fix crash by function definition in grouped property, reject itYuya Nishihara2022-09-151-4/+13
| | | | | | | | | | | | | | | | | | Before, 'Text { font { function func() {}}}' would crash because of the data inconsistency. A function defined inside a grouped property is pushed to _object->declarationsOverride->functions, whereas its compiled expression goes to _object->functionsAndExpressions. And later, QmlUnitGenerator::generate() iterates over "functions" and reads runtimeFunctionIndices[i], which is built from "functionsAndExpressions". Suppose this would be probably broken since the introduction of the functionsAndExpressions at 963875db26, and it's super confusing that a grouped property can declare anything into the ancestor object context, this patch disables a function declaration in a grouped property. Change-Id: I1d5ecf2f01afc902f43f4ef6c6f5454cedbd0766 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qqmltypecompiler: align runtime function table order to qmlcachegenAndrei Golubev2022-07-221-50/+12
| | | | | | | | | | | | | | | | When we write runtime functions to compilation unit at run time, the order of the functions in the unit (often) differs from the order of functions in the unit produced ahead of time by qmlcachegen and friends. Additionally, the order also differs from what qmltc expects (and qmlcompiler library in general) Fix the order by simplifying the procedure of JS code generation when we create the compilation unit at run time: new logic just goes over the objects in the document linearly, instead of relying on bindings (which are known to be out of order w.r.t. AST) Change-Id: I4070b9d061f03c4c76d03120654ad3f30725493a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Handle trivial signal handler constructionsUlf Hermann2022-07-071-4/+6
| | | | | | | | | | | | | | If the signal handler does nothing but return a closure, we have to compile the closure using the same signature as the outer signal handler. In order for this to work, we also have to detect unresolved argument types for signal handlers. Those are just as bad as unresolved argument types for other functions. Fixes: QTBUG-101531 Change-Id: Idb5b3994809d91a4b4ce936282685435eb75e670 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move idIndex into bitfield union of AliasUlf Hermann2022-06-201-1/+1
| | | | | | | | | | | Since we can now add a member that covers the whole storage, we can clean this up a bit. Change-Id: I707f1f3706d68a073d4b0f4937c352bd3df34335 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QML: Add an option to bind components to filesUlf Hermann2022-05-231-0/+33
| | | | | | | | | | | | | | | If a component is bound to a file context, we can be sure that the IDs present in the same file will be accessible to bindings and functions inside the component. We will need this to allow such bindings to be compiled to C++. [ChangeLog][QtQml] You can now bind components to a file scope. This way you can make sure IDs in the file are accessible to the components. Task-number: QTBUG-101012 Task-number: QTBUG-102806 Change-Id: I290a61752b4b02e13f0bb0213ba3f871bdb95260 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Port QV4::CompiledData::Property to new special integer bitfieldUlf Hermann2022-05-111-7/+7
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I46f9151536ba09417d117d690d7347bd91c13e75 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::Binding to new special integer bitfieldUlf Hermann2022-05-111-34/+39
| | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I9f8bc5fa45c61f77ee95b055a3d8de001da8f8c5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Port QV4::CompiledData::Location to new special integer bitfieldUlf Hermann2022-05-111-39/+23
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: If0d6f893f2351a4146ddf125be4079b5e312f308 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::Alias to new special integer bitfieldUlf Hermann2022-05-111-6/+6
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I554f9f903a39a83eaf601fd4fd932f685bf343d0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::Object to new special integer bitfieldUlf Hermann2022-05-111-3/+3
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: Ia57a16313e883a8d4dab15c971181440ed1d2214 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::ParameterType to new special integer bitfieldUlf Hermann2022-05-111-7/+5
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I515aa7a605accc4b45f9dd4918dd6bfb6e116379 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Replace uses of deprecated _qs with _s/QStringLiteralSona Kurazyan2022-04-291-1/+3
| | | | | | Task-number: QTBUG-101408 Change-Id: Ic925751b73f52d8fa5add5cacc52d6dd6ea2dc27 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix typo and apply some cosmeticsUlf Hermann2022-04-111-2/+2
| | | | | | Change-Id: If51b86e1741b7e9f0e7e4d5f593496bd28cec081 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Allow custom named value types in QMLUlf Hermann2022-01-251-34/+10
| | | | | | | | | | | | | | | | | | | | | | | You can now add your own, lower-case named, value types to your own module, and use them in QML. Previously the names had been ignored, but now you can actually declare properties using the value types. The QtQuick value types are now handled exactly this way, and their special casing at compile time is removed. [ChangeLog][QML][Important Behavior Changes] You can now add your own value types to QML modules. This works exactly like the registration of object types, just with Q_GADGET instead of QObject/Q_OBJECT. In turn, the QtQuick value types are only available from QtQuick now. Previously you could declare unusable properties of QtQuick value types when only importing QtQml. This is not possible anymore. Task-number: QTBUG-82443 Change-Id: I5b2e867141244531cb13d789678fb7e06a6e41e7 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Remove unused enumTableSize variableShawn Rutledge2021-12-091-2/+0
| | | | | | | | Clang complains. variable 'enumTableSize' set but not used [-Werror,-Wunused-but-set-variable] Change-Id: Ifb26309a4928e8d5cac123df843f9308d1c590cb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Initial translation binding supportFabian Kosmale2021-12-081-112/+10
| | | | | | | | | | | | | | | | | We will need to distinguish between script and translation bindings in the future (to correctly assign script binding indices). Moreover, the NOOP translation functions actually produce string literal bindings, not translation bindings. To unify the classification of translation bindings, the code from the IRBuilder has been converted into a template taking a few callbacks. This change does not add validation for translation bindings yet, but a failing autotest for a case where it would be necesseray is already provided. Change-Id: Icccba98edbdcd15068188807e8622c1bd513725c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Clean up property attributes (1/2)Fabian Kosmale2021-11-171-5/+5
| | | | | | | | | | | | Instead of directly accessing the attribute related members of UiPublicMember, we access them via a function. Moreover, we remove some redundancy: A property is readonly/default/required if and only if the corresponding token is valid. Thus we can drop the boolean members. Change-Id: I22f15b2b037e857d2f9d3167cb761cba9516a135 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Handle function as default arguments in toplevel functionsFabian Kosmale2021-11-101-0/+6
| | | | | | | | | | | | | | | | | | | | | Top level functions, that is, those directly defined in a QML component as opposed to those defined inside another function or class, are not visited directly by the ScanFunction visitor. Instead, they are manually considered in generateJSCodeForFunctionsAndBindings, and the visitor is then run on their body. This worked mostly fine, with one notable exception: In case there is a function expression used as the default value of a function parameter, that function would have never been visited. This would lead to subsequent asserts/crashes in the codegen, as the function was not properly set up. We fix this by manually visiting the function's formals in addition to the body. Pick-to: 6.2 5.15 Fixes: QTBUG-98032 Change-Id: I5cb4caae39ab45f01a0dfa1555099d7d4b796a19 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add a Pragma for list assign behaviorUlf Hermann2021-10-131-14/+53
| | | | | | | | | | [ChangeLog][QtQml] You can now specify the list property assignment behavior in QML using the "ListPropertyAssignBehavior" pragma. This is analogous to the macros you can use in C++. Fixes: QTBUG-93642 Change-Id: I9bdcf198031f1e24891f947b0990a3253d29a998 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlIR::Object: Get rid of isInlineComponent memberFabian Kosmale2021-08-251-3/+2
| | | | | | | | | | | | The necessary information is already available in the flags member. Moreover, isInlineComponent and IsComponent (used for Component properties) are mutually exclusive, so no need to check for inline component flags if IsComponent is set. Change-Id: Ibf171d63463f1e386a4063725b657aa998afd63f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>