Class Literal


public final class Literal extends Expression
A constant value. These can contain ints, floats, or booleans.
  • Method Details

    • makeFloat

      @Nonnull public static Literal makeFloat(@Nonnull Context context, int position, float value)
    • makeFloat

      @Nonnull public static Literal makeFloat(int position, float value, Type type)
    • makeInteger

      @Nonnull public static Literal makeInteger(@Nonnull Context context, int position, long value)
    • makeInteger

      @Nonnull public static Literal makeInteger(int position, long value, Type type)
    • makeBoolean

      @Nonnull public static Literal makeBoolean(@Nonnull Context context, int position, boolean value)
    • makeBoolean

      @Nonnull public static Literal makeBoolean(int position, boolean value, Type type)
    • make

      @Nonnull public static Literal make(int position, double value, Type type)
    • getKind

      public Node.ExpressionKind getKind()
      Specified by:
      getKind in class Expression
      See Also:
    • accept

      public boolean accept(@Nonnull TreeVisitor visitor)
      Description copied from class: Node
      Visit this AST with a given visitor.
      Specified by:
      accept in class Node
      Returns:
      true to stop recursion and propagate true up the stack, false to continue
    • isLiteral

      public boolean isLiteral()
      Overrides:
      isLiteral in class Expression
    • getFloatValue

      public float getFloatValue()
    • getIntegerValue

      public long getIntegerValue()
    • getBooleanValue

      public boolean getBooleanValue()
    • getValue

      public double getValue()
    • getConstantValue

      public OptionalDouble getConstantValue(int i)
      Description copied from class: Expression
      Returns the i'th compile-time constant value within a literal or constructor. Indices which do not contain compile-time constant values will return empty. `vec4(1, vec2(2), 3)` contains four compile-time constants: (1, 2, 2, 3) `mat2(f)` contains four slots, and two are constant: (empty, 0, 0, empty)
      Overrides:
      getConstantValue in class Expression
    • clone

      @Nonnull public Expression clone(int position)
      Specified by:
      clone in class Expression
    • toString

      @Nonnull public String toString(int parentPrecedence)
      Specified by:
      toString in class Expression