1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 18:35:07 +00:00
Commit graph

1586 commits

Author SHA1 Message Date
Linus Groh
c8e359c25e LibJS: Convert Temporal.PlainMonthDay functions to ThrowCompletionOr 2021-10-21 22:31:31 +01:00
Linus Groh
c043b818ad LibJS: Convert Temporal.PlainDateTime functions to ThrowCompletionOr 2021-10-21 22:31:31 +01:00
Linus Groh
2093128b24 LibJS: Convert Temporal.PlainDate functions to ThrowCompletionOr 2021-10-21 22:31:31 +01:00
Linus Groh
df67f4978e LibJS: Convert Temporal.Now functions to ThrowCompletionOr 2021-10-21 22:31:09 +01:00
Linus Groh
149231d47d LibJS: Convert Temporal.Instant functions to ThrowCompletionOr 2021-10-21 22:31:09 +01:00
Linus Groh
5e9e3f9dc8 LibJS: Convert Temporal.Duration functions to ThrowCompletionOr 2021-10-21 22:31:09 +01:00
Linus Groh
2d2ba4eec6 LibJS: Convert Temporal.Calendar functions to ThrowCompletionOr 2021-10-21 22:31:09 +01:00
Timothy Flynn
4e4db65e26 LibJS: Remove now-redundant TemporaryClearException from Promise methods
IteratorClose now handles exceptions itself before invoking VM::call(),
so outside callers doubling that work isn't helpful.
2021-10-21 14:57:43 +01:00
Timothy Flynn
f8e46ec296 LibJS: Convert all four PerformPromise* AOs to ThrowCompletionOr 2021-10-21 14:46:14 +01:00
Timothy Flynn
4fb948d8e7 LibJS: Convert IfAbruptRejectPromise AO to a GNU statement expression
GNU statement expressions fit the definition of IfAbruptRejectPromise
rather nicely, where we need to reject the failed promise (and return
the failed promise itself) on failure, and otherwise store a value on
success.
2021-10-21 14:46:14 +01:00
Timothy Flynn
9064491a47 LibJS: Convert GetPromiseResolve AO to ThrowCompletionOr
This is a bit ugly because, rather than simply wrapping the invocation
to GetPromiseResolve with TRY(), we have to invoke the promise's reject
method with any error. But this will be a bit cleaner in a subsequent
commit to change how IfAbruptRejectPromise is invoked.
2021-10-21 14:46:14 +01:00
Linus Groh
5832de62fe LibJS: Convert NativeFunction::{call,construct}() to ThrowCompletionOr
Both at the same time because many of them call construct() in call()
and I'm not keen on adding a bunch of temporary plumbing to turn
exceptions into throw completions.
Also changes the return value of construct() to Object* instead of Value
as it always needs to return an object; allowing an arbitrary Value is a
massive foot gun.
2021-10-21 09:02:23 +01: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
Linus Groh
894834b5d5 LibJS: Allow construction of ThrowCompletionOr<Value> from non-Value
TL;DR: Instead of this:

    return { TRY(my_object()) };

we can now do:

    return TRY(my_object());

just like we mostly did for Value return types before ThrowCompletionOr.
2021-10-21 09:02:23 +01:00
Timothy Flynn
03b251a704 LibJS: Convert IterableToList AO to ThrowCompletionOr 2021-10-21 00:26:45 +01:00
Timothy Flynn
ec54a7b5b0 LibJS: Implement IteratorClose with Completions and align to the spec 2021-10-21 00:26:45 +01:00
Timothy Flynn
04b4307b3d LibJS: Convert get_iterator_values helper to ThrowCompletionOr
This one is a bit unusual, so to clarify:

Previously, callers of get_iterator_values() would supply a callback
that would return an IterationDecision, and an enum to indicate whether
iterator_close() should be invoked upon IterationDecision::Break.

Now, use of both those enums is removed, and callers must return an
Optional<Completion>. If a Completion is provided, the iterator will be
closed, and that completion will be returned from get_iterator_values.
Otherwise, once the iterator is exhausted, a default-initialized
Completion will be returned.
2021-10-21 00:26:45 +01:00
Timothy Flynn
7b4814f74c LibJS: Convert IteratorValue AO to ThrowCompletionOr 2021-10-21 00:26:45 +01:00
Timothy Flynn
a64752cd34 LibJS: Convert IteratorComplete AO to ThrowCompletionOr 2021-10-21 00:26:45 +01:00
Timothy Flynn
8be1caa05d LibJS: Convert IteratorStep AO to ThrowCompletionOr 2021-10-21 00:26:45 +01:00
Timothy Flynn
c981d7b9bd LibJS: Convert IteratorNext AO to ThrowCompletionOr 2021-10-21 00:26:45 +01:00
Timothy Flynn
f4c8f2102f LibJS: Retrieve GetIterator's optional 'method' function using GetMethod
This is in alignment with the spec.
2021-10-21 00:26:45 +01:00
Timothy Flynn
860a37640b LibJS: Convert GetIterator AO to ThrowCompletionOr 2021-10-21 00:26:45 +01:00
davidot
4c8090a45d LibJS: Use ClassFieldInitializerStatement for class fields
This is necessary as we might have to perform named evaluation with the
field name.
Ideally we would also skip some setup parts of the function like
function_declaration_instantiation however this would require bigger
changes to ECMAScriptFunctionObject.
2021-10-20 23:19:17 +01:00
davidot
16cc82460f LibJS: Add parsing and evaluation of private fields and methods 2021-10-20 23:19:17 +01:00
davidot
c7a6572789 LibJS: Add private references 2021-10-20 23:19:17 +01:00
davidot
d94b5e511f LibJS: Add slot [[PrivateElements]] and related methods to Object 2021-10-20 23:19:17 +01:00
davidot
13ead80ee6 LibJS: Add PrivateEnvironment 2021-10-20 23:19:17 +01:00
davidot
1245512c50 LibJS: Make class definition evaluation more spec like in ordering 2021-10-20 23:19:17 +01:00
Linus Groh
d3ef08217b LibJS: Remove ErrorType::FixmeAddAnErrorString
Just add a proper ErrorType the first time, it's not that hard. We can
always iterate on the message later.
2021-10-20 18:46:24 +01:00
Linus Groh
cf109533de LibJS: Add ErrorTypes for Promise ownKeys trap invariant violations 2021-10-20 18:46:24 +01:00
Linus Groh
ca09f20dcf LibJS: Add ErrorType for IterableToListOfType value type mismatch 2021-10-20 18:46:24 +01:00
Linus Groh
8feae81025 LibJS: Add ErrorType for duplicate global environment binding 2021-10-20 18:46:24 +01:00
Idan Horowitz
40eb3a39d4 LibJS: Rename define_native_function => define_old_native_function
This method will eventually be removed once all native functions are
converted to ThrowCompletionOr
2021-10-20 12:27:19 +01:00
Idan Horowitz
ca27e5eff5 LibJS: Convert NativeFunction callback to ThrowCompletionOr 2021-10-20 12:27:19 +01:00
Idan Horowitz
20163c0584 LibJS: Add ThrowCompletionOr versions of the JS native function macros
The old versions were renamed to JS_DECLARE_OLD_NATIVE_FUNCTION and
JS_DEFINE_OLD_NATIVE_FUNCTION, and will be eventually removed once all
native functions were converted to the new format.
2021-10-20 12:27:19 +01:00
Idan Horowitz
56e769e4ba LibJS: Replace usages of JS_{DECLARE, DEFINE}_NATIVE_GETTER
These macros are equivalent to JS_{DECLARE, DEFINE}_NATIVE_FUNCTION and
were only sometimes used, so let's just get rid of them altogether.
2021-10-20 12:27:19 +01:00
Ben Wiederhake
0a53cf2a07 LibJS: Add missing header in EnvironmentCoordinate.h 2021-10-20 09:20:18 +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
2fa9422b3b LibJS: Convert PrototypeObject::typed_this_value() to ThrowCompletionOr 2021-10-18 21:24:30 +01:00
Linus Groh
4b7c1f703e LibJS: Convert PrototypeObject::typed_this_object() to ThrowCompletionOr 2021-10-18 21:24:30 +01:00
Linus Groh
7c29979e30 LibJS: Convert PrototypeObject::this_object() to ThrowCompletionOr 2021-10-18 21:24:30 +01:00
Linus Groh
08db3b9f66 LibJS: Convert this_symbol_value() to ThrowCompletionOr 2021-10-18 21:24:30 +01:00
Linus Groh
60366ae032 LibJS: Convert this_string_value() to ThrowCompletionOr 2021-10-18 21:24:30 +01:00
Linus Groh
233bb89929 LibJS: Convert this_number_value() to ThrowCompletionOr 2021-10-18 21:24:30 +01:00
Linus Groh
f6cf44c3db LibJS: Convert this_bigint_value() to ThrowCompletionOr 2021-10-18 21:24:30 +01:00
Linus Groh
be28a6142b LibJS: Convert to_integer_or_infinity() to ThrowCompletionOr 2021-10-18 21:24:30 +01:00