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 (uint32_t length); |
66 | |
67 | ecma_object_t * |
68 | ecma_op_new_array_object_from_length (ecma_length_t length); |
69 | |
70 | ecma_value_t |
71 | ecma_op_new_array_object_from_buffer (const ecma_value_t *args_p, uint32_t length); |
72 | |
73 | ecma_value_t |
74 | ecma_op_new_array_object_from_collection (ecma_collection_t *collection_p, bool unref_objects); |
75 | |
76 | bool |
77 | ecma_op_object_is_fast_array (ecma_object_t *object_p); |
78 | |
79 | bool |
80 | ecma_op_array_is_fast_array (ecma_extended_object_t *array_p); |
81 | |
82 | uint32_t |
83 | ecma_fast_array_get_hole_count (ecma_object_t *obj_p); |
84 | |
85 | ecma_value_t * |
86 | ecma_fast_array_extend (ecma_object_t *object_p, uint32_t new_lengt); |
87 | |
88 | bool |
89 | ecma_fast_array_set_property (ecma_object_t *object_p, uint32_t index, ecma_value_t value); |
90 | |
91 | void |
92 | ecma_array_object_delete_property (ecma_object_t *object_p, ecma_string_t *property_name_p, |
93 | ecma_property_value_t *prop_value_p); |
94 | |
95 | uint32_t |
96 | ecma_delete_fast_array_properties (ecma_object_t *object_p, uint32_t new_length); |
97 | |
98 | ecma_collection_t * |
99 | ecma_fast_array_object_own_property_keys (ecma_object_t *object_p); |
100 | |
101 | void |
102 | ecma_fast_array_convert_to_normal (ecma_object_t *object_p); |
103 | |
104 | #if ENABLED (JERRY_ESNEXT) |
105 | ecma_object_t * |
106 | ecma_op_array_species_create (ecma_object_t *original_array_p, |
107 | ecma_length_t length); |
108 | |
109 | ecma_value_t |
110 | ecma_op_create_array_iterator (ecma_object_t *obj_p, |
111 | ecma_iterator_kind_t kind); |
112 | #endif /* ENABLED (JERRY_ESNEXT) */ |
113 | |
114 | ecma_value_t |
115 | ecma_op_array_object_set_length (ecma_object_t *object_p, ecma_value_t new_value, uint32_t flags); |
116 | |
117 | ecma_value_t |
118 | ecma_op_array_object_define_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p, |
119 | const ecma_property_descriptor_t *property_desc_p); |
120 | |
121 | uint32_t ecma_array_get_length (ecma_object_t *array_p); |
122 | |
123 | ecma_value_t |
124 | ecma_array_object_to_string (ecma_value_t this_arg); |
125 | |
126 | /** |
127 | * @} |
128 | * @} |
129 | */ |
130 | |
131 | #endif /* !ECMA_ARRAY_OBJECT_H */ |
132 | |