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

AST node for variable declarations (var id1, id2 : type). More...

#include <ast.hpp>

Inheritance diagram for pascal::VarDeclNode:

Public Member Functions

 VarDeclNode (std::vector< std::string > identifiers, std::variant< std::string, std::unique_ptr< ASTNode > > type, std::vector< std::unique_ptr< ASTNode > > initializers)
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::vector< std::string > identifiers
 declared variable names
std::variant< std::string, std::unique_ptr< ASTNode > > type
 type (simple name or complex type node)
std::vector< std::unique_ptr< ASTNode > > initializers
 optional initialisers

Detailed Description

AST node for variable declarations (var id1, id2 : type).

Definition at line 132 of file ast.hpp.

Constructor & Destructor Documentation

◆ VarDeclNode()

pascal::VarDeclNode::VarDeclNode ( std::vector< std::string > identifiers,
std::variant< std::string, std::unique_ptr< ASTNode > > type,
std::vector< std::unique_ptr< ASTNode > > initializers )
inline

Definition at line 138 of file ast.hpp.

References identifiers, initializers, and type.

Member Function Documentation

◆ accept()

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

Accept an ASTVisitor (double-dispatch).

Implements pascal::ASTNode.

Definition at line 47 of file ast.cpp.

References pascal::ASTVisitor::visit().

◆ toString()

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

Return a human-readable description of this node.

Implements pascal::ASTNode.

Definition at line 51 of file ast.cpp.

References identifiers, and type.

Member Data Documentation

◆ identifiers

std::vector<std::string> pascal::VarDeclNode::identifiers

declared variable names

Definition at line 134 of file ast.hpp.

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

◆ initializers

std::vector<std::unique_ptr<ASTNode> > pascal::VarDeclNode::initializers

optional initialisers

Definition at line 136 of file ast.hpp.

Referenced by VarDeclNode().

◆ type

std::variant<std::string, std::unique_ptr<ASTNode> > pascal::VarDeclNode::type

type (simple name or complex type node)

Definition at line 135 of file ast.hpp.

Referenced by VarDeclNode(), pascal::CodeGenVisitor::getTypeString(), pascal::CodeGenVisitor::registerImportedVar(), toString(), and pascal::CodeGenVisitor::visit().


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