From b46fc47bf7f9fa37a7d49ea356843a74ac12ecbf Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sun, 12 May 2024 04:24:06 +0000 Subject: [PATCH] LibJS: Remove execute_ast_node() usage for ClassMethod function creation Call ECMAScriptFunctionObject constructor directly instead of using execute_ast_node() to emit NewFunction instruction. --- Userland/Libraries/LibJS/AST.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index 44afa205e3..23c0f69912 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -151,11 +151,9 @@ ThrowCompletionOr ClassMethod::class_element_evaluatio { auto property_key_or_private_name = TRY(class_key_to_property_name(vm, *m_key)); - auto method_value = TRY(vm.execute_ast_node(*m_function)); + auto& method_function = *ECMAScriptFunctionObject::create(*vm.current_realm(), m_function->name(), m_function->source_text(), m_function->body(), m_function->parameters(), m_function->function_length(), m_function->local_variables_names(), vm.lexical_environment(), vm.running_execution_context().private_environment, m_function->kind(), m_function->is_strict_mode(), m_function->uses_this(), m_function->might_need_arguments_object(), m_function->contains_direct_call_to_eval(), m_function->is_arrow_function()); - auto function_handle = make_handle(&method_value.as_function()); - - auto& method_function = static_cast(method_value.as_function()); + auto method_value = Value(&method_function); method_function.make_method(target); auto set_function_name = [&](ByteString prefix = "") {