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

LibJS: Leave NativeFunction's Realm unset if VM has no Interpreter

There's currently a fallback at the call site where the Realm is needed
(due to a slightly incorrect implementation of [[Call]] / [[Construct]])
so this is better than crashing (in LibWeb, currently).
This commit is contained in:
Linus Groh 2021-09-12 12:52:37 +01:00 committed by Andreas Kling
parent 7b92889e6b
commit c5bd382524

View file

@ -22,7 +22,7 @@ NativeFunction* NativeFunction::create(GlobalObject& global_object, const FlyStr
NativeFunction::NativeFunction(Object& prototype)
: FunctionObject(prototype)
, m_realm(&vm().interpreter().realm())
, m_realm(vm().interpreter_if_exists() ? &vm().interpreter().realm() : nullptr)
{
}
@ -30,14 +30,14 @@ NativeFunction::NativeFunction(FlyString name, Function<Value(VM&, GlobalObject&
: FunctionObject(prototype)
, m_name(move(name))
, m_native_function(move(native_function))
, m_realm(&vm().interpreter().realm())
, m_realm(vm().interpreter_if_exists() ? &vm().interpreter().realm() : nullptr)
{
}
NativeFunction::NativeFunction(FlyString name, Object& prototype)
: FunctionObject(prototype)
, m_name(move(name))
, m_realm(&vm().interpreter().realm())
, m_realm(vm().interpreter_if_exists() ? &vm().interpreter().realm() : nullptr)
{
}