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

AST node for a for loop (for var := start to/downto end do stmt). More...

#include <ast.hpp>

Inheritance diagram for pascal::ForStmtNode:

Public Member Functions

 ForStmtNode (const std::string &var, std::unique_ptr< ASTNode > start, std::unique_ptr< ASTNode > end, bool downto, std::unique_ptr< ASTNode > stmt)
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::string variable
 loop variable name
std::unique_ptr< ASTNodestartValue
 initial value expression
std::unique_ptr< ASTNodeendValue
 final value expression
bool isDownto
 true if downto, false if to
std::unique_ptr< ASTNodestatement
 loop body

Detailed Description

AST node for a for loop (for var := start to/downto end do stmt).

Definition at line 379 of file ast.hpp.

Constructor & Destructor Documentation

◆ ForStmtNode()

pascal::ForStmtNode::ForStmtNode ( const std::string & var,
std::unique_ptr< ASTNode > start,
std::unique_ptr< ASTNode > end,
bool downto,
std::unique_ptr< ASTNode > stmt )
inline

Definition at line 387 of file ast.hpp.

References endValue, isDownto, startValue, statement, and variable.

Member Function Documentation

◆ accept()

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

Accept an ASTVisitor (double-dispatch).

Implements pascal::ASTNode.

Definition at line 145 of file ast.cpp.

References pascal::ASTVisitor::visit().

◆ toString()

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

Return a human-readable description of this node.

Implements pascal::ASTNode.

Definition at line 149 of file ast.cpp.

References isDownto, and variable.

Member Data Documentation

◆ endValue

std::unique_ptr<ASTNode> pascal::ForStmtNode::endValue

final value expression

Definition at line 383 of file ast.hpp.

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

◆ isDownto

bool pascal::ForStmtNode::isDownto

true if downto, false if to

Definition at line 384 of file ast.hpp.

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

◆ startValue

std::unique_ptr<ASTNode> pascal::ForStmtNode::startValue

initial value expression

Definition at line 382 of file ast.hpp.

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

◆ statement

std::unique_ptr<ASTNode> pascal::ForStmtNode::statement

loop body

Definition at line 385 of file ast.hpp.

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

◆ variable

std::string pascal::ForStmtNode::variable

loop variable name

Definition at line 381 of file ast.hpp.

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


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