Class CastExpr

    • Constructor Detail

      • CastExpr

        public CastExpr​(SourceType targetType,
                        Expression expression,
                        SourceLocation location)
        Creates a cast of the given expression to the target type and reparents the operand.
        Parameters:
        targetType - the type cast to
        expression - the expression being cast
        location - the source location, or null for unknown
        Throws:
        NullPointerException - if targetType or expression is null
      • CastExpr

        public CastExpr​(SourceType targetType,
                        Expression expression)
        Creates a cast with an unknown source location.
        Parameters:
        targetType - the type cast to
        expression - the expression being cast
        Throws:
        NullPointerException - if targetType or expression is null
    • Method Detail

      • getTargetType

        public SourceType getTargetType()
        Returns:
        the target type
      • getExpression

        public Expression getExpression()
        Returns:
        the expression
      • setExpression

        public void setExpression​(Expression expression)
        Replaces the cast operand, reparenting the new child.
        Parameters:
        expression - the new operand
      • 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
      • isRecordDeconstruction

        public boolean isRecordDeconstruction()
        Returns:
        whether record deconstruction
      • setRecordDeconstruction

        public void setRecordDeconstruction​(boolean recordDeconstruction)
        Parameters:
        recordDeconstruction - true to mark this cast as a record deconstruction temp
      • 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 of this expression
      • withExpression

        public CastExpr withExpression​(Expression expression)
        Replaces the cast operand, reparenting the new child and releasing the former one.
        Parameters:
        expression - the new 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