• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright JS Foundation and other contributors, http://js.foundation
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ECMA_ARRAY_OBJECT_H
17 #define ECMA_ARRAY_OBJECT_H
18 
19 #include "ecma-globals.h"
20 
21 /** \addtogroup ecma ECMA
22  * @{
23  *
24  * \addtogroup ecmaarrayobject ECMA Array object related routines
25  * @{
26  */
27 
28 /**
29  * Maximum number of new array holes in a fast mode access array.
30  * If the number of new holes exceeds this limit, the array is converted back
31  * to normal property list based array.
32  */
33 #define ECMA_FAST_ARRAY_MAX_NEW_HOLES_COUNT 32
34 
35 /**
36  * Bitshift index for fast array hole count representation
37  */
38 #define ECMA_FAST_ARRAY_HOLE_SHIFT 8
39 
40 /**
41  * This number represents 1 array hole in underlying buffer of a fast acces mode array
42  */
43 #define ECMA_FAST_ARRAY_HOLE_ONE (1 << ECMA_FAST_ARRAY_HOLE_SHIFT)
44 
45 /**
46  * Maximum number of array holes in a fast access mode array
47  */
48 #define ECMA_FAST_ARRAY_MAX_HOLE_COUNT (1 << 24)
49 
50 /**
51  * Flags for ecma_op_array_object_set_length
52  */
53 typedef enum
54 {
55   ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_IS_THROW = 1u << 0, /**< is_throw flag is set */
56   ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_REJECT = 1u << 1, /**< reject later because the descriptor flags
57                                                        *   contains an unallowed combination */
58   ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_WRITABLE_DEFINED = 1u << 2, /**< writable flag defined
59                                                                  *   in the property descriptor */
60   ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_WRITABLE = 1u << 3, /**< writable flag enabled
61                                                          *   in the property descriptor */
62 } ecma_array_object_set_length_flags_t;
63 
64 ecma_object_t *
65 ecma_op_new_array_object (ecma_length_t length);
66 
67 ecma_object_t *
68 ecma_op_new_fast_array_object (ecma_length_t length);
69 
70 bool
71 ecma_op_object_is_fast_array (ecma_object_t *object_p);
72 
73 bool
74 ecma_op_array_is_fast_array (ecma_extended_object_t *array_p);
75 
76 uint32_t
77 ecma_fast_array_get_hole_count (ecma_object_t *obj_p);
78 
79 ecma_value_t *
80 ecma_fast_array_extend (ecma_object_t *object_p, uint32_t new_lengt);
81 
82 bool
83 ecma_fast_array_set_property (ecma_object_t *object_p, uint32_t index, ecma_value_t value);
84 
85 void
86 ecma_array_object_delete_property (ecma_object_t *object_p, ecma_string_t *property_name_p,
87                                    ecma_property_value_t *prop_value_p);
88 
89 uint32_t
90 ecma_delete_fast_array_properties (ecma_object_t *object_p, uint32_t new_length);
91 
92 ecma_collection_t *
93 ecma_fast_array_get_property_names (ecma_object_t *object_p, uint32_t opts);
94 
95 void
96 ecma_fast_array_convert_to_normal (ecma_object_t *object_p);
97 
98 ecma_value_t
99 ecma_op_create_array_object (const ecma_value_t *arguments_list_p, ecma_length_t arguments_list_len,
100                              bool is_treat_single_arg_as_length);
101 
102 #if ENABLED (JERRY_ES2015)
103 ecma_value_t
104 ecma_op_array_species_create (ecma_object_t *original_array_p,
105                               ecma_length_t length);
106 
107 ecma_value_t
108 ecma_op_create_array_iterator (ecma_object_t *obj_p,
109                                ecma_array_iterator_type_t type);
110 #endif /* ENABLED (JERRY_ES2015) */
111 
112 ecma_value_t
113 ecma_op_array_object_set_length (ecma_object_t *object_p, ecma_value_t new_value, uint32_t flags);
114 
115 ecma_value_t
116 ecma_op_array_object_define_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p,
117                                           const ecma_property_descriptor_t *property_desc_p);
118 
119 uint32_t ecma_array_get_length (ecma_object_t *array_p);
120 
121 void
122 ecma_op_array_list_lazy_property_names (ecma_object_t *obj_p,
123                                         uint32_t opts,
124                                         ecma_collection_t *main_collection_p,
125                                         ecma_collection_t *non_enum_collection_p);
126 
127 /**
128  * @}
129  * @}
130  */
131 
132 #endif /* !ECMA_ARRAY_OBJECT_H */
133