Class ArrayAccessExpr

    • Constructor Detail

      • ArrayAccessExpr

        public ArrayAccessExpr​(Expression array,
                               Expression index,
                               SourceType type,
                               SourceLocation location)
        Creates an array access over the given array and index and reparents both operands.
        Parameters:
        array - the array operand
        index - the index operand
        type - the element type produced by the access
        location - the source location, or null for unknown
        Throws:
        NullPointerException - if array, index, or type is null
      • ArrayAccessExpr

        public ArrayAccessExpr​(Expression array,
                               Expression index,
                               SourceType type)
        Creates an array access with an unknown source location.
        Parameters:
        array - the array operand
        index - the index operand
        type - the element type produced by the access
        Throws:
        NullPointerException - if array, index, or type is null
    • Method Detail

      • getArray

        public Expression getArray()
        Returns:
        the array
      • setArray

        public void setArray​(Expression array)
        Replaces the array operand, reparenting the new child.
        Parameters:
        array - the new array operand
      • getIndex

        public Expression getIndex()
        Returns:
        the index
      • setIndex

        public void setIndex​(Expression index)
        Replaces the index operand, reparenting the new child.
        Parameters:
        index - the new index operand
      • getType

        public SourceType getType()
        Description copied from interface: Expression
        Gets the inferred type of this expression.
        Specified by:
        getType in interface Expression
        Returns:
        the static type of this expression
      • getLocation

        public SourceLocation getLocation()
        Description copied from interface: ASTNode
        Gets the source location of this node.
        Specified by:
        getLocation in interface ASTNode
        Returns:
        the location
      • getParent

        public ASTNode getParent()
        Description copied from interface: ASTNode
        Gets the parent node in the AST tree.
        Specified by:
        getParent in interface ASTNode
        Returns:
        the parent
      • setParent

        public void setParent​(ASTNode parent)
        Description copied from interface: ASTNode
        Sets the parent node in the AST tree.
        Specified by:
        setParent in interface ASTNode
        Parameters:
        parent - the enclosing AST node
      • withArray

        public ArrayAccessExpr withArray​(Expression array)
        Replaces the array operand, reparenting the new child and releasing the former one.
        Parameters:
        array - the new array operand
        Returns:
        this expression
      • withIndex

        public ArrayAccessExpr withIndex​(Expression index)
        Replaces the index operand, reparenting the new child and releasing the former one.
        Parameters:
        index - the new index operand
        Returns:
        this expression
      • getChildren

        public List<ASTNode> getChildren()
        Description copied from interface: ASTNode
        Lists the direct children a node holds, in source order.
        Specified by:
        getChildren in interface ASTNode
        Returns:
        the direct children, empty for a leaf
      • accept

        public <T> T accept​(SourceVisitor<T> visitor)
        Description copied from interface: ASTNode
        Accepts a visitor for this node.
        Specified by:
        accept in interface ASTNode
        Type Parameters:
        T - the return type of the visitor
        Parameters:
        visitor - the visitor to accept
        Returns:
        the result from the visitor