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_BUILTINS_H 17#define ECMA_BUILTINS_H 18 19#include "ecma-globals.h" 20 21/** 22 * A built-in object's identifier 23 */ 24typedef enum 25{ 26/** @cond doxygen_suppress */ 27#define BUILTIN(a, b, c, d, e) 28#define BUILTIN_ROUTINE(builtin_id, \ 29 object_type, \ 30 object_prototype_builtin_id, \ 31 is_extensible, \ 32 lowercase_name) \ 33 builtin_id, 34#include "ecma-builtins.inc.h" 35#undef BUILTIN 36#undef BUILTIN_ROUTINE 37#define BUILTIN_ROUTINE(a, b, c, d, e) 38#define BUILTIN(builtin_id, \ 39 object_type, \ 40 object_prototype_builtin_id, \ 41 is_extensible, \ 42 lowercase_name) \ 43 builtin_id, 44#include "ecma-builtins.inc.h" 45#undef BUILTIN 46#undef BUILTIN_ROUTINE 47/** @endcond */ 48 ECMA_BUILTIN_ID__COUNT /**< number of built-in objects */ 49} ecma_builtin_id_t; 50 51/** 52 * Construct a routine value 53 */ 54#define ECMA_ROUTINE_VALUE(id, length) (((id) << 4) | length) 55 56/** 57 * Get routine length 58 */ 59#define ECMA_GET_ROUTINE_LENGTH(value) ((uint8_t) ((value) & 0xf)) 60 61/** 62 * Get routine ID 63 */ 64#define ECMA_GET_ROUTINE_ID(value) ((uint16_t) ((value) >> 4)) 65 66/** 67 * Construct a fully accessor value 68 */ 69#define ECMA_ACCESSOR_READ_WRITE(getter, setter) (((getter) << 8) | (setter)) 70 71/** 72 * Get accessor setter ID 73 */ 74#define ECMA_ACCESSOR_READ_WRITE_GET_SETTER_ID(value) ((uint16_t) ((value) & 0xff)) 75 76/** 77 * Get accessor getter ID 78 */ 79#define ECMA_ACCESSOR_READ_WRITE_GET_GETTER_ID(value) ((uint16_t) ((value) >> 8)) 80 81/* ecma-builtins.c */ 82void ecma_finalize_builtins (void); 83 84ecma_value_t 85ecma_builtin_dispatch_call (ecma_object_t *obj_p, ecma_value_t this_arg_value, 86 const ecma_value_t *arguments_list_p, ecma_length_t arguments_list_len); 87ecma_value_t 88ecma_builtin_dispatch_construct (ecma_object_t *obj_p, ecma_object_t *new_target_p, 89 const ecma_value_t *arguments_list_p, ecma_length_t arguments_list_len); 90ecma_property_t * 91ecma_builtin_routine_try_to_instantiate_property (ecma_object_t *object_p, ecma_string_t *string_p); 92ecma_property_t * 93ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, ecma_string_t *string_p); 94void 95ecma_builtin_routine_list_lazy_property_names (ecma_object_t *object_p, 96 uint32_t opts, 97 ecma_collection_t *main_collection_p, 98 ecma_collection_t *non_enum_collection_p); 99void 100ecma_builtin_list_lazy_property_names (ecma_object_t *object_p, 101 uint32_t opts, 102 ecma_collection_t *main_collection_p, 103 ecma_collection_t *non_enum_collection_p); 104bool 105ecma_builtin_is (ecma_object_t *obj_p, ecma_builtin_id_t builtin_id); 106ecma_object_t * 107ecma_builtin_get (ecma_builtin_id_t builtin_id); 108ecma_object_t * 109ecma_builtin_get_global (void); 110bool 111ecma_builtin_function_is_routine (ecma_object_t *func_obj_p); 112 113#endif /* !ECMA_BUILTINS_H */ 114