aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler
Commit message (Collapse)AuthorAgeFilesLines
* QmlCompiler: Allow for multiple extensions per objectUlf Hermann2021-02-011-29/+7
| | | | | | | | | | | | | | | | | | | Previously, the assumption was that each object could only have a single extension object. As proven by the new qqmllanguage test this is not the case. Each registered object in the type hierarchy can have its own extension. Therefore, adjust the algorithms that generate qmltypes and iterate the extension objects when analyzing them. This leads us to the realization that anonymous types can in fact meaningfully carry extensions and implement interfaces. Adapt qmltyperegistrar accordingly. For the test to compile, however, we need to realize that the class declaring interfaces needs to befriend all potential subclass's QmlInterface structs. Fix that, too. The rabbit hole went deep. Change-Id: Ia451897e927e03b95c3062e829edf1dfcd216613 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Generate AOT functions in same order as interpreted onesUlf Hermann2021-01-291-34/+71
| | | | | | | | Otherwise various internal indices may be off, in particular the internal classes. Change-Id: I3c2a6b8150590fc41ec55bf2dfbc989078ddce42 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Retain anonymous types in qmlnamesUlf Hermann2021-01-291-0/+7
| | | | | | | | | Prefix them with $anonymous$ so that we cannot accidentally find them. If we don't keep them, they may be deleted when their last strong reference goes out of scope. Change-Id: I24ca795f9d9c4ecea074019db41a3ca0618f8e81 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Expose getter and setter names of C++ classes in qmltypes filesFabian Kosmale2021-01-291-0/+3
| | | | | | | | | | | This simply exports the name which are already available in the json files generated by moc. We do not consider whether the methods are non-private for now. MEMBER is not supported either, but might be added if the need actually arises. Fixes: QTBUG-90711 Change-Id: If3ee18c8ce60499676a7ee22df569cba0912e22f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Return after importing a scriptUlf Hermann2021-01-261-1/+1
| | | | | | | | If we don't return there, the newly imported script is promptly overwritten by an invalid module. Change-Id: I788a7275e2c190a20c176da35f5c76ac9f6ad02b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QDeferredSharedPointer: lazy-load to determine isNull()Ulf Hermann2021-01-261-16/+42
| | | | | | | | | | | If the content is not loaded, yet, the data is always null. If it is loaded, the result might be null. So, in order to know, we have to load. The same holds for deferred weak pointers, the hash functions, and the equality operators. Change-Id: I20eec58efe5da604187c34578ee40f769090c910 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlJSTypeReader: Guard against empty JS filesUlf Hermann2021-01-261-9/+11
| | | | | Change-Id: Ie52ce15b7fa960ce84a6d17a21a0e307a38c726e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Remove exceptions for most unknown builtinsUlf Hermann2021-01-214-63/+83
| | | | | | | | | | | | All those types are properly defined in the qmltypes files now. We just need to search the enumerations the same way as methods and properties in order to find everything. Also, deduplicate the code that resolves properties, methods, and enums by using a common template for iterating the scopes. Change-Id: I0bf1423974d0ec8f602ecd0342522b3e981a8586 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlJSScope: Fix typoUlf Hermann2021-01-202-3/+3
| | | | | | Change-Id: Idb29a7483b813ed00849c13ef1324c7e931400de Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Add equality operators and hash functionsUlf Hermann2021-01-201-0/+81
| | | | | | | We want to be able to use these types in hashes. Change-Id: Iea60bb8dd1ce893a37c4856d153f0f5c77d29fcd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Support extended typesUlf Hermann2021-01-203-3/+71
| | | | | | | Fixes: QTBUG-90448 Change-Id: I5fb6b3d9223ae95ca7e039c5b9139ed086052c29 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Skip failing testsFabian Kosmale2021-01-201-0/+2
| | | | | | | | And do not choke completely on extended. Task-number: QTBUG-90448 Change-Id: I4ac5742ec70f5ba1ed1403be444d9cc7229830c2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove the qmake project filesFabian Kosmale2021-01-151-32/+0
| | | | | | | | | Remove all qmake project files, except for examples which are used to test that qmake continues to work. Change-Id: Ic4abb72dc2dcd75df7a797c56056b6b3c5fe62ac Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Pass a more comprehensive context to AOT-compiled functionsUlf Hermann2021-01-111-17/+24
| | | | | | | | | | We need the compilation unit, and a way to retrieve JavaScript metatypes from it. Also, prepare for cases where we only have a QJSEngine, not a QQmlEngine, and pass the scope object as part of the AOT context. Change-Id: Ica81e92c99f3c9b6baffd04db1e0e91603fd2ac7 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Don't add imports with "as" to the contextUlf Hermann2020-12-052-5/+3
| | | | | | | | That is wrong. The context does not contain such objects. Instead, mark the names as namespaces in the imports by giving them an empty type. Change-Id: Ie9d0bba592863878d2220cee59be369ba2534f17 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Make QQmlJSScope const-correctUlf Hermann2020-12-031-2/+19
| | | | | | | | | You should not be able to retrieve a non-const parent or child scope from a const scope. That defeats the whole point of keeping the scopes const after loading. Change-Id: If3734c65ee902c32939a54a67193d5f6276cd016 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Let AOT-compiled functions modify their argumentsUlf Hermann2020-12-021-4/+4
| | | | | | | | It allows for more natural looking generated code and there is no downside. The arguments are specially prepared for the call anyway. Change-Id: I8437e93adb1c67db1b53fbdb29cbea10f6ef278f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Mark the global scope as compositeUlf Hermann2020-11-261-0/+1
| | | | | | | | All non-C++ scopes are composite. Now that we can return the global scope, when parsing a script, this matters. Change-Id: I6c9a17bdd3acf80fce728b1df5c3d9e66035bd33 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Unify parsing of QML components, JS programs, ES modulesUlf Hermann2020-11-254-74/+96
| | | | | | | | | There is no reason to duplicate the code for retrieving method signatures 3 times over. As an added benefit, the types on those methods are resolved now. Change-Id: I2f9681911b938c4a260b6593ab49e9cc5098c546 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQmlCompiler: Notify any AOT compiler about binding scope and objectUlf Hermann2020-11-242-4/+14
| | | | | | | | | The scope can be different from the object a binding is attached to. In particular, a group property or an attached property are executed in the scope of the surrounding object but are attached to the inner object. Change-Id: I3671c0ba425b791960f3205baaff91471d2e7205 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltyperegistrar: Expose interface informationMaximilian Goldstein2020-11-233-5/+49
| | | | | Change-Id: Ica3f5c6696542921bc8d399cd46d901ba06f6d83 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: Don't crash when importing ES modulesUlf Hermann2020-11-201-2/+25
| | | | | Change-Id: Ica93a3e3fb0eb99be1498f1fcb94b09c113272d7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Allow passing arguments to AOT-compiled functionsUlf Hermann2020-11-202-13/+23
| | | | | Change-Id: I2340f4413ae9a44c71000e840a79e904b6a0fec9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Fix resolution of method and property typesUlf Hermann2020-11-184-25/+50
| | | | | | | | | | | | | | | | We need to resolve the types for QML elements in two passes because only after finishing the parsing we have the QML-declared methods and properties available. We already need the base type before, though. Also, there can be multiple methods of the same name. We need API to access them. It also turns out that the internal name of the "var" type has to be QVariant in order to match reality. "var" properties and unnamed arguments to JS functions are implemented as QVariant. Change-Id: I541f11e96db72d832f4e4443d3a5d31079a56575 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Mark dataPtr as unused for void AOT functionsUlf Hermann2020-11-131-0/+1
| | | | | | | Otherwise we get lots of "unused" warnings from the compiler. Change-Id: I7744715c476350dd3bba34500589cb1c62672c9f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Add method to get first non-composite base scopeUlf Hermann2020-11-121-0/+9
| | | | | | | That's a recurring thing. Change-Id: I8dc049a559e337c70089dd1f81ff23bf7d2140fe Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Correctly store AOT functionsUlf Hermann2020-11-121-2/+5
| | | | | | | | There always has to be an empty last function. Otherwise we might access invalid memory when loading them. Change-Id: I5e7a784c14ac8a12450926b895664a98c03f85f1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Store values QQmlJSMetaEnum when availableUlf Hermann2020-11-123-1/+26
| | | | | | | | | | | | | When parsing QML files, we need to keep the enum values around as this is the only place where we can find them (without parsing the same file again, that is). With C++ types we don't strictly need them as they are also available from the C++ header, but if the qmltypes file is nice enough to provide them, we can use them. (Which will be for types that are not actually C++ types, but rather types produced by registering a QML file with qmlRegisterType()). Change-Id: Ibcc93b30e523a00e1eeb80029943c48b83d0e1b5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Allow more convenient access to enums in QQmlJSScopeUlf Hermann2020-11-124-7/+12
| | | | | Change-Id: Ibac4dd7641a89b686bee63cf974b2257a35631a2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Allow AOT compilation of JS functionsUlf Hermann2020-11-112-0/+17
| | | | | | | Previously, only bindings were compiled. Change-Id: I6e76c3f5e628e60538a0ed754fdd915978b88c1d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Integrate sequences with registration macrosUlf Hermann2020-11-113-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | You get to write QML_SEQUENTIAL_CONTAINER(value_type) now, and qmltyperegistrar will generate a sensible registration call from that. A registration might look like this: struct MyStringListForeign { Q_GADGET QML_ANONYMOUS QML_SEQUENTIAL_CONTAINER(QString) QML_FOREIGN(MyStringList) QML_ADDED_IN_VERSION(3, 1) }; It's unfortunate that we need to use a metaobject to transfer all of this information, but there is no other sensible way. Transform the containers defined in qv4sequenceobject.cpp to use the new style, and move them out of the builtins, into QtQml. Recognize that only one of them was ever tested, and add tests for the rest. Task-number: QTBUG-82443 Change-Id: I3a30f9e27266bb575eea26c5daf5dad1ec461cc5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Use the name of a QML object as its locationUlf Hermann2020-11-031-1/+3
| | | | | | | This is in line with what the IR does. Change-Id: I9808d6e070a19e749e43c4abf612556485eb080b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Allow the specification of file scope codeUlf Hermann2020-11-032-5/+12
| | | | | | | | This can contain extra includes and code that should be added before any functions. Change-Id: Ida13d38ab7198c3986e134fe6f3786acd821927f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Allow retrieval of C++ names for builtinsUlf Hermann2020-10-282-0/+7
| | | | | | | | Access to non-exported types is necessary in order to implement an alternative QML runtime environment. Change-Id: Ia6fd7bbfbf0ec9d6fa06f3741891395a78e468ea Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Add JS scopes for script bindingsUlf Hermann2020-10-272-1/+17
| | | | | | | | This is necessary to identify the available QML and JS scopes for the binding, and to add any identifiers found there. Change-Id: Ic966e7817ccd1fdc064dd433d16fa6c42c9110cc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Introduce grouped scopesUlf Hermann2020-10-273-3/+47
| | | | | | | | This way we can analyze the left hand part of things like "anchors.fill: parent" in qmllint. Change-Id: I0f58312566c3d5062e0fb301c2bad908ab8b8cbb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Log the name of the binding being compiledUlf Hermann2020-10-271-2/+4
| | | | | | | The binding code alone is not very helpful. Change-Id: I74e8884b2345c8b60447375e38a18db65ac22cb4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Don't AOT-compile boring bindingsUlf Hermann2020-10-271-0/+11
| | | | | | | Plain literals don't benefit from AOT compilation. Change-Id: I8f20991b3e330f688f977d57acbffef36818a76c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Make sure that properties are writable by defaultUlf Hermann2020-10-261-0/+1
| | | | | | | Amends commit 7feab1fb95317b924fe39c49dd9907ca3df61a40. Change-Id: I32e22b51501d9c98af74ac00506619cfe33f6b7c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Allow AOT compiled function to specify includesUlf Hermann2020-10-262-2/+15
| | | | | | | | This is necessary for include directives specific to the types being used. Change-Id: I34e0e5907d795714797fbb99a75b863cc41e9ad3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Add method to retrieve addressable scope from visitorUlf Hermann2020-10-261-0/+1
| | | | | | | Adressable scopes are the ones with an id. Change-Id: I4975248aa920f0d567b5b5ccc8ba18a2fdd91e13 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlcachegen: Move functions to compile QML/JS files to QmlCompilerUlf Hermann2020-10-234-0/+562
| | | | | | | | We need to re-use them. Also, provide a way to insert AOT compiled functions into the C++ code. Change-Id: I7b0d13cb307e8f979745f096a9614f087d135f68 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlcachegen: Add empty AOT built functions to the loaderUlf Hermann2020-10-231-1/+2
| | | | | | | | This enables us to use the same generateloader.cpp for qmlcachegen and any replacement that actually produces AOT compiled functions. Change-Id: I12fe81236e4ef16a627729c644d54b6c171b3860 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move generateloader.cpp to QmlCompilerUlf Hermann2020-10-234-0/+294
| | | | | | | We need to be able to generate the loader code from multiple places. Change-Id: I9e04fd3583b535bc5f7d5fb293cb61309c1e199a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Properly discern between inherited and own namesUlf Hermann2020-10-226-50/+64
| | | | | | | | | | | Previously, we would mix them up on importExportedNames(), which was also misnamed. Now we keep them in their proper place in the scope hierarchy, so that we can identify which scope a property came from. Exceptions are the qmllint-specific treatment of parent properties and Connections elements. Change-Id: I7c012388b16c83439d6f2de2e83fac0da4940d30 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Make sure any import depends on the builtinsUlf Hermann2020-10-222-10/+18
| | | | | | | Otherwise types like "int" are not resolved. Change-Id: I35d0eb05e955822b082d2f6067d1e5b40c510cf1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Use size_t for qHashUlf Hermann2020-10-221-2/+2
| | | | | | | | It is expected to return an unsigned value. Change-Id: Id75c0887de7e9b0eeab378041598621c89507501 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* qmllint: Resolve aliases in nested objectsUlf Hermann2020-10-222-21/+30
| | | | | | | So far we've just ignored them. Change-Id: I2ca522ef825a341a3f4bf1c2a42fb0376180cdda Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlcachegen: Move resourcefilter.cpp into QmlCompilerUlf Hermann2020-10-204-2/+237
| | | | | | | | For backwards compatibility, a replacement for qmlcachegen will need to provide the same functionality. Change-Id: I22664230ea636d384190122223d15819ebee930c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlJSImporter: Expose the imported objectsUlf Hermann2020-10-201-0/+1
| | | | | Change-Id: I1257d4efe1813d2b95a37d95a82c21c30fc15591 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>