MXVM 1.8.1
Virtual Machine, Compiler, and Pascal Frontend
Loading...
Searching...
No Matches
pascal::IfStmtNode Class Reference

AST node for an if-then-else statement. More...

#include <ast.hpp>

Inheritance diagram for pascal::IfStmtNode:

Public Member Functions

 IfStmtNode (std::unique_ptr< ASTNode > cond, std::unique_ptr< ASTNode > thenStmt, std::unique_ptr< ASTNode > elseStmt=nullptr)
void accept (ASTVisitor &visitor) override
 Accept an ASTVisitor (double-dispatch).
std::string toString () const override
 Return a human-readable description of this node.
Public Member Functions inherited from pascal::ASTNode
virtual ~ASTNode ()=default
virtual void print (std::ostream &out, int indent=0) const
 Pretty-print this node to a stream with indentation.
void setLineNumber (int line)
 Set the originating source line number.
int getLineNumber () const
 Get the originating source line number.

Public Attributes

std::unique_ptr< ASTNode > condition
 boolean condition
std::unique_ptr< ASTNode > thenStatement
 then branch
std::unique_ptr< ASTNode > elseStatement
 optional else branch

Detailed Description

AST node for an if-then-else statement.

Definition at line 350 of file ast.hpp.

Constructor & Destructor Documentation

◆ IfStmtNode()

pascal::IfStmtNode::IfStmtNode ( std::unique_ptr< ASTNode > cond,
std::unique_ptr< ASTNode > thenStmt,
std::unique_ptr< ASTNode > elseStmt = nullptr )
inline

Definition at line 356 of file ast.hpp.

References condition, elseStatement, and thenStatement.

Member Function Documentation

◆ accept()

void pascal::IfStmtNode::accept ( ASTVisitor & visitor)
overridevirtual

Accept an ASTVisitor (double-dispatch).

Implements pascal::ASTNode.

Definition at line 125 of file ast.cpp.

References pascal::ASTVisitor::visit().

◆ toString()

std::string pascal::IfStmtNode::toString ( ) const
overridevirtual

Return a human-readable description of this node.

Implements pascal::ASTNode.

Definition at line 129 of file ast.cpp.

References elseStatement.

Member Data Documentation

◆ condition

std::unique_ptr<ASTNode> pascal::IfStmtNode::condition

boolean condition

Definition at line 352 of file ast.hpp.

Referenced by IfStmtNode(), and pascal::CodeGenVisitor::visit().

◆ elseStatement

std::unique_ptr<ASTNode> pascal::IfStmtNode::elseStatement

optional else branch

Definition at line 354 of file ast.hpp.

Referenced by IfStmtNode(), toString(), and pascal::CodeGenVisitor::visit().

◆ thenStatement

std::unique_ptr<ASTNode> pascal::IfStmtNode::thenStatement

then branch

Definition at line 353 of file ast.hpp.

Referenced by IfStmtNode(), and pascal::CodeGenVisitor::visit().


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