aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/data
Commit message (Collapse)AuthorAgeFilesLines
...
* Compiler: Handle method list return types from qmltypes fileOlivier De Cannière2024-02-143-0/+38
| | | | | | | | | | | | | | | | | | | When parsing methods details from qmltypes files, the `isList` value was ignored. It indicates that the return type of the method is a list of the type specified in the `type` value. This patch adds QQmlJSMetaReturnType (typedef of QQmlJSMetaParameter) to hold information about the method's return type. With this, we can now mark a method's return type as being a list when reading qmltypes files and we can act accordingly when resolving the method later on. As a drive-by, only expose the getter and setter of the metaReturnType in QQmlJSMetaMethod and not their internals directly. Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-122106 Change-Id: I6ea07c02fbeb6cb07d9fe9184205ff7f3274fd73 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: In debug mode, set instruction pointer before each lookupUlf Hermann2024-02-082-0/+9
| | | | | | | | | | | This produces some overhead, but helps with debugging. Without the instruction pointer we cannot determine the line numbers for console.trace(). Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-119459 Change-Id: I75a6bb1fcedd8514e2ba46d02dd2904ce222f0e4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Compiler: Also check for shadowing on optional lookupsOlivier De Cannière2024-02-082-0/+20
| | | | | | | | Amends: fc4ee77116624c784d8c42f2b8e5dbf2f78b6d89 Pick-to: 6.7 Change-Id: I3f5f2b74e4b89b82e7fb54072091143010bab8aa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Compiler: Convert from stored to original type when generating equalityOlivier De Cannière2024-02-072-0/+17
| | | | | | | Pick-to: 6.7 Fixes: QTBUG-121909 Change-Id: I913f59324364052d7893d4c4072f92fcf418a388 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Reject lookups on shadowable base typesUlf Hermann2024-02-014-3/+52
| | | | | | | | | | | | If the base type of a lookup is shadowable we cannot give any guarantees at all about what is going to happen. Only if the right hand side of the lookup is shadowable we can use our QVariant trick. Fixes: QTBUG-121734 Pick-to: 6.7 6.6 Change-Id: I969a842a6bc6d6a4446bfbfb50f1a7021b84049e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Compiler: Don't crash on optional lookups on QJSValue base typeOlivier De Cannière2024-01-293-0/+18
| | | | | | | | | | | | | Handle the case where the base type of the lookup is QJSValue so that we don't hit the assert. However, it should not be possible to get a QJSValue there at all. This should be investigated further. Created QTBUG-121662. Pick-to: 6.7 Fixes: QTBUG-121393 Change-Id: I8bea87cbff74119bb977635ec391601f47269ff0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Handle non-resettable undefined assignmentUlf Hermann2024-01-255-13/+64
| | | | | | | | | | | | We need to generate an exception if undefined is assigned to a property that can't be reset. We don't want to reject everything that can potentially be undefined. Therefore, we use the QVariant fallback and examine the value for undefined at run time. Pick-to: 6.7 6.6 6.5 6.2 Change-Id: I0a034032f4522f017b452690d93319eb4bfedb1c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Implement resetting of propertiesUlf Hermann2024-01-253-0/+56
| | | | | | | | | | | We piggy-back on the mechanism used to handle shadowable properties and pass the value as QVariant. QVariant can hold undefined and the lookup functions know how to handle it. Pick-to: 6.7 6.6 6.5 6.2 Fixes: QTBUG-120512 Change-Id: I9bca4940256c82bdcf5540b956600eb420be363e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Allow primitive conversion if output is stored in varUlf Hermann2024-01-112-0/+19
| | | | | | | | | We can always convertStored() if the contained type has been fixed. Pick-to: 6.7 Fixes: QTBUG-120322 Change-Id: I7d834fa32a12503341c863c095d578ca6e838531 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Compiler: Handle all integer signs and sizes when converting primitivesOlivier De Cannière2024-01-093-0/+49
| | | | | | | | Fixes: QTBUG-120473 Pick-to: 6.7 Change-Id: I4941cd1567d94823551e4cc94df8bc5b413e951c Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Compiler: Guard against null dereference when ignoring function returnOlivier De Cannière2024-01-092-0/+15
| | | | | | | | | | | | | | | | | | | When a function is called, two arrays with the necessary information are passed to the engine: argv: [return address, prameter 1 address, parameter 2 address, ...] types: [return type, parameter 1 type, parameter 2 type, ...] When the result of the call is ignored, the return type is set to void and the return address to null. A check for this null value was missing leading to a null derefence. Amends: 4f1b9156a48e44cf1f127a4563d0ac69ab436f12 Fixes: QTBUG-120336 Pick-to: 6.7 Change-Id: I4a21779f3276b0143087b41b0d16c0cd3ba0e7db Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Return early after reject()Ulf Hermann2023-12-222-0/+16
| | | | | | | | | | Otherwise we can run into an infinite loop. Pick-to: 6.7 Fixes: QTBUG-120322 Change-Id: I81f9402beb48faf09b4fe148271d4347b84ddc5e Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Don't crash when calling coerceAndCall() with null thisObjectUlf Hermann2023-12-082-0/+19
| | | | | | | | Pick-to: 6.6 6.5 Fixes: QTBUG-119395 Change-Id: I5877beef9a53d358a6f58f9ce5029688bd9dcedb Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Preferably wrap types in QJSPrimitiveValue for SetLookupUlf Hermann2023-12-081-0/+9
| | | | | | | | | If we store one primitive type inside another, we cannot get its content pointer. Change-Id: I7088685fdd2633085de732aab87b4b5f93300b90 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Add generic QVariant-to-typed comparisonUlf Hermann2023-12-075-0/+87
| | | | | | | Since we have a lot more shadowable values now, we need to add this. Change-Id: Ie9f389730bb6f330b1cd28f9229c5dd143727e4f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Do not adjust renamesUlf Hermann2023-12-072-0/+20
| | | | | | | | | | | | A rename always produces a register with exactly one tracked type, but we do not want to use it as base for the type adjustments. We want to adjust based on the original location and its readers (which includes any renames). Pick-to: 6.6 6.5 Change-Id: Iaefdf56992c7c101a35a056fb93c49ade5ccf393 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Use actual type for aliases of enum valuesUlf Hermann2023-12-051-0/+5
| | | | | | | | | | | | | | The metatype system and the compiler may disagree about the underlying type. It's generally better to pass the full type information. We can deal with it everywhere by now. Amends commit 3ea55bf398412d373daab9c92b1498f45de70e96 Pick-to: 6.6 Fixes: QTBUG-119531 Change-Id: I4744f5fb81fb5430ac040ec5877f7d0845a2ab12 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Let IDs in outer context override bound components' propertiesUlf Hermann2023-12-042-0/+21
| | | | | | | | | | | | | | | | | | This is necessary to make the usage of such IDs actually safe. If we let local properties override outer IDs, then adding local properties in later versions invalidates the ID lookups. [ChangeLog][QtQml][Important Behavior Changes] In QML documents with bound components, IDs defined in outer contexts override properties defined in inner contexts now. This is how qmlcachegen has always interpreted bound components when generating C++ code, and it is required to make access to outer IDs actually safe. The interpreter and JIT have previously preferred inner properties over outer IDs. Pick-to: 6.6 6.5 Fixes: QTBUG-119162 Change-Id: Ic5d3cc3342b4518d3fde1b800efe1b95d8e8b210 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Compiler: Add initial support for optional chainingOlivier De Cannière2023-11-243-0/+87
| | | | | | | | | | This patch implements the GetOptionalLookup instruction in the compiler. This enables the use of optional chains. Fixes: QTBUG-111283 Change-Id: I265f611415a946468b828b9d41f549acfcc76233 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Don't generate invalid code for argument conversionUlf Hermann2023-11-231-0/+7
| | | | | | | | | We need an additional pair of parentheses here. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-119165 Change-Id: I0d8e810ebb5baad35e2cc1bc5c6581d1ba180dc8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Do not generate lookups for bare meta enumsUlf Hermann2023-11-182-0/+13
| | | | | | | | | Such code is necessarily dead or uncompilable. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-119090 Change-Id: I7319f7ceeb0b4994d5e974bbe8a9c3ba3bf72fc5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: When rejecting empty constants, don't crash afterwardsUlf Hermann2023-11-181-0/+2
| | | | | | | | Pick-to: 6.6 6.5 Fixes: QTBUG-119091 Change-Id: I1e24583aa998976c96bf3ddd6865f33cc4d5e94c Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Don't access unavailable input accumulator on 'as'Ulf Hermann2023-11-171-0/+10
| | | | | | | | | | | We only read it if the target type is composite. Therefore, check for composite first, before looking for the accumulator. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-119122 Change-Id: I2a50214f76ee4ffe2f877dc690704e7475b8bd77 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Retrieve original types for comparisonUlf Hermann2023-11-132-0/+40
| | | | | | | | | | | | If an original type is merely wrapped into a more generic type by the basic blocks pass, we know the original data is still there and can be used for comparison. Fixes: QTBUG-117795 Change-Id: Ia7582cd8ed48e47a3a1b3bd8e2595e9cb42828de Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Allow comparison of optional typesUlf Hermann2023-11-092-0/+78
| | | | | | | | | | | | | The only extra case we have to consider is the construction of an optional type from a QObject-derived since that is stored in a QVariant rather than a QObject*. Everything else we can compare is already covered by the generic QJSPrimitiveValue comparison since QJSPrimitiveValue can store undefined. Fixes: QTBUG-117799 Change-Id: Iac89f28497c34d217af156d363b8beeda76174ef Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QmlCompiler: Always record original types for equality comparisonUlf Hermann2023-11-092-0/+55
| | | | | | | | | | | | | The shadow check may adjust the types later on and cause a different comparison to happen than what we've expected when propagating. We can only see this at code generation time. Pick-to: 6.6 6.5 6.2 Task-number: QTBUG-117795 Change-Id: I04f1dd9902385f87114e48b0994e0f243f0c2c84 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QmlCompiler: Allow internal conversions from wrapped original typesUlf Hermann2023-11-042-0/+17
| | | | | | | | | | | | | | | | | If an original type is merely wrapped into a more generic type by the basic blocks pass, we know the original data is still there and can be used for conversion. This happens if we assign the same value once via a shadowable lookup and once via an exactly typed one. The basic blocks pass then has to produce a QVariant for the shadowable lookup. However, we know that it can only contain the original type. Fixes: QTBUG-117800 Change-Id: I42335c3404dbcf8c1e7ad6427d22643ad490a345 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Extend shadow-checkingUlf Hermann2023-11-044-0/+46
| | | | | | | | | | | Method return values as well as whatever we hide behind "unknown" can contain shadowable properties. We need to check it. Pick-to: 6.6 6.5 6.2 Task-number: QTBUG-117800 Change-Id: I518bc11fd0c9c69340bf621198eeaf4c95d17dae Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QmlCompiler: Generate jump code also when skipping an instructionUlf Hermann2023-10-312-0/+33
| | | | | | | | | | | | | | | | The next instruction may still need the type conversions even if we don't need to generate any code for the current instruction. Also, generate trace info for generate_DeadTemporalZoneCheck so that we can recognize it in the generated code. Amends commit 2c410317b6077fdcfb2cdeb4b730c1b0c544147e. Pick-to: 6.6 6.5 Fixes: QTBUG-118514 Change-Id: I70ad3691486176de2177e9d5f538f7c99d121bfa Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Throw an exception in loadScopeObjectPropertyLookup when qmlScopeObject is nullDmitrii Akshintsev2023-10-242-0/+34
| | | | | | | | | | When object is being destroyed, qmlScopeObject pointer is becoming null (I assume as part of the lookup invalidation?), causing nullptr dereferencing in the subsequent Init lookup stage. This commit prevents it by introducing an "early exit" on the load stage. Fixes: QTBUG-117866 Change-Id: Ifef1a0dd48a952f00f2c0d4d5015ec2f40b7f62a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Reject calls to one of multiple fuzzy overloadsUlf Hermann2023-10-232-0/+4
| | | | | | | | | | | | | | | If we cannot statically determine the right overload better don't call any of them for now. Also, allow attempts to pass arguments as derived types during type propagation. The test shows that we don't properly pass the thisObject when calling with metatypes. Fix that, too. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-117922 Change-Id: I02e70ffb9a05f3cfedccafde6e16170b0efbcd29 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Disallow reading enums from instancesUlf Hermann2023-10-233-0/+53
| | | | | | | | Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-118089 Change-Id: Ib98bb84159847439614341a3cbd4d34d6eabfc8a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QmlCompiler: Prohibit writing to readonly propertiesUlf Hermann2023-10-181-0/+3
| | | | | | | | | | | | | | The extra check for hasOwnProperty() was wrong. It was originally meant for qmllint to find initial assignments to the same property but qmllint has a different way of identifying those these days. Amends commit d2507f238370f6432cd8d65aa7f335dd68484e5a. Pick-to: 6.6 6.5 Fixes: QTBUG-118100 Change-Id: I6151b8088315b6a99e331b0830b9fdd8188a30cb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* codegenerator: Convert to the original type of registers for unary opsOlivier De Cannière2023-10-063-0/+22
| | | | | | | | | | | | | | | | When generating the code for unary operations, we converted from the received type to the expected type in readAccumulator. Except, if the latter was replaced by a different type such as with a generalization to QVariant for example, then we would not retrieve the original type the operations should be performed on but keep the replacement type. Convert the received type to the original type instead of to the replacement. Fixes: QTBUG-117789 Pick-to: 6.6 Change-Id: Ia0109918443b1e1be2bc57b9d46a3a628799806b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Error out when writing to property of unknown typeUlf Hermann2023-09-281-0/+8
| | | | | | | | | | Otherwise we get a conversion to unknown and that is bad. Pick-to: 6.6 6.5 Fixes: QTBUG-117361 Change-Id: Iead1ddd21b692ed9fb9923dccdfa5bd01dc9d467 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Nicolas Fella <nicolas.fella@kdab.com>
* QmlCompiler: Do not crash when trying to iterate non-iterablesUlf Hermann2023-09-281-0/+7
| | | | | | | | | Amends commit a173d50a9e54d2a21a5207f6c66bb54bb8f3a612. Change-Id: I2774cd483e073c69f2ceff345436fbdd2a9ac692 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
* QmlCompiler: Implement GetIterator and IteratorNextUlf Hermann2023-09-212-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | Each GetIterator generates * A unique iterator variable that keeps track of the current index * In the case of for...of a copy of reference to the list being iterated The result register holds a pointer to the unique iterator so that it can be loaded and stored without resetting it. In order to do anything meaningful with iterators (in the tests) we also need to allow LoadElement with our "optional" types. That is a conversion of undefined and some other type to QVariant or QJSPrimitiveValue. This follows the same pattern as the other "optional"s we already have. For...of is currently not testable because it requires exception handlers. The tests will be added once we get exception handlers. Task-number: QTBUG-116725 Change-Id: I167fe16b983dc34bf86e1840dfcbf2bf682eecc1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Cache correct properties for signal handlersUlf Hermann2023-09-051-1/+1
| | | | | | | | | | | This exposes some invalid QML code in our tests: We shouldn't override signals in QML and we now notice. Since banning it outright would be a pretty drastic change in behavior, we only print a warning for now. Coverity-Id: 416620 Change-Id: I28c6b818c4abccb830b0e6998fe840bf229bf081 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QmlCompiler: Clean up equality operatorsUlf Hermann2023-08-251-0/+11
| | | | | | | | | | The special cases added for the number and null operations are generally useful also for other kinds of equalities and vice versa. Furthermore, there is no point in std::move'ing registers into equality operators. Task-number: QTBUG-115110 Change-Id: I6de634ee45e13aefd069677c4bf75020875e09fa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Allow creation of actual QVariantMaps from object literalsUlf Hermann2023-08-253-0/+27
| | | | | | | | | | | | | | There are places where we need this: a, If the method in question actually takes a QVariantMap as argument. b, If the resulting value can be shadowed. In that case we expect a QVariant. The engine has to internally convert to the expected type then. Change-Id: Ic5b3faab4578d64ca757de644fe69660fd70e52a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QmlCompiler: Allow coercing date values to numbersUlf Hermann2023-08-251-0/+10
| | | | | | | | | This is the equivalent of JavaScript's valueOf(). Change-Id: If850519d6dbc7354b447acb6aad8ac04211d059d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QmlCompiler: Allow setting values in sequencesUlf Hermann2023-08-251-0/+6
| | | | | | | | | | Since we have write-back available now, this is not difficult anymore. This does not yet cover setting properties of value type objects stored in sequences such as "a[i].b = c". You can only set the whole element. Task-number: QTBUG-116011 Change-Id: Id5f7a19125897602880e573d5f25b025f9b91f34 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QmlCompiler: Allow write-back to members of objectsUlf Hermann2023-08-245-7/+72
| | | | | | | | | | This covers recursive write-back, but not write-back to members of singletons or attached types, write-back of lists. Task-number: QTBUG-116011 Change-Id: I6d33fae3bf9fdaed8d696a708124e0a707ecb07e Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Fix conversion from/to voidUlf Hermann2023-08-232-0/+11
| | | | | | | | | | | We can convert everything to void, but we can only convert from void if the result is either void or the invalid type. Pick-to: 6.6 Fixes: QTBUG-116088 Change-Id: I532055405865c5b1581f79cc5d76c253bce6138d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QmlCompiler: Stabilize testUlf Hermann2023-08-222-0/+19
| | | | | | | | | | | | Loading the implicit import might add extra types that use up indices. So, make sure the implicit import has already been loaded at that point. Use a file that only has one type reference so that the ordering of type references cannot mess up the selection of indices for types. Change-Id: Ia33979e660e114ef608e1f5e22252c822c7f3d61 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QmlCompiler: Allow construction of Array objectsUlf Hermann2023-08-222-0/+12
| | | | | | | | | | Currently, only the constructor form of the Array function is compiled. We only compile construction of Array objects if we can determine that they are immediately assigned to a typed list. Consequently, we don't have to deal with sparse arrays. Change-Id: I2abd15139eb9a0d530ad49df7313b8dba415ae77 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Allow construction of Date objectsUlf Hermann2023-08-182-0/+21
| | | | | | | | | We map Date to QDateTime and special-case its constructors. Task-number: QTBUG-111624 Change-Id: I0496f853613da3ccee9b6f6c4cf0adffa064f9f8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Replace signal name manipulations with QQmlSignalNamesSami Shalayel2023-08-152-0/+4
| | | | | | | | | | | | | | | Remove custom implementations found in qqmljs* and use the static helper methods from qqmlsignalnames_p.h instead. This sometimes requires to move some code around to avoid bugs with property that do not have letters in their name. Add a warning in the JS implementation of the SignalSpy.qml that the used heuristic might fail on certain signal names. Add tests in in tst_qqmllanguage to see if the property change handlers work correctly for weird names. Change-Id: I4dc73c34df7f77f529511fa04ab5fcc5385b59fc Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Fix SetLookup on shadowable propertiesUlf Hermann2023-08-082-0/+9
| | | | | | | | | | | | | | | | | | | | | If we are procedurally setting a shadowable property, the read register for the value will be converted to var. We can therefore not just retrieve the property type again in the code generator to determine what we have to do. What we actually need is the information on the original scope type of the lookup. We need to know what exactly the base type was supposed to be. To that effect, store the scope of the target for each conversion in QQmlJSRegisterContent. We need to circumvent the questionable optimization of "deduplicating" functions that certain compilers exhibit, like we do for the getters. Pick-to: 6.6 Fixes: QTBUG-115526 Change-Id: I361f2e46e39ece7892df72ae13ec756f9aec4adf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Compiler: Separate function prolog block and add validation of blocksOlivier De Cannière2023-08-043-9/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function prolog logic is now separated in its own basic block. The first "real" block with user code starts at offset 0. Having the function prolog as a hidden part of the first block caused some inconsistencies in block generation and would create empty blocks. This happened for example when a back edge of a loop would target offset 0 in code where a loop condition is the very first set of instructions that are run. This is because the target block offset didn't exist due to it being part of the hidden prolog block. Validation for the basic blocks was also added. This checks for three things at the moment: 1. That return and throw blocks don't have jump targets. 2. That the basic blocks graph is connected. 3. That jump targets are the first offset of a block. Test tst_QmlCppCodegen::basicBlocksWithBackJump_infinite() is expected to fail because it contains an infinite loop and the basic blocks that are generated for it are inconsistent due to dead-code elimination happening earlier in compilation. Debug outputs for dumping basic blocks were also adapted to reflect these changes. Change-Id: I513f73856412d488d443c2b47a052b0023d45496 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>