aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmltypecompiler_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Make QML composite types inherit attached propertiesJ-P Nurmi2015-10-091-0/+2
| | | | | | | | Change-Id: Ic06af4805da987dd08e361f2668e7a1788d3eefe Task-number: QTBUG-43581 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com> Reviewed-by: Liang Qi <liang.qi@theqtcompany.com> 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>
* Make QML composite types inherit enumsJ-P Nurmi2015-09-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | Problem: in Qt Quick Controls 2, enums declared in the abstract C++ base types were not accessible with the concrete QML type name, but had to be referenced using the base type name: Slider { snapMode: AbstractSlider.SnapOnRelease } Solution: this change resolves the C++ base type and creates the missing link between the composite type and its base type's meta- object. This allows referencing enums using the concrete/composite QML type name: Slider { snapMode: Slider.SnapOnRelease } Change-Id: Icefdec91b012b12728367fd54b4d16796233ee12 Task-number: QTBUG-43582 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Remove some dead codeSimon Hausmann2015-09-211-4/+2
| | | | | | | Also get rid of the unnecessary QQmlCustomCompilerBackend interface. Change-Id: I6cfdd88ef49d3d314d07aa069da481d304e7a285 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Speed up property binding initialization on object creationSimon Hausmann2015-04-211-0/+2
| | | | | | | | | | Avoid repeated string hashing and lookups in the property cache in order to retrieve the property details when initializing literal and script bindings. Instead we now cache the property data at type validation time, similar to how the property data was encoded in the VME instructions in the old engine. Change-Id: I3957c7c4c3e26dfa97c4880b23940a3755ee90e4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup: Fix const'ness of the property binding validator codeSimon Hausmann2015-04-141-7/+8
| | | | | | | | | | | | The property validator is supposed to validate the proposed property bindings and abort type compilation if necessary. As such it is a read-only pass through the data structures and therefore we make it const. However it does have a side-effect of collecting some state, which however is "write-only" and therefore marked as mutable. Those variables are written to, but not read during this pass. Change-Id: I6a3655fedbd6691b7498cf82ca1c8e21dd635bd3 Reviewed-by: Lars Knoll <lars.knoll@digia.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>
* 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-2/+2
| | | | | | | | | 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-1/+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>
* Rework custom parser integrationSimon Hausmann2014-06-041-5/+2
| | | | | | | | | | | | | | | | | | | | | | | The custom parser design used to be so that the custom parser operates on the "AST", creates its own binary representation of the data it needs, stores it in a QByteArray and gets that at object instantiation time. That meant serializing everything necessary. With the introduction of the "binary" QML data structure, that process of serialization becomes obsolete and would require extra work in the custom parsers for example for QQuickStates to store the translation parameters. The clean solution is to eliminate this unnecessary serialization process and instead let the custom parsers do a verification pass at type compile time and then simply operate directly on the QV4::CompiledData::Bindings at object instantiation time. That simplifies the code, and allows for support of translations throughout all list model properties. Additionally this speeds up the creation of state objects and reduces memory consumption. Previously a text: qsTr("foo") binding in states would result in an actual java script binding. After this patch it is merely stored as a string and translated at object instantiation time. Change-Id: I7550274513f54abb09a0ab4de51c4c0bcdb23cae Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4: Split arguments/locals from temps.Erik Verbruggen2014-05-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are a couple of reasons to split the temporaries off from the arguments and locals: Temporaries are invisible, and changes to them cannot be observed. On the other hand, arguments and locals are visible, and writes to them can be seen from other places (nested functions), or by using the arguments array. So, in practice these correspond to memory locations. (One could argue that if neither nested functions, nor eval(), nor arguments[] is used, the loads/stores are invisible too. But that's an optimization, and changing locals/arguments to temporaries can be done in a separate pass.) Because of the "volatile" nature of arguments and locals, their usage cannot be optimized. All optimizations (SSA construction, register allocation, copy elimination, etc.) work on temporaries. Being able to easily ignore all non-temporaries has the benefit that optimizations can be faster. Previously, Temps were not uniquely numbered: argument 1, local 1, and temporary 1 all had the same number and were distinguishable by their type. So, for any mapping from Temp to something else, a QHash was used. Now that Temps only hold proper temporaries, the indexes do uniquely identify them. Add to that the fact that after transforming to SSA form all temporaries are renumbered starting from 0 and without any holes in the numbering, many of those datastructures can be changed to simple vectors. That change gives a noticeable performance improvement. One implication of this change is that a number of functions that took a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr. However, it turns out that there are very few places where that applies, as many of those places also need to take constants or names. However, explicitly separating memory loads/stores for arguments/locals from temporaries adds the benefit that it's now easier to do a peep-hole optimizer for those load/store operations in the future: when a load is directly preceded by a store, it can be eliminated if the value is still available in a temporary. Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Reduce memory consumption of runtime compiled QML typesSimon Hausmann2014-04-021-0/+17
| | | | | | | | | 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>
* Fix compilation of script stringsSimon Hausmann2014-04-021-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | The right hand side of script string properties can be evaluated in entirely dynamic scopes, due to QQmlExpressions' public API of allowing construction from a QQmlScriptString and a variable scope/context. Nevertheless we should compile these bindings at type compile time, as long as we make sure that the compiled code doesn't try to do any compile time determined property lookups and type resolution. This is implemented using a separate compilation pass that ensures the disableAcceleratedLookups flag is set. A few minor cleanups come with this patch: * Ensure that the property caches array is always symmetric to the list of compiled QML objects, as that allows the use of at() instead of value(). * The code for creating a QML callable function object for a given run-time function is now centralized in a static function QmlBindingWrapper, used for script strings and bindings from custom parsers. The provided unit test verifies the successful execution of the same script string with two different scope objects. Change-Id: Ica2cea46dd9e47263b4d494d922d3cc9664b08ae Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Eliminate noop translation bindingsSimon Hausmann2014-03-291-2/+0
| | | | | | | | | | | We can store them as regular strings. This has the advantage that the entire special handling from the custom parser of the list model goes away, we don't need astForBinding in QQmlCustomParser anymore neither and types with a custom parser can now generally benefit from the expression simplification pass. Change-Id: I39d1b76edd1273d8c73b847aed71f7bcce37d877 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Various cleanupsSimon Hausmann2014-03-281-1/+1
| | | | | | | | | | | | | * 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, part 2Simon Hausmann2014-03-181-4/+5
| | | | | | | | | | | * 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>
* Namespace cleanupSimon Hausmann2014-03-171-24/+24
| | | | | | | Move the QML IR types into the QmlIR namespace and clean them up. Change-Id: I2125449e5a519034e23670651efa620f405730b4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add support for resolving translation bindings at compile timeSimon Hausmann2014-03-111-0/+110
| | | | | | | | | | Simple calls to qsTr and qsTrId are detected at type compile time and reduced to a special Translation and TranslationById binding type, which avoids allocating a QML binding at type instantiation type just to perform a translation. Change-Id: I61e4f2db2a8092b5e6870e174b832d9c20cd62b5 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Add support for deferred propertiesSimon Hausmann2014-03-051-0/+4
| | | | | Change-Id: I592518444ef353cfcf153df0e6afa2fbac613560 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix MSVC2012 compiler warnings.Erik Verbruggen2014-03-051-1/+1
| | | | | | | | Tested on both win32 and win64. Change-Id: I47755e2da51829e61e1452eaaf84a057224b478b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
* [new compiler] Fix property initialization order for mixed list and default ↵Simon Hausmann2014-03-041-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | property setups Get a little closer to replicating the old compiler's behavior without introducing a new nested data structure for lists: * List property assignments should happen in declaration order for the items. Instead of doing magic in QmlObject::appendBinding, simply traverse the UiArrayBinding members in reverse order. Within a list, the items remain in order then, due to QmlObject::appendItem prepending. In the overall picture for the entire object, the reverse initialization order for properties is also preserved this way. * When an object has property bindings to the default property and also bindings to a named property that - after meta-object determination - turns out to be the default property, then we need to merge the bindings and preserve the declaration order. (tst_qqmlecmascript::defaultPropertyListOrder checks that) Fixes tst_qqmlenginedebugservice that expects bindings to an entire list to happen in reverse order (like other properties). Change-Id: I7408c97cdb971e06b1ee43a2a85f8cc6f008c444 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Set class name for QML types correctlySimon Hausmann2014-03-031-0/+1
| | | | | | | As required by the tst_qqmlinfo tests. Change-Id: Id163c9dab539e7fd1e1da43c4fa0dfb0d1fb6e34 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] CleanupSimon Hausmann2014-03-021-0/+23
| | | | | | | | Move SignalHandlerConverter into the type compiler and make it a proper compile pass sub-class. Change-Id: Ice8fc9acdfdb613e1d7b25728401a2376a692ccc Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix for tst_qqmlconnectionsSimon Hausmann2014-03-021-2/+2
| | | | | | | | | | | | | Make sure to pass onFooChanged handlers to QQmlConnection's custom parser by not relying on the signal handler converter to set the IsSignalHandlerExpression flag. That should only be set for real signal handlers, the custom parser gets the raw bindings. Also don't try to initialize bindings at creation time the custom parser covers. Change-Id: Iae22bc886c312843136f073959e59da440f4184c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix implicit component determination inside group propertiesSimon Hausmann2014-03-021-1/+1
| | | | | | | | | Don't only scan full-typed objects for property bindings that may define components implicitly, do this for any types we know (propertyCache populated) and that aren't explicitly of Component type. Change-Id: I918b636be6d524e919cdd4efd49c33e63da64de3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Compile functions and bindings in appropriate scopesSimon Hausmann2014-03-021-4/+23
| | | | | | | This enables accelerated property access also for this code path. Change-Id: Iafb177b1fe7878e6c54cfb258f2e8d8ea32aa59e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix error reporting for group propertiesSimon Hausmann2014-03-021-1/+1
| | | | | | | | | | Report errors when setting group properties multiple times, or when assigning values to them. Some of this can be done right after parsing, some of it requires knowledge about the type of group property (QObject or value type) Change-Id: I1aa33e64a5f64dfa4f625469f5b6a84cd8dfb18d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Implement compile time error handling for listsSimon Hausmann2014-02-171-0/+2
| | | | | Change-Id: Ic26e8a01995c296ab9cd4deb8714a5cf17cfdf2b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix order of alias vs non-alias bindingsSimon Hausmann2014-02-041-0/+12
| | | | | | | | qqmlecmascript's alias binding tests expect bindings on non-aliases to be bound before bindings on aliases, as the latter may override parts of the former. Change-Id: I23d25c2b7a449f0ed4672ef6865c4a7ef0ed0129 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix error messages when trying to create invalid property ↵Simon Hausmann2014-02-031-1/+1
| | | | | | | interceptors Change-Id: I3dd608bfceb04323f92503596b87bbcb4bf582fc Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Try to resolve qualified enums at type compile timeSimon Hausmann2014-02-031-0/+24
| | | | | | | | ... by taking some code from the old compiler. This speeds up some bindings and maintains compatibility. Change-Id: If80b1e28214cb655f70fff01a8c885edcb2d3030 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix timing of property assignment error handlingSimon Hausmann2014-01-291-0/+3
| | | | | | | | | Most property assignment errors are now handled at type compile time, just like in the old compiler. This speeds up the object creation code and restores behavior expected in the qqmllanguage tests. Change-Id: If213cd0bfa4dd51d9065c27809a79a6495c9f3ce Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Improved error handlingSimon Hausmann2014-01-281-1/+1
| | | | | | | | | | | | | | | | * When reporting errors with literal bindings, use the correct location for the report, the place where the literal value is declared. * Create property caches for group properties, so that later in the property validator we can do extra checks * Report an error when trying to declare an object to the default property of a group property * Similarlyl report an error when trying to use sub-objects with value type properties * Temporarily change tst_qqmllanguage::errors() to also try to instantiate the component, because for the moment some errors are only reported at instantiating time instead of compile time. That'll be fixed later when move checks get moved into the property validator. Change-Id: Icaa8d2edc7918c03001c40fba7880ee5cac10e69 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix error message when trying to create uncreatable typesSimon Hausmann2014-01-241-0/+2
| | | | | | | | | | Pass along the no-creation-reason properly, for regular qml types as well as singleton types. Also don't collect custom signal parameter names as types to resolve, as we never try to instantiate them anyway. Their type resolution to meta-type id is done lazily when building the meta-objects. Change-Id: I49bd51d9b851cf75cbd51afbcee168944f4350cd Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Add support for QML list modelsSimon Hausmann2014-01-201-2/+7
| | | | | | | | | | | | | List model definitions make heavy use of custom parsers, which requires AST access as well as a general port to the new QQmlCustomParser API. Additional fixes in the custom parser support were needed to pass all tests: * Fix support for AcceptsSignalHandlers and AcceptsAttachedProperties * Don't call setCustomData unless the compiler generated data earlier Change-Id: Ic42f8a890391267c94f63d35f055b60fdbf3c83d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix refcounting leaks with property cachesSimon Hausmann2014-01-201-4/+4
| | | | | | | | | | | The TypeReference is not copy-safe, as it holds refcounted property cache pointers. For the new compiler code path, don't copy them but keep pointers to TypeReference objects around. Also make sure to ref the root property cache correctly and avoid the unnecessary addref for the property cache when creating new vme meta objects (initial refcount is 1). Change-Id: I0c4b952c8300c2167d926d9c35b8579fd505d596 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix customer parser use with nested objectsSimon Hausmann2014-01-201-1/+1
| | | | | | | | Types with a custom parser attached don't need to continue with validation of properties in sub-objects. Change-Id: Ib25f8e037cf651dfb30dd4016f89980612dff4f4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Add support for type and enum resolution for custom parsersSimon Hausmann2014-01-171-1/+5
| | | | | | | | | This is in preparation for listmodel support, share the code for resolving types and enums between the old and the new compiler, as all it needs is the imports. Change-Id: I4908d71eee50c769108e0e2b68b03496722fa49d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix error reporting location for custom parsersSimon Hausmann2014-01-171-2/+0
| | | | | | | | | | After the binding of QQmlCompilePass to QQmlTypeCompiler, I forgot to change the customer parser handling to also report the errors correctly back to the QQmlTypeCompiler. Instead they were collected locally with an empty url. Change-Id: I5ee527a77e27c0339c507f326a3b0f0837353db3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Add support for value interceptors / on-assignmentsSimon Hausmann2014-01-171-0/+2
| | | | | | | | | | | | | | Behavior on x { NumberAnimation { ... } } is implemented by assigning a value interceptor (Behavior is a sub-class of that) to the x property in a special way. That requires various things: * A VME meta-object must be created and installed on the surrounding object, in order for the interceptors to work * On assignments need to be excluded from duplicate property assignment checks * Behaviours require also finalization callbacks on component creation Change-Id: I40250b71081a2e315cda3bdb6677fa4b227fa443 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Clean up property cache / meta object builderSimon Hausmann2014-01-171-7/+16
| | | | | | | | Move the outter loop into the builder class itself, use a vector instead of a list (we know that it's a fixed size and we only do indexed access) Change-Id: I933f0496ea47b3bc7c2bebde7f1a14b4f603b4c3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] CleanupsSimon Hausmann2014-01-101-0/+71
| | | | | | | | Move all compilation phase related sub-classes (property cache generator, component and alias resolver, etc.) together into qqmltypecompiler.cpp Change-Id: I598c801d9434623fc8e6338dec11e4d4ee6d7232 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Add support for implicitly defined componentsSimon Hausmann2014-01-101-0/+2
| | | | | | | | | | | | | | | Use-cases like itemDelegate: Item { ... } implicitly define a component without the item-surrounding Component {}, base on the fact that the property itself is of type QQmlComponent (or derived). This means we have to synthesize a Component {} object and insert it into the data structure. Change-Id: I8992451a5a6732c7fd898eaf83c276dc6a8b7d19 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] CleanupsSimon Hausmann2014-01-101-1/+41
| | | | | | | | Tie QQmlCompilePass and QQmlTypeCompiler together, so that we can eliminate the battery of parameters to the individual compiler phases. Change-Id: If2b6cf8416e6c2253c8f054048d1fd5ae12282b6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] CleanupsSimon Hausmann2014-01-081-0/+75
Move the code that calls the main compilation passes into a separate QQmlTypeCompiler class, away from the QQmlTypeLoader. Change-Id: Ia2f33a074d7fe7d9a092ff94d1e6cfc961ad5bdb Reviewed-by: Lars Knoll <lars.knoll@digia.com>