Skip to content

Commit

Permalink
Fix a bug that Native::BasicType#get_parent method does not work well.
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki-kimoto committed Jan 8, 2025
1 parent 2f50f73 commit 1c6139b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
[New Features]
* Add get_basic_type_in_version_from basic type native API.
* Add Native::BasicType#get_basic_type_in_version_from method.

[Bug Fix]
* Fix a bug that Native::BasicType#get_parent method does not work well.

0.990036 2024-01-07

[New Features]
Expand Down
4 changes: 1 addition & 3 deletions lib/SPVM/Native/BasicType.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ int32_t SPVM__Native__BasicType__get_parent(SPVM_ENV* env, SPVM_VALUE* stack) {
stack[0].oval = obj_address_parent;
env->call_class_method_by_name(env, stack, "Native::BasicType", "new_with_pointer", 1, &error_id, __func__, FILE_NAME, __LINE__);
if (error_id) { return error_id; }
void* obj_parent = stack[0].oval;
obj_parent = stack[0].oval;
env->set_no_free(env, stack, obj_parent, 1);

env->set_field_object_by_name(env, stack, obj_parent, "runtime", obj_runtime, &error_id, __func__, FILE_NAME, __LINE__);
Expand Down Expand Up @@ -601,8 +601,6 @@ int32_t SPVM__Native__BasicType__get_basic_type_in_version_from(SPVM_ENV* env, S

void* basic_type_in_version_from = env->api->basic_type->get_basic_type_in_version_from(runtime, self);

spvm_warn("%p", basic_type_in_version_from);

void* obj_basic_type_in_version_from = NULL;
if (basic_type_in_version_from) {
void* obj_address_basic_type_in_version_from = env->new_pointer_object_by_name(env, stack, "Address", basic_type_in_version_from, &error_id, __func__, FILE_NAME, __LINE__);
Expand Down
35 changes: 25 additions & 10 deletions t/02_vm/lib/SPVM/TestCase/Module/Native/BasicType.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class TestCase::Module::Native::BasicType {
use Array;
use Point;
use Native::Constant;
use Point3D;

static method get_methods : int () {

Expand All @@ -25,18 +26,32 @@ class TestCase::Module::Native::BasicType {
}
}

# Extra:get_basic_type_in_version_from
# Extra
{
my $current_rntime = Native->get_current_runtime;

my $basic_type = $current_rntime->get_basic_type_by_name("Int");

warn $basic_type->get_name;

my $basic_type_in_version_from = $basic_type->get_basic_type_in_version_from;
# get_basic_type_in_version_from
{
my $current_rntime = Native->get_current_runtime;

my $basic_type = $current_rntime->get_basic_type_by_name("Int");

my $basic_type_in_version_from = $basic_type->get_basic_type_in_version_from;

unless ($basic_type_in_version_from->get_name eq "SPVM") {
return 0;
}
}

unless ($basic_type_in_version_from->get_name eq "SPVM") {
return 0;
# get_parent
{
my $current_rntime = Native->get_current_runtime;

my $basic_type = $current_rntime->get_basic_type_by_name("Point3D");

my $parent_basic_type = $basic_type->get_parent;

unless ($parent_basic_type->get_name eq "Point") {
return 0;
}
}
}

Expand Down

0 comments on commit 1c6139b

Please sign in to comment.