Skip to content

Commit

Permalink
Add version_from SPVM to all classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki-kimoto committed Jan 7, 2025
1 parent 221dbf9 commit 241167f
Show file tree
Hide file tree
Showing 66 changed files with 142 additions and 13 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Add get_basic_type_name_in_version_from native API.
* Add Fn#get_basic_type_name_in_version_from method.
* Add SPVM class.
* Add version_from SPVM to all classes.
[Document Changes]
* The heading "Version Statement" to "version Statement".
* Add docs for Fn#get_version_string method.
Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/Array.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class Array {
version_from SPVM;

use Stringer;
use Cloner;
use EqualityChecker;
Expand Down
26 changes: 13 additions & 13 deletions lib/SPVM/Builder/src/spvm_compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,103 +498,103 @@ void SPVM_COMPILER_set_default_loaded_class_files(SPVM_COMPILER* compiler) {
{
const char* class_name = "Bool";
const char* rel_file = "Bool.spvm";
const char* content = "class Bool {\n INIT {\n $TRUE = new Bool;\n $TRUE->{value} = 1;\n $FALSE = new Bool;\n $FALSE->{value} = 0;\n }\n \n our $TRUE : ro Bool;\n our $FALSE : ro Bool;\n has value : ro byte;\n}";
const char* content = "class Bool {\n version_from SPVM;\n INIT {\n $TRUE = new Bool;\n $TRUE->{value} = 1;\n $FALSE = new Bool;\n $FALSE->{value} = 0;\n }\n \n our $TRUE : ro Bool;\n our $FALSE : ro Bool;\n has value : ro byte;\n}";
SPVM_COMPILER_set_class_file_with_members(compiler, class_name, rel_file, content);
}

// Add Error class file
{
const char* class_name = "Error";
const char* rel_file = "Error.spvm";
const char* content = "class Error;";
const char* content = "class Error {\n version_from SPVM;\n}";
SPVM_COMPILER_set_class_file_with_members(compiler, class_name, rel_file, content);
}

// Add Error::System class file
{
const char* class_name = "Error::System";
const char* rel_file = "Error/System.spvm";
const char* content = "class Error::System extends Error;";
const char* content = "class Error::System extends Error {\n version_from SPVM;\n}";
SPVM_COMPILER_set_class_file_with_members(compiler, class_name, rel_file, content);
}

// Add Error::NotSupported class file
{
const char* class_name = "Error::NotSupported";
const char* rel_file = "Error/NotSupported.spvm";
const char* content = "class Error::NotSupported extends Error;";
const char* content = "class Error::NotSupported extends Error {\n version_from SPVM;\n}";
SPVM_COMPILER_set_class_file_with_members(compiler, class_name, rel_file, content);
}

// Add Byte class file
{
const char* class_name = "Byte";
const char* rel_file = "Byte.spvm";
const char* content = "class Byte {\n has value : ro byte;\n static method new : Byte ($value : int) {\n my $self = new Byte;\n $self->{value} = (byte)$value;\n return $self;\n }\n}";
const char* content = "class Byte {\n version_from SPVM;\n has value : ro byte;\n static method new : Byte ($value : int) {\n my $self = new Byte;\n $self->{value} = (byte)$value;\n return $self;\n }\n}";
SPVM_COMPILER_set_class_file_with_members(compiler, class_name, rel_file, content);
}

// Add Short class file
{
const char* class_name = "Short";
const char* rel_file = "Short.spvm";
const char* content = "class Short {\n has value : ro short;\n static method new : Short ($value : int) {\n my $self = new Short;\n $self->{value} = (short)$value;\n return $self;\n }\n}";
const char* content = "class Short {\n version_from SPVM;\n has value : ro short;\n static method new : Short ($value : int) {\n my $self = new Short;\n $self->{value} = (short)$value;\n return $self;\n }\n}";
SPVM_COMPILER_set_class_file_with_members(compiler, class_name, rel_file, content);
}

// Add Int class file
{
const char* class_name = "Int";
const char* rel_file = "Int.spvm";
const char* content = "class Int {\n has value : ro int;\n static method new : Int ($value : int) {\n my $self = new Int;\n $self->{value} = $value;\n return $self;\n }\n}";
const char* content = "class Int {\n version_from SPVM;\n has value : ro int;\n static method new : Int ($value : int) {\n my $self = new Int;\n $self->{value} = $value;\n return $self;\n }\n}";
SPVM_COMPILER_set_class_file_with_members(compiler, class_name, rel_file, content);
}

// Add Long class file
{
const char* class_name = "Long";
const char* rel_file = "Long.spvm";
const char* content = "class Long {\n has value : ro long;\n static method new : Long ($value : long) {\n my $self = new Long;\n $self->{value} = $value;\n return $self;\n }\n}";
const char* content = "class Long {\n version_from SPVM;\n has value : ro long;\n static method new : Long ($value : long) {\n my $self = new Long;\n $self->{value} = $value;\n return $self;\n }\n}";
SPVM_COMPILER_set_class_file_with_members(compiler, class_name, rel_file, content);
}

// Add Float class file
{
const char* class_name = "Float";
const char* rel_file = "Float.spvm";
const char* content = "class Float {\n has value : ro float;\n static method new : Float ($value : float) {\n my $self = new Float;\n $self->{value} = $value;\n return $self;\n }\n}";
const char* content = "class Float {\n version_from SPVM;\n has value : ro float;\n static method new : Float ($value : float) {\n my $self = new Float;\n $self->{value} = $value;\n return $self;\n }\n}";
SPVM_COMPILER_set_class_file_with_members(compiler, class_name, rel_file, content);
}

// Add Double class file
{
const char* class_name = "Double";
const char* rel_file = "Double.spvm";
const char* content = "class Double {\n has value : ro double;\n static method new : Double ($value : double) {\n my $self = new Double;\n $self->{value} = $value;\n return $self;\n }\n}";
const char* content = "class Double {\n version_from SPVM;\n has value : ro double;\n static method new : Double ($value : double) {\n my $self = new Double;\n $self->{value} = $value;\n return $self;\n }\n}";
SPVM_COMPILER_set_class_file_with_members(compiler, class_name, rel_file, content);
}

// Add CommandInfo class file
{
const char* class_name = "CommandInfo";
const char* rel_file = "CommandInfo.spvm";
const char* content = "class CommandInfo {\n our $PROGRAM_NAME : ro string;\n our $ARGV : ro string[];\n our $BASE_TIME : ro long;\n }";
const char* content = "class CommandInfo {\n version_from SPVM;\n our $PROGRAM_NAME : ro string;\n our $ARGV : ro string[];\n our $BASE_TIME : ro long;\n }";
SPVM_COMPILER_set_class_file_with_members(compiler, class_name, rel_file, content);
}

// Add Address class file
{
const char* class_name = "Address";
const char* rel_file = "Address.spvm";
const char* content = "class Address : pointer {\n static method new : Address () {\n my $self = new Address;\n return $self;\n }\n}";
const char* content = "class Address : pointer {\n version_from SPVM;\n static method new : Address () {\n my $self = new Address;\n return $self;\n }\n}";
SPVM_COMPILER_set_class_file_with_members(compiler, class_name, rel_file, content);
}

// Add Error::Compile class file
{
const char* class_name = "Error::Compile";
const char* rel_file = "Error/Compile.spvm";
const char* content = "class Error::Compile extends Error;";
const char* content = "class Error::Compile extends Error {\n version_from SPVM;\n}";
SPVM_COMPILER_set_class_file_with_members(compiler, class_name, rel_file, content);
}

Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/ByteList.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class ByteList {
version_from SPVM;

use Fn;
use Array;

Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/Callback.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# MIT License

class Callback : interface_t {
version_from SPVM;

required method : void ();
}
2 changes: 2 additions & 0 deletions lib/SPVM/Callback/Grep.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# MIT License

class Callback::Grep : interface_t {
version_from SPVM;

required method : int ($element : object);
}
2 changes: 2 additions & 0 deletions lib/SPVM/Callback/Map.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# MIT License

class Callback::Map : interface_t {
version_from SPVM;

required method : object ($element : object);
}
2 changes: 2 additions & 0 deletions lib/SPVM/Callback/MapExpand.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# MIT License

class Callback::MapExpand : interface_t {
version_from SPVM;

required method : object[] ($element : object);
}
2 changes: 2 additions & 0 deletions lib/SPVM/Cloneable.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# MIT License

class Cloneable : interface_t {
version_from SPVM;

required method clone : object ();
}
2 changes: 2 additions & 0 deletions lib/SPVM/Cloner.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class Cloner : interface_t {
version_from SPVM;


use Cloneable;

Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/Comparable.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class Comparable : interface_t {
version_from SPVM;


# Interface Methods
required method cmp : int ($a : object, $b : object);
Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/Comparator.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class Comparator : interface_t {
version_from SPVM;


use Comparable;

Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/Comparator/Double.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# MIT License

class Comparator::Double : interface_t {
version_from SPVM;

required method : int ($a : double, $b : double);
}
2 changes: 2 additions & 0 deletions lib/SPVM/Comparator/Float.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# MIT License

class Comparator::Float : interface_t {
version_from SPVM;

required method : int ($a : float, $b : float);
}
2 changes: 2 additions & 0 deletions lib/SPVM/Comparator/Int.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# MIT License

class Comparator::Int : interface_t {
version_from SPVM;

required method : int ($a : int, $b : int);
}
2 changes: 2 additions & 0 deletions lib/SPVM/Comparator/Long.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# MIT License

class Comparator::Long : interface_t {
version_from SPVM;

required method : int ($a : long, $b : long);
}
2 changes: 2 additions & 0 deletions lib/SPVM/Comparator/String.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# MIT License

class Comparator::String : interface_t {
version_from SPVM;

required method : int ($a : string, $b : string);
}
2 changes: 2 additions & 0 deletions lib/SPVM/Complex_2d.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class Complex_2d : mulnum_t {
version_from SPVM;


use Fn;

Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/Complex_2f.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class Complex_2f : mulnum_t {
version_from SPVM;


# Fields
has re : float;
Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/DoubleList.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class DoubleList {
version_from SPVM;

use Fn;
use Array;

Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/EqualityCheckable.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class EqualityCheckable : interface_t {
version_from SPVM;


# Interface Methods
required method eq : int ($a : object, $b : object);
Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/EqualityChecker.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class EqualityChecker : interface_t {
version_from SPVM;


# Interface Methods
required method : int ($object1 : object, $object2 : object);
Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/EqualityChecker/Address.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class EqualityChecker::Address {
version_from SPVM;

static method new : EqualityChecker::Address () {
return new EqualityChecker::Address;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/Error/Unicode/InvalidUTF8.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# MIT License

class Error::Unicode::InvalidUTF8 {
version_from SPVM;


}
2 changes: 2 additions & 0 deletions lib/SPVM/FloatList.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class FloatList {
version_from SPVM;

use Fn;
use Array;

Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/Fn.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class Fn {
version_from SPVM;

use StringBuffer;
use StringList;
use IntList;
Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/Fn/Resource.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# MIT License

class Fn::Resource {
version_from SPVM;


}
2 changes: 2 additions & 0 deletions lib/SPVM/Format.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class Format {
version_from SPVM;

use StringBuffer;
use Fn;

Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/Hash.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class Hash {
version_from SPVM;

use Hash::Entry;
use Fn;
use Array;
Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/Hash/Entry.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class Hash::Entry {
version_from SPVM;

allow Hash;

has key : string;
Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/Immutable/ByteList.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class Immutable::ByteList {
version_from SPVM;

use Fn;
use Array;

Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/Immutable/DoubleList.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class Immutable::DoubleList {
version_from SPVM;

use Fn;
use Array;

Expand Down
2 changes: 2 additions & 0 deletions lib/SPVM/Immutable/FloatList.spvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# MIT License

class Immutable::FloatList {
version_from SPVM;

use Fn;
use Array;

Expand Down
Loading

0 comments on commit 241167f

Please sign in to comment.