From 0241071ca22f8bc38f33de5c339449d2fe81b45b Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Thu, 14 Oct 2021 12:06:08 +0100 Subject: [PATCH] LibJS: Use GlobalObject::associated_realm() for function object realms As outlined in the previous commit, this should be more reliable than Interpreter::realm(), as we don't always have access to an Interpreter. --- .../Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp | 2 +- Userland/Libraries/LibJS/Runtime/NativeFunction.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index 6498a554c5..e2acff4bb9 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -43,7 +43,7 @@ ECMAScriptFunctionObject::ECMAScriptFunctionObject(FlyString name, Statement con , m_environment(parent_scope) , m_formal_parameters(move(formal_parameters)) , m_ecmascript_code(ecmascript_code) - , m_realm(vm().interpreter_if_exists() ? &vm().interpreter().realm() : nullptr) + , m_realm(global_object().associated_realm()) , m_strict(strict) , m_name(move(name)) , m_function_length(function_length) diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp index 043968f876..1759fd22c8 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp @@ -24,7 +24,7 @@ NativeFunction* NativeFunction::create(GlobalObject& global_object, const FlyStr NativeFunction::NativeFunction(Object& prototype) : FunctionObject(prototype) - , m_realm(vm().interpreter_if_exists() ? &vm().interpreter().realm() : nullptr) + , m_realm(global_object().associated_realm()) { } @@ -32,14 +32,14 @@ NativeFunction::NativeFunction(FlyString name, Function