LibJS: Make run_executable() return simple ThrowCompletionOr<Value>

We don't need to return two values; running an executable only ever
produces a throw completion, or a normal completion, i.e a Value.

This necessitated a few minor changes, such as adding a way to check
if a JS::Cell is a GeneratorResult.
This commit is contained in:
Andreas Kling 2025-10-30 10:27:47 +01:00 committed by Andreas Kling
parent 2f7797f854
commit 5706831328
Notes: github-actions[bot] 2025-10-31 07:57:15 +00:00
10 changed files with 37 additions and 51 deletions

View file

@ -36,15 +36,10 @@ public:
ThrowCompletionOr<Value> run(ExecutionContext& context, Executable& executable, Optional<size_t> entry_point = {}, Value initial_accumulator_value = js_special_empty_value())
{
auto result_and_return_register = run_executable(context, executable, entry_point, initial_accumulator_value);
return move(result_and_return_register.value);
return run_executable(context, executable, entry_point, initial_accumulator_value);
}
struct ResultAndReturnRegister {
ThrowCompletionOr<Value> value;
Value return_register_value;
};
ResultAndReturnRegister run_executable(ExecutionContext&, Executable&, Optional<size_t> entry_point, Value initial_accumulator_value = js_special_empty_value());
ThrowCompletionOr<Value> run_executable(ExecutionContext&, Executable&, Optional<size_t> entry_point, Value initial_accumulator_value = js_special_empty_value());
ALWAYS_INLINE Value& accumulator() { return reg(Register::accumulator()); }
ALWAYS_INLINE Value& saved_return_value() { return reg(Register::saved_return_value()); }