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

AST node for a unary operator expression. More...

#include <ast.hpp>

Inheritance diagram for pascal::UnaryOpNode:

Public Types

enum  Operator { PLUS , MINUS , NOT }
 Unary operator kinds. More...

Public Member Functions

 UnaryOpNode (Operator op, std::unique_ptr< ASTNode > operandNode)
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.

Static Public Member Functions

static std::string opToString (Operator op)
 Convert a unary Operator to its string representation.

Public Attributes

Operator operator_
 the unary operator
std::unique_ptr< ASTNode > operand
 the operand expression

Detailed Description

AST node for a unary operator expression.

Definition at line 477 of file ast.hpp.

Member Enumeration Documentation

◆ Operator

Unary operator kinds.

Enumerator
PLUS 

unary +

MINUS 

unary -

NOT 

logical not

Definition at line 480 of file ast.hpp.

Constructor & Destructor Documentation

◆ UnaryOpNode()

pascal::UnaryOpNode::UnaryOpNode ( Operator op,
std::unique_ptr< ASTNode > operandNode )
inline

Definition at line 489 of file ast.hpp.

References operand, and operator_.

Member Function Documentation

◆ accept()

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

Accept an ASTVisitor (double-dispatch).

Implements pascal::ASTNode.

Definition at line 210 of file ast.cpp.

References pascal::ASTVisitor::visit().

◆ opToString()

std::string pascal::UnaryOpNode::opToString ( Operator op)
static

Convert a unary Operator to its string representation.

Definition at line 218 of file ast.cpp.

References MINUS, NOT, and PLUS.

Referenced by toString().

◆ toString()

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

Return a human-readable description of this node.

Implements pascal::ASTNode.

Definition at line 214 of file ast.cpp.

References operator_, and opToString().

Member Data Documentation

◆ operand

std::unique_ptr<ASTNode> pascal::UnaryOpNode::operand

the operand expression

Definition at line 487 of file ast.hpp.

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

◆ operator_

Operator pascal::UnaryOpNode::operator_

the unary operator

Definition at line 486 of file ast.hpp.

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


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