The value of L<string type|/"string Type"> is called string.
A string consists of characters of the C<byte> type.
A string hasits length.
A string is an L<object|/"Object">.
Normally, a string is created by a L<string literal|SPVM::Document::Language::Tokenization/"String Literal"> or L<new_string_len operator|SPVM::Document::Language::Operators/"new_string_len Operator">.
# A string created by a string literal
my$string= "Hello";
my$char= $string->[0];
# A mutable string created by the new_string_len operator
my$string= new_string_len 3;
$string->[0] = 'a';
See the following sections about operations forstrings.
At L<native level|SPVM::Document::NativeClass>, the character just afterthe lastcharacter of the string is set to C<\0>, so the characters in the string can be used as a C language string.
# The characters in the string can be used as a C language string
The value of an L<array type|/"Array Types"> is called array.
An array consists of a set of L<numbers|/"Number">, a set of L<objects|/"Object">, or a set of L<multi-numeric numbers|/"Multi-Numeric Number">.
An array hasits length.
The elements of an array are arranged by indexand the indexstarts from 0.
An array is an L<object|/"Object">.
Normally, an array is created by L<new Operator|SPVM::Document::Language::Operators/"Creating an Array"> and an L<array initialization|SPVM::Document::Language::Operators/"Array Initialization">.
# An array created by the new operator
my$numbers= new int[3];
$numbergers->[0] = 1;
my$strings= new string[3];
my$objects= new Point[3];
my$mulnum_numbers= new Complex_2d[3];
# An array created by an array initialization
my$numbers= [1, 2, 3];
All elements of an array can be got by L<forstatement|SPVM::Document::Language::Statements/"for Statement">.
# for statement
for(my$i= 0; $i< @$numbers; $i++) {
my$number= $numbers->[$i];
}
# for-each statement
formy$number(@$numbers) {
}
See the following sections about operations forarrays.
=over 2
=item * L<Creating Array in new Operator|SPVM::Document::Language::Operators/"Creating an Array">
=item * L<Getting a Referenced Multi-Numeric Field|SPVM::Document::Language::Operators/"Getting a Referenced Multi-Numeric Field">
=item * L<Setting a Referenced Multi-Numeric Field|SPVM::Document::Language::Operators/"Setting a Referenced Multi-Numeric Field">
=back
=head3 Reference Native Level Representation
At L<native level|SPVM::Document::NativeClass>, a reference is a memory address.
int32_t* num_ref = stack[0].iref;
=head1 Types
This section describes types.
=head2 Numeric Types
This section describes numeric types.
=head3 Integer Types
This section describes integer types.
An interger type is a L<numeric type|/"Numeric Types">.
=head4 byte Type
The C<byte> type is the type fora signed 8-bit integer.
byte
The C<byte> type is an L<integer type|/"Integer Types">.
=head4 short Type
The C<short> type is the type fora signed 16-bit integer.
short
The C<short> type is an L<integer type|/"Integer Types">.
=head4 intType
The C<int> type is the type fora signed 32-bit integer.
int
The C<int> type is an L<integer type|/"Integer Types">.
=head4 long Type
The C<long> type is the type fora signed 64-bit integer.
long
The C<long> type is an L<integer type|/"Integer Types">.
=head3 Floating Point Types
This section describes floating point types.
A floating point type is a L<numeric type|/"Numeric Types">.
=head4 float Type
The C<float> type is the type for32bit floating point.
float
The C<float> type is a L<floating point type|/"Floating Point Types">.
=head4 double Type
The C<double> type is the type for64bit floating point.
double
The C<double> type is a L<floating point type|/"Floating Point Types">.
=head3 Numeric Types Order
L<numeric types|/"Numeric Types"> have its order.
The order is C<byte>, C<short>, C<int>, C<long>, C<float>, C<double> from smallest to largest.
=head2 Object Types
This section lists object types.
=head3 string Type
The C<string> type is the type forL<strings|/"String">.
string
The C<string> type is an L<object type|/"Object Types">.
The C<string> type can be qualified withL<mutable type qualifier|/"mutable Type Qualifier">.
mutable string
=head3 Class Types
A class type is the type fora L<class|SPVM::Document::Language::Class/"Class">.
A class type is definedby L<class definition|SPVM::Document::Language::Class/"Class Definition">.
class CLASS_TYPE {
}
An object can be created from a class by a L<new operator|SPVM::Document::Language::Operators/"new Operator">.
Note that an L<interface type|/"Interface Types"> and a L<multi-numeric type|/"Multi-Numeric Types"> is not a class type although these types are definedby L<class definition|SPVM::Document::Language::Class/"Class Definition">.
=head4 Numeric Object Types
A numeric object type is a L<class type|/"Class Types"> that owns the corresponding field of a L<numeric type|/"Numeric Types">.
The undeftype is the type of an L<undefined value|/"Undefined Value">.
=head2 void Type
The C<void> type is the type that represents a method definedby a L<method definition|SPVM::Document::Language::Class/"Method Definition"> does not returna returnvalue.
void
=head2 Array Types
An array type is a type foran L<array|/"Array">. An array type consists of a L<basic type|/"Basic Types"> and a type dimension such as C<[]>, C<[][]>.
BASIC_TYPE[]..
(C<[]..> means one more C<[]>)
Examples:
# Numeric array
int[]
double[]
# String array
string []
# Class array
Point[]
# Any object array
object[]
# 2 dimensional array
int[][]
# 3 dimensional array
int[][][]
An array type is an L<object type|/"Object Types">.
Compilation Errors:
The dimesion is less than or equal to 255. Otherwise, a compilation error occurs.
=head3 Numeric Array Types
A numeric array type is an L<array type|/"Array Types"> of a L<numeric type|/"Numeric Types">.
The List of Numeric Array Types:
byte[]
short[]
int[]
long[]
float[]
double[]
=head3 Object Array Types
An object array type is an L<array type|/"Array Types"> of an L<object type|/"Object Types">.
Examples:
Point[]
Point[][]
Stringable[]
string[]
object[]
=head3 String Array Type
The string array type is L<array type|/"Array Types"> L<string type|/"string Type">.
string[]
=head3 Class Array Types
A class array type is an L<array type|/"Array Types"> of a L<class type|/"Class Types">.
Examples:
Int[]
Point[]
=head3 Interface Array Types
An interface array type is an L<array type|/"Array Types"> of an L<interface type|/"Interface Types">.
Examples:
Stringable[]
Cloneable[]
=head3 Multi-Dimensional Array Types
A multi-dimensional array type is an L<array type|/"Array Types"> of an L<array type|/"Array Types">.
Examples:
int[][]
Int[][]
string[][][]
object[][]
A multi-dimensional array is created by the syntax of L<creating a multi-dimensional array|SPVM::Document::Language::Operators/"Creating a Multi-Dimensional Array"> of the C<new> operator.
=head3 Multi-Numeric Array Types
A multi-numeric array type is an L<array type|/"Array Types"> of a L<multi-numeric type|"Multi-Numeric Types">.
Examples:
Complex_2d[]
Complex_2f[]
=head3 Any Object Array Type
The any object array type C<object[]> is L<array type|/"Array Types"> to which any L<object array type|/"Object Array Types"> can be assigned.
object[]
=head2 Multi-Numeric Types
A multi-numeric type is a type fora L<multi-numeric number|/"Multi-Numeric Number">.
A multi-numeric type is definedby a L<multi-numeric type definition|SPVM::Document::Language::Class/"Multi-Numeric Type Definition">.
class MULNUM_TYPE : mulnum_t {
}
=head2 Reference Types
A reference type is a type fora L<reference|/"Reference">.
TYPE*
A reference type consists of a type followed by C<*>.
I<TYPE> must be a L<numeric type|/"Numeric Types"> or a L<multi-numeric type|/"Multi-Numeric Types">.
=head3 Numeric Reference Types
A numeric reference type is a reference type of a L<numeric type|/"Numeric Types">.
The List of Numeric Reference Types:
byte*
short*
int*
long*
float*
double*
=head3 Multi-Numeric Reference Types
A multi-numeric reference types is a reference type of a L<multi-numeric type|/"Multi-Numeric Types">.
MULNUM_TYPE*
Examples:
Complex_2d*
Complex_2f*
=head2 Type Qualifiers
A type qualifier qualify a type.
QUALIFIER TYPE
The I<QUALIFIER> qualified the type I<TYPE>.
=head3 mutable Type Qualifier
The C<mutable> type qualifier qualifies string type.
mutable string;
The string of string type withthe C<mutable> type qualifier is able to be L<set a character|SPVM::Document::Language::Operators/"Setting a Character">.
my$string= (mutable string)copy "abc";
$string->[0] = 'd';
=head2 Type Initial Value
The value of a type is initialized by its type initial value.
If the value of I<TYPE_FROM> is represented by an L<interger literal|SPVM::Document::Language::Tokenization/"Integer Literals"> and between the max and minimal value of the type of I<TYPE_TO>, Yes, otherwize No.
For Floating Point types:
If the value of I<TYPE_FROM> is represented by a L<floating point literal|SPVM::Document::Language::Tokenization/"Floating Point Literals">, Yes, otherwize No.
=head3 Assignment Requirement from NumericObject to Numeric
I<InterfaceX> is a an L<interface type|"Interface Types">.
I<InterfaceSatisfiedX> is a L<class type|"Class Types"> or an L<interface type|"Interface Types"> that satisfied L<interface requirement|/"Interface Requirement"> of I<InterfaceX>.
I<InterfaceX> is a an L<interface type|"Interface Types">.
I<InterfaceSatisfiedX> is a L<class type|"Class Types"> or an L<interface type|"Interface Types"> that satisfied L<interface requirement|/"Interface Requirement"> of I<InterfaceX>.
I<D> means its type dimension that is greater than or eausl to 2.
I<X[]..D> is a multi-dimensional array.
I<ClassX> is a L<class type|"Class Types">.
I<SuperClassX> is a super class of I<ClassX>.
I<InterfaceX> is a an L<interface type|"Interface Types">.
I<InterfaceSatisfiedX> is a L<class type|"Class Types"> or an L<interface type|"Interface Types"> that satisfied L<interface requirement|/"Interface Requirement"> of I<InterfaceX>.
=head1 Cast Requirement
The cast requirement is the requirement whether one type is able to be cast to another type.
What does it mean to cast one type to another type?
Typically, it is sufficient to consider a case where a value of a type I<TYPE_FROM> is casted to I<TYPE_TO>.
my$value: TYPE_FROM;
(TYPE_TO)$value;
Abstracting this, type-to-type cast is defined.
(TYPE_TO)TYPE_FROM
Note that this is a concept, not an actual syntax.
Some type casts perform a data conversion.
Some type casts perform a data check.
In the following description, the word "Type"is omitted whenit is obvious.
I<InterfaceX> is a an L<interface type|"Interface Types">.
I<InterfaceY> is a an L<interface type|"Interface Types">.
I<InterfaceSatisfiedX> is a L<class type|"Class Types"> or an L<interface type|"Interface Types"> that satisfied L<interface requirement|/"Interface Requirement"> of I<InterfaceX>.
I<InterfaceX> is a an L<interface type|"Interface Types">.
I<InterfaceY> is a an L<interface type|"Interface Types">.
I<InterfaceSatisfiedX> is a L<class type|"Class Types"> or an L<interface type|"Interface Types"> that satisfied L<interface requirement|/"Interface Requirement"> of I<InterfaceX>.
I<D> means its type dimension that is greater than or eausl to 2.
I<X[]..D> is a multi-dimensional array.
I<ClassX> is a L<class type|"Class Types">.
I<SuperClassX> is a super class of I<ClassX>.
I<InterfaceX> is a an L<interface type|"Interface Types">.
I<InterfaceSatisfiedX> is a L<class type|"Class Types"> or an L<interface type|"Interface Types"> that satisfied L<interface requirement|/"Interface Requirement"> of I<InterfaceX>.
=head1 Interface Requirement
The interface requirement is the requirement whether an L<object type|"Object Types"> is able to be assigned to an L<interface type|"Interface Types">.
INTERFACE_TYPE_TO = OBJECT_TYPE_FROM
This is the same concept as type-to-type assignment explained in L<Assignment Requirement|/"Assignment Requirement">.
I<INTERFACE_TYPE_TO> must be an L<interface type|"Interface Types">.
I<OBJECT_TYPE_FROM> must be a L<class type|"Class Types"> or an L<interface type|"Interface Types">.
The following check is performed on every instance method of I<OBJECT_TYPE_FROM>.
If an instance method of I<INTERFACE_TYPE_TO> hasthe C<required> method attribute, I<OBJECT_TYPE_FROM> or one of its super classes must have a method withthe same name.
If I<OBJECT_TYPE_FROM> or one of its super classes hasan instance method(this is named I<METHOD_FROM>) withthe same name as an instance method of I<INTERFACE_TYPE_TO>,
I<METHOD_FROM> must be an instance method and satisfy L<interface method requirement|/"Interface Method Requirement">.
=head2 Interface Method Requirement
The interface method requirement is the requirement whether a method is able to be assigned to an interface method.
INTERFACE_METHOD_TO = METHOD_FROM
This is a concept that converts the type-to-type assignment explained in L<Assignment Requirement|/"Assignment Requirement"> to method-to-method assignment.
I<INTERFACE_METHOD_TO> must be an instance method.
I<METHOD_FROM> must be an instance method.
The lengthof the arguments of the method of the I<INTERFACE_METHOD_TO> type must be greater than or equal to the lengthof the required arguments the method of the I<INSTANT_METHOD_TYPE_FROM> type.
The every argument other than at 0 indexof the method of the I<INSTANT_METHOD_TYPE_FROM> must satisfy L<assignment requirement|/"Assignment Requirement"> to the argument as the same indexof the method of the I<INTERFACE_METHOD_TO> without a data conversion and withinterface exactly matched.
The returntype of the method of the I<INSTANT_METHOD_TYPE_FROM> must must satisfy L<assignment requirement|/"Assignment Requirement"> to the returntype of the method of the I<INTERFACE_METHOD_TO> without a data conversion and withinterface exactly matched.
=head1 See Also
=over 2
=item * L<SPVM::Document::Language::Class>
=item * L<SPVM::Document::Language::Operators>
=item * L<SPVM::Document::Language::Statements>
=item * L<SPVM::Document::Language>
=item * L<SPVM::Document>
=back
=head1 Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License
Keyboard Shortcuts
Global
s
Focus search bar
?
Bring up this help dialog
GitHub
gp
Go to pull requests
gi
go to github issues (only if github is preferred repository)