mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
LibJS: Make intrinsics getters return NonnullGCPtr
Some of these are allocated upon initialization of the intrinsics, and some lazily, but in neither case the getters actually return a nullptr. This saves us a whole bunch of pointer dereferences (as NonnullGCPtr has an `operator T&()`), and also has the interesting side effect of forcing us to explicitly use the FunctionObject& overload of call(), as passing a NonnullGCPtr is ambigous - it could implicitly be turned into a Value _or_ a FunctionObject& (so we have to dereference manually).
This commit is contained in:
@@ -615,7 +615,7 @@ ThrowCompletionOr<MarkedVector<Value>> ConsoleClient::formatter(MarkedVector<Val
|
||||
|
||||
// 1. If specifier is %s, let converted be the result of Call(%String%, undefined, « current »).
|
||||
if (specifier == "%s"sv) {
|
||||
converted = TRY(call(vm, realm.intrinsics().string_constructor(), js_undefined(), current));
|
||||
converted = TRY(call(vm, *realm.intrinsics().string_constructor(), js_undefined(), current));
|
||||
}
|
||||
// 2. If specifier is %d or %i:
|
||||
else if (specifier.is_one_of("%d"sv, "%i"sv)) {
|
||||
@@ -625,7 +625,7 @@ ThrowCompletionOr<MarkedVector<Value>> ConsoleClient::formatter(MarkedVector<Val
|
||||
}
|
||||
// 2. Otherwise, let converted be the result of Call(%parseInt%, undefined, « current, 10 »).
|
||||
else {
|
||||
converted = TRY(call(vm, realm.intrinsics().parse_int_function(), js_undefined(), current, Value { 10 }));
|
||||
converted = TRY(call(vm, *realm.intrinsics().parse_int_function(), js_undefined(), current, Value { 10 }));
|
||||
}
|
||||
}
|
||||
// 3. If specifier is %f:
|
||||
@@ -636,7 +636,7 @@ ThrowCompletionOr<MarkedVector<Value>> ConsoleClient::formatter(MarkedVector<Val
|
||||
}
|
||||
// 2. Otherwise, let converted be the result of Call(% parseFloat %, undefined, « current »).
|
||||
else {
|
||||
converted = TRY(call(vm, realm.intrinsics().parse_float_function(), js_undefined(), current));
|
||||
converted = TRY(call(vm, *realm.intrinsics().parse_float_function(), js_undefined(), current));
|
||||
}
|
||||
}
|
||||
// 4. If specifier is %o, optionally let converted be current with optimally useful formatting applied.
|
||||
|
||||
Reference in New Issue
Block a user