Class 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).
    • Constructor Detail

      • SourceLocation

        public SourceLocation​(int bytecodeOffset,
                              int lineNumber)
        Creates a location; pass -1 for a missing component.
        Parameters:
        bytecodeOffset - the bytecode offset, or -1 if unknown
        lineNumber - the source line number, or -1 if 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object