Class ThisExpr

  • All Implemented Interfaces:
    ASTNode, Expression

    public final class ThisExpr
    extends Object
    implements Expression
    A reference to the enclosing instance - the 'this' expression.
    • Constructor Detail

      • ThisExpr

        public ThisExpr​(SourceType type,
                        SourceLocation location)
        Creates a this expression.
        Parameters:
        type - the enclosing instance type
        location - the source location; defaults to UNKNOWN when null
        Throws:
        NullPointerException - if type is null
      • ThisExpr

        public ThisExpr​(SourceType type)
        Creates a this expression at an unknown source location.
        Parameters:
        type - the enclosing instance type
        Throws:
        NullPointerException - if type is null
    • Method Detail

      • getType

        public SourceType getType()
        Description copied from interface: Expression
        Gets the inferred type of this expression.
        Specified by:
        getType in interface Expression
        Returns:
        the type
      • 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 node this expression hangs under
      • 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