aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* QQmlJSImporter: Pass the source location to the resultUlf Hermann2020-10-201-0/+1
| | | | | Change-Id: I8c52efc752fbeae4485d7cc2112d615707e2afd1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Cache builtin typesUlf Hermann2020-10-202-1/+6
| | | | | | | | If we import the builtin types multiple times from different places, we want them to match. Change-Id: I3f2f0ec0d72fb4e178ee69517ecafa8260ebc35e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Drop the metaobject revision from exportsUlf Hermann2020-10-193-22/+18
| | | | | | | | | Instead, output a warning if the revision doesn't match the version. We want to get rid of generic version/revision matching. To this end, add a way to retrieve the version from an export. Change-Id: Ie887103eba910f14e49faa684ac559cc72cab199 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Add hasMethod() and hasProperty() to QQmlJSScopeUlf Hermann2020-10-191-0/+2
| | | | | | Change-Id: I29e38054a5adcf398f63df7f367ed4bc24c09c75 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Read the "bindable" attribute from plugins.qmltypesUlf Hermann2020-10-163-43/+44
| | | | | | | | | And refactor QQmlJSMetaProperty to use setters rather than a gigantic constructor. Also, notice that we don't have to construct the same property twice just to update its type. Change-Id: Ia6c195fa7088f6ecdff868daae17d4284c1edb22 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Retrieve warnings from qmltypes parserUlf Hermann2020-10-161-0/+4
| | | | | Change-Id: I83292c9db42e39e52fbf20e92c036d789bbdb2d6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlJSScope: Add a way to retrieve a single method or propertyUlf Hermann2020-10-162-5/+8
| | | | | Change-Id: Icf8f2aae869176ed864dcdd3b4231e71043cb0bc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: add operator!= to QDeferredPointerUlf Hermann2020-10-151-0/+10
| | | | | Change-Id: I2191660b731d85495d0e90152e0fe493553b7a2f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Pass source location to all scopes from QML filesUlf Hermann2020-10-152-20/+32
| | | | | Change-Id: Ic0aeb152acb0d90d15cc48a55c0ad5b15a60a6eb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Further unify findwarnings.cpp and qqmljsimportvisitor.cppUlf Hermann2020-10-152-4/+201
| | | | | | | | Most of the logic in findwarnings.cpp applies also to imported files and should live in the base class. Change-Id: I65f326f50a8bfab0dff4b5b31f7bee7300b20704 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QDeferredPointer: Remove the factory before executing itUlf Hermann2020-10-152-10/+9
| | | | | | | Only this way we avoid infinite recursion on cyclic references. Change-Id: I4d6323a093d17f7d55965dc40f9dc5f1a647df9c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Unify QQmlJSImportVisitor and FindWarningsVisitorUlf Hermann2020-10-155-106/+199
| | | | | | | | | They are both pretty much doing the same thing, except that the import visitor is not as thorough. We need the full analysis in QtQmlCompiler, so we successively move the code over. Change-Id: If7fb47f88165fd8b61f4ccc408ccfbb7dad533e6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Defer resolution of types read from QML filesUlf Hermann2020-10-158-26/+253
| | | | | | | | | | When importing a directory we most likely don't need all of the files in the directory. Therefore we now parse them only when they are accessed. This speeds up the execution and will allow us to process imports recursively without running into infinite recursion. Change-Id: I0c79313de792249e6bb86144b5014a7787dbdc5b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Unify the printing of diagnosticsUlf Hermann2020-10-155-27/+53
| | | | | | | | We can use QQmlJS::DiagnosticMessage to carry message, type, and location. Change-Id: I3868bc8035b4da13efad0d1b7d2f8dfeff1ef234 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Rename QQmlJSImportedMembersVisitorUlf Hermann2020-10-125-15/+15
| | | | | | | We need to make this a general import visitor. Change-Id: I735378fc9139cb4891f8b113d86395df856fb4e9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow optional imports in qmldir filesUlf Hermann2020-10-081-4/+6
| | | | | | | | | | This is useful for modules that select their imports at runtime using qmlRegisterModuleImport(). We can list all possible variants as optional imports so that tools can see what types might be available. Task-number: QTBUG-87130 Change-Id: I8a37bdde79aef3619fd1f05e5ea6781d521afa88 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Support 5.x style composite types in qmltypes filesUlf Hermann2020-10-071-1/+1
| | | | | | | | | In Qt6 we don't want those anymore, but it's easy enough to support them for now. Task-number: QTBUG-87164 Change-Id: I2a6cd1dd99f772d132f71575c9c5f4538a3dd0f0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Read deprecated dependency specifications from qmltypes filesUlf Hermann2020-10-072-8/+42
| | | | | | | | And produce a warning when doing so. Task-number: QTBUG-87164 Change-Id: I75eab97a37af1268a310e88e3ac6a625127a7f62 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Use the declared typeinfos rather than the defaultUlf Hermann2020-10-071-2/+15
| | | | | | | | | | ... and produce a warning when encountering the default. This shows us that the qmake build omits some typeinfo entries from common modules. Add those. Change-Id: I1c7e87e8a54ef24a6076090e6051eb1c03c09b2a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* CMake: Regenerate projects to use new qt_internal_ APIAlexandru Croitor2020-10-061-1/+1
| | | | | | | | Modify special case locations to use the new API as well. Task-number: QTBUG-86815 Change-Id: I3b964e3baf0cc7040830156dac30358ea1152801 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
* QmlCompiler: Unify and optimize directory importsUlf Hermann2020-10-061-15/+8
| | | | | | | | We don't need to import lowercase files as those can't be used anyway. Also, the code was duplicated. Change-Id: I5f24977e59a9b244b70362045524ed1e7849eeb8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Split importFileOrDirectory() in twoUlf Hermann2020-10-062-14/+12
| | | | | | | | | | | importing a file and importing a directory are really quite different things and the code paths inside the function were completely separate. We also don't have to create a map of ImportedTypes if we are only going to return a single one. Change-Id: Ifbb0caa70e9272dfde2d9f1cf5ed1b102e02f5cc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Add a source location to QQmlJSScopeUlf Hermann2020-10-051-0/+12
| | | | | | | This will come in handy when matching scopes to IR objects. Change-Id: Idff002378a27f08e7d53e8d462311156b0583a8e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>