1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 01:57:44 +00:00

js: Print the accumulator instead of the returned value in BC mode

The REPL is supposed to show the last value (and not the _returned_
value), so use the accumulator register as the 'value'.
This commit is contained in:
Ali Mohammad Pur 2022-04-02 11:53:13 +04:30 committed by Andreas Kling
parent f0f97e1db0
commit 431776ebb7

View file

@ -1051,7 +1051,11 @@ static bool parse_and_run(JS::Interpreter& interpreter, StringView source, Strin
if (s_run_bytecode) {
JS::Bytecode::Interpreter bytecode_interpreter(interpreter.global_object(), interpreter.realm());
result = bytecode_interpreter.run(*executable);
auto result_or_error = bytecode_interpreter.run_and_return_frame(*executable, nullptr);
if (result_or_error.value.is_error())
result = result_or_error.value.release_error();
else
result = result_or_error.frame->registers[0];
} else {
return ReturnEarly::Yes;
}