Andreas Kling
398c181c79
LibJS: Rename PropertyName to PropertyKey
...
Let's use the same name as the spec. :^)
2021-10-24 17:18:07 +02:00
Linus Groh
0881f8160f
LibJS: Use implicit ThrowCompletionOr<T> constructor where possible
...
Luckily this is not very widespread yet as most of it would happen in
the various JS functions instead of AOs.
2021-10-21 09:02:23 +01:00
Idan Horowitz
545d403f6b
LibJS: Convert Value operator AOs to ThrowCompletionOr
2021-10-18 23:06:11 +01:00
Idan Horowitz
48ac15758e
LibJS: Convert is_loosely_equal() to ThrowCompletionOr
2021-10-18 23:06:11 +01:00
Idan Horowitz
b5e28410c5
LibJS: Convert is_less_than() to ThrowCompletionOr
2021-10-18 23:06:11 +01:00
Idan Horowitz
c15a3b0576
LibJS: Convert Value::get() to ThrowCompletionOr
2021-10-18 23:06:11 +01:00
Linus Groh
be28a6142b
LibJS: Convert to_integer_or_infinity() to ThrowCompletionOr
2021-10-18 21:24:30 +01:00
Idan Horowitz
85a28a6555
LibJS: Convert to_index() to ThrowCompletionOr
2021-10-18 08:01:38 +03:00
Idan Horowitz
aad12b050b
LibJS: Convert to_length() to ThrowCompletionOr
2021-10-18 08:01:38 +03:00
Idan Horowitz
750da61c0f
LibJS: Convert to_u8_clamp() to ThrowCompletionOr
2021-10-18 08:01:38 +03:00
Idan Horowitz
99287afc99
LibJS: Convert to_u8() to ThrowCompletionOr
2021-10-18 08:01:38 +03:00
Idan Horowitz
1b7dbb6b3b
LibJS: Convert to_i8() to ThrowCompletionOr
2021-10-18 08:01:38 +03:00
Idan Horowitz
7bbb92dfe9
LibJS: Convert to_u16() to ThrowCompletionOr
2021-10-18 08:01:38 +03:00
Idan Horowitz
627b1205ce
LibJS: Convert to_i16() to ThrowCompletionOr
2021-10-18 08:01:38 +03:00
Idan Horowitz
cc94bba5c0
LibJS: Convert to_u32() to ThrowCompletionOr
2021-10-18 08:01:38 +03:00
Idan Horowitz
f6a5ff7b00
LibJS: Convert to_i32() to ThrowCompletionOr
2021-10-18 08:01:38 +03:00
Idan Horowitz
20d990563c
LibJS: Convert to_number() to ThrowCompletionOr
2021-10-18 08:01:38 +03:00
Idan Horowitz
c488f5a59d
LibJS: Convert to_property_key() to ThrowCompletionOr
2021-10-17 12:12:35 +01:00
Idan Horowitz
1639ed7e0a
LibJS: Convert to_double() to ThrowCompletionOr
2021-10-17 12:12:35 +01:00
Idan Horowitz
51c33b3b35
LibJS: Convert to_bigint_uint64() to ThrowCompletionOr
2021-10-17 12:12:35 +01:00
Idan Horowitz
df181809fd
LibJS: Convert to_bigint_int64() to ThrowCompletionOr
2021-10-17 12:12:35 +01:00
Idan Horowitz
e87cea8248
LibJS: Convert to_bigint() to ThrowCompletionOr
2021-10-17 12:12:35 +01:00
Idan Horowitz
b8f101888b
LibJS: Convert to_numeric() to ThrowCompletionOr
2021-10-17 12:12:35 +01:00
Luke Wilde
09536f5f48
LibJS: Fix typo in LHS Object and RHS BigInt loosely equals check
...
Step 12 was using `lhs.is_bigint()` instead of `rhs.is_bigint()`,
meaning you got:
```js
1n == Object(1n); // true
Object(1n) == 1n; // false
```
This also adds spec comments to is_loosely_equal.
2021-10-15 01:59:09 +01:00
Linus Groh
52976bfac6
LibJS: Convert to_object() to ThrowCompletionOr
2021-10-13 09:55:10 +01:00
Linus Groh
9eb065a1f6
LibJS: Convert to_primitive() to ThrowCompletionOr
2021-10-13 09:55:10 +01:00
Linus Groh
96ab116f0d
LibJS: Convert to_primitive_string() to ThrowCompletionOr
2021-10-13 09:55:10 +01:00
Linus Groh
da59c77fe3
LibJS: Convert to_utf16_string() to ThrowCompletionOr
2021-10-13 09:55:10 +01:00
Linus Groh
4d8912a92b
LibJS: Convert to_string() to ThrowCompletionOr
...
Also update get_function_name() to use ThrowCompletionOr, but this is
not a standard AO and should be refactored out of existence eventually.
2021-10-13 09:55:10 +01:00
Linus Groh
44e70d1bc0
LibJS+LibWeb: Let WrapperGenerator deal with legacy_null_to_empty_string
...
This concept is not present in ECMAScript, and it bothers me every time
I see it.
It's only used by WrapperGenerator, and even there only relevant in two
places, so let's fully remove it from LibJS and use a simple ternary
expression instead:
cpp_name = js_name.is_null() && legacy_null_to_empty_string
? String::empty()
: js_name.to_string(global_object);
2021-10-11 23:36:03 +01:00
Andreas Kling
e67155638c
LibJS: Take advantage of Value::Type::Int32 in a bunch of functions
...
If a JS::Value has type Int32, we know it's a finite, 32-bit integer.
Use this information to avoid converting it to a double if possible.
2021-10-07 19:27:30 +02:00
Linus Groh
f38a5957bf
LibJS: Convert has_property() to ThrowCompletionOr
2021-10-03 20:14:03 +01:00
Linus Groh
b7e5f08e56
LibJS: Convert Object::get() to ThrowCompletionOr
...
To no one's surprise, this patch is pretty big - this is possibly the
most used AO of all of them. Definitely worth it though.
2021-10-03 20:14:03 +01:00
Linus Groh
fa2ac5b759
LibJS: Convert ordinary_to_primitive() to ThrowCompletionOr
...
Also add spec step comments to it while we're here.
2021-10-03 20:14:03 +01:00
Andreas Kling
f0b3a06746
LibJS: Use Vector<u16, 1> for UTF-16 in a few more places
2021-10-02 18:32:56 +02:00
Linus Groh
6c2b974db2
LibJS: Convert internal_get() to ThrowCompletionOr
2021-09-29 23:49:53 +01:00
Linus Groh
5148150e1c
LibJS: Convert internal_get_prototype_of() to ThrowCompletionOr
2021-09-29 23:49:53 +01:00
Linus Groh
38157a6093
LibJS: Move has_constructor() from NativeFunction to FunctionObject
...
At a later point this will indicate whether some FunctionObject "has a
[[Construct]] internal method" (separate from the current FunctionObject
call() / construct()), to help with a more spec-compliant implementation
of [[Call]] and [[Construct]].
This means that it is no longer relevant to just NativeFunction.
2021-09-25 17:51:30 +02:00
Linus Groh
e14f420a44
LibJS: Add const Value::as_function()
2021-09-25 17:51:30 +02:00
Linus Groh
4566472ed6
LibJS: Rename BoundFunction::m_target_function to match spec name
2021-09-25 17:51:30 +02:00
Linus Groh
e37cf73300
LibJS: Rename OrdinaryFunctionObject to ECMAScriptFunctionObject
...
The old name is the result of the perhaps somewhat confusingly named
abstract operation OrdinaryFunctionCreate(), which creates an "ordinary
object" (https://tc39.es/ecma262/#ordinary-object ) in contrast to an
"exotic object" (https://tc39.es/ecma262/#exotic-object ).
However, the term "Ordinary Function" is not used anywhere in the spec,
instead the created object is referred to as an "ECMAScript Function
Object" (https://tc39.es/ecma262/#sec-ecmascript-function-objects ), so
let's call it that.
The "ordinary" vs. "exotic" distinction is important because there are
also "Built-in Function Objects", which can be either implemented as
ordinary ECMAScript function objects, or as exotic objects (our
NativeFunction).
More work needs to be done to move a lot of infrastructure to
ECMAScriptFunctionObject in order to make FunctionObject nothing more
than an interface for objects that implement [[Call]] and optionally
[[Construct]].
2021-09-25 17:51:30 +02:00
Linus Groh
facbe32fcd
LibJS: Rename abstract_relation() to is_less_than()
...
This got turned into a proper AO with a new name recently.
See: https://github.com/tc39/ecma262/commit/587adc0
2021-09-24 09:13:57 +02:00
Linus Groh
580a7e0f7c
LibJS: Rename abstract_eq() to is_loosely_equal()
...
This got turned into a proper AO with a new name recently.
See: https://github.com/tc39/ecma262/commit/c7d6d1c
2021-09-24 09:13:57 +02:00
Linus Groh
c7ff89891c
LibJS: Rename strict_eq() to is_strictly_equal()
...
This got turned into a proper AO with a new name recently.
See: https://github.com/tc39/ecma262/commit/19d7ca4
2021-09-24 09:13:57 +02:00
Idan Horowitz
ee825d6d9e
LibJS: Convert get_method to ThrowCompletionOr
2021-09-23 23:59:13 +03:00
Idan Horowitz
ab594e5f2f
LibJS: Convert Value::invoke and VM::call to ThrowCompletionOr
2021-09-23 23:59:13 +03:00
Idan Horowitz
a90107b02a
LibJS: Convert is_regexp to ThrowCompletionOr
2021-09-23 23:59:13 +03:00
Idan Horowitz
1db7e096e2
LibJS: Switch is_array to ThrowCompletionOr
2021-09-23 23:59:13 +03:00
Linus Groh
1a7828a9f3
LibJS: Return default-constructed values instead of the INVALID constant
...
This is much more common across the whole codebase and even these two
files. The same is used to return an empty JS::Value in an exception
check, for example.
2021-09-15 18:41:33 +01:00
Luke Wilde
c20669328d
LibJS: Handle +Infinity, -Infinity, +0 and -0 in modulo operator
...
Fixes 11 test262 cases.
2021-09-02 18:26:42 +01:00