Class VarRefExpr

    • Constructor Detail

      • VarRefExpr

        public VarRefExpr​(String name,
                          SourceType type,
                          SSAValue ssaValue,
                          SourceLocation location)
        Creates a variable reference.
        Parameters:
        name - the variable name
        type - the variable's declared type
        ssaValue - the IR value this reference maps back to, may be null
        location - source position, null for unknown
        Throws:
        NullPointerException - if the name or type is null
      • VarRefExpr

        public VarRefExpr​(String name,
                          SourceType type,
                          SSAValue ssaValue)
        Creates a variable reference with an unknown source position.
        Parameters:
        name - the variable name
        type - the variable's declared type
        ssaValue - the IR value this reference maps back to, may be null
        Throws:
        NullPointerException - if the name or type is null
      • VarRefExpr

        public VarRefExpr​(String name,
                          SourceType type)
        Creates a variable reference with no backing IR value and an unknown source position.
        Parameters:
        name - the variable name
        type - the variable's declared type
        Throws:
        NullPointerException - if the name or type is null
    • Method Detail

      • getName

        public String getName()
        Returns:
        the name
      • setName

        public void setName​(String name)
        Renames the referenced variable.
        Parameters:
        name - the new name
      • 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
      • getSsaValue

        public SSAValue getSsaValue()
        Returns:
        the ssa value
      • 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)
        Sets the enclosing node.
        Specified by:
        setParent in interface ASTNode
        Parameters:
        parent - the new parent, may be null
      • withName

        public VarRefExpr withName​(String name)
        Renames the referenced variable in place, for chaining.
        Parameters:
        name - the new name
        Returns:
        this reference
      • hasSSAValue

        public boolean hasSSAValue()
        Returns:
        true when this reference carries a backing IR value
      • 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