mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 02:38:11 +00:00
LibJS: Let the bytecode interpreter set the VM's last value
This commit is contained in:
parent
023df8e596
commit
319a60043b
3 changed files with 7 additions and 2 deletions
|
@ -41,6 +41,8 @@ Value Interpreter::run(Executable const& executable)
|
||||||
|
|
||||||
TemporaryChange restore_executable { m_current_executable, &executable };
|
TemporaryChange restore_executable { m_current_executable, &executable };
|
||||||
|
|
||||||
|
vm().set_last_value(Badge<Interpreter> {}, {});
|
||||||
|
|
||||||
CallFrame global_call_frame;
|
CallFrame global_call_frame;
|
||||||
if (vm().call_stack().is_empty()) {
|
if (vm().call_stack().is_empty()) {
|
||||||
global_call_frame.this_value = &global_object();
|
global_call_frame.this_value = &global_object();
|
||||||
|
@ -102,6 +104,8 @@ Value Interpreter::run(Executable const& executable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vm().set_last_value(Badge<Interpreter> {}, accumulator());
|
||||||
|
|
||||||
m_register_windows.take_last();
|
m_register_windows.take_last();
|
||||||
|
|
||||||
auto return_value = m_return_value.value_or(js_undefined());
|
auto return_value = m_return_value.value_or(js_undefined());
|
||||||
|
|
|
@ -43,7 +43,7 @@ void Interpreter::run(GlobalObject& global_object, const Program& program)
|
||||||
|
|
||||||
VM::InterpreterExecutionScope scope(*this);
|
VM::InterpreterExecutionScope scope(*this);
|
||||||
|
|
||||||
vm.set_last_value({}, {});
|
vm.set_last_value(Badge<Interpreter> {}, {});
|
||||||
|
|
||||||
CallFrame global_call_frame;
|
CallFrame global_call_frame;
|
||||||
global_call_frame.current_node = &program;
|
global_call_frame.current_node = &program;
|
||||||
|
@ -56,7 +56,7 @@ void Interpreter::run(GlobalObject& global_object, const Program& program)
|
||||||
vm.push_call_frame(global_call_frame, global_object);
|
vm.push_call_frame(global_call_frame, global_object);
|
||||||
VERIFY(!vm.exception());
|
VERIFY(!vm.exception());
|
||||||
auto value = program.execute(*this, global_object);
|
auto value = program.execute(*this, global_object);
|
||||||
vm.set_last_value({}, value.value_or(js_undefined()));
|
vm.set_last_value(Badge<Interpreter> {}, value.value_or(js_undefined()));
|
||||||
|
|
||||||
vm.pop_call_frame();
|
vm.pop_call_frame();
|
||||||
|
|
||||||
|
|
|
@ -158,6 +158,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
Value last_value() const { return m_last_value; }
|
Value last_value() const { return m_last_value; }
|
||||||
|
void set_last_value(Badge<Bytecode::Interpreter>, Value value) { m_last_value = value; }
|
||||||
void set_last_value(Badge<Interpreter>, Value value) { m_last_value = value; }
|
void set_last_value(Badge<Interpreter>, Value value) { m_last_value = value; }
|
||||||
|
|
||||||
const StackInfo& stack_info() const { return m_stack_info; };
|
const StackInfo& stack_info() const { return m_stack_info; };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue