summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime
AgeCommit message (Collapse)Author
2021-06-30LibJS: Ensure shift values in left_shift are modded by 32Idan Horowitz
This is equivalent to 58d6a2d0192b7860ecb2edb4aa5d36b389213a15 but for the left shift operation.
2021-06-30LibJS: Add String.prototype.split using the @@split methods on objectdavidot
2021-06-30LibJS: Add String.prototype.indexOf position argumentdavidot
2021-06-30LibJS: Optimize & Bring String.prototype.repeat closer to the specIdan Horowitz
Specifically, we immediately return an empty string when `this` is an empty string, instead of wasting time in a loop doing nothing N times.
2021-06-30LibJS: Bring the Array constructor slightly closer to the specificationIdan Horowitz
Specifically, we now cast to a u32 instead of an i32, as well as use the validity check required by the specification. The current constructor is still quite far from the specification, as we directly set the indexed properties' length instead of going through the Array's overriden DefineOwnProperty. (and as a result the checks imposed by the ArraySetLength abstract operation)
2021-06-29LibJS: Handle the different realms case in ArraySpeciesCreatedavidot
2021-06-29LibJS: Support the radix argument in BigInt.prototype.toStringIdan Horowitz
2021-06-29LibCrypto: Replace from_base{2,8,10,16}() & to_base10 with from_base(N)Idan Horowitz
This allows us to support parsing and serializing BigIntegers to and from any base N (such that 2 <= N <= 36).
2021-06-29LibJS: Check the target function of a bound function in is_constructorIdan Horowitz
This is not exactly compliant with the specification, but our current bound function implementation isn't either, so its not currently possible to implement it the way the specification requires.
2021-06-29LibJS: Make Array.of(...items) genericIdan Horowitz
As well as bring it generally closer to the specification.
2021-06-28LibJS: Mark FunctionObject::is_ordinary_function() as overrideLeon Albrecht
2021-06-28LibJS: Add the CreateMappedArgumentsObject abstract operationAndreas Kling
This patch adds a new ArgumentsObject class to represent what the spec calls "Arguments Exotic Objects" These are constructed by the new CreateMappedArgumentsObject when the `arguments` identifier is resolved in a callee context. The implementation is incomplete and doesn't yet support mapping of the parameter variables to the indexed properties of `arguments`.
2021-06-28LibJS: Bring Reflect.construct() closer to the specificationIdan Horowitz
This includes checking that the target is a constructor, not just a function, as well as switching the order of the list creation and argument validation to match the specification, to ensure correct exception throwing order.
2021-06-28LibJS: Rewrite String.raw() closer to the specificationIdan Horowitz
This includes not throwing a custom exception and using the length_of_array_like abstract operation where required.
2021-06-28LibJS: Use CreateUnmappedArgumentsObject for non-simple parameter listsAndreas Kling
This patch implements the IsSimpleParameterList static semantics for ordinary function objects. We now also create an unmapped arguments object for callee contexts with non-simple parameter lists, instead of only doing it in strict mode. Covered by test262.
2021-06-28LibJS: Add and use the %ThrowTypeError% intrinsicIdan Horowitz
2021-06-28LibJS: Accept FlyStrings in the NativeFunction constructorsIdan Horowitz
This makes the implicit run-time assertion in PropertyName::to_string() into an explicit compile-time requirement, removes a wasteful FlyString -> PropertyName -> FlyString construction from NativeFunction::create() and allows setting the function name to a null string for anonymous native functions.
2021-06-28LibJS: Handle values close to -0.5 correctly in Math.round(x)Idan Horowitz
This is done by just using the built-in ceiling and subtracting from the result if its in the 0.5 range.
2021-06-28LibJS: Implement the CreateUnmappedArgumentsObject abstract operationAndreas Kling
2021-06-27LibJS: Fix typo "sweeped" => "swept" everywhereAndreas Kling
2021-06-27LibJS: Stop qualifying AK::FunctionAndreas Kling
Now that JS function objects are JS::FunctionObject, we can stop qualifying AK::Function and just say "Function" everywhere. Nice. :^)
2021-06-27LibJS: Rename ScriptFunction => OrdinaryFunctionObjectAndreas Kling
These are basically what the spec calls "ordinary function objects", so let's have the name reflect that. :^)
2021-06-27LibJS: Rename Function => FunctionObjectAndreas Kling
2021-06-27LibJS: Ensure shift values in shift_right are modded by 32Andrew Kaster
The unsigned shift right implementation was already doing this, but the spec requires a mod32 of rhs before the shift for the signed shift right implementation as well. Caught by UBSAN and oss-fuzz.
2021-06-27LibJS: Avoid undefined static cast of negative values in to_u32Andrew Kaster
If the value we get after fmod in Value::to_u32 is negative, UBSAN complains that -N is out of bounds for u32. An extra static cast to i64 makes it stop complaining. An alternative implementation could add 2^32 if the fmod'd value is negative. Caught by UBSAN and oss-fuzz.
2021-06-27LibJS: Add content type check to IntegerIndexedElementSet()Linus Groh
Resolves a FIXME.
2021-06-27LibJS: Add content type check to InitializeTypedArrayFromTypedArray()Linus Groh
Resolves a FIXME.
2021-06-27LibJS: Implement the TypedArray [[ContentType]] internal slotLinus Groh
2021-06-27LibJS: Add 'is detached' check to InitializeTypedArrayFromTypedArray()Linus Groh
Resolves a FIXME.
2021-06-27LibJS: Make variables in InitializeTypedArrayFromTypedArray() match specLinus Groh
This makes it easier to follow the code and compare it to the spec.
2021-06-27LibJS: Add missing InitializeTypedArrayFromTypedArray() spec linkLinus Groh
Also move the others outside of their functions.
2021-06-27LibJS: Don't extend `arguments` object to match the parameter countAndreas Kling
The `arguments` object should only have the *arguments* as numeric properties, not the *parameters*. Given this function: function foo(a, b) { return arguments.length; } Calling foo() with no arguments now correctly returns 0 instead of 2.
2021-06-26LibJS: Implement the GetMethod() abstract operation as a Value methodLinus Groh
This was a standalone function previously (get_method()), but instead of passing a Value to it, we can just make it a method. Also add spec step comments and fix the receiver value by using GetV().
2021-06-26LibJS: Implement the GetV() abstract operationLinus Groh
Like Get(), but with any value instead of an object - it's calling ToObject() for us and passes the value to [[Get]]() as the receiver. This will be used in GetMethod() (and a couple of other places, which can be updated over time). I also tried something new here: adding the three steps from the spec as inline comments :^)
2021-06-26LibJS: Move install_error_cause() from Object to ErrorLinus Groh
This is only used by Error and its subclasses, so it doesn't need to be available to all objects.
2021-06-26Revert "LibJS: Fix this_value in native setters and getters"davidot
This reverts commit f102b563 The reverted to behavior is not correct for example with a double proxy But this change lead to problems with DOMNodes
2021-06-26LibJS: Fix propagation of setters and getters from prototypesdavidot
If we define a property with just a setter/getter (not both) we must: - take the previous getter/setter if defined on the actual object - overwrite the other to nullptr if it is from a prototype
2021-06-26LibJS: Allow setting the length of an object with prototype Arraydavidot
Before this it would always go through the native setter thus modifying the array but now you can set length to anything
2021-06-26LibJS: Don't remove non-configurable items in Array when setting lengthdavidot
2021-06-26LibJS: Make Array.prototype.lastIndexOf slightly more spec compliantdavidot
2021-06-26LibJS: Make sure `this` in the global environment is the global objectAndreas Kling
Fixes regressed with 0f9038b732a6e0f5830e5e95c0b2a1c78efea415.
2021-06-26LibJS: Add %TypedArray%.prototype.entriesLuke
2021-06-26LibJS: Add %TypedArray%.prototype.valuesLuke
2021-06-26LibJS: Add %TypedArray%.prototype.keysLuke
2021-06-26LibJS: Add TypedArray support to ArrayIteratorLuke
ArrayIteratorPrototype::next seems to implement CreateArrayIterator, which is an issue for a separate PR.
2021-06-26LibJS: Align ObjectEnvironmentRecord member names with the specAndreas Kling
In the spec, object environments have a [[BindingObject]], so let's call it the same thing in our implementation.
2021-06-26LibJS: Remove unnecessary GlobalObject& member on global environmentAndreas Kling
We already store the GlobalObject& in a base class, so no need to also store it in the subclass. :^)
2021-06-26LibJS: Create new object earlier in VM::construct()Andreas Kling
Also make use of OrdinaryCreateFromConstructor() instead of setting the prototype manually. This fixes 2 function tests in test262. :^)
2021-06-25LibJS: Change PropertyName(i32) => template<Integral T> PropertyName(T)Linus Groh
Negative numeric properties are not a thing (and we even VERIFY()'d this in the constructor). It still allows using types with a negative range for now as we have various places using int for example (without actually needing the negative range, but that's a different story). u32 is the internal type of `m_number` already, so this now allows us to leverage the full u32 range for numeric properties.
2021-06-25LibJS: Change PropertyName(Symbol*) => PropertyName(Symbol&)Linus Groh
Requires a bunch of find-and-replace updates across LibJS, but constructing a PropertyName from a nullptr Symbol* should not be possible - let's enforce this at the compiler level instead of using VERIFY() (and already dereference Symbol pointers at the call site).