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_BUILTINS_H
17425bb815Sopenharmony_ci#define ECMA_BUILTINS_H
18425bb815Sopenharmony_ci
19425bb815Sopenharmony_ci#include "ecma-globals.h"
20425bb815Sopenharmony_ci
21425bb815Sopenharmony_ci/**
22425bb815Sopenharmony_ci * A built-in object's identifier
23425bb815Sopenharmony_ci */
24425bb815Sopenharmony_citypedef enum
25425bb815Sopenharmony_ci{
26425bb815Sopenharmony_ci/** @cond doxygen_suppress */
27425bb815Sopenharmony_ci#define BUILTIN(a, b, c, d, e)
28425bb815Sopenharmony_ci#define BUILTIN_ROUTINE(builtin_id, \
29425bb815Sopenharmony_ci                        object_type, \
30425bb815Sopenharmony_ci                        object_prototype_builtin_id, \
31425bb815Sopenharmony_ci                        is_extensible, \
32425bb815Sopenharmony_ci                        lowercase_name) \
33425bb815Sopenharmony_ci  builtin_id,
34425bb815Sopenharmony_ci#include "ecma-builtins.inc.h"
35425bb815Sopenharmony_ci#undef BUILTIN
36425bb815Sopenharmony_ci#undef BUILTIN_ROUTINE
37425bb815Sopenharmony_ci#define BUILTIN_ROUTINE(a, b, c, d, e)
38425bb815Sopenharmony_ci#define BUILTIN(builtin_id, \
39425bb815Sopenharmony_ci                object_type, \
40425bb815Sopenharmony_ci                object_prototype_builtin_id, \
41425bb815Sopenharmony_ci                is_extensible, \
42425bb815Sopenharmony_ci                lowercase_name) \
43425bb815Sopenharmony_ci  builtin_id,
44425bb815Sopenharmony_ci#include "ecma-builtins.inc.h"
45425bb815Sopenharmony_ci#undef BUILTIN
46425bb815Sopenharmony_ci#undef BUILTIN_ROUTINE
47425bb815Sopenharmony_ci/** @endcond */
48425bb815Sopenharmony_ci  ECMA_BUILTIN_ID__COUNT /**< number of built-in objects */
49425bb815Sopenharmony_ci} ecma_builtin_id_t;
50425bb815Sopenharmony_ci
51425bb815Sopenharmony_ci/**
52425bb815Sopenharmony_ci * Construct a routine value
53425bb815Sopenharmony_ci */
54425bb815Sopenharmony_ci#define ECMA_ROUTINE_VALUE(id, length) (((id) << 4) | length)
55425bb815Sopenharmony_ci
56425bb815Sopenharmony_ci/**
57425bb815Sopenharmony_ci * Get routine length
58425bb815Sopenharmony_ci */
59425bb815Sopenharmony_ci#define ECMA_GET_ROUTINE_LENGTH(value) ((uint8_t) ((value) & 0xf))
60425bb815Sopenharmony_ci
61425bb815Sopenharmony_ci/**
62425bb815Sopenharmony_ci * Get routine ID
63425bb815Sopenharmony_ci */
64425bb815Sopenharmony_ci#define ECMA_GET_ROUTINE_ID(value) ((uint16_t) ((value) >> 4))
65425bb815Sopenharmony_ci
66425bb815Sopenharmony_ci/**
67425bb815Sopenharmony_ci * Construct a fully accessor value
68425bb815Sopenharmony_ci */
69425bb815Sopenharmony_ci#define ECMA_ACCESSOR_READ_WRITE(getter, setter) (((getter) << 8) | (setter))
70425bb815Sopenharmony_ci
71425bb815Sopenharmony_ci/**
72425bb815Sopenharmony_ci * Get accessor setter ID
73425bb815Sopenharmony_ci */
74425bb815Sopenharmony_ci#define ECMA_ACCESSOR_READ_WRITE_GET_SETTER_ID(value) ((uint16_t) ((value) & 0xff))
75425bb815Sopenharmony_ci
76425bb815Sopenharmony_ci/**
77425bb815Sopenharmony_ci * Get accessor getter ID
78425bb815Sopenharmony_ci */
79425bb815Sopenharmony_ci#define ECMA_ACCESSOR_READ_WRITE_GET_GETTER_ID(value) ((uint16_t) ((value) >> 8))
80425bb815Sopenharmony_ci
81425bb815Sopenharmony_ci/* ecma-builtins.c */
82425bb815Sopenharmony_civoid ecma_finalize_builtins (void);
83425bb815Sopenharmony_ci
84425bb815Sopenharmony_ciecma_value_t
85425bb815Sopenharmony_ciecma_builtin_dispatch_call (ecma_object_t *obj_p, ecma_value_t this_arg_value,
86425bb815Sopenharmony_ci                            const ecma_value_t *arguments_list_p, ecma_length_t arguments_list_len);
87425bb815Sopenharmony_ciecma_value_t
88425bb815Sopenharmony_ciecma_builtin_dispatch_construct (ecma_object_t *obj_p, ecma_object_t *new_target_p,
89425bb815Sopenharmony_ci                                 const ecma_value_t *arguments_list_p, ecma_length_t arguments_list_len);
90425bb815Sopenharmony_ciecma_property_t *
91425bb815Sopenharmony_ciecma_builtin_routine_try_to_instantiate_property (ecma_object_t *object_p, ecma_string_t *string_p);
92425bb815Sopenharmony_ciecma_property_t *
93425bb815Sopenharmony_ciecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, ecma_string_t *string_p);
94425bb815Sopenharmony_civoid
95425bb815Sopenharmony_ciecma_builtin_routine_list_lazy_property_names (ecma_object_t *object_p,
96425bb815Sopenharmony_ci                                                uint32_t opts,
97425bb815Sopenharmony_ci                                                ecma_collection_t *main_collection_p,
98425bb815Sopenharmony_ci                                                ecma_collection_t *non_enum_collection_p);
99425bb815Sopenharmony_civoid
100425bb815Sopenharmony_ciecma_builtin_list_lazy_property_names (ecma_object_t *object_p,
101425bb815Sopenharmony_ci                                       uint32_t opts,
102425bb815Sopenharmony_ci                                       ecma_collection_t *main_collection_p,
103425bb815Sopenharmony_ci                                       ecma_collection_t *non_enum_collection_p);
104425bb815Sopenharmony_cibool
105425bb815Sopenharmony_ciecma_builtin_is (ecma_object_t *obj_p, ecma_builtin_id_t builtin_id);
106425bb815Sopenharmony_ciecma_object_t *
107425bb815Sopenharmony_ciecma_builtin_get (ecma_builtin_id_t builtin_id);
108425bb815Sopenharmony_ciecma_object_t *
109425bb815Sopenharmony_ciecma_builtin_get_global (void);
110425bb815Sopenharmony_cibool
111425bb815Sopenharmony_ciecma_builtin_function_is_routine (ecma_object_t *func_obj_p);
112425bb815Sopenharmony_ci
113425bb815Sopenharmony_ci#endif /* !ECMA_BUILTINS_H */
114