Interface SourceType
-
- All Superinterfaces:
ASTNode
- All Known Implementing Classes:
ArraySourceType,GenericSourceType,IntersectionSourceType,PrimitiveSourceType,ReferenceSourceType,UnionSourceType,VoidSourceType,WildcardSourceType
public interface SourceType extends ASTNode
Sealed interface representing source-level types.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static SourceTypefromIRType(IRType irType)Creates a SourceType from an IR type.default SourceLocationgetLocation()Types carry no source position.default ASTNodegetParent()Types are shared and carry no link to the node that uses them.default booleanisArray()default booleanisPrimitive()default booleanisReference()default booleanisVoid()default voidsetParent(ASTNode parent)Does nothing, since types keep no parent link.IRTypetoIRType()Converts this source type to the equivalent IR type.StringtoJavaSource()Converts this source type to Java source code representation.-
Methods inherited from interface com.tonic.analysis.source.ast.ASTNode
accept, deepClone, findAll, findAll, findAncestor, findFirst, findFirst, getChildren, getRoot, isDescendantOf, remove, replaceWith, stream, stream, walk
-
-
-
-
Method Detail
-
toJavaSource
String toJavaSource()
Converts this source type to Java source code representation.- Returns:
- the Java source representation (e.g., "int", "String", "int[]")
-
toIRType
IRType toIRType()
Converts this source type to the equivalent IR type.- Returns:
- the corresponding IRType
-
fromIRType
static SourceType fromIRType(IRType irType)
Creates a SourceType from an IR type.- Parameters:
irType- the IR type to convert- Returns:
- the corresponding SourceType
-
isPrimitive
default boolean isPrimitive()
- Returns:
- true if this type is a primitive type
-
isReference
default boolean isReference()
- Returns:
- true if this type is a reference type (class or interface)
-
isArray
default boolean isArray()
- Returns:
- true if this type is an array type
-
isVoid
default boolean isVoid()
- Returns:
- true if this type is void
-
getParent
default ASTNode getParent()
Types are shared and carry no link to the node that uses them.
-
setParent
default void setParent(ASTNode parent)
Does nothing, since types keep no parent link.
-
getLocation
default SourceLocation getLocation()
Types carry no source position.- Specified by:
getLocationin interfaceASTNode- Returns:
SourceLocation.UNKNOWN
-
-