Skip to content

Commit

Permalink
Add get_basic_type_in_version_from basic type native API.
Browse files Browse the repository at this point in the history
  [New Features]
    * Add get_basic_type_in_version_from basic type native API.
  • Loading branch information
yuki-kimoto committed Jan 8, 2025
1 parent 9358132 commit c69e22e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* Rename version_from_basic_type_name member in struct spvm_basic_type to basic_type_name_in_version_from.
* Rename version_from_basic_type member in struct spvm_runtime_basic_type to basic_type_in_version_from.

[New Features]
* Add get_basic_type_in_version_from basic type native API.

0.990036 2024-01-07

Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/Builder/include/spvm_api_basic_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,6 @@ const char* SPVM_API_BASIC_TYPE_get_file(SPVM_RUNTIME* runtime, SPVM_RUNTIME_BAS

SPVM_RUNTIME* SPVM_API_BASIC_TYPE_get_current_runtime(SPVM_RUNTIME* runtime, SPVM_RUNTIME_BASIC_TYPE* basic_type);

SPVM_RUNTIME_BASIC_TYPE* SPVM_API_BASIC_TYPE_get_basic_type_in_version_from(SPVM_RUNTIME* runtime, SPVM_RUNTIME_BASIC_TYPE* basic_type);

#endif
1 change: 1 addition & 0 deletions lib/SPVM/Builder/include/spvm_native.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ struct spvm_api_basic_type {
int32_t (*is_super_class)(void* runtime, void* dist_basic_type, void* src_basic_type);
const char* (*get_file)(void* runtime, void* basic_type);
void* (*get_current_runtime)(void* runtime, void* basic_type);
void* (*get_basic_type_in_version_from)(void* runtime, void* basic_type);
};

struct spvm_api_class_file {
Expand Down
6 changes: 6 additions & 0 deletions lib/SPVM/Builder/src/spvm_api_basic_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ SPVM_API_BASIC_TYPE* SPVM_API_BASIC_TYPE_new_api() {
SPVM_API_BASIC_TYPE_is_super_class,
SPVM_API_BASIC_TYPE_get_file,
SPVM_API_BASIC_TYPE_get_current_runtime,
SPVM_API_BASIC_TYPE_get_basic_type_in_version_from,
};

SPVM_API_BASIC_TYPE* native_apis = calloc(1, sizeof(native_apis_init));
Expand Down Expand Up @@ -285,3 +286,8 @@ SPVM_RUNTIME* SPVM_API_BASIC_TYPE_get_current_runtime(SPVM_RUNTIME* runtime, SPV

return basic_type->current_runtime;
}

SPVM_RUNTIME_BASIC_TYPE* SPVM_API_BASIC_TYPE_get_basic_type_in_version_from(SPVM_RUNTIME* runtime, SPVM_RUNTIME_BASIC_TYPE* basic_type) {

return basic_type->basic_type_in_version_from;
}
9 changes: 9 additions & 0 deletions lib/SPVM/Document/NativeAPI/BasicType.pm
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ C<void* (*get_current_runtime)(L<void* runtime|SPVM::Document::NativeAPI::Runtim
Returns the runtime that owns the basic type I<basic_type>.
=head2 get_basic_type_in_version_from
C<void* (*get_basic_type_in_version_from)(L<void* runtime|SPVM::Document::NativeAPI::Runtime>, L<void* basic_type|SPVM::Document::NativeAPI::BasicType>);>
void* (*get_basic_type_in_version_from)(void* runtime, void* basic_type)
Returns the basic type L<basic type|SPVM::Document::NativeAPI::BasicType> object specified by C<version_from> statement.
=head1 Native API IDs
0 get_name
Expand All @@ -209,6 +217,7 @@ Returns the runtime that owns the basic type I<basic_type>.
21 is_super_class
22 get_file
23 get_current_runtime
24 get_basic_type_in_version_from
=head1 See Aloso
Expand Down
1 change: 1 addition & 0 deletions t/02_vm/lib/SPVM/TestCase/NativeAPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ int32_t SPVM__TestCase__NativeAPI__check_native_api_basic_type_ids(SPVM_ENV* env
if ((void*)&env->api->basic_type->is_super_class != &env_array[21]) { stack[0].ival = 0; return 0; }
if ((void*)&env->api->basic_type->get_file != &env_array[22]) { stack[0].ival = 0; return 0; }
if ((void*)&env->api->basic_type->get_current_runtime != &env_array[23]) { stack[0].ival = 0; return 0; }
if ((void*)&env->api->basic_type->get_basic_type_in_version_from != &env_array[24]) { stack[0].ival = 0; return 0; }

stack[0].ival = 1;

Expand Down

0 comments on commit c69e22e

Please sign in to comment.