Package com.tonic.analysis.source.ast
Class SourceLocation
- java.lang.Object
-
- com.tonic.analysis.source.ast.SourceLocation
-
public final class SourceLocation extends Object
Position of an AST node as a bytecode offset and source line number, either of which may be absent (-1).
-
-
Field Summary
Fields Modifier and Type Field Description static SourceLocationUNKNOWN
-
Constructor Summary
Constructors Constructor Description SourceLocation(int bytecodeOffset, int lineNumber)Creates a location; pass -1 for a missing component.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intbytecodeOffset()booleanequals(Object o)static SourceLocationfromLine(int line)Creates a location with only a line number.static SourceLocationfromOffset(int offset)Creates a location with only a bytecode offset.inthashCode()booleanhasLineNumber()booleanhasOffset()intlineNumber()StringtoString()
-
-
-
Field Detail
-
UNKNOWN
public static final SourceLocation UNKNOWN
-
-
Method Detail
-
fromOffset
public static SourceLocation fromOffset(int offset)
Creates a location with only a bytecode offset.- Parameters:
offset- the bytecode offset- Returns:
- the location
-
fromLine
public static SourceLocation fromLine(int line)
Creates a location with only a line number.- Parameters:
line- the source line number- Returns:
- the location
-
hasOffset
public boolean hasOffset()
- Returns:
- true if the bytecode offset is known
-
hasLineNumber
public boolean hasLineNumber()
- Returns:
- true if the line number is known
-
bytecodeOffset
public int bytecodeOffset()
- Returns:
- the bytecode offset, or -1 if unknown
-
lineNumber
public int lineNumber()
- Returns:
- the line number, or -1 if unknown
-
-