mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:28:12 +00:00
LibJS/Bytecode: Get result from accumulator in PerformEval
This is how the JS REPL retrieves the result of executing bytecode.
This commit is contained in:
parent
fe2efbb2fc
commit
9e06fe4b3f
1 changed files with 7 additions and 4 deletions
|
@ -703,10 +703,13 @@ ThrowCompletionOr<Value> perform_eval(GlobalObject& global_object, Value x, Call
|
|||
executable->name = "eval"sv;
|
||||
if (Bytecode::g_dump_bytecode)
|
||||
executable->dump();
|
||||
eval_result = TRY(bytecode_interpreter->run(*executable));
|
||||
// Turn potentially empty JS::Value from the bytecode interpreter into an empty Optional
|
||||
if (eval_result.has_value() && eval_result->is_empty())
|
||||
eval_result = {};
|
||||
auto result_or_error = bytecode_interpreter->run_and_return_frame(*executable, nullptr);
|
||||
if (result_or_error.value.is_error())
|
||||
return result_or_error.value.release_error();
|
||||
|
||||
auto& result = result_or_error.frame->registers[0];
|
||||
if (!result.is_empty())
|
||||
eval_result = result;
|
||||
} else {
|
||||
auto& ast_interpreter = vm.interpreter();
|
||||
eval_result = TRY(program->execute(ast_interpreter, global_object));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue