Name
SPVM::Document::Language::Types - Types in the SPVM Language
Description
This document describes types in the SPVM language.
Data
This section describes data.
A data is called value.
Number
The value of numeric types is called number.
Normally, numbers are created by numeric literals.
# byte - 8bit signed integer
my $number = (byte)1;
# short - 16bit signed integer
my $number = (short)1;
# int - 32bit signed integer
my $number = 1;
# long - 64bit signed integer
my $number = 1L;
# float - 32bit floating point
my $number = 1.5f;
# double - 64bit floating point
my $number = 1.0;
A character created by character literal is a number of byte type.
# A number of byte type created by a character literal
my $char = 'a';
See the following section operations for numbers.
Internal Representation of Negative Integers
Negative integers are represented by two's complement.
String
The value of string type is called string.
A string consists of characters of the byte
type.
A string has its length.
A string is an object.
Normally, a string is created by a string literal or 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 for strings.
Sting Native Level Representation
At native level, the character just after the last character of the string is set to \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
void* obj_string = stack[0].oval;
const char* chars = env->get_chars(env, stack, obj_string);
if (strcmp(chars, "Hello") == 0) {
}
Array
The value of an array type is called array.
An array consists of a set of numbers, a set of objects, or a set of multi-numeric numbers.
An array has its length.
The elements of an array are arranged by index and the index starts from 0.
An array is an object.
Normally, an array is created by new Operator and an 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 for statement.
# for statement
for (my $i = 0; $i < @$numbers; $i++) {
my $number = $numbers->[$i];
}
# for-each statement
for my $number (@$numbers) {
}
See the following sections about operations for arrays.
Object
The value of an object type is called object.
A string is an object.
An array is an object.
An objcet of class type has its fields. A field is a number or an object.
Normally, an object is created by new operator.
# An object created by the new operator
my $point = new Point;
When an object is created, memory for the object is allocated in heap memory.
Created objects are destroyed by garbage collection.
See the following sections about operations for objects.
Object Native Level Representation
At native level, an object is a memory address.
void* obj_point = stack[0].oval;
Undefined Value
The value of undef type is called undefined value.
An undefined value means the value is undefined.
An undefined value is created by undef operator.
undef
An undefined value is able to be assigned to an object type.
my $point : Point = undef;
Examples:
# Examples of undefined values
my $string : string = undef;
if (undef) {
}
my $message = "Hello";
if ($message == undef) {
}
Undefined Value Native Level Representation
At native level, an undefined value is equal to 0, normally a null pointer NULL
defined in stddef.h
.
NULL
Multi-Numeric Number
The value of a multi-numeric type is called multi-numeric number.
A multi-numeric number is a set of numbers of the same type.
my $z : Complex_2d;
$z->{re} = 1;
$z->{im} = 2;
See the following sections about operations for multi-numeric numbers.
Reference
The value of a reference type is called reference.
A reference has a referencing value.
A referencing value must be a number or a multi-numeric number
The reference operator \
creates a reference.
my $number : int;
my $number_ref = \$number;
See the following sections about operations for multi-numeric numbers.
Reference Native Level Representation
At native level, a reference is a memory address.
int32_t* num_ref = stack[0].iref;
Types
This section describes types.
Numeric Types
This section describes numeric types.
Integer Types
This section describes integer types.
An interger type is a numeric type.
byte Type
The byte
type is the type for a signed 8-bit integer.
byte
The byte
type is an integer type.
short Type
The short
type is the type for a signed 16-bit integer.
short
The short
type is an integer type.
int Type
The int
type is the type for a signed 32-bit integer.
int
The int
type is an integer type.
long Type
The long
type is the type for a signed 64-bit integer.
long
The long
type is an integer type.
Floating Point Types
This section describes floating point types.
A floating point type is a numeric type.
float Type
The float
type is the type for 32bit floating point.
float
The float
type is a floating point type.
double Type
The double
type is the type for 64bit floating point.
double
The double
type is a floating point type.
Numeric Types Order
numeric types have its order.
The order is byte
, short
, int
, long
, float
, double
from smallest to largest.
Object Types
This section lists object types.
string Type
The string
type is the type for strings.
string
The string
type is an object type.
The string
type can be qualified with mutable type qualifier.
mutable string
Class Types
A class type is the type for a class.
A class type is defined by class definition.
class CLASS_TYPE {
}
An object can be created from a class by a new operator.
Note that an interface type and a multi-numeric type is not a class type although these types are defined by class definition.
Numeric Object Types
A numeric object type is a class type that owns the corresponding field of a numeric type.
The List of Numeric Object Types:
Numeric Object Types | Corresponding Numeric Types |
---|---|
Byte | byte |
Short | short |
Int | int |
Long | long |
Float | float |
Double | double |
Interface Types
An interface type is a type for an interface.
An interface type is defined by an interface definition.
class INTERFACE_TYPE : interface_t {
}
Any Object Type
Any object type object
is the type to which any object type can be assigned.
object
Examples:
# Examples of any object type
my $object: object = new Foo;
Basic Types
A basic type is a type whose type dimension is 0 and that can be an element of an array.
The List of Basic Types:
undef Type
The undef type is the type of an undefined value.
void Type
The void
type is the type that represents a method defined by a method definition does not return a return value.
void
Array Types
An array type is a type for an array. An array type consists of a basic type and a type dimension such as []
, [][]
.
BASIC_TYPE[]..
([]..
means one more []
)
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 object type.
Compilation Errors:
The dimesion is less than or equal to 255. Otherwise, a compilation error occurs.
Numeric Array Types
A numeric array type is an array type of a numeric type.
The List of Numeric Array Types:
byte[]
short[]
int[]
long[]
float[]
double[]
Object Array Types
An object array type is an array type of an object type.
Examples:
Point[]
Point[][]
Stringable[]
string[]
object[]
String Array Type
The string array type is array type string type.
string[]
Class Array Types
A class array type is an array type of a class type.
Examples:
Int[]
Point[]
Interface Array Types
An interface array type is an array type of an interface type.
Examples:
Stringable[]
Cloneable[]
Multi-Dimensional Array Types
A multi-dimensional array type is an array type of an array type.
Examples:
int[][]
Int[][]
string[][][]
object[][]
A multi-dimensional array is created by the syntax of creating a multi-dimensional array of the new
operator.
Multi-Numeric Array Types
A multi-numeric array type is an array type of a multi-numeric type.
Examples:
Complex_2d[]
Complex_2f[]
Any Object Array Type
The any object array type object[]
is array type to which any object array type can be assigned.
object[]
Multi-Numeric Types
A multi-numeric type is a type for a multi-numeric number.
A multi-numeric type is defined by a multi-numeric type definition.
class MULNUM_TYPE : mulnum_t {
}
Reference Types
A reference type is a type for a reference.
TYPE*
A reference type consists of a type followed by *
.
TYPE must be a numeric type or a multi-numeric type.
Numeric Reference Types
A numeric reference type is a reference type of a numeric type.
The List of Numeric Reference Types:
byte*
short*
int*
long*
float*
double*
Multi-Numeric Reference Types
A multi-numeric reference types is a reference type of a multi-numeric type.
MULNUM_TYPE*
Examples:
Complex_2d*
Complex_2f*
Type Qualifiers
A type qualifier qualify a type.
QUALIFIER TYPE
The QUALIFIER qualified the type TYPE.
mutable Type Qualifier
The mutable
type qualifier qualifies string type.
mutable string;
The string of string type with the mutable
type qualifier is able to be set a character.
my $string = (mutable string)copy "abc";
$string->[0] = 'd';
Type Initial Value
The value of a type is initialized by its type initial value.
The List of Type Initial Values:
Types | Type Initial Values |
---|---|
byte | 0 |
short | 0 |
int | 0 |
long | 0 |
float | 0 (All bits are 0) |
double | 0 (All bits are 0) |
Object Types | undef |
Multi-Numeric Types | All fields are set to 0 (All bits are 0) |
Type Width
The type width is the length of runtime stack of the type.
If the type is a multi-numeric type, the type width is the length of the fields, owhterwise it is 1.
Assignment Requirement
The assignment requirement is the requirement whether one type is able to be assigned to another type.
What does it mean to assign one type to another type?
Typically, it is sufficient to consider a case where a value of a type TYPE_FROM is assigned to a variable of a type TYPE_TO.
my $value : TYPE_FROM;
my $var : TYPE_TO = $value;
Abstracting this, type-to-type assignment is defined.
TYPE_TO = TYPE_FROM
Note that this is a concept, not an actual syntax.
Some assinments perform a data conversion.
In the following description, the word "Type" is omitted when it is obvious.
Assignment Requirement to Numeric
Assignment Requirement from Numeric to Numeric
To Larger:
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | byte | byte | No |
Yes | short | short | No |
Yes | int | int | No |
Yes | long | long | No |
Yes | float | float | No |
Yes | double | double | No |
Yes | short | byte | Numeric Widening Conversion |
Yes | int | byte | Numeric Widening Conversion |
Yes | long | byte | Numeric Widening Conversion |
Yes | float | byte | Numeric Widening Conversion |
Yes | double | byte | Numeric Widening Conversion |
Yes | int | short | Numeric Widening Conversion |
Yes | long | short | Numeric Widening Conversion |
Yes | float | short | Numeric Widening Conversion |
Yes | double | short | Numeric Widening Conversion |
Yes | long | int | Numeric Widening Conversion |
Yes | float | int | Numeric Widening Conversion |
Yes | double | int | Numeric Widening Conversion |
Yes | float | long | Numeric Widening Conversion |
Yes | double | long | Numeric Widening Conversion |
Yes | double | float | Numeric Widening Conversion |
To Smaller:
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Conditional Yes | byte | short | Numeric Narrowing Conversion |
Conditional Yes | byte | int | Numeric Narrowing Conversion |
Conditional Yes | byte | long | Numeric Narrowing Conversion |
No | byte | float | No |
No | byte | double | No |
Conditional Yes | short | int | Numeric Narrowing Conversion |
Conditional Yes | short | long | Numeric Narrowing Conversion |
No | short | float | No |
No | short | double | No |
Conditional Yes | int | long | Numeric Narrowing Conversion |
No | int | float | No |
No | int | double | No |
No | long | float | No |
No | long | double | No |
Conditional Yes | float | double | Numeric Narrowing Conversion |
"Conditional Yes" means the followings.
For Integral Types:
If the value of TYPE_FROM is represented by an interger literal and between the max and minimal value of the type of TYPE_TO, Yes, otherwize No.
For Floating Point types:
If the value of TYPE_FROM is represented by a floating point literal, Yes, otherwize No.
Assignment Requirement from NumericObject to Numeric
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | byte | Byte | Unboxing Conversion |
Yes | short | Short | Unboxing Conversion |
Yes | int | Int | Unboxing Conversion |
Yes | long | Long | Unboxing Conversion |
Yes | float | Float | Unboxing Conversion |
Yes | double | Double | Unboxing Conversion |
Assignment Requirement from Any Object to Numeric
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | byte | Any Object object | Unboxing Conversion |
Yes | short | Any Object object | Unboxing Conversion |
Yes | int | Any Object object | Unboxing Conversion |
Yes | long | Any Object object | Unboxing Conversion |
Yes | float | Any Object object | Unboxing Conversion |
Yes | double | Any Object object | Unboxing Conversion |
Assignment Requirement from Other to Numeric
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
No | NumericX | Other | No |
NumericX is a numeric type.
Assignment Requirement to Multi-Numeric
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | Multi-NumericX | Multi-NumericX | No |
No | Multi-NumericX | Other | No |
Multi-NumericX is a multi-numeric type.
Assignment Requirement to Referenece
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | ReferenceX | ReferenceX | No |
No | ReferenceX | Other | No |
ReferenceX is a reference type.
Assignment Requirement to String
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | string | string | No |
Yes | string | mutable string | No |
Yes | mutable string | mutable string | No |
No | mutable string | string | No |
Yes | string | string | No |
Yes | string | NumericX | Numeric-to-String Conversion |
Yes | string | undef | No |
No | string | Other | No |
NumericX is a numeric type.
Assignment Requirement to NumericObject
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | NumericObjectX | NumericObjectX | No |
Yes | NumericObjectX | NumericX | Boxing Conversion |
Yes | NumericObjectX | undef | No |
No | NumericObjectX | Other | No |
NumericObjectX is a numeric object type.
NumericX is a numeric type.
Assignment Requirement to Class
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | ClassX | ClassX | No |
Yes | ClassX | undef | No |
Yes | SuperClassX | ClassX | No |
No | ClassX | Other | No |
ClassX is a class type.
SuperClassX is a super class of ClassX.
Assignment Requirement to Interface
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | InterfaceX | InterfaceX | No |
Yes | InterfaceX | InterfaceSatisfiedX | No |
Yes | InterfaceX | undef | No |
No | InterfaceX | Other | No |
InterfaceX is a an interface type.
InterfaceSatisfiedX is a class type or an interface type that satisfied interface requirement of InterfaceX.
Assignment Requirement to Any Object
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | Any Object object | ObjectX | No |
Yes | Any Object object | NumericX | Boxing Conversion |
Yes | Any Object object | undef | No |
No | Any Object object | Other | No |
ObjectX is an object type.
NumericX is a numeric type.
Assignment Requirement to undef
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
No | undef | X | No |
X is a type.
Assignment Requirement to void
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | void | void | No |
No | void | X | No |
X is a type.
Assignment Requirement to Numeric Array
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | NumericX[] | NumericX[] | No |
Yes | NumericX[] | undef | No |
No | NumericX[] | Other | No |
NumericX is a numeric type.
Assignment Requirement to Multi-Numeric Array
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | Multi-NumericX[] | Multi-NumericX[] | No |
Yes | Multi-NumericX[] | undef | No |
No | Multi-NumericX[] | Other | No |
Multi-NumericX is a multi-numeric type.
Assignment Requirement to String Array
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | string[] | string[] | No |
Yes | string[] | undef | No |
No | string[] | Other | No |
Assignment Requirement to Class Array
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | ClassX[] | ClassX[] | No |
Yes | SuperClassX[] | ClassX[] | No |
Yes | ClassX[] | undef | No |
No | ClassX[] | Other | No |
ClassX is a class type.
SuperClassX is a super class of ClassX.
Assignment Requirement to Interface Array
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | InterfaceX[] | InterfaceX[] | No |
Yes | InterfaceX[] | InterfaceSatisfiedX[] | No |
Yes | InterfaceX[] | undef | No |
No | InterfaceX[] | Other | No |
InterfaceX is a an interface type.
InterfaceSatisfiedX is a class type or an interface type that satisfied interface requirement of InterfaceX.
Assignment Requirement to Any Object Array
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | Any Object Array object[] | ObjectX[].. | No |
Yes | Any Object Array object[] | undef | No |
No | Any Object Array object[] | Other | No |
ObjectX is an object type.
[]..
is one or more []
.
Assignment Requirement to Multi-Dimensional Array
Assignment Requirement Satisfaction | To | From | Data Conversion |
---|---|---|---|
Yes | X[]..D | X[]..D | No |
Yes | X[]..D | undef | No |
Yes | SuperClassX[]..D | ClassX[]..D | No |
Yes | InterfaceX[]..D | InterfaceSatisfiedX[]..D | No |
No | X[]..D | Other | No |
X is a type.
[]..
is one or more []
.
D means its type dimension that is greater than or eausl to 2.
X[]..D is a multi-dimensional array.
ClassX is a class type.
SuperClassX is a super class of ClassX.
InterfaceX is a an interface type.
InterfaceSatisfiedX is a class type or an interface type that satisfied interface requirement of InterfaceX.
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 TYPE_FROM is casted to 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 when it is obvious.
Cast Requirement to Numeric
Cast Requirement from Numeric to Numeric
To Larger:
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | byte | byte | No | No |
Yes | short | short | No | No |
Yes | int | int | No | No |
Yes | long | long | No | No |
Yes | float | float | No | No |
Yes | double | double | No | No |
Yes | short | byte | Numeric Widening Conversion | No |
Yes | int | byte | Numeric Widening Conversion | No |
Yes | long | byte | Numeric Widening Conversion | No |
Yes | float | byte | Numeric Widening Conversion | No |
Yes | double | byte | Numeric Widening Conversion | No |
Yes | int | short | Numeric Widening Conversion | No |
Yes | long | short | Numeric Widening Conversion | No |
Yes | float | short | Numeric Widening Conversion | No |
Yes | double | short | Numeric Widening Conversion | No |
Yes | long | int | Numeric Widening Conversion | No |
Yes | float | int | Numeric Widening Conversion | No |
Yes | double | int | Numeric Widening Conversion | No |
Yes | float | long | Numeric Widening Conversion | No |
Yes | double | long | Numeric Widening Conversion | No |
Yes | double | float | Numeric Widening Conversion | No |
To Smaller:
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | byte | short | Numeric Narrowing Conversion | No |
Yes | byte | int | Numeric Narrowing Conversion | No |
Yes | byte | long | Numeric Narrowing Conversion | No |
Yes | byte | float | Numeric Narrowing Conversion | No |
Yes | byte | double | Numeric Narrowing Conversion | No |
Yes | short | int | Numeric Narrowing Conversion | No |
Yes | short | long | Numeric Narrowing Conversion | No |
Yes | short | float | Numeric Narrowing Conversion | No |
Yes | short | double | Numeric Narrowing Conversion | No |
Yes | int | long | Numeric Narrowing Conversion | No |
Yes | int | float | Numeric Narrowing Conversion | No |
Yes | int | double | Numeric Narrowing Conversion | No |
Yes | long | float | Numeric Narrowing Conversion | No |
Yes | long | double | Numeric Narrowing Conversion | No |
Yes | float | double | Numeric Narrowing Conversion | No |
Cast Requirement from NumericObject to Numeric
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | byte | Byte | Unboxing Conversion | No |
Yes | short | Short | Unboxing Conversion | No |
Yes | int | Int | Unboxing Conversion | No |
Yes | long | Long | Unboxing Conversion | No |
Yes | float | Float | Unboxing Conversion | No |
Yes | double | Double | Unboxing Conversion | No |
Cast Requirement from Any Object to Numeric
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | NumericX | Any Object object | Unboxing Conversion | No |
NumericX is a numeric type.
Cast Requirement from Other to Numeric
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
No | NumericX | Other | No | No |
NumericX is a numeric type.
Cast Requirement to Multi-Numeric
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | Multi-NumericX | Multi-NumericX | No | No |
No | Multi-NumericX | Other | No | No |
Multi-NumericX is a multi-numeric type.
Cast Requirement to Referenece
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | ReferenceX | ReferenceX | No | No |
No | ReferenceX | Other | No | No |
ReferenceX is a reference type.
Cast Requirement to String
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | string | string | No | No |
Yes | string | mutable string | No | No |
Yes | mutable string | mutable string | No | No |
Yes | mutable string | string | No | is_read_only Operator |
Yes | string | string | No | No |
Yes | string | NumericX | Numeric-to-String Conversion | No |
Yes | string | Any Object object | No | isa Operator |
Yes | string | undef | No | No |
No | string | Other | No | No |
NumericX is a numeric type.
Cast Requirement to NumericObject
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | NumericObjectX | NumericObjectX | No | No |
Yes | NumericObjectX | NumericX | Boxing Conversion | No |
Yes | NumericObjectX | Any Object object | No | isa Operator |
Yes | NumericObjectX | undef | No | No |
No | NumericObjectX | Other | No | No |
NumericObjectX is a numeric object type.
NumericX is a numeric type.
Cast Requirement to Class
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | ClassX | ClassX | No | No |
Yes | SuperClassX | ClassX | No | No |
Yes | ClassX | SuperClassX | No | isa Operator |
Yes | ClassX | InterfaceX | No | isa Operator |
Yes | ClassX | Any Object object | No | isa Operator |
Yes | ClassX | undef | No | No |
No | ClassX | Other | No | No |
ClassX is a class type.
SuperClassX is a super class of ClassX.
InterfaceX is a an interface type.
Cast Requirement to Interface
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | InterfaceX | InterfaceX | No | No |
Yes | InterfaceX | InterfaceSatisfiedX | No | No |
Yes | InterfaceX | InterfaceY | No | isa Operator |
Yes | InterfaceX | Any Object object | No | isa Operator |
Yes | InterfaceX | undef | No | No |
No | InterfaceX | Other | No | No |
ClassX is a class type.
SuperClassX is a super class of ClassX.
InterfaceX is a an interface type.
InterfaceY is a an interface type.
InterfaceSatisfiedX is a class type or an interface type that satisfied interface requirement of InterfaceX.
Cast Requirement to Any Object
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | Any Object object | ObjectX | No | No |
Yes | Any Object object | NumericX | Boxing Conversion | No |
Yes | Any Object object | undef | No | No |
No | Any Object object | Other | No | No |
ObjectX is an object type.
NumericX is a numeric type.
Cast Requirement to Numeric Array
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | byte[] | string | String-to-byte[] Conversion | No |
Yes | NumericX[] | NumericX[] | No | No |
Yes | NumericX[] | Any Object object | No | isa Operator |
Yes | NumericX[] | undef | No | No |
No | NumericX[] | Other | No | No |
NumericX is a numeric type.
Cast Requirement to Multi-Numeric Array
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | Multi-NumericX[] | Multi-NumericX[] | No | No |
Yes | Multi-NumericX[] | Any Object object | No | isa Operator |
Yes | Multi-NumericX[] | undef | No | No |
No | Multi-NumericX[] | Other | No | No |
Multi-NumericX is a multi-numeric type.
Cast Requirement to String Array
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | string[] | string[] | No | No |
Yes | string[] | Any Object object | No | isa Operator |
Yes | string[] | Any Object Array object[] | No | isa Operator |
Yes | string[] | undef | No | No |
No | string[] | Other | No | No |
Cast Requirement to Class Array
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | ClassX[] | ClassX[] | No | No |
Yes | SuperClassX[] | ClassX[] | No | No |
Yes | ClassX[] | SuperClassX[] | No | isa Operator |
Yes | ClassX[] | Any Object object | No | isa Operator |
Yes | ClassX[] | Any Object Array object[] | No | isa Operator |
Yes | ClassX[] | undef | No | No |
No | ClassX[] | Other | No | No |
ClassX is a class type.
SuperClassX is a super class of ClassX.
Cast Requirement to Interface Array
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | InterfaceX[] | InterfaceX[] | No | No |
Yes | InterfaceX[] | InterfaceSatisfiedX[] | No | No |
Yes | InterfaceX[] | InterfaceY[] | No | isa Operator |
Yes | InterfaceX[] | Any Object object | No | isa Operator |
Yes | InterfaceX[] | Any Object Array object[] | No | isa Operator |
Yes | InterfaceX[] | undef | No | No |
No | InterfaceX[] | Other | No | No |
ClassX is a class type.
SuperClassX is a super class of ClassX.
InterfaceX is a an interface type.
InterfaceY is a an interface type.
InterfaceSatisfiedX is a class type or an interface type that satisfied interface requirement of InterfaceX.
Cast Requirement to Any Object Array
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | Any Object Array object[] | ObjectX[].. | No | No |
Yes | Any Object Array object[] | undef | No | No |
Yes | Any Object Array object[] | Any Object object | No | isa Operator |
No | Any Object Array object[] | Other | No | No |
ObjectX is an object type.
[]..
is one or more []
.
Cast Requirement to Multi-Dimensional Array
Cast Requirement Satisfaction | To | From | Data Conversion | Data Check |
---|---|---|---|---|
Yes | X[]..D | X[]..D | No | No |
Yes | X[]..D | Any Object object | No | isa Operator |
Yes | X[]..D | Any Object Array object[] | No | isa Operator |
Yes | X[]..D | undef | No | No |
Yes | SuperClassX[].. | ClassX[]..D | No | No |
Yes | ClassX[].. | SuperClassX[]..D | No | isa Operator |
Yes | InterfaceX[]..D | InterfaceSatisfiedX[]..D | No | No |
No | Any Object Array object[] | Other | No | No |
X is a type.
[]..
is one or more []
.
D means its type dimension that is greater than or eausl to 2.
X[]..D is a multi-dimensional array.
ClassX is a class type.
SuperClassX is a super class of ClassX.
InterfaceX is a an interface type.
InterfaceSatisfiedX is a class type or an interface type that satisfied interface requirement of InterfaceX.
Interface Requirement
The interface requirement is the requirement whether an object type is able to be assigned to an interface type.
INTERFACE_TYPE_TO = OBJECT_TYPE_FROM
This is the same concept as type-to-type assignment explained in Assignment Requirement.
INTERFACE_TYPE_TO must be an interface type.
OBJECT_TYPE_FROM must be a class type or an interface type.
The following check is performed on every instance method of OBJECT_TYPE_FROM.
If an instance method of INTERFACE_TYPE_TO has the required
method attribute, OBJECT_TYPE_FROM or one of its super classes must have a method with the same name.
If OBJECT_TYPE_FROM or one of its super classes has an instance method(this is named METHOD_FROM) with the same name as an instance method of INTERFACE_TYPE_TO, METHOD_FROM must be an instance method and satisfy interface method requirement.
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 Assignment Requirement to method-to-method assignment.
INTERFACE_METHOD_TO must be an instance method.
METHOD_FROM must be an instance method.
The length of the arguments of the method of the INTERFACE_METHOD_TO type must be greater than or equal to the length of the required arguments the method of the INSTANT_METHOD_TYPE_FROM type.
The every argument other than at 0 index of the method of the INSTANT_METHOD_TYPE_FROM must satisfy assignment requirement to the argument as the same index of the method of the INTERFACE_METHOD_TO without a data conversion and with interface exactly matched.
The return type of the method of the INSTANT_METHOD_TYPE_FROM must must satisfy assignment requirement to the return type of the method of the INTERFACE_METHOD_TO without a data conversion and with interface exactly matched.
See Also
Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License