aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4objectproto.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-16/+16
| | | | | | | | | | | | 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>
* Include symbols in getOwnPropertyKeysLars Knoll2018-09-091-9/+15
| | | | | | | And fix getOwnPropertySymbols and getOwnPropertyDescriptors. Change-Id: Ie0e4c3d308ffe8a904e9a6ab9242b2cda59d779f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix handling of uninitialized exports when iterating module namespace objectsSimon Hausmann2018-08-291-1/+2
| | | | | | | | | | | | | | | | | | | | We must throw reference errors when the iteration reaches an uninitialized export. As with other module namespace cases we don't know at the call site that we're dealing with this special object, we must throw the reference error inside the iterator. That brings in the additional complexity that we can use the iterator to get a list of all names (should not throw) as well as to retrieve the values (throw on uninit). We make the distinction inside the ::next() function based on whether a Property pointer was provided, which requires slightly different variants inside the ObjectIterator that uses the internal iterator. On the upside this avoids value copying when they would be unused otherwise. Change-Id: Iac45d0ed39bea861ea92db875821225c0feb9391 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix toLocaleString implementations in (Typed)Array.prototypeLars Knoll2018-08-231-1/+1
| | | | | Change-Id: Idcabd68b1651ad3cae315a16cb0e1361cba21253 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement support for Object.valuesLars Knoll2018-08-041-0/+29
| | | | | Change-Id: I1f2507afb1c6f148d129325088a7db9d9b6fc98e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for Object.getOwnPropertyDescriptorsLars Knoll2018-08-041-0/+30
| | | | | Change-Id: I9f80c583a5c238997b7141e11f4302a9e19c5499 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add Object.entries()Lars Knoll2018-08-041-0/+40
| | | | | Change-Id: Ia06813a7cac5bd8be99e9f6ab3cd30eac26e499f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Simplify ObjectIterator::nextLars Knoll2018-08-041-9/+4
| | | | | | | Use PropertyKey instead of two out pointers Change-Id: I4f57bcb36fd412f19f0ed116042f7b094b5785dc Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix some spec incompatibilities in Object.prototypeLars Knoll2018-08-021-8/+8
| | | | | Change-Id: I5f0533a443404276ebc79fc8a1fbb33bda38556f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix the remaining test failures with non strict arguments objectsLars Knoll2018-07-301-2/+0
| | | | | Change-Id: Ib50f602263dd0146d792fb3d12bd5971585fda30 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for super callsLars Knoll2018-07-031-3/+3
| | | | | | | | Implement super call support for class constructor functions. Change-Id: I3c64276234689cf4f644b095e0fc8ca1c634ac53 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement support for new.targetLars Knoll2018-07-031-1/+1
| | | | | | | | | 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-2/+2
| | | | | | | | | 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-6/+6
| | | | | | | | 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>
* Introduce a PropertyKey class that inherits from ValueLars Knoll2018-07-021-8/+9
| | | | | | | | | | | This will replace Identifier over the next few commits. The advantage of PropertyKey is that it can be stored on the JS stack, so that a GC run won't accidentally clean up the string/symbol referenced by the key. Change-Id: Ib4daa4616bcfa537e6d371ef7c7740bc7727a50d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Cleanups in the Identifier APILars Knoll2018-07-021-1/+1
| | | | | | | | | | Rename from/asHeapObject to from/asStringOrSymbol and fix the signature. Add a isStringOrSymbol() method and redefine isValid() to also include array indices. Change-Id: Ic8272bfbe84d15421e2ebe86ddda7fdaa8db4f3e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify the get and getIndexed vtable functions of QV4::ObjectLars Knoll2018-07-021-1/+1
| | | | | | | | This finalizes the refactoring of Object's vtable API. Also added the receiver argument to the method as required by the ES7 spec. Change-Id: I36f9989211c47458788fe9f7e929862bcfe7b845 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Cleanup defineOwnPropertyLars Knoll2018-06-261-5/+5
| | | | | | | | | | | | | | | | Make it a vtable method as required by the ES7 spec. Change all calls sites to call through the virtual function. Adjust ArgumentsObject and give it it's own defineOwnProperty implementation instead of hacking it into the base implementation. Move the array object specific handling into a reimplementation. Change-Id: I48c960c4c69f99b178628c94b4808be2bab0dccc Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add Proxy support for prototype handlingLars Knoll2018-06-251-33/+15
| | | | | | | | | | | | | | Cleanup get/setPrototypeOf and fix some smaller incompatibilities in the default implementation for Object. Add the methods to the vtable and reimplement them according to spec for ProxyObjects. Clean up the Object.prototype.get/setPrototypeOf/__proto__ methods and fix a smaller bug in the Reflect API for those methods. Change-Id: I6e438753332ec4db963d6cdcf86f340ff212777a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Support preventExtensions in Proxy handlersLars Knoll2018-06-251-1/+1
| | | | | Change-Id: I03aaacc260bdb46eb09c597598a45fbb25d6d7b6 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add virtual interface for hasPropertyLars Knoll2018-06-251-6/+6
| | | | | | | This is required to correctly support Proxy Change-Id: I95ec17e919915290a05ad9501cd649452ab82135 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement a virtual interface for getOwnPropertyLars Knoll2018-06-251-9/+4
| | | | | | | | | | | | 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>
* Check that toObject() didn't failLars Knoll2018-06-211-0/+2
| | | | | | | | Avoid a crash below if the toObject call failed and threw an exception. Change-Id: I82a12c5cd8892c176d345d7f4b0cf3297357f272 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement ToPropertyKey() from the ES7 specLars Knoll2018-06-041-4/+4
| | | | | | | and use it where required. Change-Id: I309ca61e0360b26428fc2ea5a2eea47c8e0632a0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Use Symbol.toStringTag in Object.prototype.toStringLars Knoll2018-06-041-10/+24
| | | | | | | | | This should make toString comply fully with the JS Spec. Also add a couple of missing Symbol.toStringTag properties. Change-Id: I29e2018b486a0e1d174b58ce7a14f0e42cc78767 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement Object.is and Object.getOwnPropertySymbolsLars Knoll2018-05-241-0/+31
| | | | | Change-Id: Id64f91f6bf1abbcfa28590a43fb4f8673db6730b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement Object.setPrototypeOf()Lars Knoll2018-05-231-0/+25
| | | | | Change-Id: I4488ea4855a52bc7fd386d2eec8c35def83f2785 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Cleanup creation code for builtin functionsLars Knoll2018-05-021-5/+1
| | | | | | | | Centralize the code in FunctionObject::createBuiltinFunction and setup function names and length properties there. Change-Id: I21f1d42b475070ee091d96d97387149af1dc47f2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add SymbolObject, well known symbols and fix most remaining issuesLars Knoll2018-05-021-5/+5
| | | | | | | | | Added SymbolObject, the equivalent to StringObject which was still missing so far. Added the predefined standard symbols, and fixed most test failures related to symbols. Change-Id: I1e28b439e7c4f5141b4a09bd8fb666c60691f192 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Partial Symbol supportLars Knoll2018-05-021-3/+7
| | | | | | | | | Added basic infrastructure to create symbols and convert them back to strings. In addition, storing and retrieving of symbol based properties in Objects works. Change-Id: I185f7aa46e7afa19db5a801102142892e03b7bf1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Smaller cleanupLars Knoll2018-05-021-13/+12
| | | | | | | get rid of some defineProperty usages Change-Id: I683b35b3042a0ba7f1b68235acaa6325c6acf2f1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-1/+1
| | | | | | | | | | | | | From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Get rid of BuiltinFunctionLars Knoll2018-01-151-2/+2
| | | | | | | It's now unused. Change-Id: Id2941c212d488c9b0933fa06aac9922b9db13a05 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Convert runtime methods of Object to new calling conventionLars Knoll2017-11-131-96/+118
| | | | | Change-Id: Ic34164af0ad86347a791a56a438a71d458f198a4 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Change signature for call/callAsConstructorLars Knoll2017-11-071-8/+8
| | | | | Change-Id: I159b57acc7a2133ef1ad545aa84e792c63449a57 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Rename the construct 'virtual' method to callAsConstructorLars Knoll2017-11-071-1/+1
| | | | | | | To make it consistent with the rest of the engine. Change-Id: I57b98fa26134f9864c663f47371ef3e9ca16ac9c Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Further cleanup JSCallDataLars Knoll2017-11-071-1/+1
| | | | | | | Avoid allocations on the JS stack if possible Change-Id: I344cd6dceb6264314f9d22c94db22b22d1d24d14 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Simplify JSCallData constructionLars Knoll2017-11-071-1/+1
| | | | | Change-Id: Ic53532edae9a209aa7125af6f00a9d993d74f1a3 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Get rid of JSCallData::call()Lars Knoll2017-11-071-3/+3
| | | | | Change-Id: I6b99e9a7102b3dcb6a7699f54b6456eba6248699 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Rename JSCall to JSCallDataLars Knoll2017-11-071-1/+1
| | | | | | | | As, this is going to change in a simple stack based structure to keep pointers to the data to pass to calls. Change-Id: Ia9aa3f81ee3eeba36affd16aac7b2fe97d59aea9 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Change CallData::argc to be a QV4::ValueErik Verbruggen2017-09-191-12/+12
| | | | | | | | | | | Instead of mimicking a Value. This makes sure that argc now stays correct even when anything on Value changes. Most of the change is mechanical: replace callData->argc by callData->argc(). Change-Id: I521831ae1ffb3966bad6589c18d7a373e13439d7 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Always set the correct FunctionObject when calling JS functionsLars Knoll2017-09-021-3/+3
| | | | | | | | | Renamed ScopedCallData to JSCall, enforced passing a JS FunctionObject to it, and added call() and callAsConstructor() methods to it. Change-Id: I30db65c9765c2896b5909fe2105c0934c6dad861 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move ScopedCallData and ScopedStackFrame into a separate fileLars Knoll2017-09-011-0/+1
| | | | | Change-Id: I9ae42aa7a811aa93fe0950725e9d253a0c5e8dba Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't throw from within defineOwnPropertyLars Knoll2017-08-101-2/+6
| | | | | | | | | There's no need to to this there, rather throw from the places we call those methods. This also removes some more places where we access the strictMode flag of the context. Change-Id: I4bebc9d3c242850f06230d9116479a85a944dca3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove Scope::result and convert calling convention for builtinsLars Knoll2017-08-081-156/+166
| | | | | | | | Allow for faster calling of builtins, and completely avoid scope creation in many cases. Change-Id: I0f1681e19e9908db10def85a74e134a87fc2e44c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Change function signatures for call/construct backLars Knoll2017-08-041-9/+11
| | | | | | | | Change those back again to return a value. This will be required to avoid creation of Scope objects between JS function calls. Change-Id: I05cb5cf8fd0c13dcefa60d213ccd5983fab57ea3 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Unify mark handling for MemberData and ArrayDataLars Knoll2017-03-091-4/+4
| | | | | | | | Introduce a ValueArray class, that defines an array of Values at the end of a Heap Object. Change-Id: I00efbf6f5839a6687dd5bc5fc037ec8f06e0936e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Object: Introduce set and setIndexedRobin Burchell2017-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | These names are what the ES6 spec uses for this operation. We also introduce a bool to allow throwing unconditionally if a set fails (which the spec requires the Set operation to do in a number of places). This requirement was also present in ES5, but we ignored it, and thus far got away with it. Long term, put and putIndexed should go away, but I don't feel comfortable porting everything over blindly, as some operations do require throwing, namely: * Various Array & TypedArray methods that alter 'length' * Various RegExp methods that alter 'lastIndex' This change also ports the new Object.assign to use the must-throw version of set(), which coincidentally fixes the one test failure in non-strict mode. Change-Id: Ida641a552d805af0fd9de3333eb62cc6adb3713c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* ObjectPrototype: Implement Object.assign from ES6Robin Burchell2017-02-091-1/+47
| | | | | | | | | | | [ChangeLog][QtQml] Object.assign from the ES6 specification is now implemented. This fixes another bunch of failures on test/built-ins/Object/, from 375 to 348 failures. Change-Id: I815b0f3b43efcd6af8f24b26c5215ce9943b3efa Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* ObjectPrototype: Improve ES6 complianceRobin Burchell2017-02-071-32/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * getPrototypeOf: Per 19.1.2.9, we should ToObject(O), and ReturnIfAbrupt * getOwnPropertyDescriptor: Per 19.1.2.6, we should ToObject(O), and ReturnIfAbrupt * getOwnPropertyNames: Per 19.1.2.8.1, we should ToObject(O) and ReturnIfAbrupt * seal: Per 1.9.2.17, if Type(O) is not Object, return O * freeze: Per 1.9.2.5, if Type(O) is not Object, return O * preventExtensions: Per 19.1.2.15, if Type(O) is not Object, return O * isSealed: Per 19.1.2.13, if Type(O) is not Object, return true * isFrozen: Per 19.1.2.12, if Type(O) is not Object, return true * isExtensible: Per 19.1.2.11, if Type(O) is not Object, return false * keys: Per 19.1.2.14, we should ToObject(O), and ReturnIfAbrupt This improves the ES6 passrate for test/built-ins/Object/ quite a bit, before: === Summary === - Ran 6144 tests - Passed 5719 tests (93.1%) - Failed 425 tests (6.9%) After: === Summary === - Ran 6144 tests - Passed 5769 tests (93.9%) - Failed 375 tests (6.1%) ... and also fixes numerous tests in other areas. Most of the missing failures seem to be down to missing Object.assign & Symbol. It does regress on some ES5 tests that specifically check for the ES5 spec behavior. Change-Id: I039a223060c79c5bf4f5b041ad1ec4dc1afd5932 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>