class NstTree

Base class

Inheritance:


Public Fields

[more]long tree_id
Unique number of the tree
[more]NstUserInfo user_info
User information

Public Methods

[more] NstTree()
Creates an empty object tree object.
[more]int type() const
The type is NST_TREE.
[more]char* class_type() const
Returns the string NST_TREE.
[more]char* class_name() const
Returns the string NstTree.
[more]int base_type() const
Gives the base type of the object.
[more]NstTree* create_default()
Creates a default object of the base type.
[more]NstTree* cut_buffer() const
Cut buffer.
[more]void copy(const NstTree& s)
Recursive copy of s.
[more]NstTree* clone() const
Recursive cloning.
[more]NstTree& operator= (const NstTree& s)
Same as copy.
[more]void error(const char* st) const
Standard error function
[more]void warning(const char* st) const
Standard warning function
[more]ostream& operator << (ostream& s, const NstTree& t)
Unparse operator
[more]NstTree* init()
Init the list of components of the object
[more]NstTree* init(NstTrees::iterator &it)
Init the list of components of the object
[more]NstTree* next()
Returns the next components in the list of components of the object
[more]NstTree* next(NstTrees::iterator &it)
Returns the next components in the list of components of the object
[more]void traversal(int (*action)(NstTree*, void*), void* extra = NULL)
Recursive traversal of the AST
[more]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)
[more]NstTree* cut()
Remove the object from its father
[more]NstDefinition* search(const NstIdentifier& i, int tp = -1) const
Search for a definition in the eventual symbol table of the object
[more]void replace(NstTree& n)
Replace the object by another in its father
[more]NstTree* in() const
Returns the father of the object or NULL if the object has no father
[more] fathers() const
Returns the list of fathers of the object
[more]string whoami() const
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
  }
o NstTree()
Creates an empty object tree object.

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

oint type() const
The type is NST_TREE.

ochar* class_type() const
Returns the string NST_TREE.

ochar* class_name() const
Returns the string NstTree.

oint base_type() const
Gives the base type of the object.

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

oNstTree* cut_buffer() const
Cut buffer.

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

oNstTree* clone() const
Recursive cloning.

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

oNstUserInfo user_info
User information.

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

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

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

oNstTree* 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.

oNstTree* 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.

oNstTree* 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.

oNstTree* 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.

ovoid 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.

oNstTree* 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).

oNstTree* 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.

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

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

oNstTree* in() const
Returns the father of the object or NULL if the object has no father.

o fathers() const
Returns the list of fathers of the object.

ostring whoami() const
Returns a string describing who the object is.


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

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.