4141 * @return pointer to newly created Arguments object
4242 */
4343ecma_object_t *
44- ecma_create_arguments_object (ecma_object_t *func_obj_p, /* *< callee function */
45- ecma_object_t *lex_env_p, /* *< lexical environment the Arguments
46- object is created for */
47- ecma_collection_iterator_t *formal_params_iter_p, /* *< formal parameters
48- collection iterator */
49- const ecma_value_t *arguments_list_p, /* *< list of arguments */
50- ecma_length_t arguments_list_length, /* *< length of arguments' list */
51- bool is_strict) /* *< flag indicating whether strict mode is enabled */
44+ ecma_op_create_arguments_object (ecma_object_t *func_obj_p, /* *< callee function */
45+ ecma_object_t *lex_env_p, /* *< lexical environment the Arguments
46+ object is created for */
47+ ecma_collection_header_t *formal_params_p, /* *< formal parameters collection */
48+ const ecma_value_t *arguments_list_p, /* *< list of arguments */
49+ ecma_length_t arguments_list_length, /* *< length of arguments' list */
50+ bool is_strict) /* *< flag indicating whether strict mode is enabled */
5251{
5352 // 1.
5453 ecma_number_t *len_p = ecma_alloc_number ();
@@ -110,7 +109,7 @@ ecma_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function */
110109 prop_desc.is_configurable = true ;
111110 }
112111
113- ecma_string_t *indx_string_p = ecma_new_ecma_string_from_number ( ecma_uint32_to_number ( indx) );
112+ ecma_string_t *indx_string_p = ecma_new_ecma_string_from_uint32 ( indx);
114113
115114 completion = ecma_op_object_define_own_property (obj_p,
116115 indx_string_p,
@@ -121,7 +120,11 @@ ecma_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function */
121120 ecma_deref_ecma_string (indx_string_p);
122121 }
123122
124- const ecma_length_t formal_params_number = formal_params_iter_p->header_p ->unit_number ;
123+ const ecma_length_t formal_params_number = formal_params_p->unit_number ;
124+
125+ ecma_collection_iterator_t formal_params_iterator;
126+ ecma_collection_iterator_init (&formal_params_iterator, formal_params_p);
127+
125128 if (!is_strict
126129 && arguments_list_length > 0
127130 && formal_params_number > 0 )
@@ -132,17 +135,17 @@ ecma_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function */
132135 // 11.c
133136 MEM_DEFINE_LOCAL_ARRAY (formal_params, formal_params_number, ecma_string_t *);
134137
135- JERRY_ASSERT (formal_params_iter_p-> current_value_p == NULL );
138+ JERRY_ASSERT (formal_params_iterator. current_value_p == NULL );
136139 uint32_t param_index;
137140 for (param_index = 0 ;
138- ecma_collection_iterator_next (formal_params_iter_p );
141+ ecma_collection_iterator_next (&formal_params_iterator );
139142 param_index++)
140143 {
141- JERRY_ASSERT (formal_params_iter_p-> current_value_p != NULL );
144+ JERRY_ASSERT (formal_params_iterator. current_value_p != NULL );
142145 JERRY_ASSERT (param_index < formal_params_number);
143146
144- JERRY_ASSERT (ecma_is_value_string (*formal_params_iter_p-> current_value_p ));
145- formal_params[param_index] = ecma_get_string_from_value (*formal_params_iter_p-> current_value_p );
147+ JERRY_ASSERT (ecma_is_value_string (*formal_params_iterator. current_value_p ));
148+ formal_params[param_index] = ecma_get_string_from_value (*formal_params_iterator. current_value_p );
146149 }
147150 JERRY_ASSERT (param_index == formal_params_number);
148151
@@ -162,17 +165,22 @@ ecma_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function */
162165 if (ecma_compare_ecma_strings (name_p, formal_params[indx2]))
163166 {
164167 is_first_occurence = false ;
168+
169+ break ;
165170 }
166171 }
167172
168173 if (is_first_occurence)
169174 {
170- ecma_string_t *indx_string_p = ecma_new_ecma_string_from_number ( ecma_uint32_to_number (( uint32_t ) indx) );
175+ ecma_string_t *indx_string_p = ecma_new_ecma_string_from_uint32 (( uint32_t ) indx);
171176
172177 prop_desc = ecma_make_empty_property_descriptor ();
173178 {
174179 prop_desc.is_value_defined = true ;
175180 prop_desc.value = ecma_make_string_value (name_p);
181+
182+ prop_desc.is_configurable_defined = true ;
183+ prop_desc.is_configurable = true ;
176184 }
177185
178186 completion = ecma_op_object_define_own_property (map_p,
@@ -264,11 +272,14 @@ ecma_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function */
264272 }
265273
266274 return obj_p;
267- } /* ecma_create_arguments_object */
275+ } /* ecma_op_create_arguments_object */
268276
269277/* *
270278 * Get value of function's argument mapped to index of Arguments object.
271279 *
280+ * Note:
281+ * The procedure emulates execution of function described by MakeArgGetter
282+ *
272283 * @return completion value
273284 * Returned value must be freed with ecma_free_completion_value
274285 */
@@ -437,32 +448,36 @@ ecma_op_arguments_object_define_own_property (ecma_object_t *obj_p, /**< the obj
437448 // i.
438449 if (property_desc_p->is_value_defined )
439450 {
440- completion = ecma_op_object_put (map_p,
441- property_name_p,
442- property_desc_p->value ,
443- is_throw);
444- }
451+ /* emulating execution of function described by MakeArgSetter */
452+ ecma_property_t *scope_prop_p = ecma_get_internal_property (map_p, ECMA_INTERNAL_PROPERTY_SCOPE);
453+ ecma_object_t *lex_env_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t ,
454+ scope_prop_p->u .internal_property .value );
445455
446- if (unlikely (ecma_is_completion_value_throw (completion)))
447- {
448- ret_value = completion;
456+ ecma_property_t *mapped_prop_p = ecma_op_object_get_own_property (map_p, property_name_p);
457+ ecma_value_t arg_name_prop_value = ecma_get_named_data_property_value (mapped_prop_p);
458+
459+ ecma_string_t *arg_name_p = ecma_get_string_from_value (arg_name_prop_value);
460+
461+ completion = ecma_op_set_mutable_binding (lex_env_p,
462+ arg_name_p,
463+ property_desc_p->value ,
464+ true );
465+ JERRY_ASSERT (ecma_is_completion_value_empty (completion));
449466 }
450- else
451- {
452- // ii.
453- if (property_desc_p->is_writable_defined
454- && !property_desc_p->is_writable )
455- {
456- completion = ecma_op_object_delete (map_p,
457- property_name_p,
458- false );
459467
460- JERRY_ASSERT (ecma_is_completion_value_normal_true (completion));
461- }
468+ // ii.
469+ if (property_desc_p->is_writable_defined
470+ && !property_desc_p->is_writable )
471+ {
472+ completion = ecma_op_object_delete (map_p,
473+ property_name_p,
474+ false );
462475
463- // 6.
464- ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
476+ JERRY_ASSERT (ecma_is_completion_value_normal_true (completion));
465477 }
478+
479+ // 6.
480+ ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
466481 }
467482 }
468483 else
0 commit comments