diff options
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibJS/AST.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Generator.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Parser.cpp | 22 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/FunctionKind.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/EventTarget.cpp | 2 |
8 files changed, 24 insertions, 24 deletions
diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index dcf0c07477..f6708aba4c 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -1633,7 +1633,7 @@ ThrowCompletionOr<ClassElement::ClassValue> ClassField::class_element_evaluation // FIXME: A potential optimization is not creating the functions here since these are never directly accessible. auto function_code = create_ast_node<ClassFieldInitializerStatement>(m_initializer->source_range(), copy_initializer.release_nonnull(), name); - initializer = ECMAScriptFunctionObject::create(interpreter.global_object(), String::empty(), *function_code, {}, 0, interpreter.lexical_environment(), interpreter.vm().running_execution_context().private_environment, FunctionKind::Regular, true, false, m_contains_direct_call_to_eval, false); + initializer = ECMAScriptFunctionObject::create(interpreter.global_object(), String::empty(), *function_code, {}, 0, interpreter.lexical_environment(), interpreter.vm().running_execution_context().private_environment, FunctionKind::Normal, true, false, m_contains_direct_call_to_eval, false); initializer->make_method(target); } @@ -1675,7 +1675,7 @@ ThrowCompletionOr<ClassElement::ClassValue> StaticInitializer::class_element_eva // 4. Let formalParameters be an instance of the production FormalParameters : [empty] . // 5. Let bodyFunction be OrdinaryFunctionCreate(%Function.prototype%, sourceText, formalParameters, ClassStaticBlockBody, non-lexical-this, lex, privateScope). // Note: The function bodyFunction is never directly accessible to ECMAScript code. - auto* body_function = ECMAScriptFunctionObject::create(global_object, "", *m_function_body, {}, 0, lexical_environment, private_scope, FunctionKind::Regular, true, false, m_contains_direct_call_to_eval, false); + auto* body_function = ECMAScriptFunctionObject::create(global_object, "", *m_function_body, {}, 0, lexical_environment, private_scope, FunctionKind::Normal, true, false, m_contains_direct_call_to_eval, false); // 6. Perform MakeMethod(bodyFunction, homeObject). body_function->make_method(home_object); diff --git a/Userland/Libraries/LibJS/Bytecode/Generator.h b/Userland/Libraries/LibJS/Bytecode/Generator.h index 6e5f520c79..066fae8a18 100644 --- a/Userland/Libraries/LibJS/Bytecode/Generator.h +++ b/Userland/Libraries/LibJS/Bytecode/Generator.h @@ -23,7 +23,7 @@ namespace JS::Bytecode { class Generator { public: - static Executable generate(ASTNode const&, FunctionKind = FunctionKind::Regular); + static Executable generate(ASTNode const&, FunctionKind = FunctionKind::Normal); Register allocate_register(); @@ -130,7 +130,7 @@ private: u32 m_next_register { 2 }; u32 m_next_block { 1 }; - FunctionKind m_enclosing_function_kind { FunctionKind::Regular }; + FunctionKind m_enclosing_function_kind { FunctionKind::Normal }; Vector<Label> m_continuable_scopes; Vector<Label> m_breakable_scopes; }; diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp index 404802a738..2ac76f7273 100644 --- a/Userland/Libraries/LibJS/Parser.cpp +++ b/Userland/Libraries/LibJS/Parser.cpp @@ -155,7 +155,7 @@ public: if (m_var_names.contains(function_name) || m_lexical_names.contains(function_name)) throw_identifier_declared(function_name, declaration); - if (function_declaration.kind() != FunctionKind::Regular || m_parser.m_state.strict_mode) { + if (function_declaration.kind() != FunctionKind::Normal || m_parser.m_state.strict_mode) { if (m_function_names.contains(function_name)) throw_identifier_declared(function_name, declaration); @@ -708,7 +708,7 @@ RefPtr<FunctionExpression> Parser::try_parse_arrow_function_expression(bool expe load_state(); }; - auto function_kind = FunctionKind::Regular; + auto function_kind = FunctionKind::Normal; if (is_async) { consume(TokenType::Async); @@ -1293,12 +1293,12 @@ NonnullRefPtr<ClassExpression> Parser::parse_class_expression(bool expect_class_ constructor = create_ast_node<FunctionExpression>( { m_state.current_token.filename(), rule_start.position(), position() }, class_name, move(constructor_body), - Vector { FunctionNode::Parameter { FlyString { "args" }, nullptr, true } }, 0, FunctionKind::Regular, + Vector { FunctionNode::Parameter { FlyString { "args" }, nullptr, true } }, 0, FunctionKind::Normal, /* is_strict_mode */ true, /* might_need_arguments_object */ false, /* contains_direct_call_to_eval */ false); } else { constructor = create_ast_node<FunctionExpression>( { m_state.current_token.filename(), rule_start.position(), position() }, class_name, move(constructor_body), - Vector<FunctionNode::Parameter> {}, 0, FunctionKind::Regular, + Vector<FunctionNode::Parameter> {}, 0, FunctionKind::Normal, /* is_strict_mode */ true, /* might_need_arguments_object */ false, /* contains_direct_call_to_eval */ false); } } @@ -1624,7 +1624,7 @@ NonnullRefPtr<ObjectExpression> Parser::parse_object_expression() property_type = ObjectProperty::Type::KeyValue; RefPtr<Expression> property_name; RefPtr<Expression> property_value; - FunctionKind function_kind { FunctionKind::Regular }; + FunctionKind function_kind { FunctionKind::Normal }; if (match(TokenType::TripleDot)) { consume(); @@ -1653,8 +1653,8 @@ NonnullRefPtr<ObjectExpression> Parser::parse_object_expression() consume(); property_type = ObjectProperty::Type::KeyValue; property_name = parse_property_key(); - VERIFY(function_kind == FunctionKind::Regular || function_kind == FunctionKind::Async); - function_kind = function_kind == FunctionKind::Regular ? FunctionKind::Generator : FunctionKind::AsyncGenerator; + VERIFY(function_kind == FunctionKind::Normal || function_kind == FunctionKind::Async); + function_kind = function_kind == FunctionKind::Normal ? FunctionKind::Generator : FunctionKind::AsyncGenerator; } else if (match_identifier()) { auto identifier = consume(); if (identifier.original_value() == "get"sv && match_property_key()) { @@ -2381,7 +2381,7 @@ NonnullRefPtr<FunctionBody> Parser::parse_function_body(Vector<FunctionDeclarati parse_statement_list(function_body); // If the function contains 'use strict' we need to check the parameters (again). - if (function_body->in_strict_mode() || function_kind != FunctionKind::Regular) { + if (function_body->in_strict_mode() || function_kind != FunctionKind::Normal) { Vector<StringView> parameter_names; for (auto& parameter : parameters) { parameter.binding.visit( @@ -2461,17 +2461,17 @@ NonnullRefPtr<FunctionNodeType> Parser::parse_function_node(u8 parse_options) else if ((parse_options & FunctionNodeParseOptions::IsAsyncFunction) != 0) function_kind = FunctionKind::Async; else - function_kind = FunctionKind::Regular; + function_kind = FunctionKind::Normal; String name; if (parse_options & FunctionNodeParseOptions::CheckForFunctionAndName) { - if (function_kind == FunctionKind::Regular && match(TokenType::Async) && !next_token().trivia_contains_line_terminator()) { + if (function_kind == FunctionKind::Normal && match(TokenType::Async) && !next_token().trivia_contains_line_terminator()) { function_kind = FunctionKind::Async; consume(TokenType::Async); parse_options = parse_options | FunctionNodeParseOptions::IsAsyncFunction; } consume(TokenType::Function); if (match(TokenType::Asterisk)) { - function_kind = function_kind == FunctionKind::Regular ? FunctionKind::Generator : FunctionKind::AsyncGenerator; + function_kind = function_kind == FunctionKind::Normal ? FunctionKind::Generator : FunctionKind::AsyncGenerator; consume(TokenType::Asterisk); parse_options = parse_options | FunctionNodeParseOptions::IsGeneratorFunction; } diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index d4f6246bdb..28950abde1 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -32,7 +32,7 @@ ECMAScriptFunctionObject* ECMAScriptFunctionObject::create(GlobalObject& global_ { Object* prototype = nullptr; switch (kind) { - case FunctionKind::Regular: + case FunctionKind::Normal: prototype = global_object.function_prototype(); break; case FunctionKind::Generator: @@ -99,7 +99,7 @@ void ECMAScriptFunctionObject::initialize(GlobalObject& global_object) if (!m_is_arrow_function) { Object* prototype = nullptr; switch (m_kind) { - case FunctionKind::Regular: + case FunctionKind::Normal: prototype = vm.heap().allocate<Object>(global_object, *global_object.new_ordinary_function_prototype_object_shape()); MUST(prototype->define_property_or_throw(vm.names.constructor, { .value = this, .writable = true, .enumerable = false, .configurable = true })); break; @@ -787,7 +787,7 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body() // NOTE: Running the bytecode should eventually return a completion. // Until it does, we assume "return" and include the undefined fallback from the call site. - if (m_kind == FunctionKind::Regular) + if (m_kind == FunctionKind::Normal) return { Completion::Type::Return, result.value_or(js_undefined()), {} }; auto generator_object = TRY(GeneratorObject::create(global_object(), result, this, vm.running_execution_context().copy(), move(*result_and_frame.frame))); @@ -813,7 +813,7 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body() VM::InterpreterExecutionScope scope(*ast_interpreter); // FunctionBody : FunctionStatementList - if (m_kind == FunctionKind::Regular) { + if (m_kind == FunctionKind::Normal) { // 1. Perform ? FunctionDeclarationInstantiation(functionObject, argumentsList). TRY(function_declaration_instantiation(ast_interpreter)); diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h index 9a0c614a1e..5fc363ac40 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h @@ -75,7 +75,7 @@ public: bool has_simple_parameter_list() const { return m_has_simple_parameter_list; } // Equivalent to absence of [[Construct]] - virtual bool has_constructor() const override { return m_kind == FunctionKind::Regular && !m_is_arrow_function; } + virtual bool has_constructor() const override { return m_kind == FunctionKind::Normal && !m_is_arrow_function; } FunctionKind kind() const { return m_kind; } @@ -113,7 +113,7 @@ private: FlyString m_name; Optional<Bytecode::Executable> m_bytecode_executable; i32 m_function_length { 0 }; - FunctionKind m_kind { FunctionKind::Regular }; + FunctionKind m_kind { FunctionKind::Normal }; bool m_might_need_arguments_object { true }; bool m_contains_direct_call_to_eval { true }; bool m_is_arrow_function { false }; diff --git a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp index 602de95cbd..8d2e637c9d 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp @@ -76,7 +76,7 @@ ThrowCompletionOr<Value> FunctionConstructor::call() ThrowCompletionOr<Object*> FunctionConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); - auto function = TRY(create_dynamic_function_node(global_object(), new_target, FunctionKind::Regular)); + auto function = TRY(create_dynamic_function_node(global_object(), new_target, FunctionKind::Normal)); OwnPtr<Interpreter> local_interpreter; Interpreter* interpreter = vm.interpreter_if_exists(); diff --git a/Userland/Libraries/LibJS/Runtime/FunctionKind.h b/Userland/Libraries/LibJS/Runtime/FunctionKind.h index 6a4299a863..41b53001e9 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionKind.h +++ b/Userland/Libraries/LibJS/Runtime/FunctionKind.h @@ -9,8 +9,8 @@ namespace JS { enum class FunctionKind { + Normal, Generator, - Regular, Async, AsyncGenerator }; diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp index b57108dd75..5f81bc13e6 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp @@ -134,7 +134,7 @@ void EventTarget::set_event_handler_attribute(FlyString const& name, HTML::Event dbgln("Failed to parse script in event handler attribute '{}'", name); return; } - auto* function = JS::ECMAScriptFunctionObject::create(target->script_execution_context()->realm().global_object(), name, program->body(), program->parameters(), program->function_length(), nullptr, nullptr, JS::FunctionKind::Regular, false, false); + auto* function = JS::ECMAScriptFunctionObject::create(target->script_execution_context()->realm().global_object(), name, program->body(), program->parameters(), program->function_length(), nullptr, nullptr, JS::FunctionKind::Normal, false, false); VERIFY(function); listener = adopt_ref(*new DOM::EventListener(JS::make_handle(static_cast<JS::FunctionObject*>(function)), true)); } |