aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/common
Commit message (Collapse)AuthorAgeFilesLines
* QV4: Mark CompilationUnit::saveToDisk constOlivier De Cannière11 days2-2/+2
| | | | | Change-Id: I6141df5776471aea755d0b57b2015571b250088a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Qml IR: add support for virtual and override keywordsDmitrii Akshintsev2025-12-041-8/+44
| | | | | | | | | | | | | | | This patch adds two new fields, IsVirtual and IsOverride, to CompiledData::Property. These fields will later be used to populate QQmlPropertyData and to handle property override semantics. At a high level, this change focuses on the data flow from the AST to the IR, laying the groundwork for future semantic resolution. Also moves test helper Syntax namespace to the quicktestutils Task-number: QTBUG-98320 Change-Id: Ic2a2e28df08d53c8752c49304bd5f7ff46916d08 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QV4: Hotfix bump QV4_DATA_STRUCTURE_VERSION to invalidate broken cacheOlivier De Cannière2025-11-261-1/+1
| | | | | | | Task-number: QTBUG-142186 Pick-to: 6.10 Change-Id: I07228c1ddd9196532886ad3b39751d525c525432 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* CRA review: mark qml/common subfolderFabian Kosmale2025-11-1015-0/+15
| | | | | | | | | | | | | | | | Give most things default significance, except for qjsnumbercoercion.cpp which only contains documentation and qv4compileddata.cpp which gets flagged as critical for being a data-parser. That's somewhat debatable, given that we also excepect qmlc files to be as trustworthy as qml files, but while that is not explicitly stated anywhere we might want to err on the side of caution. Pick-to: 6.10 6.8 Task-number: QTBUG-136194 QUIP: 23 Change-Id: I2987cea2453dcc3b828dc4ecf0ad22fdfd0d1000 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Be explicit about type-conversion for QString::args()Edward Welbourne2025-10-081-1/+1
| | | | | | | | | | | | | | | | Passing a quint32_le depended on a type conversion that might not be obvious to the reader. That's going to stop working when QString::arg() gets finnickier about which overloads get coerced to integral types, to avoid problems with types that convert fo floating-point but aren't recognised by the compiler *as* floating-point, so were otherwise being cast via integral types and losing precision. Pick-to: 6.10 Task-number: QTBUG-138471 Change-Id: I9b4df08159502c9109fa8489b2290e213bcff2b8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlPropertyCacheCreator: decouple resolution of property type and flagsDmitrii Akshintsev2025-09-171-1/+1
| | | | | | | | | | | | | | | This patch aims to improve readability and maintainability of the logic for deriving property type and flags before adding it to cache. Now resolution of the type happens in one place and derivation of flags in another one. This not only improves separation of concerns, but also makes the dependency between attributes and type more explicit and hopefully easier to follow. Task-number: QTBUG-98320 Change-Id: I64424e959ee11aa5c9a90c8e9fd2ca1347715342 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QtQml: Only hold CU in ResolvedTypeReference where neededUlf Hermann2025-06-071-4/+1
| | | | | | | | | | | | | | | The only place that actually needs the compilation unit is the object creator. The object creator will only touch type references we need to create objects from. For everything else, the property cache and the QQmlType are good enough. Therefore, always store property cache and QQmlType in a uniform way. In turn drop the CU where we can. Task-number: QTBUG-135286 Change-Id: I1dfac132a1580679b165c2f891a8d9439fa14d1e Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Do not store type references for propertiesUlf Hermann2025-06-061-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows a type A to have a property of type B while B also has a property of type A. This is very helpful for list-like or otherwise linked data structures. For example the BaseConstraint type in the DeltaBlue benchmark wouldn't have been necessary if this feature had been available before. It has the side effect of making it impossible to validate inline component types before they're instantiated. We don't actually have the type at the point where a property is declared. However, since you certainly want to instantiate at some point and qmllint will still help you find the problem, this is acceptable. We also have to intercept URLs before we create QQmlType instances now. This is because now we only have the URLs to identify types. Having multiple QQmlType instances referring to the same logical type wsd a bad idea anyway. [ChangeLog][QtQml] You can now have cyclic type references in QML documents. A QML type A can have a property of type B while B has a property of type A. You can still not cyclically inherit or instantiate types in QML documents, of course [ChangeLog][QtQml] Your URL interceptors may get called more often now, for URLs QML neglected to intercept before. This means that more URLs may be constructed from already-intercepted base URLs. URL interceptors should check for this condition. Change-Id: I84753a883c2de98e16d1c3826e7e56e897eeafb8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Guard against missing root property cachesUlf Hermann2025-05-221-1/+3
| | | | | | | | | | | | | | A compilation unit can be created from a script, in which case there is no property cache. We shouldn't crash then. Amends commit c1bd8ee91fd1462235d4bccbcf5286864d0fcbf7 Pick-to: 6.9 6.8 Fixes: QTBUG-137072 Change-Id: Ic10dfd7a640067639894f885496dfa13719b4bf5 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Waqar Ahmed <waqar.ahmed@kdab.com>
* QtQml: Remove object/binding/parser status counts from CUsUlf Hermann2025-05-202-136/+2
| | | | | | | | | | | | | | Calculating those is a rather complex affair, and unlikely to pay off. Previously they were used to pre-allocate space in the object creator. We use standard containers with standard allocation strategies everywhere else. If this turns out to be an actual problem, we could record the actual numbers when we create a component and record those in the ExecutableCompilationUnit for next time. Task-number: QTBUG-135286 Change-Id: Ia44bbc9c49cbfb638f5d4bbbb345c48124e4fb09 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Revert "QtQml: Remove dependency hashing"Ulf Hermann2025-05-152-2/+47
| | | | | | | | | | | This reverts commit 18c421fe6159dc921643c72ae335cf189eb1cc3a. Removing the dependency hashing is not safe because there are various other bits covered by it, not only the alias target IDs. Task-number: QTBUG-136806 Change-Id: I4a8a57d810203a47945ce67916ee5b54ee7a603d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Remove dependency hashingUlf Hermann2025-05-132-47/+2
| | | | | | | | | Since we don't store any property indices in the compilation units anymore, we don't need to hash the dependencies anymore. Task-number: QTBUG-135286 Change-Id: I2ea05c920475749f2a2d6cf309d0956a74d6c688 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Do not store property indices in aliasesUlf Hermann2025-05-131-10/+3
| | | | | | | | | | | | | | | | We shouldn't store property indices in the compilation units. That makes the system brittle and vulnerable to changes in unrelated code. Rather, we should always resolve aliases from names at run time. We can store the alias target property indices in the property caches. That's where they belong. This means we need to add the alias properties to the property cache right when we resolve the aliases since we can't communicate the property indices back anymore. Task-number: QTBUG-135286 Change-Id: I1d25f66ee06cff3fdf958f766c62cb99a30f6720 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlTranslation: fix build errorZhao Yuhang2025-04-291-2/+2
| | | | | | | | | | There will be compilation errors if QByteArray's implicit conversion to const char* is disabled (which is possible in some user configurations). Just convert QByteArray to const char* manually, don't rely on such implicit conversions. Change-Id: I7b68066bc82a0a64f38ad8f9903d06ffe4bb0754 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Dissolve qqmltranslation.cppUlf Hermann2025-04-112-157/+76
| | | | | | | | | We don't want to export those symbols from QtQml. Move the code that's exclusive to the debug service into the debug service and the code exclusive to qmltc into qmltc. The remaining code can be inline. Change-Id: Icf146af8d4e5931b7ac7bac61a5ba94449ca9402 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QtQml: Drop checks for compile hash and Qt version from the CUsUlf Hermann2025-03-182-43/+5
| | | | | | | | | | | | | | | The data structure version is supposed to encode any incompatible changes to our compilation unit format. Checking the compile hash and Qt version in addition is redundant and excessively restrictive. [ChangeLog][QtQml] You can now use QML code compiled with Qt Quick Compiler across Qt versions as long as the compilation unit format hasn't changed between those versions. You cannot rely on the compilation unit format to stay unchanged under any specific circumstances. However, we won't change it unnecessarily. Change-Id: I8c407b505ac7fa952f53fa25bb6d4e7caf0fba0c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Add final property attributeOlivier De Cannière2025-03-061-5/+8
| | | | | | | | | This works the same as the FINAL attribute to Q_PROPERTY. Task-number: QTBUG-98320 Change-Id: Icc2cf1afb5354fd711770f7147ded853b74cd1da Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QV4: Reserve a bit in CompiledData::PropertyOlivier De Cannière2025-03-061-3/+8
| | | | | | | | | | | | The bit is taken from nameIndex. It should have more than enough capacity with 31 bits. The reserved bit will be used as a flag in subsequent commits. A more typed and centrally enforced aproach to the indexes will be necessary in the future. Change-Id: Ia7c686affba6d5320e674dd3f32b7c59b6321e22 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Always load from existing compilation units firstUlf Hermann2025-03-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | If a compilation unit for the given URL already exists in the type registry, we can safely use it since anything in the type registry is shareable. An exception to this are requests with explicit inline source code. Those cannot be cached at all. Conversely, if we were to re-compile, that's not only wasteful but we may end up with diverging type hierarchies and mismatched types. Revert commit d0e16e3f614d73f6694863d2cfb1fbd661c34e3f since it has become counter-productive now. We really want to have exactly one base compilation unit for each type, and that should be universally accessible. When d0e16e3f614d73f6694863d2cfb1fbd661c34e3f was written we had separate base CUs for each engine, and we didn't want those to accidentally find each other. Realize that composite types have to be indexed by url(), not finalUrl(), since url() includes any file selectors while finalUrl() does not. Fixes: QTBUG-134398 Pick-to: 6.9.0 6.9 6.8 6.8.3 Change-Id: I130cdc27ebd8a2814e194478a27eef5bb7f79eb7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Round towards 0 when coercing to 64bit integersUlf Hermann2024-12-203-5/+20
| | | | | | | | | | The regular int32 coercion doesn't apply here. We have our own logic for this case. Pick-to: 6.9 6.8 Task-number: QTBUG-132345 Change-Id: I96596567ce83fcaa714c8372171261e8dd876480 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Add missing begin/end namespace to qqmltranslation.cppUlf Hermann2024-12-121-0/+4
| | | | | | | | Amends commit e9dc0ac68134bc6a9cc6522eaca6d893ee10b86d Pick-to: 6.9 6.8 6.5 Change-Id: I4c28e1e6dc6716454f5d973c36960ef360f8fb40 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QtQml: Add some consistency to QV4::RegExpUlf Hermann2024-12-123-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The RegExp JIT should behave the same as the V4 JIT. In particular, it should honor the same JIT call threshold and not second guess any manually set thresholds. To do this we need to store the match count in 32 bits. In turn we can store the 5 flags we may have in 8 bits. To make this safe, pass typed flags to the initialization functions. Also, consider the flags when calculating hash values. Finally, in the init() function, we don't need to initialize members to zero, since that is already guaranteed by the memory manager. And we can delete the flagsAsString() method since it's unused. This requires shuffling some #includes into the places where they actually belong. [ChangeLog][QtQml] The JavaScript regular expression engine now honors QV4_JIT_CALL_THRESHOLD for its own JIT. If QV4_JIT_CALL_THRESHOLD is not set, it uses the JIT after 3 interpreted matches for any regular expression, rather than the previous 5. Matching a regular expression on a string longer than 1024 bytes counts as 3 matches. This is to retain the default behavior of JIT'ing regular expressions right away when encountering long strings. Task-number: QTBUG-131957 Change-Id: I269ccea55d34b191ef18d7cd5fccd4cad8aec7cd Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move inlineComponentName from CU to ObjectCreatorFabian Kosmale2024-12-042-41/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | A (base) compilation unit should ideally be immutable, as we otherwise open a can of worms when it comes to cross-thread usage of CUs. However, so far, we've been using a mutable inlineComponentName member of the compilation unit to select whether the root component of a CU should be constructed, or one of its inline components. This patch change prepares for making the CU immutable, by moving the inline component name tracking into the ObjectCreator itself, requiring that the name gets passed into its constructor – or that an empty string gets passed in case of the main component. The resulting refactoring makes it apparent that deferred properties did not handle inline components at all. Support for them gets added by also storing the inline component name inside of DeferredData, and passing it along when needed. A test case which verifies that deferred properties are now fixed is added as a follow-up commit. Besides the core engine, we also need to adjust qmltc which also generates code to handle deferred properties. Consequently, we also need to pass the inline component name along in the qmltc generated code. Task-number: QTBUG-131442 Pick-to: 6.5 6.8 Change-Id: Ide9bc98223c01225b954662b3f4989bbbfda7672 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Require VME MetaObjects for types with inline componentsUlf Hermann2024-11-261-0/+1
| | | | | | | | | | We need to be able to look them up in the type registry in order to locate the inline components. Pick-to: 6.8 Fixes: QTBUG-131394 Change-Id: I86a615ffab1ffcc1262ca0f282ad4893366d4654 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* SourceLocation: deduplicate row/column - offset mapping logicSami Shalayel2024-11-081-21/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the logic that maps rows and columns to offsets (and backwards) to SourceLocation static helper methods, and reuse them in qmllsutils.cpp. This avoids the code duplication that happened in SourceLocation's endZeroLengthLocation(). Also fix a bug where \r\n was confused with \n\r: \r\n is a windows newline and counts as 1 instead of 2 newlines. Fix a test that was confusing '\n\r' and `\r\n` (as the implementation in qqmllsutils was buggy) and add two tests to avoid miscounting newlines again. Change textOffsetFrom() and textRowAndColumnFrom() in QQmlLSUtils to use the implementation in SourceLocation and adapt the indexes (one starts at 0 while the other one starts at 1). Fix some tests in tst_qmlls_utils that were testing weird and invalid edge cases that treats \r like a normal character and \n like a character that can't be returned. Treat both \r and \n like characters whose offset can be returned. Adapt qmlls range formatting to the new behavior of testOffsetFrom() that returns \n instead of \r when asking for the a character behind the end of file. Add tests for files ending without newline and for files with windows newlines. The files with windows newlines has two expected outcomes: the formatted parts has \r\n newlines on windows and \n newlines otherwise. Pick-to: 6.8 Change-Id: I0ef42c1fc7073eb5fe25ceb893a5d24e976e45fc Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
* qqmljssourcelocation: fix wrong asserts on 32 bit systemsSami Shalayel2024-10-311-8/+8
| | | | | | | | | | | | | | | | | | | | | | Replace the asserts comparing 0-based offsets and 1-based columns and lines: the first character of a file has offset 0 but line and column 1, so the current assert is always false. Also, the assert tests an assumption which does not hold: for example the DOM formatting code works with "local" sourcelocation that has "local" offsets but global line and column number. Instead, use a more relaxed check and make sure that line and column are in-bounds. Also, the members of SourceLocation are not protected with setters, so anyone can write anything there anyway. Amends 4baa3b7c5b5f6a2e89f701651e6240e2a17cc38b that introduced the assert and expected the CI to complain on them. Change-Id: I330b9542e1b123bc3df401414d1c9a22504ba01b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Explicitly byte-swap on big endian when building strings from CUUlf Hermann2024-10-201-1/+1
| | | | | | | | | | Commit 9ef4c123c39c642357c9e8530d59f32f220a7824 in qtbase made the implicit conversions to QChar through one of the integer types invalid. quint16_le can cast to quint16 (at a cost) but isn't quint16. Doing an explicit casting is required now. Change-Id: I88fdff5cee3898a3aadd15acd467ac2f3e3da79b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* SourceLocation: make begin() and end() qsizetypeSami Shalayel2024-10-091-5/+6
| | | | | | | | | | | | | Change begin() and end() to return a qsizetype, as now we only process QML files where quint32 can safely be casted to qsizetype. This allows to change all users of begin() and end() to use qsizetype, and to silence all MSVC compile warnings about comparison of ints with different signedness. Fixes: QTBUG-127833 Change-Id: I251435aa598386effe0259549dbe94d17b0d806b Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qml: limit qml file size to 2GB or 4GB in parserSami Shalayel2024-10-091-1/+38
| | | | | | | | | | | | | | | | | | | | | | | | | Add a check in the lexer and fail in the parser if the file to be parsed is too big for qsizetype and quint32. QQmlJS::SourceLocation uses quint32 to save the offset, and code using QQmlJS::SourceLocation's offset usually do their computation on qsizetype. Therefore, limit the QML file size to std::numerical_limits<quint32>::max() on 64 bits machine when qsizetype has a representation for std::numerical_limits<quint32>::max(), and to std::numerical_limits<qsizetype>::max() otherwise. Thats 2Gb on 32 bits machine and 4Gb on 64 bits machine. Currently, using qml tooling on files bigger than the limits mentioned above already leads to UB without this patch. Add a helper to construct SourceLocation from qsizetype indexes. Task-number: QTBUG-127833 Change-Id: Ic255964e13ebae08488ed160e59d504638f1b9ad Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* Compiler: Create infrastructure to support multiple warningsOlivier De Cannière2024-08-211-5/+0
| | | | | | | | | | | | | | | | | Currently only one DiagnosticMessage can be stored at a time when using the compiler. However, we want to be able to show more than one to the user. Therefore, use a list that gets passed inside the compiler instead of a pointer to the sole error. This also means that the error is valid by its very existence. There is no need to check validity explicitly anymore. Task-number: QTBUG-127624 Change-Id: I356db917b86703b508dc1ad52de7825d82eafd71 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QJSEngine: Treat empty string literals as non-null, empty QStringsLuca Di Sera2024-06-281-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When evaluating a script with `QJSEngine` an empty string literal will be treated as a null string. For example evaluating `""` will produce a string-holding `QJSValue` that produces a null `QString` when the string value is extracted. This is in contrast with the general behavior of `QJSValue`, where directly constructing a `QJSValue` from a null or empty `QString` will produce a `QString` value that is empty but not null. When the engine reads the literal from the string table, it specifically returns a null `QString` for zero-sized strings. This null `QString` will then propagate its null-ness when used to allocate a string, which will in turn propagate all the way up to the returned `QJSValue` that holds the produced string. To align the behavior of a string-holding `QJSValue` produced from the engine to the behavior of a `QJSValue` directly built from a `QString`, the specialized code that produced the original null `QString` was removed, so that an empty string is constructed instead. This partially amends ff0857541d5d391c7c03cce5893b41dd9b35e7fa, which introduced the specialized construction of the null string in relation to another issue. The change was already partially amended in 86379e265e19a078545306d93c59b0d92c04920a, where some of the additional behavior introduced by the original patch was rendered unnecessary by changes in Qt itself. The null string behavior for empty literals that was added as part of the original patch was partly tied to the code removed in the first amendment and is not expected to break the original case anymore due to the changes in the context around it. A test case was added to `tst_QJSEngine` to test the behavior. The test case that was originally added in ff0857541d5d391c7c03cce5893b41dd9b35e7fa, which tested that empty string literals were treated as nulls was modified to align to the new behavior of non-null, empty strings. A slight change was made to the implementation for the String prototype `startsWith` method to adapt it to the changes which exposed a previously existing bug. When `startsWith` was given a position as part of its second argument, this would have been retrieved as a double and then directly passed to `QStringView::mid`, producing an implicit conversion to `qsizetype`. For values that `qsizetype` cannot hold, the result can be different between platforms. In particular, this showed on a ecmascript compliancy test that would now fail on ARM mac platforms. The test would pass infinity as the second argument and an empty literal string as the first in a call to `startsWith`, which, by the spec description should return true. In general, on an ARM mac platform, the conversion would saturate to the nearest integer, a positive value. On such a parameter the call to `mid` would return a null string. Due to the way the `startsWith` implementation for `QStringView` works, this would require the searched for string to be null for the search to return true. Previously, due to literal empty strings being read as null, this would silently pass. On the contrary, on a platform such as x86_64, the implicit cast would generally produce the indefinite integer value, which appears as a negative integer, producing the whole original string on a call to mid, which then would have the correct behavior on a call to `QStringView::startsWith` with regards to the test in question, so that it would generally pass. To avoid the platform specific behavior, the position in double form is now clamped between zero and the length of the string that should be searched, which should generally avoid the unexpected behavior and be relatively consistent between platforms. [ChangeLog][QtQml] Assigning an empty JavaScript string to a property of type QString now produces only an empty QString, not a null QString. Fixes: QTBUG-125611 Pick-to: 6.8 Change-Id: Id6850fd98082f33db93d2a7d0bc4f7b5fdcad45b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qv4alloca: replace hand-written wrapper with std::unique_ptrThiago Macieira2024-06-011-15/+4
| | | | | | | | There's no reason to use something different, after all. Change-Id: If3345151ddf84c43a4f1fffd17d1f213310814e8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qv4alloca: don't depend on configure-time checksThiago Macieira2024-06-011-8/+9
| | | | | | | | | | We can just use __has_include and check if the alloca macro is defined (it is a macro everywhere). This is the only use of alloca in Qt, so removing the need for the checks here allows me to remove the checks in qtbase too. Change-Id: If3345151ddf84c43a4f1fffd17d1f1b116d52c4e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Store the sign bit of NaNs in QV4::StaticValueUlf Hermann2024-05-281-2/+2
| | | | | | | | | | | We have a bit for this, which is already used on UMinus. We should also use it when directly encoding a double. This makes some ECMAScript tests pass. Pick-to: 6.7 6.5 Change-Id: Ie90c7ae9ce57064d14db0ed719a08d5858b47cd4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Deprecate coercion on type assertionsUlf Hermann2024-05-241-0/+6
| | | | | | | | | | | | | | | | | | | By using an "as" cast you want to check the type of the value, not coerce it. Previously, however, if you did this with a value type, it would create the value type instead of just checking for it. Add an attribute "Assertable" to the ValueTypeBehavior pragma that prevents this and enables the correct behavior. Also print a warning when coercing as part of an as-cast. [ChangeLog][QtQml] A new attribute "Assertable" has been added to the "ValueTypeBehavior" pragma. You should always use it if you want to type-check value types using "as". If you don't use it, an instance of the type is created as result of the "as" if the type doesn't match. Task-number: QTBUG-124662 Change-Id: I1d5a6ca0a6f97d7d48440330bed1f9f6472198aa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Properly enforce signatures of AOT-compiled functionsUlf Hermann2024-04-261-1/+1
| | | | | | | | | | | | | Pass the metatypes of the contained types rather than the stored types. [ChangeLog][QtQml][Important Behavior Changes] The AOT compiled code for type-annotated JavaScript functions does not let you pass or return values of the wrong type anymore. Fixes: QTBUG-119885 Change-Id: I685d398c0745d32a999a3abd76c622a2c0d6651f Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Consider lengths to be qsizetypeUlf Hermann2024-04-262-5/+30
| | | | | | | | | | | | | | | | | | | | This is what we get as "source material" from all the containers. In JavaScript, arrays sizes are up to 32bit unsigned, but we need to represent -1 in a few places. Therefore, we cannot clamp the result to 32bit signed if the underlying container supports 64bit indices. We can change qjslist.h here because this header is only supposed to be used from generated code. Therefore, if you rebuild any users of this code, you will also re-generate them, adapting to the new API. Since we check for QJSNumberCoercion::isArrayIndex() before we use any number as an array index when generating code, this is actually safe. We just need to adapt isArrayIndex() to consider numbers greater than INT_MAX as possible values. Fixes: QTBUG-122582 Change-Id: I1147978a05bfedb63037c7f4437921f85a6aabb1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Perform return value assignment inside generated codeUlf Hermann2024-04-241-1/+1
| | | | | | | | | | | | This is in preparation for using exact types and actually enforcing them. We shouldn't wrap the return value into a QVariant in order to then painstakingly unwrap it again. The generated code can already do the right thing. Task-number: QTBUG-119885 Change-Id: I13e517967ee982be717024a9abb74d5e02a185d6 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Silence bogus warning on mingwUlf Hermann2024-03-251-0/+7
| | | | | | Change-Id: I51e2f8c7017a4c1c479e95b7fbee9355adb2e5e9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QtQml: Make QLocale an actual value typeUlf Hermann2024-03-021-5/+0
| | | | | | | | | | | | | | | | | | | | We want to be accessible to qmllint and other QML tooling. To this end, make all legal invocations of its methods properly typed invokables. Keep two QQmlV4Function overloads to produce error messages if the methods are called with the wrong parameters. We have to do this because JavaScript is more liberal in its argument coercion than the methods would like. Un-deprecate QJSNumberCoercion::isInteger() since it's actually quite practical here. Pick-to: 6.7 Fixes: QTBUG-112366 Change-Id: I016e5edc47efaade44461c504c1b3e2b1b829b58 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Switch the sticky and unicode regexp flagsUlf Hermann2024-02-151-3/+3
| | | | | | | | | This way they match Yarr's flags, which is generally preferable. Task-number: QTBUG-121509 Change-Id: Ibb3ed8d54c54415435f12bf391daadaa70013017 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QtQml: Re-allow assigning of raw numbers to enum property aliasesUlf Hermann2024-02-011-0/+2
| | | | | | | | | | | This used to work and we cannot just take it away. Amends commit 3ea55bf398412d373daab9c92b1498f45de70e96. Pick-to: 6.7 6.6 6.5 6.2 Fixes: QTBUG-121710 Change-Id: I7f856140286bba9d49b7ed1abfdf398a65fb1962 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move header verification into CompiledData::UnitUlf Hermann2024-01-232-0/+68
| | | | | | | | There is nothing that makes it depend on ExecutableCompilationUnit. Change-Id: I482dfc0177530f748bb90e5373c64ca5558d8629 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Use CompiledData::CompilationUnit in more placesUlf Hermann2024-01-202-0/+140
| | | | | | | | | | We rarely actually need the executable CU, and where we need it, we can dynamically create or retrieve it from the engine. To that end, store all the CUs in the same container in the engine. Change-Id: I0b786048c578ac4f41ae4aee601da850fa400f2e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move the property cache creator interface into the base CUUlf Hermann2024-01-181-1/+46
| | | | | Change-Id: I521b00754593dee600465047b3fe9a57d614bc77 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move dependentScripts into base CUUlf Hermann2024-01-182-0/+4
| | | | | Change-Id: Ia332a691a4a5f04fcca50eb1c3e2018f8368dbe6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move type name cache into base CUUlf Hermann2024-01-182-6/+12
| | | | | Change-Id: Ie3504f16b34859cdef72f8138e6058dcc2d1f58f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move getters for flags into base CUUlf Hermann2024-01-181-0/+45
| | | | | Change-Id: I6bf0bd06e489d07517a9fba6f675c402e9beddbb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move qmlType into base CUUlf Hermann2024-01-182-0/+12
| | | | | Change-Id: I81ae9a4d24518dffc5b924994d45203958bb9546 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move checksum verification into base CUUlf Hermann2024-01-132-0/+17
| | | | | Change-Id: I49d48a7bc38e727bb23f3154311e1f7876f8cc03 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>