mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-24 03:52:58 +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
|
@ -237,7 +237,6 @@ static JS::ThrowCompletionOr<JS::Value> execute_a_function_body(Web::Page& page,
|
|||
|
||||
auto& realm = window->realm();
|
||||
|
||||
bool contains_direct_call_to_eval = false;
|
||||
auto source_text = ByteString::formatted("function() {{ {} }}", body);
|
||||
auto parser = JS::Parser { JS::Lexer { source_text } };
|
||||
auto function_expression = parser.parse_function_node<JS::FunctionExpression>();
|
||||
|
@ -266,8 +265,7 @@ static JS::ThrowCompletionOr<JS::Value> execute_a_function_body(Web::Page& page,
|
|||
// The result of parsing global scope above.
|
||||
// strict
|
||||
// The result of parsing strict above.
|
||||
auto function = JS::ECMAScriptFunctionObject::create(realm, "", move(source_text), function_expression->body(), function_expression->parameters(), function_expression->function_length(), function_expression->local_variables_names(), &global_scope, nullptr, function_expression->kind(), function_expression->is_strict_mode(),
|
||||
function_expression->uses_this_from_environment(), function_expression->might_need_arguments_object(), contains_direct_call_to_eval);
|
||||
auto function = JS::ECMAScriptFunctionObject::create(realm, "", move(source_text), function_expression->body(), function_expression->parameters(), function_expression->function_length(), function_expression->local_variables_names(), &global_scope, nullptr, function_expression->kind(), function_expression->is_strict_mode(), function_expression->parsing_insights());
|
||||
|
||||
// 9. Let completion be Function.[[Call]](window, parameters) with function as the this value.
|
||||
// NOTE: This is not entirely clear, but I don't think they mean actually passing `function` as
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue