« blib/lib/SPVM/Document/NativeAPI/Internal.pm
↑ Summary
blib/lib/SPVM/Document/NativeAPI/Mutex.pm »
| 1 | =head1 Name | ||
| 2 | |||
| 3 | SPVM::Document::NativeAPI::Method - Method Native APIs | ||
| 4 | |||
| 5 | =head1 Description | ||
| 6 | |||
| 7 | The method native APIs in L<SPVM> are the APIs to get definition information for methods. | ||
| 8 | |||
| 9 | =head1 Usage | ||
| 10 | |||
| 11 | SPVM_API_METHOD* api_method = env->api->method; | ||
| 12 | |||
| 13 | SPVM_NATIVE_BASIC_TYPE* basic_type = env->get_basic_type(env, stack, "Foo"); | ||
| 14 | |||
| 15 | SPVM_NATIVE_METHOD* method = env->api->basic_type->get_method_by_name(env->runtime, basic_type, "get"); | ||
| 16 | |||
| 17 | const char* method_name = api_method->get_name(env->runtime, method); | ||
| 18 | |||
| 19 | =head1 Native APIs | ||
| 20 | |||
| 21 | =head2 get_name | ||
| 22 | |||
| 23 | C<const char* (*get_name)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 24 | |||
| 25 | Returns the name of the method I<method>. | ||
| 26 | |||
| 27 | =head2 get_index | ||
| 28 | |||
| 29 | C<int32_t (*get_index)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 30 | |||
| 31 | Returns the index of the method I<method>. This index is the position of the method I<method> in its belonging class. | ||
| 32 | |||
| 33 | =head2 get_return_basic_type | ||
| 34 | |||
| 35 | C<SPVM_NATIVE_BASIC_TYPE* (*get_return_basic_type)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 36 | |||
| 37 | Returns the L<basic type|SPVM::Document::NativeAPI::BasicType> of the return type of the method I<method>. | ||
| 38 | |||
| 39 | =head2 get_return_type_dimension | ||
| 40 | |||
| 41 | C<int32_t (*get_return_type_dimension)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 42 | |||
| 43 | Returns the type dimension of the return type of the method I<method>. | ||
| 44 | |||
| 45 | =head2 get_return_type_flag | ||
| 46 | |||
| 47 | C<int32_t (*get_return_type_flag)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 48 | |||
| 49 | Returns the L<type flag ID|SPVM::Document::NativeAPI/"Type Flag IDs"> of the return type of the method I<method>. | ||
| 50 | |||
| 51 | =head2 get_arg_by_index | ||
| 52 | |||
| 53 | C<SPVM_NATIVE_ARG* (*get_arg_by_index)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>, int32_t arg_index);> | ||
| 54 | |||
| 55 | Searches an L<argument|SPVM::Document::NativeAPI::Argument> at the index I<arg_index>. | ||
| 56 | |||
| 57 | If it is found, returns it. Otherwise, returns C<NULL>. | ||
| 58 | |||
| 59 | =head2 get_args_length | ||
| 60 | |||
| 61 | C<int32_t (*get_args_length)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 62 | |||
| 63 | Returns the length of the arguments of the method I<method>. | ||
| 64 | |||
| 65 | =head2 get_required_args_length | ||
| 66 | |||
| 67 | C<int32_t (*get_required_args_length)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 68 | |||
| 69 | Returns the length of the required arguments of the method I<method>. | ||
| 70 | |||
| 71 | =head2 get_current_basic_type | ||
| 72 | |||
| 73 | C<SPVM_NATIVE_BASIC_TYPE* (*get_current_basic_type)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 74 | |||
| 75 | Returns the L<basic type|SPVM::Document::NativeAPI::BasicType> that owns the method I<method>. | ||
| 76 | |||
| 77 | =head2 get_opcode_by_index | ||
| 78 | |||
| 79 | C<SPVM_NATIVE_OPCODE* (*get_opcode_by_index)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>, int32_t opcode_index);> | ||
| 80 | |||
| 81 | Searches an operation code at the index I<opcode_index>. | ||
| 82 | |||
| 83 | If it is found, returns it. Otherwise, returns C<NULL>. | ||
| 84 | |||
| 85 | =head2 get_opcodes_length | ||
| 86 | |||
| 87 | C<int32_t (*get_opcodes_length)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 88 | |||
| 89 | Returns the length of operation codes. | ||
| 90 | |||
| 91 | =head2 is_class_method | ||
| 92 | |||
| 93 | C<int32_t (*is_class_method)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 94 | |||
| 95 | If the method I<method> is a class method, returns 1, otherwise returns 0. | ||
| 96 | |||
| 97 | =head2 is_anon | ||
| 98 | |||
| 99 | C<int32_t (*is_anon)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 100 | |||
| 101 | If the method I<method> is an anon method, returns 1, otherwise returns 0. | ||
| 102 | |||
| 103 | =head2 is_native | ||
| 104 | |||
| 105 | C<int32_t (*is_native)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 106 | |||
| 107 | If the method I<method> is a native method, returns 1, otherwise returns 0. | ||
| 108 | |||
| 109 | =head2 is_precompile | ||
| 110 | |||
| 111 | C<int32_t (*is_precompile)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 112 | |||
| 113 | If the method I<method> is a method with the C<precompile> attribute, returns 1, otherwise returns 0. | ||
| 114 | |||
| 115 | =head2 is_enum | ||
| 116 | |||
| 117 | C<int32_t (*is_enum)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 118 | |||
| 119 | If the method I<method> is an enumeration, returns 1, otherwise returns 0. | ||
| 120 | |||
| 121 | =head2 get_byte_vars_width | ||
| 122 | |||
| 123 | C<int32_t (*get_byte_vars_width)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 124 | |||
| 125 | Returns the length of the variables of the C<byte> type allocated by the method I<method>. | ||
| 126 | |||
| 127 | =head2 get_short_vars_width | ||
| 128 | |||
| 129 | C<int32_t (*get_short_vars_width)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 130 | |||
| 131 | Returns the length of the variables of the C<short> type allocated by the method I<method>. | ||
| 132 | |||
| 133 | =head2 get_int_vars_width | ||
| 134 | |||
| 135 | C<int32_t (*get_int_vars_width)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 136 | |||
| 137 | Returns the length of the variables of the C<int> type allocated by the method I<method>. | ||
| 138 | |||
| 139 | =head2 get_long_vars_width | ||
| 140 | |||
| 141 | C<int32_t (*get_long_vars_width)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 142 | |||
| 143 | Returns the length of the variables of the C<long> type allocated by the method I<method>. | ||
| 144 | |||
| 145 | =head2 get_float_vars_width | ||
| 146 | |||
| 147 | C<int32_t (*get_float_vars_width)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 148 | |||
| 149 | Returns the length of the variables of the C<float> type allocated by the method I<method>. | ||
| 150 | |||
| 151 | =head2 get_double_vars_width | ||
| 152 | |||
| 153 | C<int32_t (*get_double_vars_width)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 154 | |||
| 155 | Returns the length of the variables of the C<double> type allocated by the method I<method>. | ||
| 156 | |||
| 157 | =head2 get_object_vars_width | ||
| 158 | |||
| 159 | C<int32_t (*get_object_vars_width)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 160 | |||
| 161 | Returns the length of the variables of the object type allocated by the method I<method>. | ||
| 162 | |||
| 163 | =head2 get_ref_vars_width | ||
| 164 | |||
| 165 | C<int32_t (*get_ref_vars_width)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 166 | |||
| 167 | Returns the length of the variables of the reference type allocated by the method I<method>. | ||
| 168 | |||
| 169 | =head2 get_mortal_stack_length | ||
| 170 | |||
| 171 | C<int32_t (*get_mortal_stack_length)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 172 | |||
| 173 | Returns the length of the mortal stack of the method I<method>. | ||
| 174 | |||
| 175 | =head2 get_native_address | ||
| 176 | |||
| 177 | C<void* (*get_native_address)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 178 | |||
| 179 | Returns the C<native_address> field of the method I<method>. The address of the machine code for a native method is stored to this field. | ||
| 180 | |||
| 181 | =head2 set_native_address | ||
| 182 | |||
| 183 | C<void (*set_native_address)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>, void* address);> | ||
| 184 | |||
| 185 | Sets I<address> to the C<native_address> field of the method I<method>. | ||
| 186 | |||
| 187 | =head2 get_precompile_address | ||
| 188 | |||
| 189 | C<void* (*get_precompile_address)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 190 | |||
| 191 | Returns the C<precompile_address> field of the method I<method>. The address of the machine code for a precompiled method is stored to this field. | ||
| 192 | |||
| 193 | =head2 set_precompile_address | ||
| 194 | |||
| 195 | C<void (*set_precompile_address)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>, void* address);> | ||
| 196 | |||
| 197 | Sets I<address> to the C<precompile_address> field of the method I<method>. | ||
| 198 | |||
| 199 | =head2 is_precompile_fallback | ||
| 200 | |||
| 201 | C<int32_t (*is_precompile_fallback)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 202 | |||
| 203 | Gets the C<is_precompile_fallback> field. | ||
| 204 | |||
| 205 | If this field is a true value, the precompilation method that does not have the execution address is fallback to the vm method. | ||
| 206 | |||
| 207 | =head2 set_is_precompile_fallback | ||
| 208 | |||
| 209 | C<void (*set_is_precompile_fallback)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>, int32_t is_precompile_fallback);> | ||
| 210 | |||
| 211 | Sets the C<is_precompile_fallback> field to I<is_precompile_fallback>. | ||
| 212 | |||
| 213 | =head2 get_args_signature | ||
| 214 | |||
| 215 | C<const char* (*get_args_signature)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 216 | |||
| 217 | Returns the arguments signature of the method I<method>. | ||
| 218 | |||
| 219 | =head2 get_abs_name | ||
| 220 | |||
| 221 | C<const char* (*get_abs_name)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>);> | ||
| 222 | |||
| 223 | Returns the absolute name of the method I<method>. | ||
| 224 | |||
| 225 | =head1 Native Method API IDs | ||
| 226 | |||
| 227 | 0 get_name | ||
| 228 | 1 get_index | ||
| 229 | 2 get_return_basic_type | ||
| 230 | 3 get_return_type_dimension | ||
| 231 | 4 get_return_type_flag | ||
| 232 | 5 get_arg_by_index | ||
| 233 | 6 get_args_length | ||
| 234 | 7 get_required_args_length | ||
| 235 | 8 get_current_basic_type | ||
| 236 | 9 get_opcode_by_index | ||
| 237 | 10 get_opcodes_length | ||
| 238 | 11 is_class_method | ||
| 239 | 12 is_anon | ||
| 240 | 13 is_native | ||
| 241 | 14 is_precompile | ||
| 242 | 15 is_enum | ||
| 243 | 16 get_byte_vars_width | ||
| 244 | 17 get_short_vars_width | ||
| 245 | 18 get_int_vars_width | ||
| 246 | 19 get_long_vars_width | ||
| 247 | 20 get_float_vars_width | ||
| 248 | 21 get_double_vars_width | ||
| 249 | 22 get_object_vars_width | ||
| 250 | 23 get_ref_vars_width | ||
| 251 | 24 get_mortal_stack_length | ||
| 252 | 25 get_native_address | ||
| 253 | 26 set_native_address | ||
| 254 | 27 get_precompile_address | ||
| 255 | 28 set_precompile_address | ||
| 256 | 29 is_precompile_fallback | ||
| 257 | 30 set_is_precompile_fallback | ||
| 258 | 31 get_args_signature | ||
| 259 | 32 get_abs_name | ||
| 260 | |||
| 261 | =head1 See Also | ||
| 262 | |||
| 263 | =over 2 | ||
| 264 | |||
| 265 | =item * L<SPVM::Document::NativeAPI> | ||
| 266 | |||
| 267 | =item * L<SPVM::Document::NativeClass> | ||
| 268 | |||
| 269 | =item * L<SPVM::Document> | ||
| 270 | |||
| 271 | =back | ||
| 272 | |||
| 273 | =head1 Copyright & License | ||
| 274 | |||
| 275 | Copyright (c) 2023 Yuki Kimoto | ||
| 276 | |||
| 277 | MIT License |