mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
LibJS+LibWeb: Pass function metadata collected in parsing using a struct
By using separate struct we can avoid updating AST node and ECMAScriptFunctionObject constructors every time there is a need to add or remove some additional information colllected during parsing.
This commit is contained in:
parent
99f6528009
commit
e934132442
Notes:
sideshowbarker
2024-07-17 09:49:48 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: e934132442
Pull-request: https://github.com/SerenityOS/serenity/pull/24414
12 changed files with 75 additions and 73 deletions
|
@ -182,9 +182,8 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
|
|||
}
|
||||
|
||||
// 18. Let body be ParseText(StringToCodePoints(bodyString), bodySym).
|
||||
bool contains_direct_call_to_eval = false;
|
||||
bool uses_this_from_environment = false;
|
||||
auto body_parser = Parser::parse_function_body_from_string(body_string, parse_options, parameters, kind, contains_direct_call_to_eval, uses_this_from_environment);
|
||||
FunctionParsingInsights parsing_insights;
|
||||
auto body_parser = Parser::parse_function_body_from_string(body_string, parse_options, parameters, kind, parsing_insights);
|
||||
|
||||
// 19. If body is a List of errors, throw a SyntaxError exception.
|
||||
if (body_parser.has_errors()) {
|
||||
|
@ -219,7 +218,8 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
|
|||
PrivateEnvironment* private_environment = nullptr;
|
||||
|
||||
// 28. Let F be OrdinaryFunctionCreate(proto, sourceText, parameters, body, non-lexical-this, env, privateEnv).
|
||||
auto function = ECMAScriptFunctionObject::create(realm, "anonymous", *prototype, move(source_text), expr->body(), expr->parameters(), expr->function_length(), expr->local_variables_names(), &environment, private_environment, expr->kind(), expr->is_strict_mode(), uses_this_from_environment ? UsesThisFromEnvironment::Yes : UsesThisFromEnvironment::No, expr->might_need_arguments_object(), contains_direct_call_to_eval);
|
||||
parsing_insights.might_need_arguments_object = true;
|
||||
auto function = ECMAScriptFunctionObject::create(realm, "anonymous", *prototype, move(source_text), expr->body(), expr->parameters(), expr->function_length(), expr->local_variables_names(), &environment, private_environment, expr->kind(), expr->is_strict_mode(), parsing_insights);
|
||||
|
||||
// FIXME: Remove the name argument from create() and do this instead.
|
||||
// 29. Perform SetFunctionName(F, "anonymous").
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue