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_INTERNAL_H 17 #define ECMA_BUILTINS_INTERNAL_H 18 19 #ifndef ECMA_BUILTINS_INTERNAL 20 # error "!ECMA_BUILTINS_INTERNAL" 21 #endif /* !ECMA_BUILTINS_INTERNAL */ 22 23 #include "ecma-builtins.h" 24 #include "ecma-globals.h" 25 26 /** 27 * Type of built-in properties. 28 */ 29 typedef enum 30 { 31 ECMA_BUILTIN_PROPERTY_SIMPLE, /**< simple value property */ 32 ECMA_BUILTIN_PROPERTY_NUMBER, /**< number value property */ 33 ECMA_BUILTIN_PROPERTY_STRING, /**< string value property */ 34 #if ENABLED (JERRY_ES2015) 35 ECMA_BUILTIN_PROPERTY_SYMBOL, /**< symbol value property */ 36 ECMA_BUILTIN_PROPERTY_INTRINSIC_PROPERTY, /**< intrinsic routine property */ 37 ECMA_BUILTIN_PROPERTY_ACCESSOR_BUILTIN_FUNCTION, /**< full accessor property with builtin function object 38 getter/setter pair */ 39 #endif /* ENABLED (JERRY_ES2015) */ 40 ECMA_BUILTIN_PROPERTY_OBJECT, /**< builtin object property */ 41 ECMA_BUILTIN_PROPERTY_ROUTINE, /**< routine property */ 42 ECMA_BUILTIN_PROPERTY_ACCESSOR_READ_WRITE, /**< full accessor property */ 43 ECMA_BUILTIN_PROPERTY_ACCESSOR_READ_ONLY, /**< read-only accessor property */ 44 ECMA_BUILTIN_PROPERTY_END, /**< last property */ 45 } ecma_builtin_property_type_t; 46 47 /** 48 * Type of symbolic built-in number types (starting from 256). 49 */ 50 typedef enum 51 { 52 ECMA_BUILTIN_NUMBER_MAX = 256, /**< value of ECMA_NUMBER_MAX_VALUE */ 53 ECMA_BUILTIN_NUMBER_MIN, /**< value of ECMA_NUMBER_MIN_VALUE */ 54 #if ENABLED (JERRY_ES2015) 55 ECMA_BUILTIN_NUMBER_EPSILON, /**< value of ECMA_NUMBER_EPSILON */ 56 ECMA_BUILTIN_NUMBER_MAX_SAFE_INTEGER, /**< value of ECMA_NUMBER_MAX_SAFE_INTEGER */ 57 ECMA_BUILTIN_NUMBER_MIN_SAFE_INTEGER, /**< value of ECMA_NUMBER_MIN_SAFE_INTEGER */ 58 #endif /* ENABLED (JERRY_ES2015) */ 59 ECMA_BUILTIN_NUMBER_E, /**< value of ECMA_NUMBER_E */ 60 ECMA_BUILTIN_NUMBER_PI, /**< value of ECMA_NUMBER_PI */ 61 ECMA_BUILTIN_NUMBER_LN10, /**< value of ECMA_NUMBER_LN10 */ 62 ECMA_BUILTIN_NUMBER_LN2, /**< value of ECMA_NUMBER_LN2 */ 63 ECMA_BUILTIN_NUMBER_LOG2E, /**< value of ECMA_NUMBER_LOG2E */ 64 ECMA_BUILTIN_NUMBER_LOG10E, /**< value of ECMA_NUMBER_LOG10E */ 65 ECMA_BUILTIN_NUMBER_SQRT2, /**< value of ECMA_NUMBER_SQRT2 */ 66 ECMA_BUILTIN_NUMBER_SQRT_1_2, /**< value of ECMA_NUMBER_SQRT_1_2 */ 67 ECMA_BUILTIN_NUMBER_NAN, /**< result of ecma_number_make_nan () */ 68 ECMA_BUILTIN_NUMBER_POSITIVE_INFINITY, /**< result of ecma_number_make_infinity (false) */ 69 ECMA_BUILTIN_NUMBER_NEGATIVE_INFINITY, /**< result of ecma_number_make_infinity (true) */ 70 } ecma_builtin_number_type_t; 71 72 /** 73 * Description of built-in properties. 74 */ 75 typedef struct 76 { 77 uint16_t magic_string_id; /**< name of the property */ 78 uint8_t type; /**< type of the property */ 79 uint8_t attributes; /**< attributes of the property */ 80 uint16_t value; /**< value of the property */ 81 } ecma_builtin_property_descriptor_t; 82 83 #define BUILTIN_ROUTINE(builtin_id, \ 84 object_type, \ 85 object_prototype_builtin_id, \ 86 is_extensible, \ 87 lowercase_name) \ 88 extern const ecma_builtin_property_descriptor_t \ 89 ecma_builtin_ ## lowercase_name ## _property_descriptor_list[]; \ 90 ecma_value_t \ 91 ecma_builtin_ ## lowercase_name ## _dispatch_call (const ecma_value_t *, \ 92 ecma_length_t); \ 93 ecma_value_t \ 94 ecma_builtin_ ## lowercase_name ## _dispatch_construct (const ecma_value_t *, \ 95 ecma_length_t); \ 96 ecma_value_t \ 97 ecma_builtin_ ## lowercase_name ## _dispatch_routine (uint16_t builtin_routine_id, \ 98 ecma_value_t this_arg_value, \ 99 const ecma_value_t [], \ 100 ecma_length_t); 101 #define BUILTIN(builtin_id, \ 102 object_type, \ 103 object_prototype_builtin_id, \ 104 is_extensible, \ 105 lowercase_name) \ 106 extern const ecma_builtin_property_descriptor_t \ 107 ecma_builtin_ ## lowercase_name ## _property_descriptor_list[]; \ 108 ecma_value_t \ 109 ecma_builtin_ ## lowercase_name ## _dispatch_routine (uint16_t builtin_routine_id, \ 110 ecma_value_t this_arg_value, \ 111 const ecma_value_t [], \ 112 ecma_length_t); 113 #include "ecma-builtins.inc.h" 114 115 #undef BUILTIN_ROUTINE 116 #undef BUILTIN 117 118 #endif /* !ECMA_BUILTINS_INTERNAL_H */ 119