Interface Type
- All Known Implementing Classes:
ArrayType,BooleanType,ByteType,CharType,DoubleType,FloatType,FunctionType,IntType,LongType,ObjectType,ShortType,StringType,UnitType
public sealed interface Type
permits BooleanType, ByteType, CharType, ShortType, IntType, LongType, FloatType, DoubleType, ArrayType, ObjectType, UnitType, StringType, FunctionType
The interface representing all JFuncMachine types
-
Method Summary
Modifier and TypeMethodDescriptiondefault TypeReturns the type of this type's box class, if any.default StringReturns the name of this type's box class, if any For example, SimpleTypes.INT has a box class name of "java.lang.Integer"default charReturns the character that the JVM uses to represent this typedefault intThe number of stack slots that this type consumes on the JVM stack.default TypeReturns the unboxed type of this type, if anydefault booleanTests whether this type is represented as an int in the JVM.default booleanTest whether this type is a box typedefault booleanisEnum()Tests whether this type is an enum typedefault booleanisUnboxableFrom(String className) Test whether this type can be unboxed from the given class namedefault booleansameJavaType(Type other) Tests whether this type has the same JVM representation as another type
-
Method Details
-
getBoxTypeName
Returns the name of this type's box class, if any For example, SimpleTypes.INT has a box class name of "java.lang.Integer"- Returns:
- The name of the box class, or null if there isn't one
-
getBoxType
Returns the type of this type's box class, if any. For example, SimpleTypes.INT has a box type of new ObjectType("java.lang.Integer")- Returns:
- The type of this type's box class, or null if there isn't one
-
getUnboxedType
Returns the unboxed type of this type, if any- Returns:
- The unboxed type of this type, or null if there isn't one
-
isBoxType
default boolean isBoxType()Test whether this type is a box type- Returns:
- True if this type is a box type
-
isUnboxableFrom
Test whether this type can be unboxed from the given class name- Parameters:
className- The name of a possible box type- Returns:
- True if this type can be unboxed from the given class name
-
getStackSize
default int getStackSize()The number of stack slots that this type consumes on the JVM stack. A long or double type consumes two slots, all others consume one.- Returns:
- The number of stack slots this type consumes
-
hasIntRepresentation
default boolean hasIntRepresentation()Tests whether this type is represented as an int in the JVM. This is true for boolean, byte, char, int, and short.- Returns:
- True if this type is represented as an int by the JVM
-
getJVMTypeRepresentation
default char getJVMTypeRepresentation()Returns the character that the JVM uses to represent this type- Returns:
- I for types represented by an int, J for Long, F for Float, D for double, A for object
-
sameJavaType
Tests whether this type has the same JVM representation as another type- Parameters:
other- The other type to compare against- Returns:
- True if the types have the same representation in the JVM
-
isEnum
default boolean isEnum()Tests whether this type is an enum type- Returns:
- True if this type represents an enum
-