1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:27:43 +00:00

LibJS: Move the GlobalEnvironment from GlobalObject to Realm

This is where the spec wants to have it. Requires a couple of hacks as
currently everything that needs a Realm actually has a GlobalObject, so
we need to go via the Interpreter.
This commit is contained in:
Linus Groh 2021-09-11 20:27:36 +01:00
parent 1e79934acf
commit f29a82dd84
6 changed files with 13 additions and 16 deletions

View file

@ -37,6 +37,8 @@ Interpreter::~Interpreter()
void Interpreter::run(GlobalObject& global_object, const Program& program)
{
// FIXME: Why does this receive a GlobalObject? Interpreter has one already, and this might not be in sync with the Realm's GlobalObject.
auto& vm = this->vm();
VERIFY(!vm.exception());
@ -49,8 +51,8 @@ void Interpreter::run(GlobalObject& global_object, const Program& program)
execution_context.this_value = &global_object;
static FlyString global_execution_context_name = "(global execution context)";
execution_context.function_name = global_execution_context_name;
execution_context.lexical_environment = &global_object.environment();
execution_context.variable_environment = &global_object.environment();
execution_context.lexical_environment = &realm().global_environment();
execution_context.variable_environment = &realm().global_environment();
VERIFY(!vm.exception());
execution_context.is_strict_mode = program.is_strict_mode();
vm.push_execution_context(execution_context, global_object);