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 OPCODES_H 17 #define OPCODES_H 18 19 #include "ecma-globals.h" 20 #include "vm-defines.h" 21 22 /** \addtogroup vm Virtual machine 23 * @{ 24 * 25 * \addtogroup vm_opcodes Opcodes 26 * @{ 27 */ 28 29 /** 30 * Number arithmetic operations. 31 */ 32 typedef enum 33 { 34 NUMBER_ARITHMETIC_SUBTRACTION, /**< subtraction */ 35 NUMBER_ARITHMETIC_MULTIPLICATION, /**< multiplication */ 36 NUMBER_ARITHMETIC_DIVISION, /**< division */ 37 NUMBER_ARITHMETIC_REMAINDER, /**< remainder calculation */ 38 #if ENABLED (JERRY_ES2015) 39 NUMBER_ARITHMETIC_EXPONENTIATION, /**< exponentiation */ 40 #endif /* ENABLED (JERRY_ES2015) */ 41 } number_arithmetic_op; 42 43 /** 44 * Number bitwise logic operations. 45 */ 46 typedef enum 47 { 48 NUMBER_BITWISE_LOGIC_AND, /**< bitwise AND calculation */ 49 NUMBER_BITWISE_LOGIC_OR, /**< bitwise OR calculation */ 50 NUMBER_BITWISE_LOGIC_XOR, /**< bitwise XOR calculation */ 51 NUMBER_BITWISE_SHIFT_LEFT, /**< bitwise LEFT SHIFT calculation */ 52 NUMBER_BITWISE_SHIFT_RIGHT, /**< bitwise RIGHT_SHIFT calculation */ 53 NUMBER_BITWISE_SHIFT_URIGHT, /**< bitwise UNSIGNED RIGHT SHIFT calculation */ 54 NUMBER_BITWISE_NOT, /**< bitwise NOT calculation */ 55 } number_bitwise_logic_op; 56 57 /** 58 * The stack contains spread object during the upcoming APPEND_ARRAY operation 59 */ 60 #define OPFUNC_HAS_SPREAD_ELEMENT (1 << 8) 61 62 ecma_value_t 63 vm_var_decl (ecma_object_t *lex_env_p, ecma_string_t *var_name_str_p, bool is_configurable_bindings); 64 65 ecma_value_t 66 vm_set_var (ecma_object_t *lex_env_p, ecma_string_t *var_name_str_p, bool is_strict, ecma_value_t lit_value); 67 68 ecma_value_t 69 opfunc_equality (ecma_value_t left_value, ecma_value_t right_value); 70 71 ecma_value_t 72 do_number_arithmetic (number_arithmetic_op op, ecma_value_t left_value, ecma_value_t right_value); 73 74 ecma_value_t 75 opfunc_unary_operation (ecma_value_t left_value, bool is_plus); 76 77 ecma_value_t 78 do_number_bitwise_logic (number_bitwise_logic_op op, ecma_value_t left_value, ecma_value_t right_value); 79 80 ecma_value_t 81 opfunc_addition (ecma_value_t left_value, ecma_value_t right_value); 82 83 ecma_value_t 84 opfunc_relation (ecma_value_t left_value, ecma_value_t right_value, bool left_first, bool is_invert); 85 86 ecma_value_t 87 opfunc_in (ecma_value_t left_value, ecma_value_t right_value); 88 89 ecma_value_t 90 opfunc_instanceof (ecma_value_t left_value, ecma_value_t right_value); 91 92 ecma_value_t 93 opfunc_typeof (ecma_value_t left_value); 94 95 void 96 opfunc_set_accessor (bool is_getter, ecma_value_t object, ecma_string_t *accessor_name_p, ecma_value_t accessor); 97 98 ecma_value_t 99 vm_op_delete_prop (ecma_value_t object, ecma_value_t property, bool is_strict); 100 101 ecma_value_t 102 vm_op_delete_var (ecma_value_t name_literal, ecma_object_t *lex_env_p); 103 104 ecma_collection_t * 105 opfunc_for_in (ecma_value_t left_value, ecma_value_t *result_obj_p); 106 107 #if ENABLED (JERRY_ES2015) 108 ecma_collection_t * 109 opfunc_spread_arguments (ecma_value_t *stack_top_p, uint8_t argument_list_len); 110 #endif /* ENABLED (JERRY_ES2015) */ 111 112 ecma_value_t 113 opfunc_append_array (ecma_value_t *stack_top_p, uint16_t values_length); 114 115 #if ENABLED (JERRY_ES2015) 116 ecma_value_t 117 opfunc_create_executable_object (vm_frame_ctx_t *frame_ctx_p); 118 119 ecma_value_t 120 opfunc_resume_executable_object (vm_executable_object_t *executable_object_p, ecma_value_t value); 121 122 ecma_value_t 123 opfunc_return_promise (ecma_value_t value); 124 125 ecma_value_t 126 opfunc_create_implicit_class_constructor (uint8_t opcode); 127 128 void 129 opfunc_push_class_environment (vm_frame_ctx_t *frame_ctx_p, ecma_value_t **vm_stack_top, ecma_value_t class_name); 130 131 ecma_value_t 132 opfunc_init_class (vm_frame_ctx_t *frame_context_p, ecma_value_t *stack_top_p); 133 134 void 135 opfunc_pop_lexical_environment (vm_frame_ctx_t *frame_ctx_p); 136 137 void 138 opfunc_finalize_class (vm_frame_ctx_t *frame_ctx_p, ecma_value_t **vm_stack_top_p, ecma_value_t class_name); 139 140 ecma_value_t 141 opfunc_form_super_reference (ecma_value_t **vm_stack_top_p, vm_frame_ctx_t *frame_ctx_p, ecma_value_t prop_name, 142 uint8_t opcode); 143 144 ecma_value_t 145 opfunc_assign_super_reference (ecma_value_t **vm_stack_top_p, vm_frame_ctx_t *frame_ctx_p, uint32_t opcode_data); 146 #endif /* ENABLED (JERRY_ES2015) */ 147 148 /** 149 * @} 150 * @} 151 */ 152 153 #endif /* !OPCODES_H */ 154