1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:37:34 +00:00

LibJS+LibTest+js: Convert BC::Interpreter::run to ThrowCompletionOr<>

Note that this is just a shallow API change.
This commit is contained in:
Ali Mohammad Pur 2021-11-11 04:11:56 +03:30 committed by Linus Groh
parent 3b0bf05fa5
commit 070d2eaa51
7 changed files with 19 additions and 11 deletions

View file

@ -542,7 +542,7 @@ ThrowCompletionOr<Value> perform_eval(Value x, GlobalObject& caller_realm, Calle
executable.name = "eval"sv;
if (JS::Bytecode::g_dump_bytecode)
executable.dump();
eval_result = bytecode_interpreter->run(executable);
eval_result = TRY(bytecode_interpreter->run(executable));
} else {
auto& ast_interpreter = vm.interpreter();
// FIXME: We need to use evaluate_statements() here because Program::execute() calls global_declaration_instantiation() when it shouldn't

View file

@ -772,7 +772,7 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body()
return throw_completion(exception->value());
VERIFY(result_and_frame.frame != nullptr);
auto result = result_and_frame.value;
auto result = TRY(result_and_frame.value);
// NOTE: Running the bytecode should eventually return a completion.
// Until it does, we assume "return" and include the undefined fallback from the call site.

View file

@ -102,10 +102,7 @@ ThrowCompletionOr<Value> GeneratorObject::next_impl(VM& vm, GlobalObject& global
bytecode_interpreter->accumulator() = next_argument.value_or(js_undefined());
}
// Temporarily switch to the captured execution context
vm.push_execution_context(m_execution_context, global_object);
m_previous_value = bytecode_interpreter->run(*m_generating_function->bytecode_executable(), next_block);
auto next_result = bytecode_interpreter->run(*m_generating_function->bytecode_executable(), next_block);
m_frame = move(*bytecode_interpreter->pop_frame());
@ -113,6 +110,8 @@ ThrowCompletionOr<Value> GeneratorObject::next_impl(VM& vm, GlobalObject& global
m_done = TRY(generated_continuation(m_previous_value)) == nullptr;
m_previous_value = TRY(next_result);
result->define_direct_property("value", TRY(generated_value(m_previous_value)), JS::default_attributes);
result->define_direct_property("done", Value(m_done), JS::default_attributes);