Introduction Projects and Files Statements Expressions Symbols Types
Attributes Labels Non-Member Functions Constructing Declarations Example Programs Index

Statements

Files are broken down into statements. SgStatement is the base class for the representation of statements. SgStatement has many derived classes, corresponding to the many different kinds of statements in the languages Sage++ can deal with.

Each statement has a unique integer identifier id, and an integer variant tag which can be used to identify its type. These are available through SgStatement's id() and variant() member functions. SgStatement's thebif member provides access to the low level representation of statements, known as the bif nodes.

Each statement has a context: it may have a lexical predecessor and a lexical successor, and it may be nested within a control block of another statement, or in a block structured definition like a C struct. This enclosing statement is called the control parent. It defines the basic structure of the parse tree.


SgStatement

Represents the fundamental class for all statements.

class  SgStatement {
  public:
  PTR_BFND thebif;
  SgStatement(int variant); 
  SgStatement(PTR_BFND bif);
  SgStatement(int code, SgLabel *lab, SgSymbol *symb, SgExpression *e1, 
              SgExpression *e2, SgExpression *e3);  // code is variant
  inline SgStatement(SgStatement &);
  // info about statement
  inline int lineNumber();          // source text line number
  inline int id();                  // unique id;
  inline int variant();             // the type of the statement
  SgExpression *expr(int i); // i = 0,1,2 returns the i-th expression.

inline int hasSymbol(); // returns TRUE if tmt has symbol, FALSE otherwise // returns the symbol field. Used by loop headers to point to the // loop variable symbol; Used by function and subroutine headers to // point to the function or subroutine name. SgSymbol *symbol(); // returns the symbol field. inline char *fileName(); inline int hasLabel(); // returns 1 if there is a label on the stmt. SgLabel *label(); // the label

// modifying the info. inline void setlineNumber(int n); // change the line number info inline void setId(int n); // cannot change the id info inline void setVariant(int n); // change the type of the statement void setExpression (int i, SgExpression &e); // change the i-th expression inline void setLabel(SgLabel &l); // change the label inline void setSymbol(SgSymbol &s); // change the symbol

// Control structure inline SgStatement *lexNext(); // the next statement in lexical order. inline SgStatement *lexPrev(); // the previous stmt in lexical order. inline SgStatement *controlParent(); // the enclosing control statement

inline void setLexNext(SgStatement &s); // change the lexical ordering void setControlParent(SgStatement &s); // change the control parent. void setControlParent(SgStatement *s); // change the control parent.

// Access statement using the tree structure // Describe BLOB lists here?

inline int numberOfChildrenList1(); inline int numberOfChildrenList2(); inline SgStatement *childList1(int i); inline SgStatement *childList2(int i); SgStatement *nextInChildList();

inline SgStatement *lastDeclaration(); inline SgStatement *lastExecutable(); inline SgStatement *lastNodeOfStmt(); inline SgStatement *nodeBefore(); inline void insertStmtBefore(SgStatement &s); inline void insertStmtBefore(SgStatement &s, SgStatement &cp); void insertStmtAfter(SgStatement &s); void insertStmtAfter(SgStatement &s, SgStatement &cp); inline SgStatement *extractStmt(); inline SgStatement *extractStmtBody(); inline void replaceWithStmt(SgStatement &s); inline void deleteStmt(); inline SgStatement &copy (void); inline SgStatement *copyPtr (void); inline SgStatement &copyOne (void); inline SgStatement *copyOnePtr (void); inline SgStatement &copyBlock (void); inline SgStatement *copyBlockPtr (void); inline int isIncludedInStmt(SgStatement &s); inline void replaceSymbByExp(SgSymbol &symb, SgExpression &exp); inline void replaceSymbBySymb(SgSymbol &symb, SgSymbol &newsymb); inline void replaceSymbBySymbSameName(SgSymbol &symb, SgSymbol &newsymb); inline void replaceTypeInStmt(SgType &old, SgType &newtype); char* unparse(); inline void unparsestdout(); void sunparse(char *buffer); //unparsing functions. inline char *comments(); //preceding comment lines. void addComment(char *com); /* ajm: setComments: set ALL of the node's comments */ inline void setComments (char *comments);

int numberOfComments(); //number of preceeding comments. CAREFUL!

int hasAnnotations(); //1 if there are annotations; 0 otherwise ~SgStatement(); // These function must be removed. Doesn't make sense here. int IsSymbolInScope(SgSymbol &symb); // TRUE if symbol is in scope int IsSymbolReferenced(SgSymbol &symb); inline SgStatement *getScopeForDeclare(); // return where a variable // can be declared;

/////////////// FOR ATTRIBUTES //////////////////////////

int numberOfAttributes(); int numberOfAttributes(int type); // of a specified type; void *attributeValue(int i); int attributeType(int i); void *attributeValue(int i,int type); // only considering one type attribute void *deleteAttribute(int i); void addAttribute(int type, void *a, int size); // void * can be NULL; void addAttribute(int type); //void * is NULL; void addAttribute(void *a, int size); //no type specifed; void addAttribute(SgAttribute *att); SgAttribute *getAttribute(int i); SgAttribute *getAttribute(int i,int type);

//////////// FOR DECL_SPECS (friend, inline, extern, static) ////////////

inline void addDeclSpec(int type); // type should be one of BIT_EXTERN, // BIT_INLINE, BIT_FRIEND, BIT_STATIC inline void clearDeclSpec(); // resets the decl_specs field to zero inline int isFriend(); // returns non-zero if friend modifier set // returns zero otherwise inline int isInline(); inline int isExtern(); inline int isStatic(); };

Member Functions

SgStatement(int variant)

SgStatement(PTR_BFND bif)

int lineNumber()

int id()

int variant()

SgExpression *expr(int i)

int hasSymbol()

SgSymbol *symbol()

char *fileName()

int hasLabel()

SgLabel *label()

void setlineNumber(int n)

void setId(int n)

void setVariant(int n)

void setExpression(int i, SgExpression &e)

void setLabel(SgLabel &l)

void setSymbol(SgSymbol &s)

SgStatement *lexNext()

SgStatement *lexPrev()

SgStatement *controlParent()

void setLexNext(SgStatement &s)

void setControlParent(SgStatement &s)

int numberOfChildrenList1()

int numberOfChildrenList2()

SgStatement *childList1(int i)

SgStatement *childList2(int i)

SgStatement *nextInChildList()

SgStatement *lastDeclaration()

SgStatement *lastExecutable()

SgStatement *lastNodeOfStmt()

SgStatement *nodeBefore()

void insertStmtBefore(SgStatement &s)

void insertStmtBefore(SgStatement &s, SgStatement &cp)

void insertStmtAfter(SgStatement &s)

void insertStmtAfter(SgStatement &s, SgStatement &cp)

SgStatement *extractStmt()

SgStatement *extractStmtBody()

void replaceWithStmt(SgStatement &s)

void deleteStmt()

SgStatement &copy()

SgStatement *copyPtr()

SgStatement &copyOne()

SgStatement *copyOnePtr()

SgStatement &copyBlock()

SgStatement *copyBlockPtr()

int isIncludedInStmt(SgStatement &s)

void replaceSymbByExp(SgSymbol &symb, SgExpression &exp)

void replaceSymbBySymb(SgSymbol &symb, SgSymbol &newsymb)

void replaceSymbBySymbSameName(SgSymbol &symb, SgSymbol &newsymb)

void replaceTypeInStmt(SgType &old, SgType &newtype)

char* unparse()

void unparsestdout()

void sunparse(char *buffer)

char *comments()

void addComment(char *com)

void setComment(char *commments)

int numberOfComments()

int hasAnnotations()

int IsSymbolInScope(SgSymbol &symb)

int IsSymbolReferenced(SgSymbol &symb)

SgStatement *getScopeForDeclare()

void addDeclSpec(int type)

void clearDeclSpec()

int isFriend()

int isInline()

int isExtern()

int isStatic()

SgStatement Usage

A statement can have up to two lists of children statements. For example, for an if statement, all the statements in the "true" branch belong to childList1 and all the statements in the "false" branch belong to childList2. For function definitions, all the statements in the function body belong to childList1.

Once a statement has been extracted from the parse tree one may make a copy of it with copy() and insert the copy or the original in another position. For example, S1.insertStmtAfter(S2) will insert S2 in the lexical position following S1.

One may also search a statement and its subexpressions for a symbol and replace all occurrences with another symbol or expression. Similarly, one may replace any reference to a given type with another type.

To illustrate the use of the statement classes consider the following simple example. Suppose we wish to traverse a file and apply the unrolling transformation to all the inner most loops whose body consists of only assignment statements. The function that accomplishes this is shown below.

This function illustrates an important aspect of the programming style used in Sage++. The main body of the function is a loop which scans the statements in the file in lexical order. The variable s is a pointer to a generic statement object. There are two ways to tell if a statement is a loop. One is to check to see if the variant is FOR_NODE. The other way is to use a special casting function, in this case, isSgForStmt(), which will check the variant and return a pointer cast to the correct subclass or NULL if it is not a match. Because C++ is a strongly typed language, if we wish to apply the methods of the subclass, such a cast is necessary. A function of the type

     SgSUBCLASS * isSgSUBCLASS( SgBASECLASS *)
is provided for each subclass of SgStatement, SgExpression and SgType. We feel that this mechanism is an effective way to use the strong typing of C++ to reduce errors.

Methods copyBlock() and *copyBlockPtr() copy all the remaining statements in the current block (i.e., with the same control parent as the given statement) including the given statement. All the children statements are copied as well. Warning: things like block-copying of a statement that is itself a block-copy of something else will not work because a statement returned by copyBlock() does not have a control parent.

Methods addDeclSpec(int type), clearDeclSpec(), isFriend(), isInline(), isExtern(), and isStatic() are used to handle specifiers friend, extern, static, and inline. In older versions of Sage++ these were modifiers of type nodes. Starting in July 1994, they are modifiers of statement (bif) nodes. In order to set a particular modifier, use one of BIT_EXTERN, BIT_INLINE, BIT_FRIEND, or BIT_STATIC.

Here's an example illustrating the use of these methods:

Example Programs

SgStatement is used in the following example programs:


Header Statements


SgFuncHedrStmt

Represents functions, for all languages.

class  SgFuncHedrStmt: public SgProcHedrStmt {
  // Fortran and C function.
  // variant == FUNC_HEDR
public:
  inline SgFuncHedrStmt(SgSymbol &name, SgStatement &Body);
  inline SgFuncHedrStmt(SgSymbol &name, SgType &type, SgStatement &Body);
  inline SgFuncHedrStmt(SgSymbol &name, SgSymbol &resultName, SgType &type, 
                        SgStatement &Body);
  inline SgFuncHedrStmt(SgSymbol &name);
  inline SgFuncHedrStmt(SgSymbol &name, SgExpression *exp);
  inline SgFuncHedrStmt(char *name);
  inline ~SgFuncHedrStmt();
  
  inline SgSymbol *resultName();  // name of result variable.;
  int  setResultName(SgSymbol &symbol); // set name of result variable.;
  
  inline SgType *returnedType();  // type of returned value
  inline void setReturnedType(SgType &type);  // set type of returned value
};

Member Functions

SgFuncHedrStmt(SgSymbol &name, SgStatement Body)

SgFuncHedrStmt(SgSymbol &name, SgType &type, SgStatement Body)

SgFuncHedrStmt(SgSymbol &name, SgSymbol &resultName, SgType &type, SgStatement Body)

SgFuncHedrStmt(SgSymbol &name)

SgFuncHedrStmt(char *name)

SgSymbol *resultName()

int setResultName(SgSymbol &symbol)

SgType *returnedType()

void setReturnedType(SgType &type)

SgFuncHedrStmt Usage

Example Programs

SgFuncHedrStmt is used in the following example programs:


SgBasicBlockStmt

Represents C basic blocks.

class SgBasicBlockStmt: public SgStatement {
  // in C we have: {  body; }
  // variant == BASIC_BLOCK
public:
  inline SgBasicBlockStmt();
  inline ~SgBasicBlockStmt();
};

Member Functions

SgBasicBlockStmt()

SgBasicBlockStmt Usage

Not all statements that are compound statements in C and C++ are represented as SgBasicBlockStmt. Those that are not include: function bodies, branches of if statements, bodies of while statements, etc. Only those compound statements that do not fall into the above category are represented as SgBasicBlockStmt. For example:

includes no SgBasicBlockStmt, whereas,

includes one SgBasicBlockStmt.

Example Programs

SgBasicBlockStmt is used in the following example programs:


SgClassStmt

Represents C++ classes.

class SgClassStmt: public {SgStatement} {
  // C++ class statement
  //    class name : superclass_list ElementTypeOf collection_name {
  //            body
  //     } variables_list;
  // variant == CLASS_DECL, IDL_INTERFACE_DECL, IDL_MODULE_DECL,
  //            IDL_EXCEPTION_DECL
public:
  inline SgClassStmt(int variant);
  inline SgClassStmt(SgSymbol &name);
  inline SgClassStmt(int variant, SgSymbol &name);
  inline ~SgClassStmt();
  inline int numberOfSuperClasses();
  inline SgSymbol *name();
  SgSymbol *superClass(int i);
  void setSuperClass(int i, SgSymbol &symb);
  void setSuperClass(int i, SgSymbol &symb, int access);
                                 //access = one of BIT_PRIVATE
                                 //         BIT_PROTECTED
                                 //         BIT_PUBLIC
                                 //         BIT_PRIVATE | BIT_VIRTUAL
                                 //         BIT_PROTECTED | BIT_VIRTUAL
                                 //         BIT_PUBLIC | BIT_VIRTUAL
};

A class declaration consists of a name, a list of super classes, a body consisting of public, private and protected functions and fields, and a list of variables that name instances, arrays of instances, pointers to instances and references to instances of the class.

Member Functions

SgClassStmt(int variant)

SgClassStmt(SgSymbol &name)

int numberOfSuperClasses()

SgSymbol *name()

SgSymbol *superClass(int i)

void setSuperClass(int i, SgSymbol &symb)

Example Usage

SgClassStmt represents both forward declarations of classes, as in:

and real class declarations (that is, definitions) as in:

Declarations of the form,

are also represented as SgClassStmt's. But a declaration:

where A has been declared as a class earlier, is a SgVarDeclStmt. Once a class has been defined, information about its fields can be acessed using the methods of the SgClassType class. If cls is a pointer to a SgClassStmt, then you can use

to get a pointer to the type.

A note about how superclasses (also known as base-clauses in C++ grammar) are represented. In a definition:

the list

is the base-clause.

Until Sage++ version 1.9, this list was stored as an EXPR_LIST where each expression was a VAR_REF whose variable was the class name symbol. The public, virtual, etc. specifiers were stored as T_DESCRIPT type with no base class; this type was attached to the VAR_REF expression.

Starting with version 1.9, the representation of base-clause is also an EXPR_LIST containing VAR_REF expressions; however now the variables are "nameless" symbols (i.e., the names are empty strings) and the information about the class and specifiers is stored as type info (this is similar to the representation of the list of nameless arguments in a function prototype). So, for example,

is represented by a VAR_REF, with symbol that does not have a name. The type of the whole expression and the type of the symbol is T_DESCRIPT with BIT_PUBLIC set; the base type is T_DERIVED_TYPE whose typeName is the symbol for B.

This representation is closer to the semantics of C++ and lets us refer to nested classes, as in

Similarly, for template base classes, as in

the information about

is stored as the type info; in this case T_DESCRIPT whose base class is T_DERIVED_TEMPLATE, where template name is the symbol for S and the arguments field contains information about T. Before, information about T was stored as the right child of the VAR_REF node.

Also starting with version 1.9, the unparser does not add the public: specifier automatically. For example, before version 1.9,

would unparse to

Now it unparses to

Also note that the old behavior could introduce bugs since a base class without explicitly specified access is not the same as public access! Furthermore, versions 1.7 and earlier had a bug where an empty class definition such as,

would unparse to a class declaration,

Now it unparses to

As you can see, placing the public: inside is not perfect, but that seems not to confuse any of the C++ compilers. @sp 2 A new method, SgClassStmt::setSuperClass, has been added. It takes three arguments:

the third argument gives the access modifier; it should be one of: BIT_PRIVATE, BIT_PROTECTED, BIT_PUBLIC, BIT_PRIVATE, BIT_VIRTUAL, BIT_PROTECTED, BIT_VIRTUAL, BIT_PRIVATE, or BIT_VIRTUAL.

Example Programs

SgClassStmt is used in the following example programs:


SgStructStmt

Represents C++ structures.

class SgStructStmt: public SgClassStmt {

// basic C++ structure // struct name ; // body // } variables_list; // variant == STRUCT_DECL public: // consider like a class. inline SgStructStmt(); inline SgStructStmt(SgSymbol &name); inline ~SgStructStmt(); };

Member Functions

SgStructStmt()

SgStructStmt(SgSymbol &name)


SgUnionStmt

Represents C++ unions.

class SgUnionStmt: public SgClassStmt {
  // basic C++ structure
  // union name  {
  //     body
  //    } variables_list;
  // variant == UNION_DECL
public:
  // consider like a class.
  inline SgUnionStmt();
  inline SgUnionStmt(SgSymbol &name);
  inline ~SgUnionStmt();
};

Member Functions

SgUnionStmt()

SgUnionStmt(SgSymbol &name)


SgEnumStmt

Represents C++ enumerations.

class SgEnumStmt: public SgClassStmt {
  // basic C++ structure
  // enum name  {
  //     body
  //    } variables_list;
  // variant == ENUM_DECL
public:
  // consider like a class.
  inline SgEnumStmt();
  inline SgEnumStmt(SgSymbol &name);
  inline ~SgEnumStmt();
};

Member Functions

SgEnumStmt()

SgEnumStmt(SgSymbol &name)


SgCollectionStmt

Represents pC++ collections.

class SgCollectionStmt: public SgClassStmt {
  // basic C++ structure
  // collection name ;
  //                    body
  //                } variables_list;
  // variant == COLLECTION_DECL
public:
  inline SgCollectionStmt();
  inline SgCollectionStmt(SgSymbol &name);
  inline ~SgCollectionStmt();
  inline SgStatement *firstElementMethod();
};

Member Functions

SgCollectionStmt()

SgCollectionStmt(SgSymbol &name)

SgStatement *firstElementMethod()

Example Programs

SgCollectionStmt is used in the following example programs:


SgProgHedrStmt

Represents Fortran program blocks.

class  SgProgHedrStmt: public SgStatement {
  // fortran Program block
  // variant == PROG_HEDR
public:
  inline SgProgHedrStmt(PTR_BFND bif);
  inline SgProgHedrStmt(int variant);
  inline SgProgHedrStmt(SgSymbol &name, SgStatement &Body);
  inline SgProgHedrStmt(SgSymbol &name);
  inline SgProgHedrStmt(char *name);
  inline SgSymbol &name();
  inline void setName(SgSymbol &symbol); // set program name 

inline int numberOfFunctionsCalled(); // the number of functions called inline SgSymbol *calledFunction(int i);// the i-th called function inline int numberOfStmtFunctions(); // the number of statement funcions; inline SgStatement *statementFunc(int i); // the i-th statement function; inline int numberOfEntryPoints(); // the number of entry points; inline SgStatement *entryPoint(int i); // the i-th entry point; inline int numberOfParameters(); // the number of parameters; inline SgSymbol *parameter(int i); // the i-th parameter inline int numberOfSpecificationStmts(); inline SgStatement *specificationStmt(int i); inline int numberOfExecutionStmts(); inline SgStatement *executionStmt(int i); inline int numberOfInternalFunctionsDefined(); inline SgStatement *internalFunction(int i); inline int numberOfInternalSubroutinesDefined(); inline SgStatement *internalSubroutine(int i); inline int numberOfInternalSubProgramsDefined(); inline SgStatement *internalSubProgram(int i); inline int isSymbolInScope(SgSymbol &symbol); inline int isSymbolDeclaredHere(SgSymbol &symbol); // global analysis data inline int numberOfVarsUsed(); // list of used variable access sections inline SgExpression *varsUsed(int i); // i-th var used section descriptor inline int numberofVarsMod(); // list of modifed variable access sections inline SgExpression *varsMod(int i); // i-th var mod section descriptor inline ~SgProgHedrStmt(); };

Member Functions

SgProgHedrStmt(PTR_BFND bif)

SgProgHedrStmt(int variant)

SgProgHedrStmt(SgSymbol &name, SgStatement Body)

SgProgHedrStmt(SgSymbol &name)

SgProgHedrStmt(char *name)

SgSymbol &name()

void setName(SgSymbol &symbol)

int numberOfFunctionsCalled()

SgSymbol *calledFunction(int i)

int numberOfStmtFunctions()

SgStatement *statementFunc(int i)

int numberOfEntryPoints()

SgStatement *entryPoint(int i)

int numberOfParameters()

SgSymbol *parameter(int i)

int numberOfSpecificationStmts()

SgStatement *specificationStmt(int i)

int numberOfExecutionStmts()

SgStatement *executionStmt(int i)

int numberOfInternalFunctionsDefined()

SgStatement *internalFunction(int i)

int numberOfInternalSubroutinesDefined()

SgStatement *internalSubroutine(int i)

int numberOfInternalSubProgramsDefined()

SgStatement *internalSubProgram(int i)

int isSymbolInScope(SgSymbol &symbol)

int isSymbolDeclaredHere(SgSymbol &symbol)

int numberOfVarsUsed()

SgExpression *varsUsed(int i)

int numberofVarsMod()

SgExpression *varsMod(int i)

Example Programs

SgProgHedrStmt is used in the following example programs:


SgProcHedrStmt

Represents Fortran subroutines.

class  SgProcHedrStmt: public SgProgHedrStmt {
  // Fortran subroutine
  // variant == PROC_HEDR
public:        
  inline SgProcHedrStmt(int variant);
  inline SgProcHedrStmt(SgSymbol &name, SgStatement &Body);
  inline SgProcHedrStmt(SgSymbol &name);
  inline SgProcHedrStmt(char *name);
  inline void AddArg(SgExpression &arg); 
  SgExpression * AddArg(char *name, SgType &t); // returns decl expr created.
  SgExpression * AddArg(char *name, SgType &t, SgExpression &initializer);
  inline int isRecursive();  // 1 if recursive.;
  inline int numberOfEntryPoints();      // the number of entry points
                                         // other than the main, 0 for C funcs.
  inline SgStatement *entryPoint(int i);  // the i-th entry point
  // this is incorrect. Takes only subroutines calls into account.
  // Should be modified to take function calls into account too.
  inline int numberOfCalls();            // number of calls to this proc.
  inline SgStatement *call(int i);       // position of the i-th call.  
  inline ~SgProcHedrStmt();
};      

Member Functions

SgProcHedrStmt(int variant)

SgProcHedrStmt(SgSymbol &name, SgStatement Body)

SgProcHedrStmt(SgSymbol &name)

SgProcHedrStmt(char *name)

void AddArg(SgExpression &arg)

int isRecursive()

int numberOfEntryPoints()

SgStatement *entryPoint(int i)

int numberOfCalls()

SgStatement *call(int i)

Example Programs

SgProcHedrStmt is used in the following example programs:


SgBlockDataStmt

Represents Fortran block data statements.

class  SgBlockDataStmt: public SgStatement {
  // Fortran Block Data statement
  // variant == BLOCK_DATA
public:
  SgBlockDataStmt(SgSymbol &name, SgStatement &body);
  ~SgBlockDataStmt();
  
  SgSymbol *name();  // block data name if given;
  int setName(SgSymbol &symbol);           // set block data name 
  
  int isSymbolInScope(SgSymbol &symbol);
  int isSymbolDeclaredHere(SgSymbol &symbol);
};

Member Functions

SgBlockDataStmt(SgSymbol &name, SgStatement &body)

SgSymbol *name()

int setName(SgSymbol &symbol)

int isSymbolInScope(SgSymbol &symbol)

int isSymbolDeclaredHere(SgSymbol &symbol)


SgModuleStmt

Represents Fortran 90 module statements.

class  SgModuleStmt: public SgStatement {
  // Fortran 90 Module statement
  // variant ==  MODULE_STMT
public:
  SgModuleStmt(SgSymbol &moduleName, SgStatement &body);
  SgModuleStmt(SgSymbol &moduleName);
  ~SgModuleStmt();
  
  SgSymbol *moduleName();               // module name 
  void setName(SgSymbol &symbol);        // set module name 
  
  int numberOfSpecificationStmts();
  int numberOfRoutinesDefined();
  int numberOfFunctionsDefined();
  int numberOfSubroutinesDefined();
  
  SgStatement *specificationStmt(int i);
  SgStatement *routine(int i);
  SgStatement *function(int i);
  SgStatement *subroutine(int i);
  
  int isSymbolInScope(SgSymbol &symbol);
  int isSymbolDeclaredHere(SgSymbol &symbol);
  
  SgSymbol &addVariable(SgType &T, char *name); 
                                        //add a declaration for new variable
  
  SgStatement *addCommonBlock(char *blockname, int noOfVars,
                              SgSymbol *Vars); // add a new common block
};

Member Functions

SgModuleStmt(SgSymbol &moduleName, SgStatement &body)

SgModuleStmt(SgSymbol &moduleName)

SgSymbol *moduleName()

void setName(SgSymbol &symbol)

int numberOfSpecificationStmts()

int numberOfRoutinesDefined()

int numberOfFunctionsDefined()

int numberOfSubroutinesDefined()

SgStatement *specificationStmt(int i)

SgStatement *routine(int i)

SgStatement *function(int i)

SgStatement *subroutine(int i)

int isSymbolInScope(SgSymbol &symbol)

int isSymbolDeclaredHere(SgSymbol &symbol)

SgSymbol &addVariable(SgType &T, char *name)

SgStatement *addCommonBlock(char *blockname, int noOfVars, SgSymbol *Vars)


SgInterfaceStmt

Represents Fortran 90 operator interface statements.

class  SgInterfaceStmt: public SgStatement {
  // Fortran 90 Operator Interface Statement
  // variant == INTERFACE_STMT
public:
  SgInterfaceStmt(SgSymbol &name, SgStatement &body, SgStatement &scope);
  ~SgInterfaceStmt();
  
  SgSymbol *interfaceName();               // interface name if given
  int setName(SgSymbol &symbol);           // set interface name 
  
  int numberOfSpecificationStmts();
  
  SgStatement *specificationStmt(int i);
  
  int isSymbolInScope(SgSymbol &symbol);
  int isSymbolDeclaredHere(SgSymbol &symbol);
};

Member Functions

SgInterfaceStmt(SgSymbol &name, SgStatement &body, SgStatement &scope)

SgSymbol *interfaceName()

int setName(SgSymbol &symbol)

int numberOfSpecificationStmts()

SgStatement *specificationStmt(int i)

int isSymbolInScope(SgSymbol &symbol)

int isSymbolDeclaredHere(SgSymbol &symbol)


Declaration Statements


SgDeclarationStatement

Represents base class for declaration statements.

class  SgDeclarationStatement: public SgStatement {
  // Declaration class
  // abstract class
public:
  inline SgDeclarationStatement(int variant);
  inline ~SgDeclarationStatement();
  
  inline SgExpression *varList();
  inline int numberOfVars();
  inline SgExpression *var(int i);
  inline void deleteVar(int i);
  inline void deleteTheVar(SgExpression &var);
  inline void addVar(SgExpression &exp);
};

Member Functions

SgDeclarationStatement(int variant)

SgExpression *varList()

int numberOfVars()

SgExpression *var(int i)

void deleteVar(int i)

void deleteTheVar(SgExpression &var)

void addVar(SgExpression &exp)


SgVarDeclStmt

Represents declaration statements, for all languages.

class  SgVarDeclStmt: public SgDeclarationStatement {
  // Declaration Statement
  // variant == VAR_DECL
public:
  // varRefValList is a list of low-level nodes of
  // variants VAR_REFs or ARRAY_REFs or ASSIGN_OPs
  inline SgVarDeclStmt(SgExpression &varRefValList, 
                       SgExpression &attributeList, SgType &type);
  inline SgVarDeclStmt(SgExpression &varRefValList, SgType &type);
  inline SgVarDeclStmt(SgExpression &varRefValList);
  inline ~SgVarDeclStmt();
  inline SgType *type();  // the type;
  inline int numberOfAttributesF90(); // the number of F90 attributes;
  // the attributes are: PARAMETER_OP | PUBLIC_OP |
  //    PRIVATE_OP | ALLOCATABLE_OP | EXTERNAL_OP |
  //    OPTIONAL_OP | POINTER_OP | SAVE_OP TARGET_OP
  inline int numberOfSymbols();  // the number of variables declared;        
  inline SgSymbol *symbol(int i);
  
  inline void deleteSymbol(int i);
  inline void deleteTheSymbol(SgSymbol &symbol);
  inline SgExpression *initialValue(int i);  // the initial value of the 
                                             // i-th variable
  SgExpression *completeInitialValue(int i); // The complete ASSGN_OP
				// expression of the initial value *BW* from M. Golden
  void setInitialValue(int i, SgExpression &initVal); // sets the initial 
                                // value ofthe i-th variable; this is an
                                // alternative way to initialize variables. 
                                // The low-level node (VAR_REF or ARRAY_REF)
                                // is replaced by a ASSIGN_OP low-level node.
  void clearInitialValue(int i);  // removes initial value of the i-th 
                                  // declaration 
};

Member Functions

Below, varRefValList is a list of low-level nodes of variants VAR_REFs or ARRAY_REFs or ASSIGN_OPs.

SgVarDeclStmt(SgExpression &varRefValList, SgExpression &attributeList, SgType &type)

SgVarDeclStmt(SgExpression &varRefValList, SgType &type)

SgType *type()

int numberOfAttributesF90()

int numberOfSymbols()

SgSymbol * symbol(int i)

void deleteSymbol(int i)

void deleteTheSymbol(SgSymbol &symbol)

SgExpression *initialValue(int i)

SgExpression *completeInitialValue(int i)

void setInitialValue(int i, SgExpression &initVal)

void clearInitialValue(int i)

NOTE: There are some methods in the SgSymbol class that can be very useful for constructing SgVarDeclStmt once the symbol exists.

Example Programs

SgVarDeclStmt is used in the following example programs:


SgVarListDeclStmt

Represents lists of variable declarations, for all languages.

class  SgVarListDeclStmt: public SgDeclarationStatement {
  // Declaration Statement
  // variant == INTENT_STMT, OPTIONAL_STMT, SAVE_STMT, PUBLIC_STMT,
  // PRIVATE_STMT, EXTERNAL_STAT, INTRINSIC_STAT, DIM_STAT, 
  // ALLOCATABLE_STAT, POINTER_STAT, TARGET_STAT, MODULE_PROC_STMT
public:
  SgVarListDeclStmt(int variant, SgExpression &symbolRefList);
  SgVarListDeclStmt(int variant, SgSymbol &symbolList, SgStatement &scope);

inline ~SgVarListDeclStmt(); inline int numberOfSymbols(); inline SgSymbol *symbol(int i); inline void appendSymbol(SgSymbol &symbol); inline void deleteSymbol(int i); inline void deleteTheSymbol(SgSymbol &symbol); };

Member Functions

SgVarListDeclStmt(int variant, SgExpression &symbolRefList)

SgVarListDeclStmt(int variant, SgSymbol &symbolList, SgStatement &scope)

int numberOfSymbols()

SgSymbol *symbol(int i)

void appendSymbol(SgSymbol &symbol)

void deleteSymbol(int i)

void deleteTheSymbol(SgSymbol &symbol)

Example Programs

SgVarListDeclStmt is used in the following example programs:


SgNestedVarListDeclStmt

Represents Fortran lists of lists of variable declarations.

class SgNestedVarListDeclStmt: public SgDeclarationStatement {
  // Declaration statement
  // variant == NAMELIST_STAT, EQUI_STAT, COMM_STAT,
  //            and  PROS_COMM for Fortran M
  // These statements have the format of a list of variable lists. For example,
  // EQUIVALENCE (A, C, D), (B, G, F), ....
public:
  SgNestedVarListDeclStmt(int variant, SgExpression &listOfVarList);
  // varList must be of low-level variant appropriate to variant. For example,
  // if the variant is COMM_STAT, listOfVarList must be of variant COMM_LIST.
  ~SgNestedVarListDeclStmt();
  
  SgExpression *lists();
  int numberOfLists();
  SgExpression *list(int i);
  void addList(SgExpression &list);
  void  addVarToList(SgExpression &varRef);
  void deleteList(int i);
  void deleteTheList(SgExpression &list);
  void deleteVarInList(int i, SgExpression &varRef);
  void deleteVarInTheList(SgExpression &list, SgExpression &varRef);
};

Member Functions

SgNestedVarListDeclStmt(int variant, SgExpression &listOfVarList)

SgExpression *lists()

int numberOfLists()

SgExpression *list(int i)

SgExpression *leadingVar(int i)

void addList(SgExpression &list)

void addVarToList(SgExpression &varRef)

void deleteList(int i)

void deleteTheList(SgExpression &list)

void deleteVarInList(int i, SgExpression &varRef)

void deleteVarInTheList(SgExpression &list, SgExpression &varRef)

Example Programs

SgNestedVarListDeclStmt is used in the following example programs:


SgParameterStmt

Represents Fortran constants.

class SgParameterStmt: public SgDeclarationStatement {
  // Fortran constants declaration statement
  // variant = PARAM_DECL
public:
  SgParameterStmt(SgExpression &constants, SgExpression &values);
  SgParameterStmt(SgExpression &constantsWithValues);
  ~SgParameterStmt();
  
  int numberOfConstants();    // the number of constants declared
  
  SgSymbol *constant(int i);  // the i-th variable
  SgExpression *value(int i); // the value of i-th variable
  
  void addConstant(SgSymbol &constant, SgExpression &value);
  void deleteConstant(int i);
  void deleteTheConstant(SgSymbol &constant);
};

Member Functions

SgParameterStmt(SgExpression &constants, SgExpression &values)

SgParameterStmt(SgExpression &constantsWithValues)

int numberOfConstants()

SgSymbol *constant(int i)

void addConstant(SgSymbol &constant, SgExpression &value)

void deleteConstant(int i)

void deleteTheConstant(SgSymbol &constant)

Example Programs

SgParameterStmt is used in the following example programs:


SgImplicitStmt

Represents Fortran implicit type declarations.

class SgImplicitStmt: public SgDeclarationStatement {
  // Fortran implicit type declaration statement
  // variant = IMPL_DECL
public:
  SgImplicitStmt(SgExpression &implicitLists);
  ~SgImplicitStmt();
  
  int numberOfImplicitTypes();  // the number of implicit types declared;
  SgType *implicitType(int i); // the i-th implicit type
  SgExpression *implicitRangeList(int i) ;
  void  appendImplicitNode(SgExpression &impNode);
};

Member Functions

SgImplicitStmt(SgExpression &implicitLists)

int numberOfImplicitTypes()

SgType *implicitType(int i)

SgExpression *implicitRangeList(int i)

void appendImplicitNode(SgExpression &impNode)

void addImplicitType(SgType Type, char alphabet[])

int deleteImplicitItem(int i)

int deleteTheImplicitItem(SgExpression &implicitItem)

Example Programs

SgImplicitStmt is used in the following example programs:


SgStmtFunctionStmt

Represents Fortran statement function declarations.

class  SgStmtFunctionStmt: public SgDeclarationStatement {
  // Fortran statement function declaration
  // variant == STMTFN_DECL
public:        
  SgStmtFunctionStmt(SgSymbol &name, SgExpression &args, SgStatement Body);
  ~SgStmtFunctionStmt();
  SgSymbol *name();
  void setName(SgSymbol &name);
  SgType *type();
  int numberOfParameters();       // the number of parameters
  SgSymbol *parameter(int i);     // the i-th parameter
};      

Member Functions

SgStmtFunctionStmt(SgSymbol &name, SgExpression &args, SgStatement Body)

SgSymbol *name()

void setName(SgSymbol &name)

SgType *type()

int numberOfParameters()

SgSymbol *parameter(int i)


SgStructureDeclStmt

Represents Fortran 90 structure declarations.

class SgStructureDeclStmt: public SgDeclarationStatement {
  // Fortran 90 structure declaration statement
  // variant == STRUCT_DECL
public:
  SgStructureDeclStmt(SgSymbol &name, SgExpression &attributes, 
                      SgStatement &body);
  ~SgStructureDeclStmt();
};

Member Functions

SgStructureDeclStmt(SgSymbol &name, SgExpression &attributes, SgStatement &body)

int isPrivate()

int isPublic()

int isSequence()

Example Programs

SgStructureDeclStmt is used in the following example programs:


SgUseStmt

Represents Fortran 90 module usage statements.

class SgUseStmt: public SgDeclarationStatement {
  // Fortran 90 module usuage statement
  // variant = USE_STMT
public:
  SgUseStmt(SgSymbol &moduleName, SgExpression &renameList, SgStatement &scope);
  // renameList must be a list of low-level nodes of variant RENAME_NODE
  ~SgUseStmt();
  
  int isOnly();
  SgSymbol *moduleName();
  void setModuleName(SgSymbol &moduleName);
  int numberOfRenames();
  SgExpression *renameNode(int i);
  void  addRename(SgSymbol &localName, SgSymbol &useName);
  void  addRenameNode(SgExpression &renameNode);
  void  deleteRenameNode(int i);
  void deleteTheRenameNode(SgExpression &renameNode);
};

Member Functions

SgUseStmt(SgSymbol &moduleName, SgExpression &renameList, SgStatement &scope)

int isOnly()

SgSymbol *moduleName()

void setModuleName(SgSymbol &moduleName)

int numberOfRenames()

SgExpression *renameNode(int i)

void addRename(SgSymbol &localName, SgSymbol &useName)

void addRenameNode(SgExpression &renameNode)

void deleteRenameNode(int i)

void deleteTheRenameNode(SgExpression &renameNode)


SgMiscellStmt

Represents Fortran 90 contains statements, private statements, sequence statements.

class  SgMiscellStmt: public SgDeclarationStatement {
#if 0
  // Fortran 90 simple miscellaneous statements
  // variant == CONTAINS_STMT, PRIVATE_STMT, SEQUENCE_STMT
public:        
   SgMiscellStmt(int variant);
  ~SgMiscellStmt();
};      

Member Functions

SgMiscellStmt(int variant)


Control Statements


SgForStmt

This class has a set of high level functions for semantic analysis and transformations. This includes the analysis of implicit induction variables defined in the loop body as well as information about the interactions with other loops that may be in the same loop nest. In addition, there are functions for performing very high level transformations such as normalization, interchange, unrolling, and fusion. However, in the current version, many of these functions are still unimplemented because they depend on data dependency information.

class  SgForStmt: public SgStatement {
  // for Fortran Do and C for();
  // variant = FOR_NODE
public:
  inline SgForStmt(SgSymbol &do_var, SgExpression &start, SgExpression &end,
            SgExpression &step, SgStatement &body);
  inline SgForStmt(SgSymbol *do_var, SgExpression *start, SgExpression *end,
            SgExpression *step, SgStatement *body);
  inline SgForStmt(SgSymbol &do_var, SgExpression &start, SgExpression &end,
            SgStatement &body);
  inline SgForStmt(SgExpression &start, SgExpression &end, SgExpression &step,
            SgStatement &body);
  
  inline SgSymbol * doName();                // the name of the loop (for F90.)
  inline void setDoName(SgSymbol &doName);// sets the name of the loop(for F90)

inline SgExpression *start(); inline void setStart(SgExpression &lbound);

inline SgExpression *end(); inline void setEnd(SgExpression &ubound);

inline SgExpression *step(); inline void setStep(SgExpression &step);

inline SgLabel *endOfLoop();

// body is returned with control end statement // still attached. inline SgStatement *body(); // s is assumed to terminate with a // control end statement. inline void set_body(SgStatement &s); inline int isPerfectLoopNest(); inline SgStatement *getNextLoop(); inline SgStatement *getPreviousLoop(); // returns outer nested loop inline SgStatement *getInnermostLoop(); // returns innermost nested loop inline int isEnddoLoop(); // TRUE if the loop ends with an Enddo inline int convertLoop(); // Convert the loop into a Good loop. inline ~SgForStmt(); };

Member Functions

SgForStmt(SgSymbol &do_var, SgExpression &start, SgExpression &end, SgExpression &step, SgStatement &body)

SgForStmt(SgSymbol *do_var, SgExpression *start, SgExpression *end, SgExpression *step, SgStatement *body)

SgForStmt(SgSymbol &do_var, SgExpression &start, SgExpression &end, SgStatement &body)

SgForStmt(SgExpression &start, SgExpression &end, SgExpression &step, SgStatement &body)

SgSymbol *doName()

void setDoName(SgSymbol &doName)

SgExpression *start()

void setStart(SgExpression &lbound)

SgExpression *end()

void setEnd(SgExpression &ubound)

SgExpression *step()

void setStep(SgExpression &step)

SgLabel *endOfLoop()

SgExpression &bounds()

void setBounds(SgTripletOp &bounds)

SgStatement *body()

void set_body(SgStatement &s)

int isPerfectLoopNest()

SgStatement *getNextLoop()

SgStatement *getPreviousLoop()

SgStatement *getInnermostLoop()

int isEnddoLoop()

int convertLoop()

Example Programs

SgForStmt is used in the following example programs:


SgDoWhileStmt

Represents the C do...while and Fortran dowhile statements.

class  SgDoWhileStmt: public SgWhileStmt {
  // For Fortran  dowhile().. and C do {....) while();
  // variant = DO_WHILE_NODE
public:
  inline SgDoWhileStmt(SgExpression &cond, SgStatement &body);
  inline ~SgDoWhileStmt();
};

Member Functions

SgDoWhileStmt(SgExpression &cond, SgStatement &body)


SgWhileStmt

Represents the C while() statement.

class  SgWhileStmt: public SgStatement {
  // for C while()
  // variant = WHILE_NODE
public:
  inline SgWhileStmt(int variant);
  inline SgWhileStmt(SgExpression &cond, SgStatement &body);
  inline SgExpression *conditional();      // the while test
  inline void replaceBody(SgStatement &s); // new body = s and lex successors.
  inline ~SgWhileStmt();
};

Member Functions

SgWhileStmt(int variant)

SgWhileStmt(SgExpression &cond, SgStatement &body)

SgExpression *conditional()

void replaceBody(SgStatement &s)

Example Programs

SgWhileStmt is used in the following example programs:


SgIfStmt

Represents the C if and Fortran if .. then .. else statement.

class  SgIfStmt: public SgStatement {
  // For Fortran if then else and C  if()
  // variant == IF_NODE
public:
  inline SgIfStmt(int variant);
  inline SgIfStmt(SgExpression &cond, SgStatement &trueBody, SgStatement &falseBody,
                  SgSymbol &construct_name);
  inline SgIfStmt(SgExpression &cond, SgStatement &trueBody, SgStatement &falseBody);
  inline SgIfStmt(SgExpression &cond, SgStatement &trueBody);
  inline SgStatement *trueBody();      // the first stmt in the True clause
  // SgBlock is needed? 
  inline SgStatement *trueBody(int i); // i-th stmt in True clause, i=0,1,...
  inline SgStatement *falseBody();     // the first stmt in the False
  inline SgStatement *falseBody(int i);// i-th stmt of the body, i=0,1,...
  inline SgExpression *conditional();  // the while test
  inline SgSymbol *construct_name();
  inline void replaceTrueBody(SgStatement &s);// new body=s and lex successors.
  inline void replaceFalseBody(SgStatement &s);//new body=s and lex successors.
  inline ~SgIfStmt();
};

Member Functions

SgIfStmt(int variant)

SgIfStmt(SgExpression &cond, SgStatement &trueBody, SgStatement &falseBody, SgSymbol &construct_name)

SgIfStmt(SgExpression &cond, SgStatement &trueBody, SgStatement &falseBody)

SgIfStmt(SgExpression &cond, SgStatement &trueBody)

SgStatement *trueBody()

SgStatement *trueBody(int i)

SgStatement *falseBody()

SgStatement *falseBody(int i)

SgExpression *conditional()

SgSymbol *construct_name()

void replaceTrueBody(SgStatement &s)

void replaceFalseBody(SgStatement &s)

Example Programs

SgIfStmt is used in the following example programs:


SgSwitchStmt

Represents the C switch and Fortran case statement.

class  SgSwitchStmt: public SgStatement {
  // Fortran Case and C  switch();
  // variant == SWITCH_NODE
public:
  inline SgSwitchStmt(SgExpression &selector, SgStatement &caseOptionList,
                      SgSymbol &constructName);
  inline SgSwitchStmt(SgExpression &selector, SgStatement * caseOptionList,
                      SgSymbol &constructName);
  inline SgSwitchStmt(SgExpression &selector, SgStatement * caseOptionList,
                      SgSymbol *constructName);
  inline ~SgSwitchStmt();
  inline SgExpression *selector();  // the switch selector
  inline void setSelector(SgExpression &cond);
  inline int numberOfCaseOptions();       // the number of cases
  inline SgStatement *caseOption(int i);  // i-th case block
  inline void addCaseOption(SgStatement &caseOption);
};

Member Functions

SgSwitchStmt(SgExpression &selector, SgStatement &caseOptionList, SgSymbol &constructName)

SgExpression *selector()

void setSelector(SgExpression &cond)

int numberOfCaseOptions()

SgStatement *caseOption(int i)

void addCaseOption(SgStatement &caseOption)


SgLogIfStmt

Represents the Fortran logical if statement.

class  SgLogIfStmt: public SgStatement {
  // For Fortran logical if  - only one body statement allowed
  // variant == LOGIF_NODE
public:
  inline SgLogIfStmt(int variant);
  inline SgLogIfStmt(SgExpression &cond, SgStatement &s);
  inline SgStatement *body();  // returns reference to first stmt in the body
  inline SgExpression *conditional();  // the while test
  // check if the statement s is a single statement. 
  inline void setBody(SgStatement &s); // new body = s 
  // this code won't work, since after the addition false
  //   clause, it should become SgIfThenElse statement.
  inline void addFalseClause(SgStatement &s); // make it into if-then-else
  inline SgIfStmt *convertLogicIf();
  inline ~SgLogIfStmt();
};

Member Functions

SgLogIfStmt(int variant)

SgLogIfStmt(SgExpression &cond, SgStatement &s)

SgStatement *body()

SgExpression *conditional()

void setBody(SgStatement &s)

void addFalseClause(SgStatement &s)

SgIfStmt *convertLogicIf()

Example Programs

SgLogIfStmt is used in the following example programs:


SgIfElseIfStmt

Represents the Fortran if .. then .. elseif statement.

class  SgIfElseIfStmt: public SgIfStmt {
  // For Fortran if then elseif .. elseif ... case
  // variant == ELSEIF_NODE
public:
  SgIfElseIfStmt(SgExpression &condList, SgStatement &blockList,
                 SgSymbol &constructName);
  int numberOfConditionals();       // the number of conditionals
  SgStatement *body(int b);          // block b
  void setBody(int b);              // sets block 
  SgExpression *conditional(int i); // the i-th conditional
  void setConditional(int i);       // sets the i-th conditional
  void addClause(SgExpression &cond, SgStatement &block);
  void removeClause(int b);          // removes block b and it's conditional
  ~SgIfElseIfStmt();
};

Member Functions

SgIfElseIfStmt(SgExpression &condList, SgStatement &blockList, SgSymbol &constructName)

int numberOfConditionals()

SgStatement *body(int b)

void setBody(int b)

SgExpression *conditional(int i)

void setConditional(int i)

void addClause(SgExpression &cond, SgStatement &block)

void removeClause(int b)


SgArithIfStmt

Represents the Fortran arithmentic if statement.

class  SgArithIfStmt: public SgStatement {
  // For Fortran Arithementic if
  // variant == ARITHIF_NODE
public:
  inline SgArithIfStmt(int variant);
  inline SgArithIfStmt(SgExpression &cond, SgLabel &llabel, 
                       SgLabel &elabel, SgLabel &glabel);
  inline SgExpression *conditional();
  inline void set_conditional(SgExpression &cond);
  inline SgExpression *label(int i);  // the <, ==, and > goto labels. 
                                      // in order 0->2.
  inline void setLabel(SgLabel &label);
  inline ~SgArithIfStmt();
};

Member Functions

SgArithIfStmt(int variant)

SgArithIfStmt(SgExpression &cond, SgLabel &llabel, SgLabel &elabel, SgLabel &glabel)

SgExpression *conditional()

void set_conditional(SgExpression &cond)

SgExpression *label(int i)

void setLabel(SgLabel &label)

Example Programs

SgArithIfStmt is used in the following example programs:


SgWhereStmt

Represents the Fortran where statement.

class  SgWhereStmt: public SgLogIfStmt {
  // fortran Where stmt
  // variant == WHERE_NODE
public:
  inline SgWhereStmt(SgExpression &cond, SgStatement &body);
  inline ~SgWhereStmt();
};

Member Functions

SgWhereStmt(SgExpression &cond, SgStatement &body)


SgWhereBlockStmt

Represents the Fortran where .. elsewhere statement.

class  SgWhereBlockStmt: public SgIfStmt {
  // fortran Where - Elsewhere stmt
  // variant == WHERE_BLOCK_STMT
public:
  SgWhereBlockStmt(SgExpression &cond, SgStatement &trueBody, 
                   SgStatement &falseBody);
  ~SgWhereBlockStmt();
};

Member Functions

SgWhereBlockStmt(SgExpression &cond, SgStatement &trueBody, SgStatement &falseBody)


SgCaseOptionStmt

Represents the case option statement.

class SgCaseOptionStmt: public SgStatement {
  // Fortran case option statement
  // variant == CASE_NODE
public:
  inline SgCaseOptionStmt(SgExpression &caseRangeList, SgStatement &body, 
                          SgSymbol &constructName);
  inline SgCaseOptionStmt(SgExpression &caseRangeList, SgStatement *body, 
                          SgSymbol &constructName);
  inline SgCaseOptionStmt(SgExpression &caseRangeList, SgStatement *body, 
                          SgSymbol *constructName);
  inline ~SgCaseOptionStmt();
  
  inline SgExpression *caseRangeList();
  inline void setCaseRangeList(SgExpression &caseRangeList);
  inline SgExpression *caseRange(int i);
  inline void setCaseRange(SgExpression &caseRange);
  inline SgStatement *body();
  inline void setBody(SgStatement &body);
};

Member Functions

SgCaseOptionStmt(SgExpression &caseRangeList, SgStatement &body, SgSymbol &constructName)

SgExpression *caseRangeList()

void setCaseRangeList(SgExpression &caseRangeList)

SgExpression *caseRange(int i)

void setCaseRange(int i, SgExpression &caseRange)

SgStatement *body()

void setBody(SgStatement &body)


Executable and Other Statements


SgExecutableStatement

Represents executable statements, for all languages.

class  SgExecutableStatement: public  SgStatement {
  // this is really a non-control, non-declaration stmt.
  // no special functions here.
public: 
  inline SgExecutableStatement(int variant);
};

Member Functions

SgExecutableStatement(int variant)


SgContinueStmt

Represents the continue statement for all languages.

class  SgContinueStmt: public SgExecutableStatement {
  // variant == CONT_STAT in Fortran and
  // variant == CONTINUE_NODE in C
public:
  inline SgContinueStmt();
  inline ~SgContinueStmt();
};

Member Functions

SgContinueStmt()


SgControlEndStmt

Represents the end statements of basic blocks for all languages.

class  SgControlEndStmt: public SgExecutableStatement {
  // the end of a basic block
  // variant == CONTROL_END 
public:
  inline SgControlEndStmt(int variant);
  inline SgControlEndStmt();
  inline ~SgControlEndStmt();
};

NOTE: In C++, SgControlEnd usually corresponds to }, but the usage is inconsistent, so one should not count on SgControlEnd appearing every place where } appears in the code. Similarly, SgControlEnd might appear in certain places where it is not expected. Furthermore, you should be aware that SgControlEnd is also used to represent an empty class definition as in: class A{};. This was done to distinguish such definitions from forward declarations, as in class A;.

Member Functions

SgControlEndStmt(int variant)

SgControlEndStmt()

Example Programs

SgControlEndStmt is used in the following example programs:


SgReturnStmt

Represents the return statement for all languages.

class  SgReturnStmt: public SgExecutableStatement {
  // the return (expr) node
  // variant == RETURN_NODE//RETURN_STAT
public:
  SgReturnStmt(SgExpression &returnValue);
  SgReturnStmt();
  inline SgExpression *returnValue();
  inline void setReturnValue(SgExpression &retVal);
  inline ~SgReturnStmt();
};

Member Functions

SgReturnStmt(SgExpression &returnValue)

SgReturnStmt()

SgExpression *returnValue()

void setReturnValue(SgExpression &retVal)

Example Programs

SgReturnStmt is used in the following example programs:


SgGotoStmt

Represents the goto for all languages.

class  SgGotoStmt: public SgExecutableStatement {
  // the fortran or C goto
  // variant == GOTO_NODE
public:
  inline SgGotoStmt(SgLabel &label);
  inline SgLabel *branchLabel();
  inline ~SgGotoStmt();
};

Member Functions

SgGotoStmt(SgLabel &label)

SgLabel *branchLabel()

SgStatement *target()

Example Programs

SgGotoStmt is used in the following example programs:


SgCExpStmt

Represents C expression statements.

class  SgCExpStmt: public SgExecutableStatement {
  // C non-control expression Statment
  // variant == EXPR_STMT_NODE
public:
  inline SgCExpStmt(SgExpression &exp);
  inline SgCExpStmt(SgExpression &lhs, SgExpression &rhs);
  inline SgExpression *expr();  // the expression
  inline void replaceExpression(SgExpression &e); // replace exp with e
  inline ~SgCExpStmt();
};

Member Functions

SgCExpStmt(SgExpression &exp)

SgCExpStmt(SgExpression &lhs, SgExpression &rhs)

SgExpression *expr()

void replaceExpression(SgExpression &e)

Example Programs

SgCExpStmt is used in the following example programs:


SgBreakStmt

Represents the C break statement.

class  SgBreakStmt: public SgExecutableStatement {
  // the end of a basic block
  // variant == BREAK_NODE 
public:
  inline SgBreakStmt();
  inline ~SgBreakStmt();
};

Member Functions

SgBreakStmt()


SgAssignStmt

Represents Fortran assignment statements.

class SgAssignStmt: public SgExecutableStatement {
  // Fortran assignment Statment
  // variant == ASSIGN_STAT
public:
  inline SgAssignStmt(int variant);
  inline SgAssignStmt(SgExpression &lhs, SgExpression &rhs);
  inline SgExpression *lhs();  // the left hand side
  inline SgExpression *rhs();  // the right hand side
  inline void replaceLhs(SgExpression &e); // replace lhs with e
  inline void replaceRhs(SgExpression &e); // replace rhs with e
};

Member Functions

SgAssignStmt(int variant)

SgAssignStmt(SgExpression &lhs, SgExpression &rhs)

SgExpression *lhs()

SgExpression *rhs()

void replaceLhs(SgExpression &e)

void replaceRhs(SgExpression &e)

SgExpression *varReferenced()

SgExpression *varUsed()

SgExpression *varDefined()

Example Programs

SgAssignStmt is used in the following example programs:


SgPointerAssignStmt

Represents Fortran pointer assignment statements.

class  SgPointerAssignStmt: public SgAssignStmt {
  // Fortran  pointer assignment statement
  // variant == POINTER_ASSIGN_STAT
public:
  inline SgPointerAssignStmt(SgExpression lhs, SgExpression rhs);
  inline ~SgPointerAssignStmt();
};

Member Functions

SgPointerAssignStmt(SgExpression lhs, SgExpression rhs)


SgHeapStmt

Represents Fortran allocate and deallocate.

class  SgHeapStmt: public SgExecutableStatement {
  // Fortran heap space allocation and deallocation statements
  // variant == ALLOCATE_STMT or DEALLOCATE_STMT 
public:
  inline SgHeapStmt(int variant, SgExpression &allocationList, 
                    SgExpression &statVariable);
  inline ~SgHeapStmt();
  inline SgExpression *allocationList();
  inline void setAllocationList(SgExpression &allocationList);
  inline SgExpression *statVariable();
  inline void setStatVariable(SgExpression &statVar);
};

Member Functions

SgHeapStmt(int variant, SgExpression &allocationList, SgExpression &statVariable)

SgExpression *allocationList()

void setAllocationList(SgExpression &allocationList)

SgExpression *statVariable()

void setStatVariable(SgExpression &statVar)


SgNullifyStmt

Represents Fortran pointer initialization statement.

class  SgNullifyStmt: public SgExecutableStatement {
  // Fortran pointer initialization statement
  // variant == NULLIFY_STMT 
public:
  inline SgNullifyStmt(SgExpression &objectList);
  inline ~SgNullifyStmt();
  inline SgExpression *nullifyList();
  inline void setNullifyList(SgExpression &nullifyList);
};

Member Functions

SgNullifyStmt(SgExpression &objectList)

SgExpression *nullifyList()

void setNullifyList(SgExpression &nullifyList)


SgLabelListStmt

Represents Fortran statements containing lists of labels.

class SgLabelListStmt: public SgExecutableStatement {
  // the fortran
  // statements containg a list of labels
public:
  SgLabelListStmt(int variant);
  int numberOfTargets();
  SgExpression *labelList();
  void setLabelList(SgExpression &labelList);
};

Member Functions

SgLabelListStmt(int variant)

int numberOfTargets()

SgExpression *labelList()

void setLabelList(SgExpression &labelList)

SgStatement *target(int i)


SgAssignedGotoStmt

Represents Fortran assigned goto statement.

class SgAssignedGotoStmt: public SgLabelListStmt {
  // the fortran 
  // variant == ASSGOTO_NODE
public:
  SgAssignedGotoStmt(SgSymbol &symbol, SgExpression &labelList);
  SgSymbol *symbol();
  void setSymbol(SgSymbol &symb);
  ~SgAssignedGotoStmt();
};

Member Functions

SgAssignedGotoStmt(SgSymbol &symbol, SgExpression &labelList)

SgSymbol *symbol()

void setSymbol(SgSymbol &symb)

Example Programs

SgAssignedGotoStmt is used in the following example programs:


SgComputedGotoStmt

Represents Fortran computed goto statement.

class SgComputedGotoStmt: public SgLabelListStmt {
  // the fortran goto
  // variant == COMGOTO_NODE
public:
  inline SgComputedGotoStmt(SgExpression &expr, SgLabel &label);
  inline void addLabel(SgLabel &label);
  inline SgExpression *exp();
  inline void setExp(SgExpression &exp);
  inline ~SgComputedGotoStmt();
};

Member Functions

SgComputedGotoStmt(SgExpression &expr, SgLabel &label)

void addLabel(SgLabel &label)

SgExpression *exp()

void setExp(SgExpression &exp)

Example Programs

SgComputedGotoStmt is used in the following example programs:


SgStopOrPauseStmt

Represents the Fortran stop statement.

class  SgStopOrPauseStmt: public SgExecutableStatement {
  // the fortran stop
  // variant == STOP_STAT
public:
  SgStopOrPauseStmt(int variant, SgExpression *expr);
  SgExpression *exp();
  void setExp(SgExpression &exp);
  ~SgStopOrPauseStmt();
};

Member Functions

SgStopOrPauseStmt(int variant, SgExpression &expr)

SgExpression *exp()

void setExp(SgExpression &exp)


SgCallStmt

Represents the Fortran call statement.

class  SgCallStmt: public SgExecutableStatement {
  // the fortran call
  // variant == PROC_STAT
public:
  SgCallStmt(SgSymbol &name, SgExpression &args);
  SgCallStmt(SgSymbol &name);
  SgSymbol *name();    // name of subroutine being called
  int numberOfArgs();  // the number of arguement expressions
  void  addArg(SgExpression &arg);
  SgExpression *arg(int i); // the i-th argument expression
  ~SgCallStmt();
};

Member Functions

SgCallStmt(SgSymbol &name, SgExpression &args)

SgCallStmt(SgSymbol &name)

SgSymbol *name()

int numberOfArgs()

void addArg(SgExpression &arg)

SgExpression *arg(int i)

int numberOfVarsUsed()

SgExpression *varsUsed(int i)

int numberOfVarsMod()

SgExpression *varsMod(int i)

Example Programs

SgCallStmt is used in the following example programs:


SgIOStmt

Represents IO statements, for all languages.

class SgIOStmt: public SgExecutableStatement {
  // fortran input/output and their control statements
  // abstract class
public:
   inline SgIOStmt(int variant);
};

Member Functions

SgIOStmt(int variant)

Example Programs

SgIOStmt is used in the following example programs:


SgInputOutputStmt

Represents the Fortran read, write, and print statements.

class SgInputOutputStmt: public SgIOStmt {
  // fortran input and output statements
  // variant = READ_STAT, WRITE_STATE, PRINT_STAT
public:
  inline SgInputOutputStmt(int variant, SgExpression &specList, 
                           SgExpression &itemList);
  inline SgExpression *specList();
  inline void setSpecList(SgExpression &specList);
  inline SgExpression *itemList();
  inline void setItemList(SgExpression &itemList);
  inline ~SgInputOutputStmt();
};

Member Functions

SgInputOutputStmt(int variant, SgExpression &specList, SgExpression &itemList)

SgExpression *specList()

void setSpecList(SgExpression &specList)

SgExpression *itemList()

void setItemList(SgExpression &itemList)

Example Programs

SgInputOutputStmt is used in the following example programs:


SgIOControlStmt

Represents the Fortran open, close, inquire, backspace, rewind, endfile, and format statements.

class SgIOControlStmt: public SgExecutableStatement {
  // fortran input/output control and editing statements
  // variant = OPEN_STAT, CLOSE_STAT, INQUIRE_STAT, BACKSPACE_STAT,
  // REWIND_STAT, ENDFILE_STAT, FORMAT_STAT
public:
  SgIOControlStmt(int variant, SgExpression &controlSpecifierList);
  inline SgExpression *controlSpecList();
  inline void setControlSpecList(SgExpression &controlSpecList);
  inline ~SgIOControlStmt();
};

Member Functions

SgIOControlStmt(int variant, SgExpression &controlSpecifierList)

SgExpression *controlSpecList()

void setControlSpecList(SgExpression &controlSpecList)

Example Programs

SgIOControlStmt is used in the following example programs:


SgCycleStmt

Represents the Fortran 90 cycle statements.

class  SgCycleStmt: public SgExecutableStatement {
  // the fortran 90 cycle statement
  // variant == CYCLE_STMT
public:
  inline SgCycleStmt(SgSymbol &symbol);
  inline SgSymbol *constructName();  // the name of the loop to cycle
  inline void setConstructName(SgSymbol &constructName);
  inline ~SgCycleStmt();
};

Member Functions

SgCycleStmt(SgSymbol &symbol)

SgSymbol *constructName()

void setConstructName(SgSymbol &constructName)


SgExitStmt

Represents the Fortran 90 exit statements.

class  SgExitStmt: public SgControlEndStmt {
  // the fortran 90 exit statement
  // variant == EXIT_STMT
public:
  inline SgExitStmt(SgSymbol &construct_name);
  inline ~SgExitStmt();
  inline SgSymbol *constructName();  // the name of the loop to cycle
  inline void setConstructName(SgSymbol &constructName);
};

Member Functions

SgExitStmt(SgSymbol &construct_name)

SgSymbol *constructName()

void setConstructName(SgSymbol &constructName)


Exit Sage++ User's Guide