summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime
AgeCommit message (Collapse)Author
2022-01-04LibJS: Remove the now retired TRY_OR_DISCARD() macro :^)Linus Groh
2022-01-04LibJS: Convert PropertyKey::from_value() to ThrowCompletionOrLinus Groh
Lots of MUST() - perhaps we'll eventually come up with a better API for the common case where it can't fail.
2022-01-04LibJS: Convert FunctionObject::bind() to ThrowCompletionOrLinus Groh
2022-01-04LibJS: Convert PromiseResolvingElementFunction to ThrowCompletionOrLinus Groh
2022-01-04LibJS: Remove unused Accessor::call_{getter,setter}()Linus Groh
If only we had such "a way to communicate to our caller if an exception happened" - too bad it's dead code :^)
2022-01-04LibJS: Remove unused IndexedProperties::take_{first,last}()Linus Groh
2022-01-04LibJS+LibUnicode: Convert UnicodeLocale to link with weak symbolsTimothy Flynn
2022-01-04LibJS: Implement Number.prototype.toExponentialTimothy Flynn
2022-01-04LibJS: Implement Number.prototype.toPrecisionTimothy Flynn
As noted in the prototype comments, this implementation becomes less accurate as the precision approaches the limit of 100. For example: (3).toPrecision(100) Should result in "3." followed by 99 "0"s. However, due to the loss of accuracy in the floating point computations, we currently result in "2.9999999...".
2022-01-03LibJS: Propagate errors from TypedArray for_each_item{,_from_last} callsLinus Groh
Another mistake uncovered by moving away from manual exception checks and relying on correct completion types instead :^)
2022-01-03LibJS: Update AST to use completions :^)Linus Groh
This is another major milestone on our journey towards removing global VM exception state :^) Does pretty much exactly what it says on the tin: updating ASTNode::execute() to return a Completion instead of a plain value. This will *also* allow us to eventually remove the non-standard unwinding mechanism and purely rely on the various completion types.
2022-01-03LibJS: Don't assume non-empty [[Value]] in Completion TRY() helpersLinus Groh
2022-01-03LibJS: Remove redundant abrupt completion checkLinus Groh
A throw completion is always an abrupt completion, no need to check :^)
2022-01-03LibJS: Return Optional<T> from Completion::{value,target}(), not TLinus Groh
In the end this is a nicer API than having separate has_{value,target}() and having to check those first, and then making another Optional from the unwrapped value: completion.has_value() ? completion.value() : Optional<Value> {} // ^^^^^^^^^^^^^^^^^^ // Implicit creation of non-empty Optional<Value> This way we need to unwrap the optional ourselves, but can easily pass it to something else as well. This is in anticipation of the AST using completions :^)
2022-01-03LibJS: Implement the Extend TimeZoneName Option ProposalTimothy Flynn
This is a stage 4 proposal that was recently merged into the main ECMA-402 spec. See: https://github.com/tc39/ecma402/commit/1ba5ee7
2022-01-02 LibJS: Let Completion::update_empty() take an Optional<Value>Linus Groh
It also needs to be able to take what the spec calls 'empty', which is an Optional<Value> in this case (*not* an empty JS::Value). The common use case is updating a completion with another completion, that may also have an empty [[Value]] slot.
2022-01-02LibJS: Move provided Optional<Value> argument in normal_completion()Linus Groh
2022-01-02LibJS: Update ToRawPrecision / ToRawFixed AO spec commentsTimothy Flynn
This is a normative change in the Intl spec: https://github.com/tc39/ecma402/commit/f0f66cf There are two main changes here: 1. Converting BigInt/Number objects to mathematical values. 2. A change in how ToRawPrecision computes its exponent and significant digits. For (1), we do not yet support BigInt number formatting, thus already have coerced Number objects to a double. When BigInt is supported, the number passed into these methods will likely still be a Value, thus can be coereced then. For (2), our implementation already returns the expected edge-case results pointed out on the spec PR.
2022-01-02LibJS: Explicitly handle postive/negative infinity in Intl.NumberFormatTimothy Flynn
This is a normative change in the Intl spec: https://github.com/tc39/ecma402/commit/f0f66cf Our implementation is unaffected by this change. LibUnicode pre-computes positive, negative, and signless format patterns, so we already format negative infinity correctly. Also, the CLDR does not contain specific locale-dependent strings for negative infinity anyways.
2021-12-31LibJS: Convert to_reference() to ThrowCompletionOrdavidot
2021-12-31LibJS: Convert resolve_this_binding() to ThrowCompletionOrdavidot
Also add spec comments.
2021-12-30LibJS: Fix spec comment in Temporal::PlainDate::balance_iso_date()Emanuele Torre
This matches the text of the spec, and is more correct since the variable is being updated, not defined it. See: https://github.com/tc39/proposal-temporal/commit/5ab1822 --- I also changed `test_year += 1` to `test_year++` for consistency with step 11.c that has the same description.
2021-12-30LibJS: Convert thrown exception to completion in binding initializationdavidot
This regressed in 676554d3 as it assumed to_reference() (already) returned a completion type instead of putting the error in vm.exception().
2021-12-30LibJS: Add and fix some spec comments in AbstractOperationsdavidot
2021-12-30LibJS: Convert get_identifier_reference() to ThrowCompletionOrdavidot
And while we're here add spec comments.
2021-12-30LibJS: Convert resolve_binding() to ThrowCompletionOrdavidot
The spec has a note stating that resolve binding will always return a reference whose [[ReferencedName]] field is name. However this is not correct as the underlying method GetIdentifierReference may throw on env.HasBinding(name) thus it can throw. However, there are some scenarios where it cannot throw because the reference is known to exist in that case we use MUST with a comment.
2021-12-29LibJS: Remove unused declaration copy_data_propertiesdavidot
The method was moved to Object but this declaration was not removed.
2021-12-29LibJS: Convert create_global_function_binding() to ThrowCompletionOrLinus Groh
2021-12-29LibJS: Convert create_global_var_binding() to ThrowCompletionOrLinus Groh
2021-12-29LibJS: Convert can_declare_global_function() to ThrowCompletionOrLinus Groh
2021-12-29LibJS: Convert can_declare_global_var() to ThrowCompletionOrLinus Groh
2021-12-29LibJS: Convert has_restricted_global_property() to ThrowCompletionOrLinus Groh
2021-12-29LibJS: Add spec comments to remaining GlobalEnvironment methodsLinus Groh
2021-12-29LibJS: Implement and use the MakeMethod AOLinus Groh
Two direct uses of the set_home_object() setter remain, we should fix those up and remove it eventually.
2021-12-29LibJS: Implement and use the InitializeBoundName AOLinus Groh
2021-12-29LibJS: Add spec comments to VM::binding_initialization()Linus Groh
2021-12-29LibJS: Remove unused FunctionEnvironment this value getter/setterLinus Groh
The this value is only supposed to be set via the BindThisValue and accessed via the GetThisBinding AOs, so exposing a direct getter/setter would only lead to potentially non-spec-compliant behavior down the line.
2021-12-29LibJS: Ensure get_new_target() never returns an empty valueLinus Groh
Also add spec comments and remove a redundant exception check while we're here :^)
2021-12-28LibJS: Also throw exception when returning throw completion from awaitLinus Groh
...for now - the reason being that the AST breaks 'completion bubbling' and returns a plain Value, and code at the call site relies on the VM having an exception set when converting the plain value back into a completion. Fixes #11301.
2021-12-27LibJS: Implement console.time/timeLog/timeEnd() methodsSam Atkins
2021-12-27LibJS+WebContent+Browser+js: Implement console.group() methodsSam Atkins
This implements: - console.group() - console.groupCollapsed() - console.groupEnd() In the Browser, we use `<details>` for the groups, which is not actually implemented yet, so groups are always open. In the REPL, groups are non-interactive, but still indent any output. This looks weird since the console prompt and return values remain on the far left, but this matches what Node does so it's probably fine. :^) I expect `console.group()` is not used much outside of browsers.
2021-12-26LibJS: Add spec comments to Number.prototype functionsLinus Groh
2021-12-26LibJS: Fix toFixed throwing on undefined, null and NaN fractionDigitsLuke Wilde
It was checking the original fractionDigits argument was a finite number instead of the coerced fraction_digits.
2021-12-24LibJS: Require 'T' prefix for ambiguous time-only stringsLinus Groh
This is a normative change in the Temporal spec. See: https://github.com/tc39/proposal-temporal/commit/514ede3
2021-12-22LibJS: Avoid crashing when the Unicode data generators are disabledTimothy Flynn
The general idea when ENABLE_UNICODE_DATABASE_DOWNLOAD is OFF has been that the Intl APIs will provide obviously incorrect results, but should not crash. This regressed a bit with NumberFormat and DateTimeFormat.
2021-12-22LibJS: Fix modulo in get_iso_parts_from_epoch() for negative epoch nsLinus Groh
This now matches the spec change from reminder() to modulo which was done here: https://github.com/tc39/proposal-temporal/commit/bdf60f5
2021-12-22LibJS: Add modulo(x, y) overload for Crypto::{Unsigned,Signed}BigIntegerLinus Groh
Just like with integral and floating numbers, doing it manually is error-prone: when we get a negative remainder, y has to be added to the result to match the spec's modulo. Solve this by just adding another (templated) overload to also permit using the function for LibCrypto BigInts.
2021-12-22LibJS: Support modulo(x, y) with different typesLinus Groh
It's a bit annoying having to add '.0' to y given that it's an integral number in most cases. This turns the single template parameter T into T and U to permit that.
2021-12-21AK+Everywhere: Replace __builtin bit functionsNick Johnson
In order to reduce our reliance on __builtin_{ffs, clz, ctz, popcount}, this commit removes all calls to these functions and replaces them with the equivalent functions in AK/BuiltinWrappers.h.
2021-12-21LibJS: Add TypedArray.prototype.@@iteratorLuke Wilde