All Implemented Interfaces:
FromSourceLocation, ToNode, TypeCheck, ToCondition, ToExpression

public final class GetAttr extends LibraryFunction
A rule-set expression for indexing a record/object or array.
  • Field Details

  • Method Details

    • getDefinition

      public static GetAttr.Definition getDefinition()
      Gets the FunctionDefinition implementation.
      Returns:
      the function definition.
    • ofExpressions

      public static GetAttr ofExpressions(ToExpression arg1, ToExpression arg2)
      Creates a GetAttr function from the given expressions.
      Parameters:
      arg1 - the argument to extract from.
      arg2 - the path to extract.
      Returns:
      The resulting GetAttr function.
    • ofExpressions

      public static GetAttr ofExpressions(ToExpression arg1, String arg2)
      Creates a GetAttr function from the given expressions.
      Parameters:
      arg1 - the argument to extract from.
      arg2 - the path to extract.
      Returns:
      The resulting GetAttr function.
    • evaluate

      public Value evaluate(Value target)
      Gets the value at the defined path out of the target value.
      Parameters:
      target - the target value to retrieve a value out of.
      Returns:
      the retrieve value.
    • getTarget

      public Expression getTarget()
      Gets the expression to retrieve an attribute of.
      Returns:
      the expression targeted by this function.
    • getPath

      public List<GetAttr.Part> getPath()
      Gets the list of GetAttr.Parts that make up the path to the requested attribute.
      Returns:
      the list of path parts to the requested attribute.
    • accept

      public <R> R accept(ExpressionVisitor<R> visitor)
      Description copied from class: Expression
      Invoke the ExpressionVisitor functions for this expression.
      Specified by:
      accept in class Expression
      Type Parameters:
      R - the visitor return type.
      Parameters:
      visitor - the visitor to be invoked.
      Returns:
      the return value of the visitor.
    • typeCheckLocal

      protected Type typeCheckLocal(Scope<Type> scope)
      Overrides:
      typeCheckLocal in class LibraryFunction
    • template

      public String template()
      Description copied from class: SyntaxElement
      Converts this expression to a string template. By default, this implementation returns a RuntimeException.
      Overrides:
      template in class SyntaxElement
      Returns:
      the String template.
    • toNode

      public Node toNode()
      Description copied from interface: ToNode
      Converts a value to a Node.
      Specified by:
      toNode in interface ToNode
      Overrides:
      toNode in class LibraryFunction
      Returns:
      Returns the creates Node.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class LibraryFunction
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class LibraryFunction
    • toString

      public String toString()
      Overrides:
      toString in class LibraryFunction