summaryrefslogtreecommitdiff
path: root/src/qmlcompiler
Commit message (Collapse)AuthorAgeFilesLines
...
* QmlCompiler: Generate correct code for non-double constantsUlf Hermann2022-08-032-9/+33
| | | | | | | | | This can actually not happen because we only use this instruction for doubles. However, it's clearly intended to be compatible with other types. Change-Id: I50618913373560eee6be2aeb2a9be387ff8ba753 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Also check methods when linting modulesMaximilian Goldstein2022-08-011-0/+29
| | | | | | | | | | Also lint methods in addition to properties when verifying whether any types are missing or not fully resolved. Change-Id: Ia7629d2b2427053c497bffca2b5d5b3a3f0bb027 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: Support CONSTANT and RESET property attributes in aliasesAndrei Golubev2022-07-292-0/+6
| | | | | | | | | As a drive by, propagate CONSTANT attribute through the .qmltypes file and qmlcompiler library Task-number: QTBUG-91956 Change-Id: I5802fa29ddedcdadae3e505efca0c4fb4d6b2593 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: Make unused import warning less redundantMaximilian Goldstein2022-07-281-5/+1
| | | | | | | | There's no reason to have the location in the warning. It already gets printed by the logger. Change-Id: Ia1335cab6324587a4e35a25bbb46537f358e1bd7 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Support RegExpLiteral bindings in qmltcAndrei Golubev2022-07-272-0/+10
| | | | | | | Task-number: QTBUG-91956 Pick-to: 6.4 Change-Id: I02f8c6d1f0d6e4411985ffe3f22fb3c51fb36db6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix warning from iterating over referencesVolker Hilsheimer2022-07-261-3/+3
| | | | | | | | | | | Apple clang says: error: loop variable 'kv' is always a copy because the range of type 'QtPrivate::QKeyValueRange<const QHash...> &>' does not return a reference [-Werror,-Wrange-loop-analysis] Change-Id: I4dc43805d3d3f723e5ec8cc504969cda3d99fb43 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: Acknowledge BINDABLE-only propertiesAndrei Golubev2022-07-261-0/+27
| | | | | | | Task-number: QTBUG-91956 Change-Id: I4c34ccd9d6d5cf4c6a6c1b54e67374515e67861a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Revise build to source dir mapping for QML toolingAndrei Golubev2022-07-263-1/+53
| | | | | | | | | | | | | | | | Instead of doing build file path to source file path mapping for each QML file, we could store qml module prefix to qml module output directory mapping instead. This reduces the produced qrc size and makes it more convenient to work with Do a clean separation at the QQmlJSImporter level to prevent using resource file mapper for build directory path resolution Amends 7f567e6a424a3919337aad498543d58c1252df62 Change-Id: If984abada1d39c386af5712af778eb29956e0537 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: Use QMetaObject hierarchy as reference for meta index calculationAndrei Golubev2022-07-261-0/+74
| | | | | | | | | qmltc needs to compute a QMetaProperty index ahead of time when creating property bindings. This procedure has to acknowledge that extensions exist Change-Id: I7bf6b6c558ce78e0fec5ee880bc4d39a79fe5640 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Implement module lintingMaximilian Goldstein2022-07-254-76/+216
| | | | | | | | | | | | | | | | This change allows for modules to be linted via the -M flag. This will check whether an individual module has a sound qmldir and qmltypes. It will also verify whether all its types and the types of properties can be resolved. It does not lint individual QML files. [ChangeLog][qmllint][New Feature] Individual modules can now be linted via the -M option Fixes: QTBUG-103264 Change-Id: I3ced4b0bc05358e9216c9819f1dca67af909405e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Recognize script types when looking up membersUlf Hermann2022-07-221-0/+6
| | | | | | | | | | If you import a module with a prefix, you can use its scripts as members of that prefix. Pick-to: 6.4 Fixes: QTBUG-104701 Change-Id: I35f79005ea793f501e782e748f7ad5badd3d75ef Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Support conversions between QString and QByteArrayUlf Hermann2022-07-223-1/+21
| | | | | | | Pick-to: 6.4 Fixes: QTBUG-104702 Change-Id: I80d3a28e17751d440ec4bea4c7be0d09c935fa19 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmltypecompiler: align runtime function table order to qmlcachegenAndrei Golubev2022-07-221-10/+11
| | | | | | | | | | | | | | | | 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: Implement Math.pow()Ulf Hermann2022-07-211-2/+2
| | | | | | | | | Also, add missing positive infinity to test data. Pick-to: 6.4 Fixes: QTBUG-104745 Change-Id: I958aca672cca8cc83c540ed3ea75b08e70eb90fd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Extend all sequence types with JS ArrayUlf Hermann2022-07-194-9/+44
| | | | | | | | | QV4::SequenceObject and QV4::QmlListWrapper both implement all the array methods. Therefore we can safely state this. Fixes: QTBUG-104706 Change-Id: I82c40f161b49463a9399a8bc58d741c7c4a1d5fe Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmljslogger: Print ids of warningsMaximilian Goldstein2022-07-133-7/+13
| | | | | | | | Also exposes the id information in the Message object and adds it to the JSON output. Change-Id: I6b27e644583408cca3e39b75210610db09fefa8b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Allow storeNameSloppy to reset a propertyUlf Hermann2022-07-112-22/+23
| | | | | | | | | We should not convert from undefined on storeNameSloppy. The reset is intentional. Task-number: QTBUG-104508 Change-Id: Iede88fe6331dd173c9e8ea0ec4200df2b8bd30eb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add license headers to cmake filesLucie Gérard2022-07-081-0/+3
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I72c89a98c42bbc9234d8495e9e503bec81d11037 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* qmljscompiler: Replace categories with more specific warning idsMaximilian Goldstein2022-07-087-69/+131
| | | | | | | | | | This change replaces a lot of generic category names with several warning ids to replace them. Change-Id: I9b13b931e7ed3d56b71d6292a6a77bec69647ffd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Pass the "reset" attribute from metatypes through qmltypesUlf Hermann2022-07-072-2/+8
| | | | | | | | | We need it when deciding what to do with an undefined value assigned to a property. Task-number: QTBUG-104508 Change-Id: I621d531040fe423e11372eea8903d69c93f4ecd6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Handle trivial signal handler constructionsUlf Hermann2022-07-076-46/+105
| | | | | | | | | | | | | | 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>
* QmlCompiler: Allow wrapping enums into intUlf Hermann2022-07-073-14/+29
| | | | | | | | | This is what we do internally in the QML engine. Pick-to: 6.4 Fixes: QTBUG-104683 Change-Id: I2f8712cb2cdc56b6c483500627fd8a218edbad81 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Don't crash on unknown list value typesUlf Hermann2022-07-061-3/+4
| | | | | | | Pick-to: 6.4 Fixes: QTBUG-104743 Change-Id: I551b21498bb746acf05be525dbcb72a74f816c04 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Clean up state merging codeUlf Hermann2022-07-063-18/+9
| | | | | | | | | | | | | Generally, we need to merge all registers when merging different branches of execution in the type propagator, even those that were written by the same instruction on all branches. Doing this right relieves us from the need to special case the arguments (which most of the time are only "written" once) all over the place. Pick-to: 6.4 Task-number: QTBUG-104462 Change-Id: If30f7382c43d1e04ad91c88cfbc217e070de518a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix the compilation errorTimur Pocheptsov2022-07-061-1/+1
| | | | | | | Clang does not like the ref. and says: "note, use non-reference type ..." Change-Id: I838f81e2b02ebaac57295ca7d662a0a6db4ac056 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* QmlCompiler: Initialize registers with undefined where necessaryUlf Hermann2022-07-054-3/+26
| | | | | | | | | | | If we read the initial state of a register, we need to make sure it actually exists at that point. Uninitialized variables are implicitly undefined in JavaScript. Pick-to: 6.4 Task-number: QTBUG-104687 Change-Id: Ide4fe429b10ec28dcf267e7d34c6316355b16baa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Don't push type conversions back into the engineUlf Hermann2022-07-051-11/+33
| | | | | | | | | | In many cases we can generate better code for type conversions. Furthermore, the engine only does QMetaType::convert(). This misses a lot of conversions we do in other places. Pick-to: 6.4 Change-Id: I1526ec327d189420885f6a7385f6cc1c2c94b19e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Really fix writing into argument valuesUlf Hermann2022-07-055-20/+64
| | | | | | | | | | | | | | | | | | | | | | Arguments are now treated as registers "written" at the beginning of the first basic block. By modeling them this way, we can avoid all the complicated logic on whether to use a local or the arguments array when accessing any particular one of them. Furthermore, we can detect whether they are overwritten or not. If they are not overwritten, we can initialize them as a const reference into the arguments array. This way we save a copy. Treating the arguments as generic registers causes the basic blocks pass to aggressively adjust their types, pushing some conversions back into the QML engine. This is good. Unused arguments become void, for example, and don't have to be passed at all. However, we also need a special case for QJSPrimitiveValue arguments now. Pick-to: 6.4 Fixes: QTBUG-104462 Change-Id: I994bea0929bd508aa41db58dee4a7f12cd20f053 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QmlCompiler: Fix register propagation in basic blocks passUlf Hermann2022-07-052-44/+72
| | | | | | | | | | | | | a, We were recording too many jump origins and targets. That messed up the basic blocks ordering logic. b, In the presence of backward jumps, we need to revisit earlier basic blocks if additional writes are discovered. Otherwise the type adjustment will optimize "dead" type conversions out. Pick-to: 6.4 Fixes: QTBUG-104665 Change-Id: I7219f85625761817ae4f63582d80d247a85df73b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltyperegistrar: Extract into own librarySami Shalayel2022-07-013-232/+0
| | | | | | | | | | | | | | | | | Split qmltyperegistrar in two parts: the tool (commandline parsing etc) and the lib (that does the actual qmltyperegistration generation). The tool lives at tools/qmltyperegistrar and the lib lives in src/qmltyperegistrar. This would allow to test qmltyperegistrar and is a first step into adding some structure to qmltyperegistrar. Moves the qqmljsstreamwriter from QmlCompiler to QmlTypeRegistrar. Also, moves the qmltypes.prf from the lib to the tool, so it can still be used from qmake projects! Fixes: QTBUG-103862 Change-Id: I8627d1181db139d043228a802f047a35bff63bb5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Hide plugin categoryMaximilian Goldstein2022-07-011-1/+1
| | | | | | | | | The plugin category is only used for our debugging passes anymore, just hide it from the user from now. Maybe it could be removed later on. Change-Id: Ifa7e55ee950277d0b9e75cfe590b9052767a256a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QQmlJSLogger: Switch to an ID based systemMaximilian Goldstein2022-06-3011-283/+389
| | | | | | | | | | | | | | | | This change makes qmljslogger use an ID based system for categorizing logging entries instead of using an enum. This allows plugins to register their own logging categories after the fact. It's also necessary for us to later show the warning ID when printing warnings and for creating documentation for each ID entry. Currently not every ID maps cleanly to only one type of warning, this has to be cleaned up in a follow-up change. Task-number: QTBUG-103453 Change-Id: I4cac6be7ca165b938e0ea032d077823bf17baf75 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmljstypepropagator: Use object that is being attached to as contextMaximilian Goldstein2022-06-292-3/+17
| | | | | | | | | | | | | Previously the read/writeContext of an attached property was being set by the scope the attached object was being accessed in. This is now set by the actual object the attached property belongs to instead. Task-number: QTBUG-104209 Change-Id: I6617a88fab9a88b9f69f149df9e12e0df0a4bcbc Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Don't generate invalid code for storing undefinedUlf Hermann2022-06-291-4/+8
| | | | | | | | | | We don't actually have to store the retrieved value if it's not storable. Pick-to: 6.4 Fixes: QTBUG-104508 Change-Id: Ib091eabf4f4034a577b94e0d5761c5307815599e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Add missing parentheses to in-place arithmetic operationsUlf Hermann2022-06-281-1/+1
| | | | | | | Pick-to: 6.4 Fixes: QTBUG-104512 Change-Id: I3d592eeda5cefd9e9805b1811b37bebec5d6fc9c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Inline String.arg() into generated codeUlf Hermann2022-06-244-0/+67
| | | | | | | | This way we can compile common translation expressions with .arg(a). Task-number: QTBUG-101387 Change-Id: I89cdef48b63886684569c5b587ea69c937085b62 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Inline translation methodsUlf Hermann2022-06-246-11/+218
| | | | | | | | | We hardcode them into QQmlJSTypePropagator and QQmlJSCodegenerator for now. This is OK for builtins. Task-number: QTBUG-101387 Change-Id: Ifab46083b3a782f009859ce969c283d5bb2b4e8b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Drop unused variableUlf Hermann2022-06-241-2/+0
| | | | | Change-Id: I8836ea1c5873ac29ef75de81dd0f02f9d8ef0cc1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Fix miscompilation if arguments are overwrittenUlf Hermann2022-06-231-2/+15
| | | | | | | | | | | | | | | | | In that case we need to allocate extra registers. We already did so before, but we wouldn't use the registers afterwards. This works nicely in 6.4 because we have a separate type for each store operation. Therefore, the original function argument (being of a different "type") won't be found in the list of local registers. Access to it falls back on the actual arguments array. Only once we've stored something into the register that mirrors the argument we can retrieve it. Pick-to: 6.4 Fixes: QTBUG-104462 Change-Id: Ibb0315cd2f8a8e4106d39fff88a6097b1623eb48 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Properly annotate ThrowException instructionUlf Hermann2022-06-232-3/+6
| | | | | | | | | | | | It doesn't write the accumulator, but it does read it. Generating code for throwing exceptions reveals that we have to default-construct the return type rather than converting from undefined/void when throwing an exception. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-104447 Change-Id: I0a725679d8ecb7e87bb20528033097bc0c3c7bb6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmljsimportvisitor: Fix bindings on prefixed attached propertiesMaximilian Goldstein2022-06-202-9/+52
| | | | | | | | | | Previously these would have not been created properly. This change fixes this and adds some tests. Fixes: QTBUG-104197 Pick-to: 6.2 6.4 Change-Id: I3d2d7d5a0e4019d9f7bd3496ea5762d4b7d680cd Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* fix and add test for DOM standalone build against 6.3Fawzi Mohamed2022-06-182-3/+4
| | | | | | | | | Adds a test that downloads the latest 6.3.x (6.3.1 currently) and tries to build and run the example using the standalone QML DOM library against it on MacOS x86_64. Change-Id: Ifca8669a4cdb9e2aeb311e6b5988d5d648472aeb Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
* QmlLintQuickPlugin: Warn about unexpected property binding typesMaximilian Goldstein2022-06-172-0/+7
| | | | | | | | | | | | Sometimes we use var or Item property types when we actually expect some very specific types. We warn about these at runtime, let's also warn in the linter. Task-number: QTBUG-102859 Change-Id: I68c2bc8b2bf5097723a432d02d76f45651f4ef12 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* qqmljsimportvisitor: Fix relative paths being broken with resourcesMaximilian Goldstein2022-06-171-1/+1
| | | | | | | | | qrc cannot handle ".." in paths, so we need to clean our paths in order to make relative directory imports work. Fixes: QTBUG-103903 Change-Id: I31386728a7a20c30bd8c087dd3a1f2affc369cf4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlJSLogger: disable warning from GCC 11 & 12Thiago Macieira2022-06-151-0/+11
| | | | | | | | | | | | | | | | I think it's coming from the push_back in QQmlJSLogger::log(), but GCC appears to require the warning be suppressed at the template, not the instantiation point. GCC 11: qarraydataops.h:581:11: error: ‘*(QArrayDataPointer<FixSuggestion::Fix>*)((char*)&tmp + offsetof(Message, Message::fixSuggestion.std::optional<FixSuggestion>::<unnamed>.std::_Optional_base<FixSuggestion, false, false>::<unnamed>)).QArrayDataPointer<FixSuggestion::Fix>::ptr’ is used uninitialized [-Werror=uninitialized] GCC 12: qarraydataops.h:581:11: error: ?*(QArrayDataPointer<FixSuggestion::Fix>*)((char*)&tmp + offsetof(Message, Message::fixSuggestion.std::optional<FixSuggestion>::<unnamed>.std::_Optional_base<FixSuggestion, false, false>::<unnamed>)).QArrayDataPointer<FixSuggestion::Fix>::d? may be used uninitialized [-Werror=maybe-uninitialized] Pick-to: 6.2 6.3 6.4 Change-Id: I0e5f6bec596a4a78bd3bfffd16c995116afc2718 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QmlCompiler: Reject conversions via QJSValueUlf Hermann2022-06-151-7/+7
| | | | | | | | | | | | Those are generally less efficient than what the interpreter would do, they can have side effects, and they can throw exceptions. We don't want to deal with any of that. Most of those implicit conversions have explicit equivalents. For those that don't we can add them. Pick-to: 6.2 6.4 Fixes: QTBUG-104010 Change-Id: I62898db92219386c94f2a6c9b56f6fb0b7578832 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-1157-1539/+114
| | | | | | | | | | | | 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>
* QmlCompiler: Don't retrieve metaobjects for value and sequence typesUlf Hermann2022-06-101-8/+15
| | | | | | | | | | | This is not valid QML, and the generated code crashes. Pick-to: 6.2 6.4 Fixes: QTBUG-104092 Change-Id: If609acc2f2dc84a2e8f7c26d4d1b6c626f337cad Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Allow subclasses of QQmlJSImportVisitor be used in QML importingAndrei Golubev2022-06-093-8/+44
| | | | | | | | | | | Make it possible for different tools to supply specialized import visitor subclasses for import purposes. In particular, qmltc is interested in doing this as it could seed code generation specific information into the QQmlJSScope structure of imported documents Pick-to: 6.4 Change-Id: I9087484a6e4dee09b4ff1bc291562a1896ea652e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: Set alias property methods in QmltcVisitorAndrei Golubev2022-06-092-8/+37
| | | | | | | | | We can now sensibly do alias setup in the visitor so no need to keep a special prototype pass around for it Pick-to: 6.4 Change-Id: I29d2d395cfa6d66eabb36d7fdbd9bfa3bc3df988 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>