tipc
A TIP to LLVM compiler
Public Member Functions | Protected Member Functions | List of all members
ASTIfStmt Class Reference

Class for if-then-else. More...

#include <ASTIfStmt.h>

Inheritance diagram for ASTIfStmt:
Inheritance graph
[legend]
Collaboration diagram for ASTIfStmt:
Collaboration graph
[legend]

Public Member Functions

std::vector< std::shared_ptr< ASTNode > > getChildren () override
 Return all of the children for the node. More...
 
 ASTIfStmt (std::shared_ptr< ASTExpr > COND, std::shared_ptr< ASTStmt > THEN, std::shared_ptr< ASTStmt > ELSE)
 
ASTExprgetCondition () const
 
ASTStmtgetThen () const
 
ASTStmtgetElse () const
 
void accept (ASTVisitor *visitor) override
 Visit the children of this node and apply the visitor. More...
 
llvm::Value * codegen () override
 Perform code generation and return an LLVM value the code. More...
 
- Public Member Functions inherited from ASTStmt
 ~ASTStmt ()=default
 
- Public Member Functions inherited from ASTNode
virtual ~ASTNode ()=default
 
void setLocation (int l, int c)
 
int getLine ()
 
int getColumn ()
 

Protected Member Functions

std::ostream & print (std::ostream &out) const override
 

Detailed Description

Class for if-then-else.

Constructor & Destructor Documentation

◆ ASTIfStmt()

ASTIfStmt::ASTIfStmt ( std::shared_ptr< ASTExpr COND,
std::shared_ptr< ASTStmt THEN,
std::shared_ptr< ASTStmt ELSE 
)
inline

Member Function Documentation

◆ accept()

void ASTIfStmt::accept ( ASTVisitor visitor)
overridevirtual

Visit the children of this node and apply the visitor.

This virtual function is overridden by each ASTNode subtype in order to visit each of its child nodes, by calling their accept methods. The visitor parameter defines the operations that are applied to each node that is visited; a subtype of ASTVisitor defines those operations.

Parameters
visitorThe subtype of ASTVisitor that carries out per-ASTNode work.

Implements ASTNode.

◆ codegen()

llvm::Value * ASTIfStmt::codegen ( )
overridevirtual

Perform code generation and return an LLVM value the code.

This virtual function is overridden by each ASTNode subtype in order to generate the executable code. This function does not use the visitor due to the fact that a high-degree of control on the ordering of the nodes is required.

Returns
LLVM value holding an representation of the generated code.

Implements ASTNode.

◆ getChildren()

std::vector< std::shared_ptr< ASTNode > > ASTIfStmt::getChildren ( )
overridevirtual

Return all of the children for the node.

This is not a pure virtual function so subclasses can selectively override it.

Returns
a collection of the nodes children.

Reimplemented from ASTNode.

◆ getCondition()

ASTExpr* ASTIfStmt::getCondition ( ) const
inline

◆ getElse()

ASTIfStmt::getElse ( ) const
inline
Returns
Else statement if it exists and nullptr otherwise.

◆ getThen()

ASTStmt* ASTIfStmt::getThen ( ) const
inline

◆ print()

std::ostream & ASTIfStmt::print ( std::ostream &  out) const
overrideprotectedvirtual

Implements ASTNode.


The documentation for this class was generated from the following files: