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

LibJS: Decouple new_function_environment() from FunctionObject

Now that only ECMAScriptFunctionObject uses this, we can remove the
FunctionObject::new_function_environment() pure virtual method and just
implement it as a standalone AO with an ECMAScriptFunctionObject
parameter, next to the other NewFooEnvironment AOs.
This commit is contained in:
Linus Groh 2021-10-08 21:24:51 +01:00
parent 53af66d57d
commit fe5c2b7bb9
11 changed files with 30 additions and 43 deletions

View file

@ -195,19 +195,6 @@ Value NativeFunction::construct(FunctionObject&)
VERIFY_NOT_REACHED();
}
FunctionEnvironment* NativeFunction::new_function_environment(Object* new_target)
{
// Simplified version of 9.1.2.4 NewFunctionEnvironment ( F, newTarget )
Environment* parent_scope = nullptr;
if (!vm().execution_context_stack().is_empty())
parent_scope = vm().lexical_environment();
auto* environment = heap().allocate<FunctionEnvironment>(global_object(), parent_scope);
environment->set_new_target(new_target ? new_target : js_undefined());
return environment;
}
bool NativeFunction::is_strict_mode() const
{
return true;