Class Literal


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

    • makeFloat Link icon

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

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

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

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

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

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

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

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

      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 Link icon

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

      public float getFloatValue()
    • getIntegerValue Link icon

      public long getIntegerValue()
    • getBooleanValue Link icon

      public boolean getBooleanValue()
    • getValue Link icon

      public double getValue()
    • getConstantValue Link icon

      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 Link icon

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

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