mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:47:35 +00:00
LibJS: Convert Interpreter::run() to ThrowCompletionOr<Value>
Instead of making it a void function, checking for an exception, and then receiving the relevant result via VM::last_value(), we can consolidate all of this by using completions. This allows us to remove more uses of VM::exception(), and all uses of VM::last_value().
This commit is contained in:
parent
f73afbb5ae
commit
eb60d16549
13 changed files with 62 additions and 56 deletions
|
@ -98,11 +98,11 @@ void CalculatorProvider::query(String const& query, Function<void(NonnullRefPtrV
|
|||
if (parser.has_errors())
|
||||
return;
|
||||
|
||||
interpreter->run(interpreter->global_object(), *program);
|
||||
if (interpreter->exception())
|
||||
auto completion = interpreter->run(interpreter->global_object(), *program);
|
||||
if (completion.is_error())
|
||||
return;
|
||||
|
||||
auto result = interpreter->vm().last_value();
|
||||
auto result = completion.release_value();
|
||||
String calculation;
|
||||
if (!result.is_number()) {
|
||||
calculation = "0";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue