1425bb815Sopenharmony_ci/* Copyright JS Foundation and other contributors, http://js.foundation
2425bb815Sopenharmony_ci *
3425bb815Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4425bb815Sopenharmony_ci * you may not use this file except in compliance with the License.
5425bb815Sopenharmony_ci * You may obtain a copy of the License at
6425bb815Sopenharmony_ci *
7425bb815Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8425bb815Sopenharmony_ci *
9425bb815Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10425bb815Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS
11425bb815Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12425bb815Sopenharmony_ci * See the License for the specific language governing permissions and
13425bb815Sopenharmony_ci * limitations under the License.
14425bb815Sopenharmony_ci */
15425bb815Sopenharmony_ci
16425bb815Sopenharmony_ci#ifndef ECMA_ARRAY_OBJECT_H
17425bb815Sopenharmony_ci#define ECMA_ARRAY_OBJECT_H
18425bb815Sopenharmony_ci
19425bb815Sopenharmony_ci#include "ecma-globals.h"
20425bb815Sopenharmony_ci
21425bb815Sopenharmony_ci/** \addtogroup ecma ECMA
22425bb815Sopenharmony_ci * @{
23425bb815Sopenharmony_ci *
24425bb815Sopenharmony_ci * \addtogroup ecmaarrayobject ECMA Array object related routines
25425bb815Sopenharmony_ci * @{
26425bb815Sopenharmony_ci */
27425bb815Sopenharmony_ci
28425bb815Sopenharmony_ci/**
29425bb815Sopenharmony_ci * Maximum number of new array holes in a fast mode access array.
30425bb815Sopenharmony_ci * If the number of new holes exceeds this limit, the array is converted back
31425bb815Sopenharmony_ci * to normal property list based array.
32425bb815Sopenharmony_ci */
33425bb815Sopenharmony_ci#define ECMA_FAST_ARRAY_MAX_NEW_HOLES_COUNT 32
34425bb815Sopenharmony_ci
35425bb815Sopenharmony_ci/**
36425bb815Sopenharmony_ci * Bitshift index for fast array hole count representation
37425bb815Sopenharmony_ci */
38425bb815Sopenharmony_ci#define ECMA_FAST_ARRAY_HOLE_SHIFT 8
39425bb815Sopenharmony_ci
40425bb815Sopenharmony_ci/**
41425bb815Sopenharmony_ci * This number represents 1 array hole in underlying buffer of a fast acces mode array
42425bb815Sopenharmony_ci */
43425bb815Sopenharmony_ci#define ECMA_FAST_ARRAY_HOLE_ONE (1 << ECMA_FAST_ARRAY_HOLE_SHIFT)
44425bb815Sopenharmony_ci
45425bb815Sopenharmony_ci/**
46425bb815Sopenharmony_ci * Maximum number of array holes in a fast access mode array
47425bb815Sopenharmony_ci */
48425bb815Sopenharmony_ci#define ECMA_FAST_ARRAY_MAX_HOLE_COUNT (1 << 24)
49425bb815Sopenharmony_ci
50425bb815Sopenharmony_ci/**
51425bb815Sopenharmony_ci * Flags for ecma_op_array_object_set_length
52425bb815Sopenharmony_ci */
53425bb815Sopenharmony_citypedef enum
54425bb815Sopenharmony_ci{
55425bb815Sopenharmony_ci  ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_IS_THROW = 1u << 0, /**< is_throw flag is set */
56425bb815Sopenharmony_ci  ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_REJECT = 1u << 1, /**< reject later because the descriptor flags
57425bb815Sopenharmony_ci                                                       *   contains an unallowed combination */
58425bb815Sopenharmony_ci  ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_WRITABLE_DEFINED = 1u << 2, /**< writable flag defined
59425bb815Sopenharmony_ci                                                                 *   in the property descriptor */
60425bb815Sopenharmony_ci  ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_WRITABLE = 1u << 3, /**< writable flag enabled
61425bb815Sopenharmony_ci                                                         *   in the property descriptor */
62425bb815Sopenharmony_ci} ecma_array_object_set_length_flags_t;
63425bb815Sopenharmony_ci
64425bb815Sopenharmony_ciecma_object_t *
65425bb815Sopenharmony_ciecma_op_new_array_object (ecma_length_t length);
66425bb815Sopenharmony_ci
67425bb815Sopenharmony_ciecma_object_t *
68425bb815Sopenharmony_ciecma_op_new_fast_array_object (ecma_length_t length);
69425bb815Sopenharmony_ci
70425bb815Sopenharmony_cibool
71425bb815Sopenharmony_ciecma_op_object_is_fast_array (ecma_object_t *object_p);
72425bb815Sopenharmony_ci
73425bb815Sopenharmony_cibool
74425bb815Sopenharmony_ciecma_op_array_is_fast_array (ecma_extended_object_t *array_p);
75425bb815Sopenharmony_ci
76425bb815Sopenharmony_ciuint32_t
77425bb815Sopenharmony_ciecma_fast_array_get_hole_count (ecma_object_t *obj_p);
78425bb815Sopenharmony_ci
79425bb815Sopenharmony_ciecma_value_t *
80425bb815Sopenharmony_ciecma_fast_array_extend (ecma_object_t *object_p, uint32_t new_lengt);
81425bb815Sopenharmony_ci
82425bb815Sopenharmony_cibool
83425bb815Sopenharmony_ciecma_fast_array_set_property (ecma_object_t *object_p, uint32_t index, ecma_value_t value);
84425bb815Sopenharmony_ci
85425bb815Sopenharmony_civoid
86425bb815Sopenharmony_ciecma_array_object_delete_property (ecma_object_t *object_p, ecma_string_t *property_name_p,
87425bb815Sopenharmony_ci                                   ecma_property_value_t *prop_value_p);
88425bb815Sopenharmony_ci
89425bb815Sopenharmony_ciuint32_t
90425bb815Sopenharmony_ciecma_delete_fast_array_properties (ecma_object_t *object_p, uint32_t new_length);
91425bb815Sopenharmony_ci
92425bb815Sopenharmony_ciecma_collection_t *
93425bb815Sopenharmony_ciecma_fast_array_get_property_names (ecma_object_t *object_p, uint32_t opts);
94425bb815Sopenharmony_ci
95425bb815Sopenharmony_civoid
96425bb815Sopenharmony_ciecma_fast_array_convert_to_normal (ecma_object_t *object_p);
97425bb815Sopenharmony_ci
98425bb815Sopenharmony_ciecma_value_t
99425bb815Sopenharmony_ciecma_op_create_array_object (const ecma_value_t *arguments_list_p, ecma_length_t arguments_list_len,
100425bb815Sopenharmony_ci                             bool is_treat_single_arg_as_length);
101425bb815Sopenharmony_ci
102425bb815Sopenharmony_ci#if ENABLED (JERRY_ES2015)
103425bb815Sopenharmony_ciecma_value_t
104425bb815Sopenharmony_ciecma_op_array_species_create (ecma_object_t *original_array_p,
105425bb815Sopenharmony_ci                              ecma_length_t length);
106425bb815Sopenharmony_ci
107425bb815Sopenharmony_ciecma_value_t
108425bb815Sopenharmony_ciecma_op_create_array_iterator (ecma_object_t *obj_p,
109425bb815Sopenharmony_ci                               ecma_array_iterator_type_t type);
110425bb815Sopenharmony_ci#endif /* ENABLED (JERRY_ES2015) */
111425bb815Sopenharmony_ci
112425bb815Sopenharmony_ciecma_value_t
113425bb815Sopenharmony_ciecma_op_array_object_set_length (ecma_object_t *object_p, ecma_value_t new_value, uint32_t flags);
114425bb815Sopenharmony_ci
115425bb815Sopenharmony_ciecma_value_t
116425bb815Sopenharmony_ciecma_op_array_object_define_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p,
117425bb815Sopenharmony_ci                                          const ecma_property_descriptor_t *property_desc_p);
118425bb815Sopenharmony_ci
119425bb815Sopenharmony_ciuint32_t ecma_array_get_length (ecma_object_t *array_p);
120425bb815Sopenharmony_ci
121425bb815Sopenharmony_civoid
122425bb815Sopenharmony_ciecma_op_array_list_lazy_property_names (ecma_object_t *obj_p,
123425bb815Sopenharmony_ci                                        uint32_t opts,
124425bb815Sopenharmony_ci                                        ecma_collection_t *main_collection_p,
125425bb815Sopenharmony_ci                                        ecma_collection_t *non_enum_collection_p);
126425bb815Sopenharmony_ci
127425bb815Sopenharmony_ci/**
128425bb815Sopenharmony_ci * @}
129425bb815Sopenharmony_ci * @}
130425bb815Sopenharmony_ci */
131425bb815Sopenharmony_ci
132425bb815Sopenharmony_ci#endif /* !ECMA_ARRAY_OBJECT_H */
133