Skip to content

Commit

Permalink
Rename version_from_basic_type_name member in struct spvm_basic_type …
Browse files Browse the repository at this point in the history
…to basic_type_name_in_version_from. and etc.

  [Internal Changes]
    * 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.
  • Loading branch information
yuki-kimoto committed Jan 8, 2025
1 parent 29eb821 commit fdb6207
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 20 deletions.
10 changes: 10 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
0.990037 2024-01-08

[Incompatible Changes]
* Rename SPVM::Builder::Config::Info to SPVM::Builder::ScriptInfo.
* SPVM::Builder::ScriptInfo#get_class_names returns also multi-numeric types.
[Internal Changes]
* 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.


0.990036 2024-01-07

[New Features]
Expand Down
2 changes: 1 addition & 1 deletion lib/SPVM/Builder/include/spvm_basic_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct spvm_basic_type {
const char* class_rel_file;
const char* version_string;
SPVM_VERSION_FROM* version_from;
const char* version_from_basic_type_name;
const char* basic_type_name_in_version_from;
SPVM_LIST* constant_strings;
SPVM_HASH* constant_string_symtable;
SPVM_STRING_BUFFER* string_pool;
Expand Down
2 changes: 1 addition & 1 deletion lib/SPVM/Builder/include/spvm_runtime_basic_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct spvm_runtime_basic_type {
const char* class_dir;
const char* class_rel_file;
const char* version_string;
SPVM_RUNTIME_BASIC_TYPE* version_from_basic_type;
SPVM_RUNTIME_BASIC_TYPE* basic_type_in_version_from;
SPVM_RUNTIME_BASIC_TYPE* parent;
const char* string_pool;
SPVM_RUNTIME_STRING* constant_strings;
Expand Down
8 changes: 4 additions & 4 deletions lib/SPVM/Builder/src/spvm_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -5610,10 +5610,10 @@ int32_t SPVM_API_seed_initialized(SPVM_ENV* env, SPVM_VALUE* stack) {

const char* SPVM_API_get_basic_type_name_in_version_from(SPVM_ENV* env, SPVM_VALUE* stack, SPVM_RUNTIME_BASIC_TYPE* basic_type) {

const char* version_from_basic_type_name = NULL;
if (basic_type->version_from_basic_type) {
version_from_basic_type_name = basic_type->version_from_basic_type->name;
const char* basic_type_name_in_version_from = NULL;
if (basic_type->basic_type_in_version_from) {
basic_type_name_in_version_from = basic_type->basic_type_in_version_from->name;
}

return version_from_basic_type_name;
return basic_type_name_in_version_from;
}
6 changes: 3 additions & 3 deletions lib/SPVM/Builder/src/spvm_compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,9 +961,9 @@ SPVM_RUNTIME* SPVM_COMPILER_build_runtime(SPVM_COMPILER* compiler) {
runtime_basic_type->version_string = runtime_basic_type->constant_strings[basic_type_version_string->index].value;
}

if (basic_type->version_from_basic_type_name) {
SPVM_BASIC_TYPE* version_from_basic_type = SPVM_HASH_get(compiler->basic_type_symtable, basic_type->version_from_basic_type_name, strlen(basic_type->version_from_basic_type_name));
runtime_basic_type->version_from_basic_type = SPVM_API_RUNTIME_get_basic_type_by_id(runtime, version_from_basic_type->id);
if (basic_type->basic_type_name_in_version_from) {
SPVM_BASIC_TYPE* basic_type_in_version_from = SPVM_HASH_get(compiler->basic_type_symtable, basic_type->basic_type_name_in_version_from, strlen(basic_type->basic_type_name_in_version_from));
runtime_basic_type->basic_type_in_version_from = SPVM_API_RUNTIME_get_basic_type_by_id(runtime, basic_type_in_version_from->id);
}

runtime_basic_type->is_anon = basic_type->is_anon;
Expand Down
4 changes: 2 additions & 2 deletions lib/SPVM/Builder/src/spvm_op.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ SPVM_OP* SPVM_OP_build_class(SPVM_COMPILER* compiler, SPVM_OP* op_class, SPVM_OP
break;
}

if (type->basic_type->version_from_basic_type_name) {
if (type->basic_type->basic_type_name_in_version_from) {
SPVM_COMPILER_error(compiler, "Both version statement and version_from statement cannnot be used at the same time.\n at %s line %d", op_decl->file, op_decl->line);
break;
}
Expand Down Expand Up @@ -517,7 +517,7 @@ SPVM_OP* SPVM_OP_build_class(SPVM_COMPILER* compiler, SPVM_OP* op_class, SPVM_OP

type->basic_type->version_from = op_version_from->uv.version_from;

type->basic_type->version_from_basic_type_name = op_version_from->uv.version_from->basic_type_name;
type->basic_type->basic_type_name_in_version_from = op_version_from->uv.version_from->basic_type_name;
}
// use statement
else if (op_decl->id == SPVM_OP_C_ID_USE) {
Expand Down
10 changes: 5 additions & 5 deletions lib/SPVM/Fn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1089,14 +1089,14 @@ int32_t SPVM__Fn__get_basic_type_name_in_version_from(SPVM_ENV* env, SPVM_VALUE*
return env->die(env, stack, "The class specified by the basic type name $basic_type_name must be loaded.", __func__, FILE_NAME, __LINE__);
}

const char* version_from_basic_type_name = env->get_basic_type_name_in_version_from(env, stack, basic_type);
const char* basic_type_name_in_version_from = env->get_basic_type_name_in_version_from(env, stack, basic_type);

void* obj_version_from_basic_type_name = NULL;
if (version_from_basic_type_name) {
obj_version_from_basic_type_name = env->new_string(env, stack, version_from_basic_type_name, strlen(version_from_basic_type_name));
void* obj_basic_type_name_in_version_from = NULL;
if (basic_type_name_in_version_from) {
obj_basic_type_name_in_version_from = env->new_string(env, stack, basic_type_name_in_version_from, strlen(basic_type_name_in_version_from));
}

stack[0].oval = obj_version_from_basic_type_name;
stack[0].oval = obj_basic_type_name_in_version_from;

return 0;
}
Expand Down
8 changes: 4 additions & 4 deletions t/02_vm/lib/SPVM/TestCase/Module/Fn.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -8212,16 +8212,16 @@ class TestCase::Module::Fn {
static method get_basic_type_name_in_version_from : int () {

{
my $version_from_basic_type_name = Fn->get_basic_type_name_in_version_from("TestCase::Examples");
my $basic_type_name_in_version_from = Fn->get_basic_type_name_in_version_from("TestCase::Examples");

unless ($version_from_basic_type_name eq "TestCase") {
unless ($basic_type_name_in_version_from eq "TestCase") {
return 0;
}
}

{
my $version_from_basic_type_name = Fn->get_basic_type_name_in_version_from("TestCase::Empty");
if ($version_from_basic_type_name) {
my $basic_type_name_in_version_from = Fn->get_basic_type_name_in_version_from("TestCase::Empty");
if ($basic_type_name_in_version_from) {
return 0;
}
}
Expand Down

0 comments on commit fdb6207

Please sign in to comment.