Package icyllis.arc3d.compiler
Class Position
java.lang.Object
icyllis.arc3d.compiler.Position
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 ifstart >= 0 && start <= end && end <= 0x7FFFFF
.
-
Field Details
-
NO_POS
public static final int NO_POS- See Also:
-
MAX_OFFSET
public static final int MAX_OFFSET- See Also:
-
-
Method Details
-
range
public static int range(int start, int end) Pack a range into a position, the position is valid only ifstart >= 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)
-