class NstTree

Base class

Inheritance:


Public Fields

unsigned long tree_id
Unique number of the tree
NstUserInfo user_info
User information

Public Methods

virtual int base_type()
Gives the base type of the object.
virtual const char* class_name()
Returns the string NstTree.
virtual const char* class_type()
Returns the string NST_TREE.
virtual NstTree* clone()
Recursive cloning.
void copy(const NstTree& s)
Recursive copy of s.
virtual NstTree* create_default()
Creates a default object of the base type.
virtual NstTree* cut()
Remove the object from its father
NstTree* cut_buffer()
Cut buffer.
virtual void error(const char* st)
Standard error function
list <NstTree*> fathers()
Returns the list of fathers of the object
NstTree* in()
Returns the father of the object or NULL if the object has no father
virtual NstTree* init()
Init the list of components of the object
virtual NstTree* init(NstTrees::iterator &it)
Init the list of components of the object
virtual NstTree* next()
Returns the next components in the list of components of the object
virtual NstTree* next(NstTrees::iterator &it)
Returns the next components in the list of components of the object
NstTree()
Creates an empty object tree object.
friend ostream& operator << (ostream& s, const NstTree& t)
Unparse operator
NstTree& operator= (const NstTree& s)
Same as copy.
virtual void replace(NstTree& n)
Replace the object by another in its father
virtual NstDefinition* search(const NstIdentifier& i, int tp = -1)
Search for a definition in the eventual symbol table of the object
void traversal(int (*action)(NstTree*, void*), void* extra = NULL)
Recursive traversal of the AST
virtual int type()
The type is NST_TREE.
NstTree* upsearch(int (*comptest)(NstTree*, void*), void* extra = NULL)
Retrieves a father of the current object, according to the comparison function comptest (this function must returns 1 as TRUE)
virtual void warning(const char* st)
Standard warning function
string whoami()
Returns a string describing who the object is

Documentation

Base class.

This class is the main class of the Base library. All the other classes of the library inherit (directly or undirectly) this class. It provides virtual methods to get the type of a derived object and some error methods. Each child class redefines the virtual method type. It permits to know the actual type of an object, even if we only know its NstTree part (or another ancestor of the class). Here is an example, with the NstStatementContinue class that is defined further:

 
NstStatementContinue test_object;
NstTree* tree = (NstTree*)&test_object; 
int rt = tree->type();
The variable rt will contain NST_STATEMENT_CONTINUE, because the object tree is in fact an instance of the class NstStatementContinue.

The method dynamic_cast<T>(t) should be used to cast an object. Example:

if(NstStatement* st = dynamic_cast<NstStatement*>(t))
  {
    // some operation on st
  }
NstTree()
Creates an empty object tree object.

unsigned long tree_id
Unique number of the tree. This number is incremented each time a new NstTree object is created.

virtual int type()
The type is NST_TREE.

virtual const char* class_type()
Returns the string NST_TREE.

virtual const char* class_name()
Returns the string NstTree.

virtual int base_type()
Gives the base type of the object.

virtual NstTree* create_default()
Creates a default object of the base type.

NstTree* cut_buffer()
Cut buffer.

void copy(const NstTree& s)
Recursive copy of s.

virtual NstTree* clone()
Recursive cloning.

NstTree& operator= (const NstTree& s)
Same as copy.

NstUserInfo user_info
User information

virtual void error(const char* st)
Standard error function. Terminates the calling process by calling the system function exit(EXIT_FAILURE).

virtual void warning(const char* st)
Standard warning function. Displays a message and sets the global variable unparse_status to 1. Does not exit.

friend ostream& operator << (ostream& s, const NstTree& t)
Unparse operator. Depends on nst_unparse_mode, nst_fortran_type and nst_nestor_mode.

virtual NstTree* init()
Init the list of components of the object. Returns the first component of the list. Returns NULL is the list has no components.

Example: let t be a NstStatementDo object:

       NstTree* current = t->init();
       while (current)
        {
          cout << *current << endl;
          current = t->next();
        }
       

The first value of current is the index of the loop, the second the range and the third the list of statements in the loop.

virtual NstTree* init(NstTrees::iterator &it)
Init the list of components of the object. Returns the first component of the list. This is the same as init without arguments, but here an iterator must be provided, instead of being stored into the object. Returns NULL is the list has no components.

Example: let t be a NstStatementDo object:

       NstTrees::iterator it;
       NstTree* current = t->init(it);
       while (current)
        {
          cout << *current << endl;
          current = t->next(it);
        }
       

The first value of current is the index of the loop, the second the range and the third the list of statements in the loop.

virtual NstTree* next()
Returns the next components in the list of components of the object. A call to init has to be made before any call to this method. Returns NULL when the list is empty.

virtual NstTree* next(NstTrees::iterator &it)
Returns the next components in the list of components of the object. A call to init has to be made before any call to this method. This is the same as next without arguments, but here an iterator must be provided, instead of being stored into the object. Returns NULL when the list is empty.

void traversal(int (*action)(NstTree*, void*), void* extra = NULL)
Recursive traversal of the AST. This method traverses the tree and calls the function action with the current node as parameter and the pointer extra. If the function action returns a value different from 0, the recursion stops.

NstTree* upsearch(int (*comptest)(NstTree*, void*), void* extra = NULL)
Retrieves a father of the current object, according to the comparison function comptest (this function must returns 1 as TRUE)

virtual NstTree* cut()
Remove the object from its father. Puts in the father a default object or remove the object from the list if the father is a list. Returns the default object created.

virtual NstDefinition* search(const NstIdentifier& i, int tp = -1)
Search for a definition in the eventual symbol table of the object

virtual void replace(NstTree& n)
Replace the object by another in its father. The object is cutted and not destroyed.

NstTree* in()
Returns the father of the object or NULL if the object has no father

list <NstTree*> fathers()
Returns the list of fathers of the object

string whoami()
Returns a string describing who the object is


Direct child classes:
NstStatement
NstInstruction
NstList
NstProcessor
NstOntopology
NstOnclause
NstOn
NstDistribution
NstDistformat
NstVariable
NstParameter
NstOp
NstExpression
NstConstant
NstLoopinfo
NstIdentifier
NstAlign
NstComputationUnit
NstUnit
NstType
NstShape
NstDefinition
NstDeclaration

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de