summaryrefslogtreecommitdiff
path: root/src/qml/compiler/qqmlcodegenerator.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Cleanup, part 2Simon Hausmann2014-03-181-1818/+0
| | | | | | | | | | | * 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-81/+72
| | | | | | | 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 QQmlTypeData object leakLiang Jian2014-03-131-0/+1
| | | | | | | | 1) unref QQmlTypeData object stored in m_compositeSingletons 2) unref QQmlTypeData object in resolveQmlType() Change-Id: I5f2e3a542637f62509c4a2f2ed8a6ba080eacf1b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* [new compiler] Fix property initialization order for mixed list and default ↵Simon Hausmann2014-03-041-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | 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 tst_qqmlvaluetypesSimon Hausmann2014-03-031-2/+5
| | | | | | | | | | | | | | * 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-1/+1
| | | | | | | | 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] CleanupSimon Hausmann2014-03-021-194/+0
| | | | | | | | 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 qquickvisualdatamodel testsSimon Hausmann2014-03-021-9/+10
| | | | | | | | | 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 tst_qqmlqt's trace testSimon Hausmann2014-03-021-3/+2
| | | | | | | Fix name of signal handler functions to be the original onFoo name. Change-Id: I80247cd9be9d77d99e4de0f0e945ff5a1a420244 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Clean up error handling in AST passSimon Hausmann2014-03-021-80/+16
| | | | | | | | When traversing the AST, record all errors using the same method, which makes sure to include the url - as expected by some tests. Change-Id: Ib83623742db86f20144b9aa41f7f0628702d285a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix a few more tests related to property declarations with ↵Simon Hausmann2014-03-021-7/+4
| | | | | | | | | | | initializers Consistently declare the property first before processing the initializer tree or binding statement. Some tests expect errors in the declaration to show up before errors in the statement for example. Change-Id: If66bc4969fe9db7ae32f00023f3c90343bbe98e0 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix evaluateEnum for custom parsersSimon Hausmann2014-03-021-3/+8
| | | | | | | | | When storing the string for a script binding - next to to the AST node - then for expression statements skip the (potentially synthetically inserted) semicolon. Its omission is required for the use of QQmlCustomParser::evaluateEnum. Change-Id: I3b556fd6a884f5c9c290d7d793eeab4dd135343e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Compile functions and bindings in appropriate scopesSimon Hausmann2014-03-021-24/+36
| | | | | | | This enables accelerated property access also for this code path. Change-Id: Iafb177b1fe7878e6c54cfb258f2e8d8ea32aa59e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix memory leaksSimon Hausmann2014-03-021-9/+14
| | | | | | | | | | | In memory pool allocated classes we cannot have members that require a destructor to run to free memory. Therefore this patch removes the QSets in the object class used for duplicate property and signal name checking. The checking is instead done using linear search, which should be fine given that usually the number declared signals and newly declared properties is low per type. Change-Id: Id7a7a9bdd9e145975dcee4d5340489615f4f71e3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix error reporting for group propertiesSimon Hausmann2014-03-021-32/+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] Fix error reporting when trying to set list properties ↵Simon Hausmann2014-03-021-2/+9
| | | | | | | multiple times Change-Id: Ifcbed45894b739a57873356e8963670084614880 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] When resolving names of attached properties, don't report the ↵Simon Hausmann2014-03-021-0/+2
| | | | | | | | | 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] Improve error message for incorrect signal assignmentsSimon Hausmann2014-03-021-1/+5
| | | | | Change-Id: I16e7cdc6b5b49200259ea7e57d84e00f095554f4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Ensure that qualified type names end in an id with an upper ↵Simon Hausmann2014-03-021-12/+35
| | | | | | | case letter Change-Id: I35166b86ddc7c2e87dc77b59f4d8272279ca5688 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Clean up our internal namespacesLars Knoll2014-02-231-142/+143
| | | | | | | | QQmlJS::MASM -> QV4::JIT QQmlJS::V4IR -> QV4::IR Change-Id: I707e8990459114a699c200fe3c22cec3c8df1afc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* [new compiler] Fix location of id property in error messagesSimon Hausmann2014-02-171-2/+2
| | | | | Change-Id: If7cde17acb1dd63a51e2e31415533a21302d8b41 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix order of alias vs non-alias bindingsSimon Hausmann2014-02-041-1/+2
| | | | | | | | 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 binding initialization orderSimon Hausmann2014-02-041-8/+27
| | | | | | | | | | | | | | | | | Since commit 3d958cec8d53094a1bbab895377e451b07716e1f (loong time ago!) property bindings are stored in a linked list and newly encounted bindings at parse time are prepended to the list, causing the binding processing to happen in reverse order. There are however exception to the rule. For example list bindings are processed in declaration order and assignments to the default property are sorted by location in the file. In addition various tests rely on value properties being installed first, then followed by signal handlers and group/attached properties. Change-Id: I3bcae29faec5b2420fbba362cd81b8ba960ed19f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Cleanup empty string handlingSimon Hausmann2014-02-041-12/+11
| | | | | | | | | 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] Fix sanity checking of parameter names when connecting to C++ ↵Simon Hausmann2014-02-031-2/+16
| | | | | | | signals Change-Id: Ie2dc8689786a61fe5f38a0f91ff86f011e965b2d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix error message when assigning lists to singular propertiesSimon Hausmann2014-02-031-0/+2
| | | | | | | | Also adjust the error message for the other compiler when trying to assign lists to script strings. Change-Id: I50f833c340f3634a59c5b36f30aeafc53003e65e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Don't allow setting the id property multiple timesSimon Hausmann2014-02-031-2/+5
| | | | | Change-Id: Ic7f1938dd048db6c6975d78ad4f69d3c646cece5 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix error messages for binding vs. property declarationsSimon Hausmann2014-02-031-46/+67
| | | | | | | | Separate binding errors from property declaration errors - they were accidentally mixed up. Change-Id: Id2d5134dc98ee3e1d7ce0c3d356f165e144e0d82 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] CleanupsSimon Hausmann2014-02-031-68/+101
| | | | | | | | | | | When creating the initial object tree from the AST, encapsulate the declarations and bindings in the QmlObject class, in order to centralize the redirection via declarationsOverride as well as the error handling. This also replaces the hashes to detect duplicate properties/signals from being QString based to simply use the existing string indices from the compilation unit. Change-Id: Ia6ceae56977a98b5c5a7a738bf983a731e608d46 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix invalid id error messaging for empty IDsSimon Hausmann2014-02-031-3/+4
| | | | | | | | | When an ID is specified as string literal, which is empty, don't try to take the literal quotes as ID. Instead it's empty and so an error needs to be thrown. Change-Id: I9b42295a33dceb3cc9e57456908c65bbc12eb296 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix location reported on function declaration errorsSimon Hausmann2014-02-031-1/+1
| | | | | Change-Id: I7549930a1152c257b3da6951afefef5d8b783f32 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix signal handlers that are fuzzily matchedSimon Hausmann2014-02-031-5/+5
| | | | | | | | Use the same logic at object creation time as during the signal handler conversion phase. Change-Id: Idb48a3849da7b6543ec50c15e1ccbf2939c3ee39 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix location when reporting signal declaration errorsSimon Hausmann2014-02-031-1/+1
| | | | | Change-Id: Iaddb51cb7b0e28048761b98d6e48c70723cd5d00 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix signal handler parameters for overloaded signalsSimon Hausmann2014-02-031-0/+1
| | | | | | | | When extracting the parameters for a signal, make sure to pick the original variant that has all the parameters. Change-Id: Ie28cb75ce32d8840812884ce2eef2934d473466c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Add support for signal handler objectsSimon Hausmann2014-02-031-1/+8
| | | | | Change-Id: I644dcea86fa886a6a2dc7cd230ad6942d165c4c5 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix property declarations inside group propertiesSimon Hausmann2014-02-031-10/+25
| | | | | | | | Property declarations inside group properties as well as their initializers go into into the surrounding object. Change-Id: I5b2b0f7bc41daea1275eb17ed04560e17052ca42 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix location of errors in group property objectsSimon Hausmann2014-02-031-8/+5
| | | | | Change-Id: I63aa43ec7d9e90c1593c54dfc44890330c8669ae Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Avoid uncreatable type errors for types that aren't createdSimon Hausmann2014-01-291-3/+6
| | | | | | | | | QtQuick.Keys for example is not creatable, but it's also never created but only used as attached properties. Therefore types used as attached properties create the needCreation = false flag in the referenced types. Change-Id: I6ca3a3ff677858bf3c55d3e08a0f0fc8ee9160fe Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Report errors when trying to bind to read-only propertiesSimon Hausmann2014-01-281-4/+17
| | | | | | | | | | | The only exception are initializers for read-only property declarations. Also adjusted the error location of one test to point to the correct value location as opposed to the property location, as with all the other similar errors. Change-Id: I2333d3c485fc374b1b39a5f5a4408af5cf08a20f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Improved error handlingSimon Hausmann2014-01-281-0/+8
| | | | | | | | | | | | | | | | * 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>
* Improved error handling for namespaced property bindingsSimon Hausmann2014-01-281-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | A binding with a qualified name that starts with a name space, must be followed by a type. For example MyNamespace.someThing.foo: 100 is not valid, something must be a valid type name and therefore start with an upper case letter. Similarly an object declaration like this: MyNamespace.something { ... } is not valid neither. The current compiler reported the latter as "Expected type" and the former as "Invalid attached property name". The message for the latter is not very good, because we know that "MyNamespace" is a namespace and therefore "something" cannot be a attached property name, it must be the attached property type first. In the new compiler this hits the same code path and thus the same error message. So this patch introduces the correct error message in the new compiler, adjusts it for attached properties in the old one and adjusts the test that now passes with both. Change-Id: I51c265a2acb80079c1dd62ef5ef77d5ff07d3ac1 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix support for namespaces in attached propertiesSimon Hausmann2014-01-271-11/+26
| | | | | | | | | | | | | When doing import QtQml 2.0 as MyQml with MyQml.Component.onComplete: ... We now store "MyQml.Component" as one string as the type name, in order to get resolved correctly. Change-Id: I11a6def88bcb8b98b5fa9548053e27fb58170e62 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix error message when trying to create uncreatable typesSimon Hausmann2014-01-241-7/+5
| | | | | | | | | | 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] Fix crash in loading qtquick controlsSimon Hausmann2014-01-241-1/+2
| | | | | | | | Don't create meta-objects for attached properties or group properties by default. Change-Id: Ie6263ae45e0186cf0489b45aafe4b951d336550a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix duplicate property/signal name detection for group objectsSimon Hausmann2014-01-201-9/+5
| | | | | | | | | | | | | | | For a rectangle like this: color: "blue" border.color: "red" we must not issue a duplicate property error for "color" because they are in different objects. This patch fixes that by moving the sets for checking the presence of these into the object itself, so that the qSwap on _object also transitions to the correct property/signal name set. Change-Id: I9ac0e5877eb9f60b618b031f99290707de28112d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Add support for QML list modelsSimon Hausmann2014-01-201-1/+2
| | | | | | | | | | | | | 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/+6
| | | | | | | | | | | 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] Add support for value interceptors / on-assignmentsSimon Hausmann2014-01-171-7/+10
| | | | | | | | | | | | | | 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] Fix group property initializersSimon Hausmann2014-01-171-1/+7
| | | | | | | | | | | | | | | | Bindings with an object initializer without a type name must be group properties, instead of regular object bindings. Fixes font { pixelSize: 24 } versus font.pixelSize: 24 Change-Id: I468caa48be13f91f88545ef001ac9aaa46ba5d14 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix error handling for property names that look like signalsSimon Hausmann2014-01-141-4/+4
| | | | | | | | | The check for the right hand side of a potential signal handler declaration needs be placed after we determined that we are really assigning to a signal. Change-Id: I7f5417dc30ba7365327560e1b16ee9ceaa9bed76 Reviewed-by: Lars Knoll <lars.knoll@digia.com>