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

AST node for a case statement. More...

#include <ast.hpp>

Inheritance diagram for pascal::CaseStmtNode:

Classes

struct  CaseBranch
 A single case branch (one or more values mapping to a statement). More...

Public Member Functions

 CaseStmtNode (std::unique_ptr< ASTNode > expr, std::vector< std::unique_ptr< CaseBranch > > branches, 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< ASTNodeexpression
 selector expression
std::vector< std::unique_ptr< CaseBranch > > branches
 case branches
std::unique_ptr< ASTNodeelseStatement
 optional else/otherwise branch

Detailed Description

AST node for a case statement.

Definition at line 400 of file ast.hpp.

Constructor & Destructor Documentation

◆ CaseStmtNode()

pascal::CaseStmtNode::CaseStmtNode ( std::unique_ptr< ASTNode > expr,
std::vector< std::unique_ptr< CaseBranch > > branches,
std::unique_ptr< ASTNode > elseStmt = nullptr )
inline

Definition at line 415 of file ast.hpp.

References branches, elseStatement, and expression.

Member Function Documentation

◆ accept()

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

Accept an ASTVisitor (double-dispatch).

Implements pascal::ASTNode.

Definition at line 293 of file ast.cpp.

References pascal::ASTVisitor::visit().

◆ toString()

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

Return a human-readable description of this node.

Implements pascal::ASTNode.

Definition at line 297 of file ast.cpp.

References branches.

Member Data Documentation

◆ branches

std::vector<std::unique_ptr<CaseBranch> > pascal::CaseStmtNode::branches

case branches

Definition at line 412 of file ast.hpp.

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

◆ elseStatement

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

optional else/otherwise branch

Definition at line 413 of file ast.hpp.

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

◆ expression

std::unique_ptr<ASTNode> pascal::CaseStmtNode::expression

selector expression

Definition at line 411 of file ast.hpp.

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


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