Aseba  1.5.5
Public Types | Public Member Functions | Public Attributes | List of all members
Aseba::Node Struct Referenceabstract

An abstract node of syntax tree. More...

#include <tree.h>

Inheritance diagram for Aseba::Node:
Aseba::AbstractTreeNode Aseba::ArrayReadNode Aseba::ArrayWriteNode Aseba::AssignmentNode Aseba::BinaryArithmeticNode Aseba::BlockNode Aseba::CallNode Aseba::CallSubNode Aseba::EmitNode Aseba::EventDeclNode Aseba::FoldedIfWhenNode Aseba::FoldedWhileNode Aseba::IfWhenNode Aseba::ImmediateNode Aseba::LoadNativeArgNode Aseba::LoadNode Aseba::ReturnNode Aseba::StoreNode Aseba::SubDeclNode Aseba::UnaryArithmeticNode Aseba::WhileNode

Public Types

enum  ReturnType { TYPE_UNIT = 0, TYPE_BOOL, TYPE_INT }
 A type a node can return.
 
enum  MemoryErrorCode { E_NOVAL = UINT_MAX }
 
typedef std::vector< Node * > NodesVector
 Vector for children of a node.
 

Public Member Functions

 Node (const SourcePos &sourcePos)
 Constructor.
 
virtual ~Node ()
 Destructor, delete all children.
 
virtual NodeshallowCopy ()=0
 Return a shallow copy of the object (children point to the same objects)
 
virtual NodedeepCopy ()
 Return a deep copy of the object (children are also copied)
 
virtual void checkVectorSize () const
 Check the consistency in vectors' size.
 
virtual NodeexpandAbstractNodes (std::wostream *dump)
 Second pass to expand "abstract" nodes into more concrete ones. More...
 
virtual NodeexpandVectorialNodes (std::wostream *dump, Compiler *compiler=0, unsigned int index=0)
 Third pass to expand vectorial operations into mutliple scalar ones. More...
 
virtual ReturnType typeCheck (Compiler *compiler)
 Typecheck this node, throw an exception if there is any type violation.
 
virtual Nodeoptimize (std::wostream *dump)=0
 Optimize this node, return the optimized node.
 
virtual unsigned getStackDepth () const
 Return the stack depth requirement for this node and its children.
 
virtual void emit (PreLinkBytecode &bytecodes) const =0
 Generate bytecode.
 
virtual std::wstring toWString () const =0
 Return a string representation of this node.
 
virtual std::wstring toNodeName () const =0
 Return a string representation of the name of this node.
 
virtual void dump (std::wostream &dest, unsigned &indent) const
 Dump this node and the rest of the tree.
 
std::wstring typeName (const Node::ReturnType &type) const
 Return the name of a type.
 
void expectType (const Node::ReturnType &expected, const Node::ReturnType &type) const
 Check for a specific type, throw an exception otherwise.
 
virtual unsigned getVectorAddr () const
 return the address of the left-most operand, or E_NOVAL if none
 
virtual unsigned getVectorSize () const
 return the children's size, check for equal size, or E_NOVAL if no child
 

Public Attributes

NodesVector children
 children of this node
 
SourcePos sourcePos
 position is source
 

Detailed Description

An abstract node of syntax tree.

Member Function Documentation

Node * Aseba::Node::expandAbstractNodes ( std::wostream *  dump)
virtual
Node * Aseba::Node::expandVectorialNodes ( std::wostream *  dump,
Compiler compiler = 0,
unsigned int  index = 0 
)
virtual

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