mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 03:34:58 +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
|
@ -70,12 +70,15 @@ JS::Value ClassicScript::run(RethrowErrors rethrow_errors)
|
|||
|
||||
auto timer = Core::ElapsedTimer::start_new();
|
||||
auto interpreter = JS::Interpreter::create_with_existing_realm(m_script_record->realm());
|
||||
interpreter->run(interpreter->global_object(), m_script_record->parse_node());
|
||||
auto& vm = interpreter->vm();
|
||||
if (vm.exception())
|
||||
vm.clear_exception();
|
||||
|
||||
auto result = interpreter->run(interpreter->global_object(), m_script_record->parse_node());
|
||||
dbgln("ClassicScript: Finished running script {}, Duration: {}ms", filename(), timer.elapsed());
|
||||
return vm.last_value();
|
||||
if (result.is_error()) {
|
||||
// FIXME: Propagate error according to the spec.
|
||||
interpreter->vm().clear_exception();
|
||||
return {};
|
||||
}
|
||||
return result.value();
|
||||
}
|
||||
|
||||
ClassicScript::ClassicScript(AK::URL base_url, String filename)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue