Class PrimitiveSourceType
- java.lang.Object
-
- com.tonic.analysis.source.ast.type.PrimitiveSourceType
-
- All Implemented Interfaces:
ASTNode,SourceType
public final class PrimitiveSourceType extends Object implements SourceType
Represents a primitive type in the source AST.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPrimitiveSourceType.PrimitiveKindThe eight Java primitives, each paired with its source keyword and IR type.
-
Field Summary
Fields Modifier and Type Field Description static PrimitiveSourceTypeBOOLEANstatic PrimitiveSourceTypeBYTEstatic PrimitiveSourceTypeCHARstatic PrimitiveSourceTypeDOUBLEstatic PrimitiveSourceTypeFLOATstatic PrimitiveSourceTypeINTstatic PrimitiveSourceTypeLONGstatic PrimitiveSourceTypeSHORT
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(SourceVisitor<T> visitor)Accepts a visitor for this node.booleanequals(Object obj)static PrimitiveSourceTypefromPrimitive(PrimitiveType irType)Maps an IR primitive type onto its source type constant.PrimitiveSourceType.PrimitiveKindgetKind()inthashCode()IRTypetoIRType()Converts this source type to the equivalent IR type.StringtoJavaSource()Converts this source type to Java source code representation.StringtoString()-
Methods inherited from interface com.tonic.analysis.source.ast.ASTNode
deepClone, findAll, findAll, findAncestor, findFirst, findFirst, getChildren, getRoot, isDescendantOf, remove, replaceWith, stream, stream, walk
-
Methods inherited from interface com.tonic.analysis.source.ast.type.SourceType
getLocation, getParent, isArray, isPrimitive, isReference, isVoid, setParent
-
-
-
-
Field Detail
-
BOOLEAN
public static final PrimitiveSourceType BOOLEAN
-
BYTE
public static final PrimitiveSourceType BYTE
-
CHAR
public static final PrimitiveSourceType CHAR
-
SHORT
public static final PrimitiveSourceType SHORT
-
INT
public static final PrimitiveSourceType INT
-
LONG
public static final PrimitiveSourceType LONG
-
FLOAT
public static final PrimitiveSourceType FLOAT
-
DOUBLE
public static final PrimitiveSourceType DOUBLE
-
-
Method Detail
-
getKind
public PrimitiveSourceType.PrimitiveKind getKind()
- Returns:
- the kind
-
fromPrimitive
public static PrimitiveSourceType fromPrimitive(PrimitiveType irType)
Maps an IR primitive type onto its source type constant.- Parameters:
irType- the IR primitive type- Returns:
- the matching shared constant
- Throws:
IllegalArgumentException- if the IR type is not one of the eight primitives
-
toJavaSource
public String toJavaSource()
Description copied from interface:SourceTypeConverts this source type to Java source code representation.- Specified by:
toJavaSourcein interfaceSourceType- Returns:
- the Java source representation (e.g., "int", "String", "int[]")
-
toIRType
public IRType toIRType()
Description copied from interface:SourceTypeConverts this source type to the equivalent IR type.- Specified by:
toIRTypein interfaceSourceType- Returns:
- the corresponding IRType
-
accept
public <T> T accept(SourceVisitor<T> visitor)
Description copied from interface:ASTNodeAccepts a visitor for this node.
-
-