mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:17:34 +00:00
LibJS: Convert Value::invoke and VM::call to ThrowCompletionOr
This commit is contained in:
parent
a90107b02a
commit
ab594e5f2f
35 changed files with 196 additions and 328 deletions
|
@ -662,7 +662,7 @@ void VM::ordinary_call_bind_this(FunctionObject& function, ExecutionContext& cal
|
|||
callee_context.this_value = this_value;
|
||||
}
|
||||
|
||||
Value VM::call_internal(FunctionObject& function, Value this_value, Optional<MarkedValueList> arguments)
|
||||
ThrowCompletionOr<Value> VM::call_internal(FunctionObject& function, Value this_value, Optional<MarkedValueList> arguments)
|
||||
{
|
||||
VERIFY(!exception());
|
||||
VERIFY(!this_value.is_empty());
|
||||
|
@ -680,8 +680,8 @@ Value VM::call_internal(FunctionObject& function, Value this_value, Optional<Mar
|
|||
// This needs to be moved to NativeFunction/OrdinaryFunctionObject's construct() (10.2.2 [[Construct]])
|
||||
ExecutionContext callee_context(heap());
|
||||
prepare_for_ordinary_call(function, callee_context, nullptr);
|
||||
if (exception())
|
||||
return {};
|
||||
if (auto* exception = this->exception())
|
||||
return JS::throw_completion(exception->value());
|
||||
|
||||
ScopeGuard pop_guard = [&] {
|
||||
pop_execution_context();
|
||||
|
@ -696,10 +696,13 @@ Value VM::call_internal(FunctionObject& function, Value this_value, Optional<Mar
|
|||
if (callee_context.lexical_environment)
|
||||
ordinary_call_bind_this(function, callee_context, this_value);
|
||||
|
||||
if (exception())
|
||||
return {};
|
||||
if (auto* exception = this->exception())
|
||||
return JS::throw_completion(exception->value());
|
||||
|
||||
return function.call();
|
||||
auto result = function.call();
|
||||
if (auto* exception = this->exception())
|
||||
return JS::throw_completion(exception->value());
|
||||
return result;
|
||||
}
|
||||
|
||||
bool VM::in_strict_mode() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue