An abstract node of syntax tree. More...
#include <tree.h>
Public Types | |
typedef std::vector< Node * > | NodesVector |
Vector for children of a node. | |
enum | ReturnType { TYPE_UNIT = 0, TYPE_BOOL, TYPE_INT } |
A type a node can return. More... | |
Public Member Functions | |
virtual void | dump (std::ostream &dest, unsigned &indent) const |
Dump this node and the rest of the tree. | |
virtual void | emit (PreLinkBytecode &bytecodes) const =0 |
Generate bytecode. | |
void | expectType (const Node::ReturnType &expected, const Node::ReturnType &type) const |
Check for a specific type, throw an exception otherwise. | |
virtual unsigned | getStackDepth () const |
Return the stack depth requirement for this node and its children. | |
Node (const SourcePos &sourcePos) | |
Constructor. | |
virtual Node * | optimize (std::ostream *dump)=0 |
Optimize this node, return the optimized node. | |
virtual std::string | toNodeName () const =0 |
Return a string representation of the name of this node. | |
virtual std::string | toString () const =0 |
Return a string representation of this node. | |
virtual ReturnType | typeCheck () const |
Typecheck this node, throw an exception if there is any type violation. | |
std::string | typeName (const Node::ReturnType &type) const |
Return the name of a type. | |
virtual | ~Node () |
Destructor, delete all children. | |
Public Attributes | |
NodesVector | children |
children of this node | |
SourcePos | sourcePos |
position is source |
An abstract node of syntax tree.
Definition at line 47 of file tree.h.
typedef std::vector<Node *> Aseba::Node::NodesVector |
Aseba::Node::Node | ( | const SourcePos & | sourcePos | ) | [inline] |
virtual void Aseba::Node::emit | ( | PreLinkBytecode & | bytecodes | ) | const [pure virtual] |
Generate bytecode.
Implemented in Aseba::BlockNode, Aseba::ProgramNode, Aseba::AssignmentNode, Aseba::IfWhenNode, Aseba::FoldedIfWhenNode, Aseba::WhileNode, Aseba::FoldedWhileNode, Aseba::EventDeclNode, Aseba::EmitNode, Aseba::SubDeclNode, Aseba::CallSubNode, Aseba::BinaryArithmeticNode, Aseba::UnaryArithmeticNode, Aseba::ImmediateNode, Aseba::LoadNode, Aseba::StoreNode, Aseba::ArrayReadNode, Aseba::ArrayWriteNode, and Aseba::CallNode.
virtual Node* Aseba::Node::optimize | ( | std::ostream * | dump | ) | [pure virtual] |
Optimize this node, return the optimized node.
Implemented in Aseba::BlockNode, Aseba::AssignmentNode, Aseba::IfWhenNode, Aseba::FoldedIfWhenNode, Aseba::WhileNode, Aseba::FoldedWhileNode, Aseba::EventDeclNode, Aseba::EmitNode, Aseba::SubDeclNode, Aseba::CallSubNode, Aseba::BinaryArithmeticNode, Aseba::UnaryArithmeticNode, Aseba::ImmediateNode, Aseba::LoadNode, Aseba::StoreNode, Aseba::ArrayReadNode, Aseba::ArrayWriteNode, and Aseba::CallNode.
virtual std::string Aseba::Node::toNodeName | ( | ) | const [pure virtual] |
Return a string representation of the name of this node.
Implemented in Aseba::BlockNode, Aseba::ProgramNode, Aseba::AssignmentNode, Aseba::IfWhenNode, Aseba::FoldedIfWhenNode, Aseba::WhileNode, Aseba::FoldedWhileNode, Aseba::EventDeclNode, Aseba::EmitNode, Aseba::SubDeclNode, Aseba::CallSubNode, Aseba::BinaryArithmeticNode, Aseba::UnaryArithmeticNode, Aseba::ImmediateNode, Aseba::LoadNode, Aseba::StoreNode, Aseba::ArrayReadNode, Aseba::ArrayWriteNode, and Aseba::CallNode.
virtual std::string Aseba::Node::toString | ( | ) | const [pure virtual] |
Return a string representation of this node.
Implemented in Aseba::BlockNode, Aseba::ProgramNode, Aseba::AssignmentNode, Aseba::IfWhenNode, Aseba::FoldedIfWhenNode, Aseba::WhileNode, Aseba::FoldedWhileNode, Aseba::EventDeclNode, Aseba::EmitNode, Aseba::SubDeclNode, Aseba::CallSubNode, Aseba::BinaryArithmeticNode, Aseba::UnaryArithmeticNode, Aseba::ImmediateNode, Aseba::LoadNode, Aseba::StoreNode, Aseba::ArrayReadNode, Aseba::ArrayWriteNode, and Aseba::CallNode.