Package icyllis.arc3d.compiler

# Class Position

java.lang.Object
icyllis.arc3d.compiler.Position

public final class Position extends Object
Represents a position that encapsulates the offset and length. It's packed as a `int` value to reduce object allocation. This class provides static methods to pack and unpack positions.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `MAX_OFFSET`
  `static final int`
  `NO_POS`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static int`
  `getEndOffset(int pos)`
  `static int`
  `getLine(int pos, char[] source)`
  `static int`
  `getStartOffset(int pos)`
  `static int`
  `range(int start, int end)`
  Pack a range into a position, the position is valid only if `start >= 0 && start <= end && end <= 0x7FFFFF`.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### NO_POS

    public static final int NO_POS
    See Also:
      - Constant Field Values

  - ### MAX_OFFSET

    public static final int MAX_OFFSET
    See Also:
      - Constant Field Values

- ## Method Details

  - ### range

    public static int range(int start, int end)
    Pack a range into a position, the position is valid only if `start >= 0 && start <= end && end <= 0x7FFFFF`.
    - 0-24 bits: offset, signed, -1 means invalid
    - 24-32 bits: length, unsigned, saturate at 0xFF
    Returns:
      the position

  - ### getStartOffset

    public static int getStartOffset(int pos)

  - ### getEndOffset

    public static int getEndOffset(int pos)

  - ### getLine

    public static int getLine(int pos, char[] source)