1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +00:00

LibJS: Rename CallFrame => ExecutionContext

This struct represents what the ECMAScript specification calls an
"execution context" so let's use the same terminology. :^)
This commit is contained in:
Andreas Kling 2021-06-24 19:17:45 +02:00
parent 7c88caf99f
commit c2ad599783
13 changed files with 139 additions and 138 deletions

View file

@ -46,21 +46,21 @@ void Interpreter::run(GlobalObject& global_object, const Program& program)
vm.set_last_value(Badge<Interpreter> {}, {});
CallFrame global_call_frame;
global_call_frame.current_node = &program;
global_call_frame.this_value = &global_object;
ExecutionContext execution_context;
execution_context.current_node = &program;
execution_context.this_value = &global_object;
static FlyString global_execution_context_name = "(global execution context)";
global_call_frame.function_name = global_execution_context_name;
global_call_frame.lexical_environment = &global_object.environment_record();
global_call_frame.variable_environment = &global_object.environment_record();
execution_context.function_name = global_execution_context_name;
execution_context.lexical_environment = &global_object.environment_record();
execution_context.variable_environment = &global_object.environment_record();
VERIFY(!vm.exception());
global_call_frame.is_strict_mode = program.is_strict_mode();
vm.push_call_frame(global_call_frame, global_object);
execution_context.is_strict_mode = program.is_strict_mode();
vm.push_execution_context(execution_context, global_object);
VERIFY(!vm.exception());
auto value = program.execute(*this, global_object);
vm.set_last_value(Badge<Interpreter> {}, value.value_or(js_undefined()));
vm.pop_call_frame();
vm.pop_execution_context();
// At this point we may have already run any queued promise jobs via on_call_stack_emptied,
// in which case this is a no-op.
@ -134,8 +134,8 @@ void Interpreter::enter_scope(const ScopeNode& scope_node, ScopeType scope_type,
if (!scope_variables_with_declaration_kind.is_empty()) {
auto* environment_record = heap().allocate<DeclarativeEnvironmentRecord>(global_object, move(scope_variables_with_declaration_kind), lexical_environment());
vm().call_frame().lexical_environment = environment_record;
vm().call_frame().variable_environment = environment_record;
vm().running_execution_context().lexical_environment = environment_record;
vm().running_execution_context().variable_environment = environment_record;
pushed_environment_record = true;
}
@ -147,8 +147,8 @@ void Interpreter::exit_scope(const ScopeNode& scope_node)
while (!m_scope_stack.is_empty()) {
auto popped_scope = m_scope_stack.take_last();
if (popped_scope.pushed_environment) {
vm().call_frame().lexical_environment = vm().call_frame().lexical_environment->outer_environment();
vm().call_frame().variable_environment = vm().call_frame().variable_environment->outer_environment();
vm().running_execution_context().lexical_environment = vm().running_execution_context().lexical_environment->outer_environment();
vm().running_execution_context().variable_environment = vm().running_execution_context().variable_environment->outer_environment();
}
if (popped_scope.scope_node.ptr() == &scope_node)
break;
@ -200,8 +200,8 @@ Value Interpreter::execute_statement(GlobalObject& global_object, const Statemen
FunctionEnvironmentRecord* Interpreter::current_function_environment_record()
{
VERIFY(is<FunctionEnvironmentRecord>(vm().call_frame().lexical_environment));
return static_cast<FunctionEnvironmentRecord*>(vm().call_frame().lexical_environment);
VERIFY(is<FunctionEnvironmentRecord>(vm().running_execution_context().lexical_environment));
return static_cast<FunctionEnvironmentRecord*>(vm().running_execution_context().lexical_environment);
}
}