@@ -59,58 +59,6 @@ ecma_builtin_function_dispatch_call (const ecma_value_t *arguments_list_p, /**<
5959 return ecma_builtin_function_dispatch_construct (arguments_list_p , arguments_list_len );
6060} /* ecma_builtin_function_dispatch_call */
6161
62- /**
63- * Helper method to count and convert the arguments for the Function constructor call.
64- *
65- * Performs the operation described in ECMA 262 v5.1 15.3.2.1 steps 5.a-d
66- *
67- *
68- * @return ecma value - concatenated arguments as a string.
69- * Returned value must be freed with ecma_free_value.
70- */
71- static ecma_value_t
72- ecma_builtin_function_helper_get_function_arguments (const ecma_value_t * arguments_list_p , /**< arguments list */
73- ecma_length_t arguments_list_len ) /**< number of arguments */
74- {
75- JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL );
76-
77- if (arguments_list_len <= 1 )
78- {
79- return ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY );
80- }
81-
82- ecma_string_t * final_str_p = ecma_op_to_string (arguments_list_p [0 ]);
83-
84- if (JERRY_UNLIKELY (final_str_p == NULL ))
85- {
86- return ECMA_VALUE_ERROR ;
87- }
88-
89- if (arguments_list_len == 2 )
90- {
91- return ecma_make_string_value (final_str_p );
92- }
93-
94- for (ecma_length_t idx = 1 ; idx < arguments_list_len - 1 ; idx ++ )
95- {
96- ecma_string_t * new_str_p = ecma_op_to_string (arguments_list_p [idx ]);
97-
98- if (JERRY_UNLIKELY (new_str_p == NULL ))
99- {
100- ecma_deref_ecma_string (final_str_p );
101- return ECMA_VALUE_ERROR ;
102- }
103-
104- final_str_p = ecma_append_magic_string_to_string (final_str_p ,
105- LIT_MAGIC_STRING_COMMA_CHAR );
106-
107- final_str_p = ecma_concat_ecma_strings (final_str_p , new_str_p );
108- ecma_deref_ecma_string (new_str_p );
109- }
110-
111- return ecma_make_string_value (final_str_p );
112- } /* ecma_builtin_function_helper_get_function_arguments */
113-
11462/**
11563 * Handle calling [[Construct]] of built-in Function object
11664 *
@@ -123,70 +71,7 @@ ecma_value_t
12371ecma_builtin_function_dispatch_construct (const ecma_value_t * arguments_list_p , /**< arguments list */
12472 ecma_length_t arguments_list_len ) /**< number of arguments */
12573{
126- JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL );
127-
128- ecma_value_t arguments_value = ecma_builtin_function_helper_get_function_arguments (arguments_list_p ,
129- arguments_list_len );
130-
131- if (ECMA_IS_VALUE_ERROR (arguments_value ))
132- {
133- return arguments_value ;
134- }
135-
136- ecma_string_t * function_body_str_p ;
137-
138- if (arguments_list_len > 0 )
139- {
140- function_body_str_p = ecma_op_to_string (arguments_list_p [arguments_list_len - 1 ]);
141-
142- if (JERRY_UNLIKELY (function_body_str_p == NULL ))
143- {
144- ecma_free_value (arguments_value );
145- return ECMA_VALUE_ERROR ;
146- }
147- }
148- else
149- {
150- /* Very unlikely code path, not optimized. */
151- function_body_str_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY );
152- }
153-
154- ecma_string_t * arguments_str_p = ecma_get_string_from_value (arguments_value );
155-
156- ECMA_STRING_TO_UTF8_STRING (arguments_str_p , arguments_buffer_p , arguments_buffer_size );
157- ECMA_STRING_TO_UTF8_STRING (function_body_str_p , function_body_buffer_p , function_body_buffer_size );
158-
159- #if ENABLED (JERRY_LINE_INFO ) || ENABLED (JERRY_ERROR_MESSAGES ) || ENABLED (JERRY_ES2015_MODULE_SYSTEM )
160- JERRY_CONTEXT (resource_name ) = ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON );
161- #endif /* ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ERROR_MESSAGES) || ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
162-
163- ecma_compiled_code_t * bytecode_data_p = NULL ;
164-
165- ecma_value_t ret_value = parser_parse_script (arguments_buffer_p ,
166- arguments_buffer_size ,
167- function_body_buffer_p ,
168- function_body_buffer_size ,
169- ECMA_PARSE_NO_OPTS ,
170- & bytecode_data_p );
171-
172- if (!ECMA_IS_VALUE_ERROR (ret_value ))
173- {
174- JERRY_ASSERT (ecma_is_value_true (ret_value ));
175-
176- ecma_object_t * func_obj_p = ecma_op_create_function_object (ecma_get_global_environment (),
177- bytecode_data_p );
178-
179- ecma_bytecode_deref (bytecode_data_p );
180- ret_value = ecma_make_object_value (func_obj_p );
181- }
182-
183- ECMA_FINALIZE_UTF8_STRING (function_body_buffer_p , function_body_buffer_size );
184- ECMA_FINALIZE_UTF8_STRING (arguments_buffer_p , arguments_buffer_size );
185-
186- ecma_deref_ecma_string (arguments_str_p );
187- ecma_deref_ecma_string (function_body_str_p );
188-
189- return ret_value ;
74+ return ecma_op_create_dynamic_function (arguments_list_p , arguments_list_len , ECMA_PARSE_NO_OPTS );
19075} /* ecma_builtin_function_dispatch_construct */
19176
19277/**
0 commit comments