aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmltypecompiler.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix crash when loading QML that tries to set non-existent group propertiesSimon Hausmann2014-04-241-1/+2
| | | | | | | | | | This happens when trying to search for implicit component definitions, which only makes sense if we have a property cache. Task-number: QTBUG-38466 Change-Id: I788159453efc24bcda1b9709a1933b49fd54d6a7 Reviewed-by: Liang Qi <liang.qi@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Extend the QML bootstrap library by the IR buildersSimon Hausmann2014-04-231-1/+1
| | | | | | | | | | | | | 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>
* Don't append garbage to the function parameter slotswip/gcThiago Macieira2014-04-041-1/+2
| | | | | | | | | | | | | | If the argument is neither a temporary nor a constant, slot isn't initialized. So don't try to add it. qqmltypecompiler.cpp:2548:36: error: variable 'slot' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] qqmltypecompiler.cpp:2553:36: note: uninitialized use occurs here _functionParameters.append(slot); ^~~~ Change-Id: I5a538bfa0ef1fbbd00e23dfd6e15c404359c7c46 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Use RAII for VME profilerUlf Hermann2014-04-031-0/+1
| | | | | | | | | | | | | | Now that object creation is done in nested function calls we can use an RAII-type profiler to trace it. This makes the profiling much simpler and more robust. Also, the stack of profiling data in the VME profiler has to match the stack of completion callbacks in the VME, so the push and pop operations are synchronized now. Task-number: QTBUG-37978 Change-Id: I1bc5e0665b88e5b3772e48c8676cdda3fae59e1b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Reduce memory consumption of runtime compiled QML typesSimon Hausmann2014-04-021-2/+55
| | | | | | | | | 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-6/+60
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Remove object index parameter from QQmlCustomParser::compileSimon Hausmann2014-03-291-1/+1
| | | | | | | | There is no need anymore to pass through the object index of the object being "custom compiled". Change-Id: I8ef8e578b27523d9e7190503fbf95d1eb863a149 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Eliminate noop translation bindingsSimon Hausmann2014-03-291-16/+38
| | | | | | | | | | | 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-19/+14
| | | | | | | | | | | | | * 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>
* Fix instantiation of QML list models with custom object propertiesSimon Hausmann2014-03-271-6/+1
| | | | | | | | | | | | | | | | | | When doing something like property Item blah: Item { ... } in a list model, we would erroneously pass "blah" to the custom parser of the list model, which is wrong as the binding to blah is on an existing property (not custom). For regular properties there's a code path in place to avoid passing this to the custom parser, but for sub-object bindings we'd unconditionally register it with the custom parser. This patch corrects that and also adds a unit test to verify that we don't pass any bindings to existing properties to the custom parser. Task-number: QTBUG-37795 Change-Id: I1a3091fb5fad4be08b577cf74a85f24c3ab62ef4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanupsv5.3.0-beta1Simon Hausmann2014-03-211-4/+4
| | | | | | | | | * Get rid of members in QQmlCompiledData that were used by the VME and are now unused * Get rid of QQmlVME friend declarations that are not needed anymore Change-Id: I11b4b6f0b4b0b60edf92a1256be3d0d44d76bbc9 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Compilation fixaavit2014-03-191-8/+7
| | | | | | | | gcc 4.6 chokes on this construct. Replace with a shorter and more readable one :) Change-Id: I02ff7a2c5300de656e61ee5ca8effabdd74991bb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup, part 2Simon Hausmann2014-03-181-20/+20
| | | | | | | | | | | * 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-106/+106
| | | | | | | Move the QML IR types into the QmlIR namespace and clean them up. Change-Id: I2125449e5a519034e23670651efa620f405730b4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix QQmlTypeNameCache object leakLiang Jian2014-03-131-1/+0
| | | | | | | | Remove redundant ref to QQmlTypeNameCache object in QQmlTypeCompiler::compile() Change-Id: Ie166e8d04c1504194bec227bf5e945b273778a20 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix QV4::IR::Function object leakLiang Jian2014-03-131-0/+1
| | | | | | | Delete the QV4::IR::Function object before removing it Change-Id: Ie85de6f18034b2def5645c07df1ccc84ac3060ec Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add support for resolving translation bindings at compile timeSimon Hausmann2014-03-111-18/+322
| | | | | | | | | | 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] Fix incorrect accelerated lookups to id objectsSimon Hausmann2014-03-061-2/+1
| | | | | | | | | | When compiling JS code in the scope of a component, make sure to always set the id object mapping, even if it is empty. Otherwise the id objects from one scope might leak into another, leading to id object dependencies that are invalid. Change-Id: Ib2bca11203acd6924e8c74f9560a1ee3e00d7e39 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix auto component creation with composite typesSimon Hausmann2014-03-051-3/+7
| | | | | | | | | | | | | A binding like this property Component foo: SomeComposite {} should not do an implicit component insertion if SomeComposite is actually a component. The property assignment is compatible and can proceed normally. Fixes tst_qquickcanvasitem, but added a separate unit test for this case. Change-Id: I7221eebd38dba3f2a82b59341739b9b67211e352 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Add support for deferred propertiesSimon Hausmann2014-03-051-7/+46
| | | | | Change-Id: I592518444ef353cfcf153df0e6afa2fbac613560 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix invalid memory reads when JS closures outlive QML typesSimon Hausmann2014-03-051-1/+2
| | | | | | | | | | | | | If QQmlCompiledData gets destroyed while somebody still has refcount on the QV4::CompiledData::CompilationUnit, then unit's _data_ would be freed already by ~QQmlCompiledData. Given that compilationUnit->data is pointing to the same malloc'ed address as QQmlCompiledData::qmlUnit, we can just let the CompilationUnit always own the data. Fixes tst_qquickloader and makes it possible to run the qquickcomponent tests. Change-Id: Ie3f3e5335139236d7c2524a327665bda0a9cc847 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix property initialization order for mixed list and default ↵Simon Hausmann2014-03-041-0/+61
| | | | | | | | | | | | | | | | | | | | | | | | 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] Fix profiler supportSimon Hausmann2014-03-041-0/+1
| | | | | | | | | Add profiler tracing calls during objection creation and make sure to set the function token / source location correctly for the synthesized function declarations of signal handlers. Change-Id: Ie4f8accce3a5c5d1d57bb0646cda588b89b76718 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix some qqmlincubator testsSimon Hausmann2014-03-041-4/+7
| | | | | | | | | | | | | | | We need to track the objects created and pass them over to the VME guard used in the incubator. The incremental build nature of the incubator requires that to avoid crashes. For nested incubators we need to set the activeVMEData field in the root QQmlContext, to allow child incubators to locate the parent. Lastly we need can emulate most of the VME behavior in terms of build states when running with QQmlInstantiationInterrupt by presenting four build steps: The initial state, two build steps, a finalization step and the state when we're done. Change-Id: I16cd7f71744decb9d4735ec77e9d944fad18e88d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix tst_qqmlvaluetypesSimon Hausmann2014-03-031-0/+4
| | | | | | | | | | | | | | * Make sure to remove earlier set bindings for any value type property, not just scripts. We want font.bold: false to also override an earlier actual binding for example. * Propagate on assignments on qualified property names throughout the chain of bindings - that makes it easier to detect them early on. * The group property collection in the bindings validator should only include value bindings to group properties, not on assignments - as they can always appear in parallel. Change-Id: Ib7ec4de755a5a8d269324a77cba36eb945366274 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Detect when writing to read-only value type property and bail outSimon Hausmann2014-03-031-3/+8
| | | | | | | | Also annotate QML expressions in the IR with a proper function name, to make debugging easier. Change-Id: I5bacf446f40d35896f50bed0732f6f10408d9c97 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Set class name for QML types correctlySimon Hausmann2014-03-031-4/+2
| | | | | | | As required by the tst_qqmlinfo tests. Change-Id: Id163c9dab539e7fd1e1da43c4fa0dfb0d1fb6e34 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Add the correct object index to the custom parserSimon Hausmann2014-03-021-1/+1
| | | | | | | | Without the correct index the calls to astForBinding run out of bounds. Fixes tst_qqmllistmodel crash. Change-Id: I6fb8b77866cbf247e7373cdbece6833c92be3615 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] CleanupSimon Hausmann2014-03-021-4/+194
| | | | | | | | 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-5/+12
| | | | | | | | | | | | | 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 qquickvisualdatamodel testsSimon Hausmann2014-03-021-1/+1
| | | | | | | | | Allow for signal handlers to be installed on group property objects. We determine the property cache objects earlier correctly, so the empyt type name check is not necessary. Change-Id: Idc38fdc1a78c0f4d5147ec882e7872a62510e790 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix QQmlPropertyMap testsSimon Hausmann2014-03-021-1/+24
| | | | | | | | | QQmlPropertyMap is treated as a type that cannot be cached with QQmlPropertyCache, doesn't allow for accelerated property access and also doesn't allow for declarations of any kind in sub-types. Change-Id: Id8a6811120aa61ffb5037394e758cc62501e0fc3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix implicit component determination inside group propertiesSimon Hausmann2014-03-021-10/+13
| | | | | | | | | 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-20/+118
| | | | | | | 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-16/+62
| | | | | | | | | | 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] Don't allow for attached properties inside group properties ↵Simon Hausmann2014-03-021-2/+6
| | | | | | | or nested Change-Id: I7ca4e1c1b111d587f519275b146179b4e6f6a51f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] When resolving names of attached properties, don't report the ↵Simon Hausmann2014-03-021-2/+1
| | | | | | | | | error at import time Instead report it later with a more specific error message. This is consistent with the old compiler. Change-Id: Iba345b7ecc8a9ff474938f69118665eb0d965594 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix determination of property caches for attached propertiesSimon Hausmann2014-03-021-1/+13
| | | | | | | | That in turn fixes error messages around property validation in attached types. Change-Id: Idef9f7652b225c5769b7fdf43e41731b197c1144 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Report errors when a property name starts with an upper case ↵Simon Hausmann2014-03-021-0/+11
| | | | | | | letter and lacks a qualification Change-Id: I66e9669459920cfb3543a3ebcec8501465c2ef85 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix error reporting for invalid component specificationsSimon Hausmann2014-03-021-1/+7
| | | | | Change-Id: I435845ab1188e65a7ef019d758fbbba57e2e0bec Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Clean up our internal namespacesLars Knoll2014-02-231-7/+7
| | | | | | | | QQmlJS::MASM -> QV4::JIT QQmlJS::V4IR -> QV4::IR Change-Id: I707e8990459114a699c200fe3c22cec3c8df1afc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* [new compiler] Report errors at type compile time for invalid group property ↵Simon Hausmann2014-02-181-0/+12
| | | | | | | access Change-Id: I36a945dd4e4c0e699a2b34af066eae4d4c73a588 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix reported error location for unknown type assignmentsSimon Hausmann2014-02-171-1/+1
| | | | | Change-Id: Ib564002f790921d4e233bb56d1a6ff6ef6aa6c2b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Compile time check for objects assigned to script stringsSimon Hausmann2014-02-171-0/+3
| | | | | Change-Id: I873bded73a0d2210910c496312fb3b7b04e4a65f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Implement compile time error handling for listsSimon Hausmann2014-02-171-1/+29
| | | | | Change-Id: Ic26e8a01995c296ab9cd4deb8714a5cf17cfdf2b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix parser status and created bindings allocationSimon Hausmann2014-02-071-0/+21
| | | | | | | | | | | | | | | Pre-calculate the amount of space we need for binding and parser status callbacks at compile time and therefore use a much simpler data structure (vector) to store the points to the bindings and callbacks. They need to be stored because during object construction and binding enabling phase, it may happen that they get destroyed and thus their m_mePtr pointing into the array gets deleted. The contiguous vector will also make it possible to interrupt the completion phase. Change-Id: Ic7c985bb8325ab355112e30e9d33d6ae4e7476d1 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix logic error in enum resolverSimon Hausmann2014-02-051-1/+1
| | | | | Change-Id: I614cc1428439801ed20cdee099cf8260ff930618 Reviewed-by: Liang Qi <liang.qi@digia.com>
* [new compiler] Fix order of alias vs non-alias bindingsSimon Hausmann2014-02-041-0/+36
| | | | | | | | 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] Cleanup empty string handlingSimon Hausmann2014-02-041-10/+7
| | | | | | | | | Ensure that the empty string always has index 0, that simplifies the code in a few places and makes it easier to check for the empty string in other places where there's no access to the string pool itself. Change-Id: Icd204aec478e8350ef3fee75d89bda1f88cffe26 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Propagate JS code gen errorsSimon Hausmann2014-02-031-0/+5
| | | | | Change-Id: I3b99f3fc762df7ac820b26597bf809a80849b5ce Reviewed-by: Lars Knoll <lars.knoll@digia.com>