aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmlirbuilder_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Add support for enum declarations in QMLMichael Brasser2017-07-131-0/+26
| | | | | | | | | | | | | | | | | Enums can be declared with the following syntax: enum MyEnum { Value1, Value2 } Grammar changes done by Simon Hausmann. [ChangeLog][QtQml] Enums can now be declared directly in QML. Task-number: QTBUG-14861 Change-Id: Ic6b6e032651d01ee2ecf9d5ce5734976cb3ad7ab Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.8' into 5.9Simon Hausmann2017-03-151-1/+1
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qqmltypecompiler.cpp src/qml/compiler/qqmltypecompiler_p.h src/qml/qml/qqmltypeloader.cpp src/qml/qml/qqmltypeloader_p.h Change-Id: I4894555ab7a0879b56bbda7a46d16d1c40c19e7c
| * Clean up type dependency hashing for QML cachingSimon Hausmann2017-03-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of passing the engine parameter all the way through the data structure generator, along with the dependent type data structure that is unused otherwise, let's simply provide a function object for the dependency hashing. This is also in preparation for adding singleton types to the dependency hash. Task-number: QTBUG-58486 Change-Id: I5bb5e5c06b7b5c77195cec3da13141333cfea7a8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Fix old QML compiler buildsSimon Hausmann2017-02-271-1/+1
| | | | | | | | | | | | | | Do a private export of the IR loader as the code is in QtQml now. Change-Id: If98c38b84d60b2904752c2adb2f9beb5e5e6d774 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Re-do QML type compilation of ahead-of-time generated QML cache filesSimon Hausmann2017-01-311-0/+15
| | | | | | | | | | | | | | | | | | | | As we currently lack the ability to do type resolution at AOT cache generation time, we need to re-do the work after loading the cache file, making us essentially only re-use the code and avoiding the step of parsing. Change-Id: I12844692d4766345d8a313b59d21abf1f868e2d1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | qqmlirbuilder_p.h: add missing 'override'Anton Kudryavtsev2016-09-181-20/+20
|/ | | | | | | ... and drop redundant 'virtual' Change-Id: I98d30f28db571c2d65fae8c4e447e1c0a4555ad9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Make the unit mapping on Windows configurable with regards to executable mappingSimon Hausmann2016-08-171-1/+0
| | | | | | | | | | If we generate byte code, then we can mmap without the executable flags, otherwise we need them. This should make things work out of the box on platforms where special rights are needed before executable mappings are allowed. Change-Id: I24e663f85d661bc51cd3bf2463547b1d1590ea32 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Add a checksum to the generated QML compilation unitsSimon Hausmann2016-08-021-1/+1
| | | | | Change-Id: Icd5b1d805059981cbbb4c0eb2a5c842d59223839 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Split out creation of alias properties in the property cachesSimon Hausmann2016-07-151-0/+2
| | | | | | | | | | | | Similar to the regular property cache creation code, this also has to become a template function so that it can be run on the compilation units loaded from disk in the future. What is shared between the code path of a fresh compilation vs. re-use of a unit from disk is the code to propagate the CompiledData::Alias entries into entries in the property cache. The code for iterating through the component spaces and resolving the alias references is not shared. Change-Id: I04c2a5575310400156b457ae7b709cffecb7455e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix endian support in compiled data structuresSimon Hausmann2016-07-141-1/+1
| | | | | | | | | | | | The goal is to make the compiled data structures persistent on disk. In order to make it possible to create these data structures on a "host" system that may have a different endianness than the target system, we now make all the word sized fields little-endian. The template wrappers from QJson provide zero-overhead access for little-endian machines (the vast majority) while maintaining a large degree of source compatibility. Change-Id: I3d30da1fcf3bffb98dbe9337d3a35482fb7b57c8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* IR: Remove unused QHashRobin Burchell2016-07-081-1/+0
| | | | | | | Hasn't been used since it was introduced AFAICT. Change-Id: Id2691ae9abf1275319fdb618a5e3f8dd527ec72f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Minor optimizationSimon Hausmann2016-06-271-0/+1
| | | | | | | | | | | | | | | I've seen people write property SomeItem myProperty: null This is an unnecessary initialization that ends up creating a binding expression. Generally there's handling missing for null and undefined, but in this very case we should just optimize away the initializer expression, because QObject style properties are initialized to null by default, as opposed to undefined. Change-Id: I7af4cd45461304753c93cef3926f6e92d3b6c95d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* PropertyCacheCreator traversal cleanupSimon Hausmann2016-06-161-0/+34
| | | | | | | | | Replace the direct linked list object traversal with iterators. This will allow for re-use of the code against the QV4::CompiledData structures when they get the same interface. Change-Id: I901fd3377ef0f0317e5d9278cface37d80f93abf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Small data structure cleanupSimon Hausmann2016-06-161-2/+2
| | | | | | | | | Changed the QList<QmlIR::Object*> for IR object storage to use a QVector instead, to secure the guarantee of contiguous storage in memory. This will later be useful for direct indexing. Change-Id: I3c0a5f2c346627c8436971ec1d69160865eeb22e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Clean up property cache creation codeSimon Hausmann2016-06-161-5/+5
| | | | | | | | | | | | | | | | | | * Reduce the complexity of the recursive tree traversal by moving the base type property cache creation into a helper function and using a context to encapsulate the origin of the current traversal * ensureVMEMetaObject() had only one call site and it's easiest to inline that for now. * Transition to a new state-less error handling, so that in the future this code can be used without the QQmlTypeCompiler dependency, which will be needed for loading of compilation units from disk. * A few missing consts. Change-Id: Ibe7209c357a3c7e101fac6960ece40a033e55f72 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Cleanup: generalize type reference collection codeSimon Hausmann2016-06-141-3/+34
| | | | | | | | | | For loading compilation units from disk we'll have to scan the unit for type references, in order to correctly load dependencies. In preparation for that this patch template'izes the loops so that they can work on the Qml IR as well as on the CompiledData::Object structures. Change-Id: I32e4e3277e16c5a2d1bf6baf24456c9837c189ff Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Small type compilation data structure cleanupSimon Hausmann2016-05-261-0/+10
| | | | | | | | | | After the removal of the named object hash tables in the persistent compilation unit data, we can also eliminate them from the temporary internal type compilation structures. We have everything we need in the object naming table in the CompiledData::Object - the only thing missing are the component roots. Change-Id: Ia2a7b3894310cfdb5cfecf1c2a921fb51e2a883b Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Optimize named object handlingSimon Hausmann2016-05-261-1/+3
| | | | | | | | | | | | | | | | By storing the object indices of named objects in the CompiledData::Object of a component, we can achieve two things: (1) We can eliminate the hash of vectors in QQmlCompiledData for the object-to-id mapping (2) We can store the mapping from object name to integer object id in the CompilationUnit and share it across different QQmlContextData instances (as long as it is not modified). Also added a new test that verifies the functionality of a .qml file starting with Component{} itself with object names, something that was previously only implicitly tested through some of the examples (corkboards.qml for example). Change-Id: I28c70217222dc0e5252bf5247b7e3fc4def47446 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Simplify object to id-in-context mappingSimon Hausmann2016-05-261-2/+3
| | | | | | | | | By storing the calculated integer id for an id-named object in CompiledData::Object we can simplify the code and replace a hash table with a plain vector. Change-Id: I4a84cdd00e98766d603d152e5a6574b232771a02 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Add a flag to CompiledData::Object record component boundariesSimon Hausmann2016-05-261-2/+3
| | | | | | | | This allows simplifying some code and reducing the usage of the objectIndexToId hash maps. Change-Id: I1f08d4b224c4f9fa498d90471fa545ae4e4f2af4 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Minor cleanup of pool array allocationSimon Hausmann2016-05-261-2/+7
| | | | | | | | | We store the CompiledData::Function indices for a give QML object in a fixed sized array in the memory pool in the IR. That array can be stored as pointer/len pair directly, there is no need for another pointer indirection. Change-Id: Iccad465ab873e0e7203dc563abb67cf6354a8bfd Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* Remove QQmlVMEMetaData::AliasData::contextIdxSimon Hausmann2016-05-231-1/+1
| | | | | | | We can store the id (in QQmlContextData::idValues) for the alias target in the QV4::CompiledData::Alias. Change-Id: I3f32648aef28d96ddedff6b3d2cde75969a46fa1 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Optimize property/alias data structuresSimon Hausmann2016-05-231-1/+13
| | | | | | | | | | | | | We used to store property declarations and alias declarations in the same properties array in CompiledData::Object. However at run-time the QQmlVMEMetaObject implements them separately, using separate data structures (in the meta-data) and (most importantly) using separate property id segments: First the properties, then the aliases. By reflecting the same separation in CompiledData::Object with property arrays and alias arrays, we can pave the way for getting rid of the meta-data in QQmlVMEMetaObject. Change-Id: Ia84813fe3da6f3fdbd4d2b16136a8bf11fa175a6 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Fix regression with assignments to default propertiesSimon Hausmann2016-05-191-1/+5
| | | | | | | | | | | | | | | | | With commit ad8d760decd5f1c6242a42688417b3c86122121c the precision of the location (row/column) fields was reduced. The same fields are used to preserve the insertion orer of bindings as they appear in the .qml file, which meant that for large qml files without any line feeds we may end up with an overrun in the column range (2048). This happened in the Tests_TabView::test_mousePressOnTabBar test in qtquickcontrols. The reduced precision is fine because those column/row fields should only be used for error reporting. In this case where we need the precision we can just as well use the file offset in the temporary QML-IR Binding data structure. Task-number: QTBUG-53115 Change-Id: Ifb6f76b4f83a06fa228211134d12cc67c071bbec Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* Merge remote-tracking branch 'origin/5.6' into devLiang Qi2016-01-291-2/+7
|\ | | | | | | Change-Id: Iec1b2de53c275996364c4bab0123ccb3e6e9895e
| * Don't check for revisions when assigning to grouped propertiesLars Knoll2016-01-271-2/+7
| | | | | | | | | | | | | | | | | | | | This leads to wrong behavior in some cases, where we reject valid revisions, and there is probably no case, where this could lead to a conflict for the user of the API. Change-Id: I1614332cf4c07c6a227551612331dd69b2ae71f3 Task-number: QTBUG-40043 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Updated license headersJani Heikkinen2016-01-191-14/+20
|/ | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Add missing "We mean it" comments to private headers.Friedemann Kleint2015-10-061-0/+11
| | | | | | Task-number: QTBUG-48594 Change-Id: Ifc207938de7f0c8995fc712df92665f222612647 Reviewed-by: Alan Alpert <aalpert@blackberry.com>
* Access the id objects through a specialized runtime methodLars Knoll2015-08-121-1/+0
| | | | | | | | This brings us one step closer to getting rid of the QQmlContextWrapper. Change-Id: Ied57f4c174c2ebd95096310a4ad4c0c28787e7a4 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Access context properties through the qml contextLars Knoll2015-08-101-1/+0
| | | | | | | And get rid of another temp in the IR. Change-Id: I039393e020e5141f1986aee276246c30fd8057f3 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Use the QmlContext to access properties of the scope objectLars Knoll2015-08-101-1/+0
| | | | | | | | | Add some runtime methods to access properties of the scope object directly (using the QmlContext), and generate proper code to call those. Change-Id: I0b29357c9a3b9ad53ba568ec6cb763e8ecb10f21 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Add ability to retrieve and use the QmlContext from our generated codeLars Knoll2015-08-101-0/+1
| | | | | | | | | | | | | | Our generated code (JIT and interpreter) should operate on the QML context to retrieve QML related things. That's better than operating on 4 different temps. So this commit introduces the QML context as a temp in the code we generate for QML. The next commits will move things over to use that context with specialized runtime methods instead of using generic subscript/get calls on the different subobjects. Change-Id: Ia05cf339de9cdd23003f35cf78ede17d2590f8de Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Remove unused QQmlPoolFrank Meerkoetter2015-07-311-1/+0
| | | | | | | This code is no longer in use. Change-Id: If0cb009ac6622ed36cba5886d6685d3f242c3c87 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-121-7/+7
| | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9 Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
* Clean up JS .import/.pragma directive scanningSimon Hausmann2015-01-081-1/+15
| | | | | | | | | | | There's a scanner in QQmlJS::Lexer::scanDirectives that can parse those, so let's get rid of extra parser that operates on a string. Instead this way we can do the scanning all in one shot, avoid detaching a copy of the source code string and (most importantly) bring the parser closer to the copy in Qt Creator, which uses the directives approach to extract imports and pragma. Change-Id: Iff6eb8d91a45d8a70f383f953115692be48259de Reviewed-by: Fawzi Mohamed <fawzi.mohamed@theqtcompany.com>
* Fix QQmlExpression/QQmlScriptString/QQmlBinding crashesSimon Hausmann2014-10-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | In the QQmlScriptString we store the binding id and it is an index into the runtimeFunctions array of the compilation unit. However we don't store the compilation unit and instead in QQmlBinding and QQmlExpression try to retrieve it from the cache via the context url (we have the context after all). That turns out to be not a reliable way, as sometimes the URL might slightly differ from the originally compiled cache (qrc:/// turning to qrc:/ maybe). Consequently the type is (unnecessarily) compiled again and unfortunately not _linked_, therefore the runtime functions array is empty. Another option is that when the component was created from a QByteArray, then no entry exists in the cache in the first place. This patch addresses the problem by storing a reference to the compilation unit in the QQmlContextData. That we can safely retrieve and it'll make sure the compilation unit also stays alive. In the process of that the manual reference counting was switched over to QQmlRefCount and QQmlRefPointer for QV4::CompilationUnit. Task-number: QTBUG-41193 Change-Id: I9111f9a3b65618e453954abcd789c039e65a94f7 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Update license headers and add new licensesJani Heikkinen2014-08-251-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0 Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* CleanupSimon Hausmann2014-08-151-1/+1
| | | | | | | | | Merge QV4::CompiledData::QmlUnit into QV4::CompiledData::Unit. For pure JS units it means a slight increase of memory usage by a few bytes, but overall it makes the code a lot simpler. Change-Id: Ib48927749720b056f004aac0fe22cb8ec729e3f6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup: Get rid of the url and file name members in QQmlCompiledDataSimon Hausmann2014-06-051-2/+1
| | | | | | | | This is part of the effor of moving members from QQmlCompiledData into QV4::CompilationUnit in order to eliminate the former in the long run. Change-Id: Icce7fe0ee9a49cb3a7677fd7020008fc55ecdcf6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix linking of qmlimportscanner in MSVC debug builds.Friedemann Kleint2014-04-281-1/+1
| | | | | | | | | | Qt5QmlDevToolsd.lib(qqmlirbuilder.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QmlIR::CompiledFunctionOrExpression::CompiledFunctionOrExpression(void)" Use Q_QML_PRIVATE_EXPORT so that it does not have effect when building qmldevtools. Change-Id: I138fe9cba518829d7ec1d0bfe9d4a9d657446c7d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Extend the QML bootstrap library by the IR buildersSimon Hausmann2014-04-231-11/+17
| | | | | | | | | | | | | This is among other things needed to fix the qml import scanner to detect dependencies from .js files correctly. The patch also fixes the use of Q_QML_EXPORT towards Q_QML_PRIVATE_EXPORT where appropriate and corrects the wrong include path for the double conversion code to actually be relative to the file it is included from. This worked by accident because of other include paths present in the build. Change-Id: I338583dad2f76300819af8ab0dae8e5724c84430 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Reduce memory consumption of runtime compiled QML typesSimon Hausmann2014-04-021-0/+1
| | | | | | | | | Don't store the string of binding scripts in the compiled data. The only exception to the rule are properties of type QQmlScriptString as well as types with custom parsers. Change-Id: I7f53262bf957b442bac4db71d0a2c0bed74a9b54 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Various cleanupsSimon Hausmann2014-03-281-24/+18
| | | | | | | | | | | | | * Encapsulate the string pooling for the V4 data generation into a StringGenerator class. * Move type reference collection into the IR::Document, where it belongs (as it writes into the typeReferences there) * const fixes * Remove unused methods and members * Store unit and qml unit sizes right in the generated data structure. That makes copying easier (like we do when generating the QML data based on the JS fields) Change-Id: I053146ab0b00cc90ac7f72f867415962d1be121b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup: Remove last traces of QQmlScriptSimon Hausmann2014-03-191-1/+3
| | | | | | | | | | What remains is the code for removing .pragma from script source code (and replacing it with white-space to preserve line/column numbers). The previous code even returned the value of the pragmas, but for the remaining caller sites that value isn't used, so we can just return void. Change-Id: I16db15da236970660b817d6c4493005365a7a1af Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup: Remove dead codeSimon Hausmann2014-03-191-6/+0
| | | | | Change-Id: I073a8c61d666a08b5e88edcbf4cefa71d7f5b7c3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Clean up script importsSimon Hausmann2014-03-191-0/+5
| | | | | | | | | | Move the .pragma and .import script extraction out of qqmlscript and into qqmlirbuilder, where it can populate a QQmlIR::Document. Changed the script part of the type loader to use that, which also allowed eliminating the m_source member and m_metaData. Change-Id: Icc64d219fff5666679a02e6afda73f7edfca132b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Clean, part 3Simon Hausmann2014-03-191-1/+1
| | | | | | | | | | * Get rid of QQmlScript::Pragma * Allow retrieving the QML unit size after generation * Add flag equivalent of .pragma library to QV4::CompiledData * Remove unused method Change-Id: I2f95b83f919004013741bc539c82960cc878f3a4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup, part 2Simon Hausmann2014-03-181-0/+502
* QQmlCodeGenerator -> QQmlIR::IRBuilder (it doesn't generate code, it generates the Object/Property/Signal/etc. IR of the .qml file, that's going to get transformed to QV4::CompiledData::*) * ParsedQML -> QQmlIR::Document Change-Id: I329e858487b66e1ae528d44316761f5dd34b79f4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>