aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4stringobject.cpp
Commit message (Collapse)AuthorAgeFilesLines
* CRA review qml/jsruntimeFabian Kosmale2025-09-161-0/+1
| | | | | | | | | | | | | | | | | | This relies heavily on the documented fact that we only support trusted QML/JS content, meaning most files are only significant, not critical. This also extends to the handling of qmlc files (as in compilationunitmapper), as we store them in a user owned, non-shared cache directory – so any vulnerability there would already mean that an attacker has write-priviledges on user data. An exception is ArrayBuffer, which can be used with arbitrary user data, and should create a valid QBA. Fixes: QTBUG-136970 Pick-to: 6.10 6.9 6.8 QUIP: 23 Change-Id: I22033fe6ab4acf8362a8183e25b92331d45cb32c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Harden namespacingTim Blechmann2025-08-081-1/+2
| | | | | | | | | | | | | | | When using namespaced Qt, we need to prevent symbol clashes with symbols of the same name. * namespace some publicly visible classes * hide classes in implementation in an anonymous namespace * rename read/write to readValue/writeValue to avoid name clash with c functions. Task-number: QTBUG-138543 Pick-to: 6.10 Change-Id: Ica77462c1f81f1e01cc60477e5b56ecfe3c1abb4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Reduce access to uninitialized scoped allocationsLuca Di Sera2025-07-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `Scope` provides a mean of performing uninitialized scoped allocations on the JS stack. This can generally be unsafe as this form of allocation temporarily leaves an element representing garbage memory on the JS stack, which could be accessed by other parts of the program. Indeed, a set of bugs related to this kind of behavior was recently solved. Hence, to reduce the surface of those kind of bugs, the usages of uninitialized scoped allocations were reduced to a minimum. The solution to the recent set of bugs related to uninitialized scoped allocations introduced a series of `construct` methods that ensure that the uninitialized allocation and the initialization of the allocated elements are performed as a single step of computation, reducing the surface for incorrect usages of those kind of allocations. The solution was expanded by the introduction of new `construct` methods that cover initialization from other types and some different means of initialization that were used around the code-base to work with uninitialized scoped allocations. Similarly, the various allocation methods in `Scope` were subsumed by the new `construct` methods, with the only remaining means of allocation being the uninitialized one that is used as a building block for the `construct` methods. In particular, `Scope` provided three forms of allocation under the various `alloc` methods. The aforementioned uninitialized allocation and an allocation that performed initialization to either the Undefined or the Empty value. The latter two forms of allocation were converted to forms of `construct`. Since they directly map to the same concept of allocation plus initialization, the conversion avoids having two names for the same concept. More specifically, the form of allocation that initialized to the Undefined value was converted to the new `constructUndefined` which keeps the same behavior. The different naming from the basic `construct` methods is justified by the different interface, which doesn't require choosing a initial value, and the different implementation which is built on the more general `construct` methods rather than the lower level allocation routines. The form of allocation that initialized to the Empty value was removed as it was found to be unused in the code-base. The converted allocation methods generally provides the same interface and behavior with the exception of always requiring the user to specify the amount of allocate objects. This is a change compared to the previous interface which allowed a zero-argument version that allocated a single element. The writer of the patch considered the additional terseness inconsequential compared to the required additional code so that the possibility was not preserved. The code related to the converted allocation forms was removed as a consequence of the conversion. The remaining uninitialized allocation form was made private, to avoid general usage outside of `Scope`, and favoring usages of the substitute `construct` methods. A comment that was related to usages of uninitialized scoped allocations was moved to the lower level `jsAlloca`, which forms the basis for those allocations and creates the abovementioned issues, where it was expanded upon. Usages of the non-uninitialized allocation forms around the code-base were modified to use the new `constructUndefined` method. Most usages of the uninitialized allocation form were modified to use the new `construct` methods that were added to replace them. Exceptions were made for those cases where the initialization routine is either very complex or depends on details that shouldn't belong to `Scope` such that they cannot be trivially encapsulated in a `construct` method. Instead, the relevant function or object was friended by `Scope` to allow accesses to the now private form of allocation. Those usages were previously checked and are supposed to be safe but should be scrutinized if they are modified or the code around them is modified. One of the friended functions, `callDatafromJs`, previously offered a default argument that was not made use of in the code-base. The default value for the argument was removed to simplify friending the function, considering the difficulty the language has with friended function with default arguments and considering that it would have required the default value to be moved out of the function definition into a forward declaration in the unrelated header that defines `Scope`. It is expected that the changes will reduce the surface of usage of uninitialized scoped allocations in favor of a slightly safer approach, make the issue that those usages can produce more apparent and generally centralize the usages as much as possible to make them easier to evaluate and keep track of. Change-Id: I351329f2c139201e0728791df6da297698170f55 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QtQml: Re-fix regular expressions with multiple matchesUlf Hermann2024-12-111-1/+8
| | | | | | | | | | | | | We should only bump the previous match if it was of size 0. Otherwise oldSize + 1 is already one-past-end. Amends commit 9d9413f3d3983b1d24fd878da14eed153e83cbaa. Pick-to: 6.9 6.8 6.5 Fixes: QTBUG-132050 Change-Id: I5d6e85143723a2695c639109b68ee8df7d0fef50 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: <carl@carlschwan.eu>
* V4: make JS functions toLocale{Lower,Upper}Case aware of the localeJohnny Jazeix2024-11-221-2/+54
| | | | | | | | | We now call the toUpper/toLower function for the correct locale. It fixes the case of the Turkish uppercase i is İ not I. Fixes: QTBUG-112898 Change-Id: Ibd0174656e0aa561747490f3e6d52c639bd06b63 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Fix regular expressions with multiple matchesUlf Hermann2024-11-141-1/+1
| | | | | | | | | | We have to match the next capture one character past the last one, not at the same place. Otherwise we match the same thing again. Pick-to: 6.8 6.5 Fixes: QTBUG-130974 Change-Id: Ifc1cf7c95c7777ba7140f141b26455e155db73db Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QJSEngine: Treat empty string literals as non-null, empty QStringsLuca Di Sera2024-06-281-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* V4: Slim down FunctionObjectUlf Hermann2024-05-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most FunctionObjects do not actually need their custom jsCall members. They will only call the functions from the vtable anyway. FunctionObject can therefore be split into a static and a dynamic variant. Only the dyanmic variant needs to carry (and invoke) the extra pointer. The jsCallWithMetaTypes pointer is completely pointless because none of the dynamic functions actually implement it. Furthermore, the QV4::Function and QV4::ExecutionContext pointers in FunctionObject are only needed by actual JavaScript functions. The builtins that like to be dynamic functions never need them. Therefore, split out another class for this. In the generic FunctionObject, we need the capability to decide at run time whether the function shall be a constructor or not. Add a flag to replace the check for jsCallAsConstructor. Also, where we can, avoid the pessimization of checking whether a function is a constructor before trying to call it as constructor. Rather have the default implementation throw the exception. As a side effect, for most functions we don't need an ExecutionContext anymore. The engine is enough. Task-number: QTBUG-124662 Change-Id: Iac657fa71288dd6ec230a33de2986ba3bcf4628c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qml: replace fromLatin with _L1Anton Kudryavtsev2023-09-151-2/+3
| | | | | | | to improve readability and reduce allocations Change-Id: I1ffe10d6a14fb9cc09dd438cca84f4a1d74b8cb8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-10-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that on() was replaced with a matcher that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-29/+29
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Remove unused includes in qml, final partSemih Yavuz2022-09-141-1/+1
| | | | | | | | | | | | | | Drop unnecessary includes detected by clangd-iwyu. Add new includes due to the transitive includes. Also, some of the includes were detected as unused even if they were actually in use. In those cases, use angular brackets instead of "" which deceives the tool not to complain. Affected subfolders: JsRuntime, Qml Fixes: QTBUG-106473 Change-Id: I483da15d42a8e3ce6cd3b654909665fff3075d6b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Fix index calculations in String prototypeUlf Hermann2022-08-311-17/+17
| | | | | | | | | We generally have to do those calculations in double as we must not collapse inf into 0. Task-number: QTBUG-100242 Change-Id: Iaf8082160a1ab25060c131ee1a5fa259bbd31214 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Replace all includes of windows.h with qt_windows.hUlf Hermann2021-10-251-1/+1
| | | | | | | We don't want min and max to be macros. Change-Id: Ifa79eaecf00c9f8b9c61494aa9d883eebfdabc65 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use QV4::Scope::hasException() where applicableUlf Hermann2021-06-301-4/+4
| | | | | | | It is shorter and encapsulates the exception handling a bit. Change-Id: I8e2dc0eb3b930e222b8cb4852b73d99ca18a0379 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QV4 Engine: Remove MSVC special casingFabian Kosmale2020-12-101-2/+2
| | | | | | | | | | This patch removes a workaround for old versions of MSVC; we should be able to rely on the standard library nowadays. Original-patch-by: Alexander Neumann Fixes: QTBUG-89203 Change-Id: I8047565000fc7e4e3b8ac28584ff4a479b648274 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* V4 string object: Avoid some compile warningsUlf Hermann2020-11-091-2/+2
| | | | | | | | Assigning a plain char to QChar is deprecated. What we want here is the special Null character, though. Change-Id: I0f3cd56c8820fdf5afa40cf608e738e04163680a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qtdeclarative: finish fixing compilation with explicit QChar(int)David Faure2020-11-071-3/+3
| | | | | Change-Id: Idb26e2df6d4fe8940db57066a30fa8c243f6d2c9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Do not write the 0 terminator for QStringLars Knoll2020-09-151-2/+0
| | | | | | | | | | | | | QString does this for us in any case, and writing there was always undefined behavior. This is causing problems after an optimization in QString, where creating a QString with size 0 will avoid any memory allocation and simply point to the (readonly) _empty member in QString. Change-Id: I0516dc2e8672b8290efa891bd9b5486dac8021b6 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Port QtDeclarative from QStringRef to QStringViewKarsten Heimrich2020-06-161-8/+8
| | | | | | | | Task-number: QTBUG-84319 Change-Id: I2dcfb8a2db98282c7a1acdad1e6f4f949f26df15 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Check in even more places for exceptionsFabian Kosmale2020-04-211-1/+2
| | | | | | | | | Amends commit 4c5ed04e64ea9ac0038ae30e1189cfe745b29bd9 Task-number: QTBUG-83384 Pick-to: 5.15 5.12 Change-Id: I0918c27dfa73dff83cbf0f58b41ce8620dff8a0a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* V4: Check for exceptions before we use the result of a JS callUlf Hermann2020-01-231-1/+1
| | | | | | | | If the call resulted in an exception the return value is undefined. Task-number: QTBUG-81581 Change-Id: Ibfdd5e1229cf5437f270232d3b1a91308adeec72 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Split compiler and runtime more clearlyUlf Hermann2019-07-111-1/+1
| | | | | | | | Provide different export macros and different top level headers for each, don't include runtime headers from compiler sources. Change-Id: I7dc3f8c95839a00a871ba045ec65af87123154be Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-04-181-2/+1
|\ | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlimport.cpp Change-Id: I6add6267297ea50a646d43d212027a168dca8916
| * Fix string replacement with invalid capturesUlf Hermann2019-04-151-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | If we have a theoretically valid capture reference that just didn't capture anything in this match, we don't want to treat it as literal. Only capture references that clearly are outside the range of things we can possibly capture with this expression should be treated as literal strings. Change-Id: Iab0bf329d11a6b9e172aa662f11751d86cfc26a6 Fixes: QTBUG-75121 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Don't use UINT_MAX as invalid array index in PropertyKeyUlf Hermann2019-04-161-7/+8
|/ | | | | | | | | | | Technically UINT_MAX is actually a valid array index, although that is an academic problem right now. However, we do have a method isArrayIndex() and should just use that to determine if a PropertyKey is an array index. Fixes: QTBUG-73893 Change-Id: I302e7894331ed2ab4717f7d8d6cc7d8974dabb4e Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Don't keep raw pointers to SparseArrayNodeUlf Hermann2019-03-141-1/+1
| | | | | | | | | | | | The nodes are owned by the SparseArrayData and will be freed whenever an item is deleted from the array. Therefore, we have to look up the node for each iteration. This is slightly slower, but at least it doesn't crash. Fixes: QTBUG-74188 Change-Id: Id24324a8c83b00b3ad1212cdaabccabd6c8a999f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Bring behavior of String.replace() in line with other enginesLars Knoll2019-01-251-14/+25
| | | | | | | | | | | | | | | | "x".replace("x", "$1") gives "$1" in both JSC and V8, as there are no captures that could be used as a replacement for $1. Implement the same behavior as it's the most logical thing to do (even though it's undefined according to the spec). Two digit captures ($nm) work in a way that they get applied if $nm captures exist. If there are less than nm but more than n captures available $n is replaced by the n'th capture and m is copied over verbatim. Change-Id: I8b5f576f2c42c8334859ab7854dcdf07104dd35b Fixes: QTBUG-73152 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Ensure our builtin constructors are subclassableLars Knoll2018-11-221-2/+8
| | | | | | | | | Respect the newTarget passed into those constructors and make sure we set up the proto chain correctly. Change-Id: I3d12c7dbef4b33660a6715d73e9fb0f89105167a Fixes: QTBUG-71138 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* INTEGRITY: Fix build failures on 64-bit ARMPasi Petäjäjärvi2018-10-221-2/+2
| | | | | Change-Id: I44a90dec16dc1421a32a7770b353a4df14c057f9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Make Object::getOwnProperty() constLars Knoll2018-09-231-3/+3
| | | | | | | | Object::getOwnProperty never modifies the object, so make it a const member function. Change-Id: I175bb45d61a66a1d9f577c087129562d44d62e17 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-22/+22
| | | | | | | | | | | | Get rid of Primitive and move the corresponding methods directly into Value. Mark many methods in Value as constexpr and turn Value into a POD type again. Keep Primitive as a pure alias to Value for source compatibility of other modules that might be using it. Change-Id: Icb47458947dd3482c8852e95782123ea4346f5ec Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix ownKey iteration over Proxy objectsLars Knoll2018-09-091-1/+2
| | | | | Change-Id: I045a4844c06df9232cc8b04485ab0a39bb990e3f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix some details in RegExp handlingLars Knoll2018-08-151-1/+4
| | | | | Change-Id: If9f7c07ea657ba8503b9188a7b77e301f23423ef Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement String.prototype.match as per ES7 specLars Knoll2018-08-151-29/+17
| | | | | | | The implementation is supposed to call arg[Symbol.match]. Change-Id: Ia8028d259e152b1e65eb6b0e817ef60bdc0d37e2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement String.rawLars Knoll2018-08-061-0/+42
| | | | | Change-Id: I331fd4d114f68fb5cb71186813f851af25539ffa Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement ObjectIterator using the new iteration mechanismLars Knoll2018-08-021-29/+0
| | | | | | | And with that get rid of the old advanceIterator methods. Change-Id: I969fa89d25df8992a4b08c8c081b91c92ffdfddd Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Introduce a new mechanism to iterate over object propertiesLars Knoll2018-08-021-11/+45
| | | | | | | | | | | | | | | | | The old advanceIterator schema was extremely ugly and in addition not flexible enough to support the requirements for Proxy.ownKeys and some of the methods in Object Implemented a new scheme through a OwnPropertyKeys method in the Object VTable that creates and returns an iterator object. Ported QJSValueIterator and for-in to use the new mechanism. There's still many places where we use the old ObjectIterator (that relies on advanceIterator). Those will be ported in subsequent commits. Change-Id: I091a9bea9ff6b2b63630cc336814700757a718be Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement support for new.targetLars Knoll2018-07-031-2/+2
| | | | | | | | | Support the new.target meta property in the codegen, and add support for passing the newtarget into the constructor vtable methods and the execution context. Change-Id: I62ea58e5e92d894035a76e35776203e9837c383b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Prefix vtable methods with virtualLars Knoll2018-07-031-9/+9
| | | | | | | | | Turns out that the overloading of vtable methods and regular ones is problematic in some cases. So let's rather make it explicit which methods are part of the vtable, and which aren't. Change-Id: Ifee32a26104d30f3c82bca8b5a9cdea2d4f4f526 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Replace Identifier by PropertyKeyLars Knoll2018-07-021-3/+3
| | | | | | | | Change all uses of Identifier to use the new PropertyKey class and get rid of Identifier. Change-Id: Ib7e83b06a3c923235e145b6e083fe980dc240452 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify deleteProperty and deleteIndexedProperty vtable methodsLars Knoll2018-06-261-9/+9
| | | | | Change-Id: I25245818c6ff2104642594476cb9684bac824f29 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move special handling of getOwnProperty for StringObject where it belongsLars Knoll2018-06-261-0/+20
| | | | | | | | Move the code into a virtual method of StringObject, bringing us closer in line with the ES7 spec. Change-Id: Iaf460f5a5517fe059a30be8c403d71625453b80a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix length properties of global constructorsLars Knoll2018-06-251-1/+1
| | | | | Change-Id: I4e9e1635f404082b0e8b333dc13a33d27e4f4b50 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement a virtual interface for getOwnPropertyLars Knoll2018-06-251-2/+1
| | | | | | | | | | | | This is required to support Proxy properly, and at the same time fixes a couple of test failures. The new interface also replaces the old query and queryIndexed virtual interfaces, as those where doing a subset of what getOwnProperty does. Change-Id: I750e366b475ce971d6d9edf35fa17b7a2b07f771 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement String.prototype.padEnd/padStartLars Knoll2018-05-231-0/+84
| | | | | Change-Id: I3ff082fd2d7764f87dd079901750fe668f553521 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement String.prototype.normalizeLars Knoll2018-05-231-0/+28
| | | | | Change-Id: Ic018606ddb92772705bbb06aaed07722827737ea Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement String.fromCodePointLars Knoll2018-05-151-12/+42
| | | | | | | And add a zero termination in String.fromCharCode. Change-Id: Id86b9e35bfbf2e41f3a461d7b8f4c108df30f741 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement String.prototype.codePointAtLars Knoll2018-05-151-0/+24
| | | | | Change-Id: I30f19d750ee4cde767912c87bbc53d3abc0f6bb5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>