LibJS: Add spec comments to Value::invoke_internal()

This commit is contained in:
Linus Groh 2022-12-10 00:11:42 +00:00
parent 14e5003ece
commit 78895984e9
Notes: sideshowbarker 2024-07-17 03:30:19 +09:00

View file

@ -2455,11 +2455,13 @@ ThrowCompletionOr<TriState> is_less_than(VM& vm, Value lhs, Value rhs, bool left
// 7.3.21 Invoke ( V, P [ , argumentsList ] ), https://tc39.es/ecma262/#sec-invoke
ThrowCompletionOr<Value> Value::invoke_internal(VM& vm, PropertyKey const& property_key, Optional<MarkedVector<Value>> arguments)
{
auto property = TRY(get(vm, property_key));
if (!property.is_function())
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, property.to_string_without_side_effects());
// 1. If argumentsList is not present, set argumentsList to a new empty List.
return call(vm, property.as_function(), *this, move(arguments));
// 2. Let func be ? GetV(V, P).
auto function = TRY(get(vm, property_key));
// 3. Return ? Call(func, V, argumentsList).
return call(vm, function, *this, move(arguments));
}
}