mirror of
https://github.com/RGBCube/serenity
synced 2025-07-03 00:52:12 +00:00
LibJS/Bytecode: Add codegen for "named evaluation if anonymous function"
This gives anonymous functions the name from the LHS they are being assigned to. 171 new passes on test262. :^)
This commit is contained in:
parent
a92d94f4e9
commit
85a3a1c085
8 changed files with 109 additions and 27 deletions
|
@ -302,13 +302,12 @@ Completion FunctionExpression::execute(Interpreter& interpreter) const
|
|||
InterpreterNodeScope node_scope { interpreter, *this };
|
||||
|
||||
// 1. Return InstantiateOrdinaryFunctionExpression of FunctionExpression.
|
||||
return instantiate_ordinary_function_expression(interpreter, name());
|
||||
return instantiate_ordinary_function_expression(interpreter.vm(), name());
|
||||
}
|
||||
|
||||
// 15.2.5 Runtime Semantics: InstantiateOrdinaryFunctionExpression, https://tc39.es/ecma262/#sec-runtime-semantics-instantiateordinaryfunctionexpression
|
||||
Value FunctionExpression::instantiate_ordinary_function_expression(Interpreter& interpreter, DeprecatedFlyString given_name) const
|
||||
Value FunctionExpression::instantiate_ordinary_function_expression(VM& vm, DeprecatedFlyString given_name) const
|
||||
{
|
||||
auto& vm = interpreter.vm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
if (given_name.is_empty())
|
||||
|
@ -316,7 +315,7 @@ Value FunctionExpression::instantiate_ordinary_function_expression(Interpreter&
|
|||
auto has_own_name = !name().is_empty();
|
||||
|
||||
auto const& used_name = has_own_name ? name() : given_name;
|
||||
auto environment = NonnullGCPtr { *interpreter.lexical_environment() };
|
||||
auto environment = NonnullGCPtr { *vm.running_execution_context().lexical_environment };
|
||||
if (has_own_name) {
|
||||
VERIFY(environment);
|
||||
environment = new_declarative_environment(*environment);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue