Polaris: StmtList Class Reference

StmtList Class Reference

Modification History: 97-09-24.0015 evansl WHAT: Added: 1) private _move_block_either 96-11-13.2120 evansl WHAT: Added: 1) ins_DO_END_after 2) ins_WHILE_after A class for Fortran Statement Lists. More...

#include <StmtList.h>

Inheritance diagram for StmtList:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 StmtList ()
 StmtList (const StmtList &stmts)
StmtListoperator= (const StmtList &stmts)
void convert (BinRep &stmts, ExprTable &etable, Symtab &symtab, const NamelistDict &namelists, const FormatDB &formats, const char *initial_stmt)
 Convert a list of statements.
virtual StmtListclone () const
virtual Listablelistable_clone () const
 Needed for Listable class.
virtual ~StmtList ()
BinRepoverflow_ref () const
 Return the FLOW_ENTRY statement.
const Statementfirst () const
Statementfirst ()
 Return the FLOW_EXIT statement.
const Statementlast () const
Statementlast ()
const Statementfind_ref (const char *stmt_tag) const
Statementfind_ref (const char *stmt_tag)
 Search for a statement using the statement tag, such as "S1", "S2", "ST30", etc.
Iterator< Statementiterate_entry_points () const
 Returns an iterator which loops through all entry points in the StmtList.
virtual void ins_before (Statement *new_stmt, Statement *ref_stmt)
 Insert new_stmt after ref_stmt.
virtual void ins_after (Statement *new_stmt, Statement *ref_stmt)
 Insert new_stmt after ref_stmt.
virtual void ins_first (Statement *stmt)
 Insert stmt first in StmtList.
virtual void ins_last (Statement *stmt)
 Insert stmt last in StmtList.
virtual void ins (Statement *new_stmt, int loc)
 Insert new_stmt at location loc, where 0 <= loc <= entries().
void ins_before (List< Statement > *stmts, Statement *ref_stmt)
 Insert the statement block, stmts, before ref_stmt and then delete stmts.
void ins_after (List< Statement > *stmts, Statement *ref_stmt)
 Insert the statement block, stmts, after ref_stmt and then delete stmts.
Statementins_IF_ELSE_after (Expression *cond_exp, Statement *ref_stmt=0, Statement *last_of_then_clause=0, Statement *last=0)
 Insert a block IF-ELSE-ENDIF around a (possibly empty) set of statements with the conditional expression cond_exp and return the IfStmt.
Statementins_IF_after (Expression *cond_exp, Statement *ref_stmt=0, Statement *last=0)
 Same as ins_IF_ELSE_after(), except no ELSE part is inserted.
Statementins_ELSEIF_after (Expression *cond_expr, Statement *if_stmt, Statement *last_of_then_clause=0)
 No additional ENDIF is added.
Statementins_ELSE_after (Statement *if_stmt, Statement *last_of_then_clause=0)
 No additional ENDIF is added.
Statementins_DO_after (Expression *index_exp, Expression *init_exp, Expression *limit_exp, Expression *step_exp, Statement *ref_stmt=0, Statement *last=0)
 Insert a DO block around a set of statements with the specifications given by index_exp, init_exp, limit_exp and step_exp.
Statementins_WHILE_after (Expression *cond_exp, Statement *ref_stmt=0, Statement *last=0)
 Insert a WHILE block around a set of statements with the specifications given by cond_exp.
Statementins_DO_END_after (Statement *do_stmt, Statement *ref_stmt=0, Statement *last=0)
 Insert a DO..ENDDO block around a set of statements with the specifications given by do_stmt(either DoStmt or WhileStmt).
Statementins_BLOCK_after (Statement *ref_stmt=0, Statement *last=0)
 Insert a BLOCK_ENTRY/EXIT around a set of statements.
void move_block_before (Statement &first_stmt, Statement &last_stmt, Statement *ref_stmt=0)
 Move all statements from first_stmt to last_stmt, inclusive, to before ref_stmt.
void move_block_after (Statement &first_stmt, Statement &last_stmt, Statement *ref_stmt=0)
 Move all statements from first_stmt to last_stmt, inclusive, to after ref_stmt (or beginging if !ref).
void move_before (Statement &stmt, Statement *ref_stmt=0)
 Move statement to before ref_stmt.
void move_after (Statement &stmt, Statement *ref_stmt=0)
 Move statement to after ref_stmt.
virtual void del (Statement &s)
 Delete a single statement.
virtual void del (RefSet< Statement > &stmt_list)
 Delete a set of statements.
void del (Statement &first_stmt, Statement &last_stmt)
 Delete the block delimited by first_stmt and last_stmt.
virtual void clear ()
 Delete the entire StmtList.
List< Statement > * copy (const Statement &first_stmt, const Statement &last_stmt, RE_LABEL relabel=RELABEL) const
 Return a copied list of statements between first_stmt and last_stmt, inclusive.
List< Statement > * grab (Statement &first_stmt, Statement &last_stmt, RE_LABEL relabel=RELABEL)
 Remove and return the statements between first_stmt and last_stmt, inclusive.
virtual Statementgrab (Statement &el)
 The equivalent of calling grab( , RELABEL) on a single statement block.
virtual Statementgrab (int loc)
 Grab the locth statement.
virtual void modify (Statement &el, Statement *replacement)
 Replace 'el' with 'replacement'. 'el' is deleted.
virtual void modify (int loc, Statement *replacement)
 Replace the locth statement with replacement.
virtual Statementmodify_and_grab (Statement &el, Statement *replacement)
 Replace 'el' with 'replacement'. 'el' is returned.
Boolean contains_DO (Statement &st)
 Checks whether there is an inner DO in the given DO loop "st".
int number_of_stmts_in_DO (Statement &st)
 Returns the number of statements in the loop, excluding ENDDO, BLOCK_ENTRY, BLOCK_EXIT, FLOW_ENTRY, FLOW_EXIT, ENDIF, IMPLIED_GOTO, and LABEL stmts.
Iterator< Statementstmts_of_type (STMT_TYPE type) const
 Return a list of all statements of the given type The list will be in textual order of statements.
Iterator< Statementstmts_of_type (STMT_TYPE type1, STMT_TYPE type2, STMT_TYPE type3=UNDEFINED_STMT, STMT_TYPE type4=UNDEFINED_STMT, STMT_TYPE type5=UNDEFINED_STMT) const
 Return a list of all statements of any of the given types (up to five types may be specified for this method) The list will be in textual order of statements.
Iterator< Statementiterate_loop_body (const Statement *do_stmt) const
 Return a list of statement pointers to each statement in a DO loop, including the DO and ENDDO statements.
Iterator< Statementiterator (const Statement &first_stmt, const Statement &last_stmt) const
 Return an iterator for first_stmt to last_stmt, inclusive.
Iterator< Statementiterator () const
 Return an iterator for the entire StmtList.
const LabelDBlabels () const
LabelDBlabels ()
 Return a reference to the label database.
void relabel (const int value, const int new_value)
 Change the label of statement within the StmtList from value to new_value.
char * new_tag ()
 Return a new statement tag.
void retag (const char *old_tag, const char *new_tag)
 Change the statement tag of old_tag into new tag;.
int new_label (int target=0) const
 Return a new value for a LABEL statement.
void split_elseif (Statement &s)
 Change the program from ELSEIF to ELSE;IF.
void build_all_refs ()
 Call build_refs() to create the in/out/act _refs sets for each Statement in the ProgramUnit.
void create_directives ()
 Create the pre- & post- directives from the assertions.
void remove_directives ()
 Remove all pre- & post- directives.
void create_assertions ()
 Remove all pre- & post- directives and create Directive statements.
void create_flow_graph ()
 Erase the old flow graph and rebuild it.
void delete_flow_graph ()
 Erase the old flow graph.
void exchange_convert (VDL &vdl)
 Convert the Statement list into the exchange format.
void display (ostream &o) const
void write (ostream &o) const
virtual void print (ostream &o) const
 Methods to be used in conjuntion with ProgramUnit's display and write.
virtual int structures_OK () const
 StmtList consistant and correct?

Protected Member Functions

Statement_last_ref () const
 < For friend use only: equiv to last_ref, but not returning const

Friends

class ProgramUnit
class Program
class Directive
class StopStmt
class ReturnStmt

Classes

class  ElseIf_or_Else_Stmt

Detailed Description

Modification History: 97-09-24.0015 evansl WHAT: Added: 1) private _move_block_either 96-11-13.2120 evansl WHAT: Added: 1) ins_DO_END_after 2) ins_WHILE_after A class for Fortran Statement Lists.

Base General utility routines

See also:
StmtList.h

StmtList.cc

StmtList.h

Overview

This class contains the list of statements found in a ProgramUnit as well as all manipulation methods associated with statements. Access to the structure is strictly controlled to ensure that consistency is maintained.

Description

This class is derived from the List<Statement> class but has many additional methods which allow Fortran-specific manipulations. The methods defined here guarantee the syntactic correctness of the Fortran code at the conclusion of the method. Incorrect syntax will result in a run-time error. These methods also guarantee the correctness of the flow-graph.

Inserting Statements

The new statement to be inserted MUST have been created on the heap and MUST NOT already be part of another structure. If the statement is used elsewhere, use the clone method to create a new statement such as,

pgm.stmts().ins_before(old_stmt->clone(), ref_stmt);

where old_stmt->clone() will make a copy of old_stmt to be inserted.

The reference statement in any of these functions may be 0. If it is, and the function inserts a new statement after the reference statement, the new statement will be inserted at the beginning. Otherwise, if the function inserts a new statement before the reference statement, the new statement will be inserted at the end.

When inserting a single statement, that statement is not allowed to be part of a multiple statement construct, like an IF, ENDIF, DO, ENDDO, etc. statement, as that would result in incorrect syntax.

When inserting a block of statements the block must be completely well formed, i.e. all IF's, DO's, ENDDO's, etc. must contain the matching ENDTHEN/ELSE/ENDIF/DO/ENDDO, etc.

Deleting Statements

When deleting single statements, if the statement is ANY part of a block (such as IF, ELSE, ENDIF, DO, ENDDO, etc.) then that statement and all related parts are deleted out from around the inner statements. E.g., if the statement is an ELSE, then the related IF, ENDTHEN, ELSE, and END statements are all deleted, but all the statements within the THEN and ELSE clause are left intact!

If you want to delete all the inner statements as well, use block del().

When deleting a block of statements, the block must be well formed with respect to any block statements.

Note:
When a statement/set of related block-delimiting statements are deleted, they are deallocated completely from memory. If you wish to keep a copy of a statement that you are deleting, you must FIRST make a copy, then delete the original.

Currently, delete routines automatically deletes label statements. It is an error to delete a label which is the target of an existing statement.

Definition at line 128 of file StmtList.h.


Constructor & Destructor Documentation

StmtList::StmtList  ) 
 

... build initial control flow information for statements ... 13 Nov 95 Thomas R. Lawrence

Definition at line 116 of file StmtList.cc.

References first(), Statement::fix_flow(), ins_first(), ins_last(), last(), BinRep::put_set(), and register_instance().

Referenced by clone().

StmtList::StmtList const StmtList stmts  ) 
 

Definition at line 139 of file StmtList.cc.

References register_instance().

StmtList::~StmtList  )  [virtual]
 

... Remove pred and succ RefSets

Definition at line 191 of file StmtList.cc.

References delete_flow_graph(), and unregister_instance().


Member Function Documentation

Statement * StmtList::_last_ref  )  const [inline, protected]
 

< For friend use only: equiv to last_ref, but not returning const

Definition at line 578 of file StmtList.h.

References List< Statement >::last_ref().

StmtList & StmtList::operator= const StmtList s  ) 
 

... First remove any existing flow graph

... copy s's statements if any exist

Definition at line 154 of file StmtList.cc.

References _tag_count, clear(), BinRep::clone(), create_flow_graph(), delete_flow_graph(), DONT_RELABEL, and ins_after().

void StmtList::convert BinRep stmts,
ExprTable etable,
Symtab symtab,
const NamelistDict namelists,
const FormatDB formats,
const char *  initial_stmt
 

Convert a list of statements.

Put the results in StmtList in their correct order. A complete Expression table, Symbol table and format list are required. This procedure works in two passes, the first doing the translation and building up a Dictionary relating statement tags to pointers to the statement object. In this pass, all fields which should be pointers to other statements are set to DummyStatements with the tag of the statement to be linked. The second pass removes these dummy statements and replaces them with actual pointers.

... cout << initial_stmt << endl << flush; ... Remove any FLOW_ENTRY or FLOW_EXIT statements that may be in the list. ... First remove any existing flow graph

... This dictionary will be used to determine which statement corresponds ... to the \'next\' field of a given statement when the statements are ... ordered.

... first pass: convert all statements

... Add tag to dictionary (even flow entry and exit tags ... are needed for conversion pass)

... Second pass: ... order the statements and determine the largest value ... used as the integral suffix to statement tags and build the ... label database.

... determine maximum tag number

... If label statement, insert entry into label database

... This must have been the last statement

... Third pass: ... call setptrs on all statements to convert StmtPtrs ... to pointers to actual statements (had to do this as a third pass ... because as the list is built, successor statements wouldn't be on ... the list until this pass).

... This must have been the last statement

... statements, if there are statements. If there are not, ... then add them (this will be necessary, for instance, ... for BLOCK DATA program units)

... Fix up any pointers in the program blocks.

... Set lead, matching_if and matching_endif fields

Definition at line 386 of file StmtList.cc.

References Statement::build_refs(), clear(), Statement::convert(), delete_flow_graph(), ELSE_STMT, ELSEIF_STMT, ENDIF_STMT, Dictionary< T >::find_ref(), List< Statement >::first_ref(), FLOW_ENTRY_STMT, FLOW_EXIT_STMT, get_tag_num(), IMPLIED_GOTO_STMT, Dictionary< T >::ins(), ins_first(), ins_last(), List< T >::ins_last(), LABEL_STMT, List< Statement >::last_ref(), make_statement(), new_tag(), NextEntry::next_ref(), Statement::prev_ref(), BinRep::put_set(), Statement::stmt_class(), and BinRep::to_string().

Referenced by ProgramUnit::create_program_unit().

StmtList * StmtList::clone  )  const [virtual]
 

Definition at line 180 of file StmtList.cc.

References StmtList().

Referenced by listable_clone().

Listable * StmtList::listable_clone void   )  const [virtual]
 

Needed for Listable class.

Reimplemented from List< Statement >.

Definition at line 186 of file StmtList.cc.

References clone().

BinRep * StmtList::overflow_ref  )  const
 

Return the FLOW_ENTRY statement.

Definition at line 206 of file StmtList.cc.

const Statement & StmtList::first  )  const
 

Definition at line 212 of file StmtList.cc.

References List< Statement >::first_ref(), FLOW_ENTRY_STMT, and Statement::stmt_class().

Referenced by ProgramUnit::distribution_of(), and StmtList().

Statement & StmtList::first  ) 
 

Return the FLOW_EXIT statement.

Definition at line 223 of file StmtList.cc.

References List< Statement >::first_ref(), FLOW_ENTRY_STMT, and Statement::stmt_class().

const Statement & StmtList::last  )  const
 

Definition at line 234 of file StmtList.cc.

References FLOW_EXIT_STMT, List< Statement >::last_ref(), and Statement::stmt_class().

Referenced by StmtList().

Statement & StmtList::last  ) 
 

Definition at line 245 of file StmtList.cc.

References FLOW_EXIT_STMT, List< Statement >::last_ref(), and Statement::stmt_class().

const Statement * StmtList::find_ref const char *  stmt_tag  )  const [inline]
 

Definition at line 584 of file StmtList.h.

References Dictionary< T >::find_ref().

Referenced by IPCPProcData::add_constant_set(), IPCPProcData::add_maymods(), coalese_loop_pu(), normalize_loop_pu(), peel_first_loop_pu(), peel_last_loop_pu(), preroll_loop_pu(), reverse_loop_pu(), strip_horiz_loop_pu(), strip_vert_loop_pu(), and unroll_loop_pu().

Statement * StmtList::find_ref const char *  stmt_tag  )  [inline]
 

Search for a statement using the statement tag, such as "S1", "S2", "ST30", etc.

Return a pointer to the statement with this tag (return 0 if not found)

Definition at line 592 of file StmtList.h.

References Dictionary< T >::find_ref().

Iterator< Statement > StmtList::iterate_entry_points  )  const
 

Returns an iterator which loops through all entry points in the StmtList.

Currently this means that the statements it will loop through are either FlowEntryStmt's or EntryStmt's. If you desire to place code after each entry point in a statement list, use this iterator and insert after each statement it iterates through. In case you need more information about where to expect what kinds of statements using this iterator: Usually the iterator returned will iterate through only EntryStmt's, and they will follow lexical order. That means that if there is a PROGRAM, SUBROUTINE or FUNCTION statement, that will be the first entry returned. There is only one exception to this rule. It is legal Fortran to have a main program (i.e. a PROGRAM_PU_TYPE ProgramUnit) which has no PROGRAM statement. In this case, there will be no EntryStmt, and this iterator will iterate simply through the FlowEntryStmt.

Definition at line 2993 of file StmtList.cc.

References ENTRY_STMT, FLOW_ENTRY_STMT, stmts_of_type(), and Iterator< T >::valid().

Referenced by ProgramUnit::create_program_unit(), main(), process(), and InlineObject::remap_arg_names().

void StmtList::ins_before Statement new_stmt,
Statement ref_stmt
[virtual]
 

Insert new_stmt after ref_stmt.

... If label statement, insert entry into label database

... WARNING: this is a private member access!

Definition at line 1261 of file StmtList.cc.

References BaseMapRoot::clear(), Iterator< T >::current(), Statement::fix_flow(), List< T >::ins_before(), LABEL_STMT, List< Statement >::last_ref(), redundant_flow_ins(), and Iterator< T >::valid().

Referenced by add_dummy_global_assignments_at_calls(), ins_last(), SSAProgramUnit::insert_phi_stmt(), main(), and move_block_before().

void StmtList::ins_after Statement new_stmt,
Statement ref_stmt
[virtual]
 

Insert new_stmt after ref_stmt.

... If label statement, insert entry into label database

... WARNING: this is a private member access!

Definition at line 1299 of file StmtList.cc.

References Statement::build_refs(), RefSet< T >::clear(), ENDDO_STMT, List< T >::ins_after(), LABEL_STMT, Statement::modify_succ(), and redundant_flow_ins().

Referenced by add_dummy_eta_assignments_after_loops(), ProgramUnit::create_program_unit(), ins(), ins_first(), SSAProgramUnit::insert_phi_stmt(), main(), modify(), modify_and_grab(), move_saved_vars(), operator=(), and process().

void StmtList::ins_first Statement stmt  )  [virtual]
 

Insert stmt first in StmtList.

Definition at line 1508 of file StmtList.cc.

References FLOW_ENTRY_STMT, and ins_after().

Referenced by convert(), and StmtList().

void StmtList::ins_last Statement stmt  )  [virtual]
 

Insert stmt last in StmtList.

Definition at line 1517 of file StmtList.cc.

References FLOW_EXIT_STMT, and ins_before().

Referenced by convert(), and StmtList().

void StmtList::ins Statement new_stmt,
int  loc
[virtual]
 

Insert new_stmt at location loc, where 0 <= loc <= entries().

Definition at line 1526 of file StmtList.cc.

References ins_after().

void StmtList::ins_before List< Statement > *  stmts,
Statement ref_stmt
 

Insert the statement block, stmts, before ref_stmt and then delete stmts.

... We need to delete the list itself, even if empty

Definition at line 1334 of file StmtList.cc.

References List< Statement >::last_ref().

void StmtList::ins_after List< Statement > *  stmts,
Statement ref_stmt
 

Insert the statement block, stmts, after ref_stmt and then delete stmts.

... We need to delete the list itself, even if empty

Definition at line 1493 of file StmtList.cc.

References List< Statement >::first_ref().

Statement& StmtList::ins_IF_ELSE_after Expression cond_exp,
Statement ref_stmt = 0,
Statement last_of_then_clause = 0,
Statement last = 0
 

Insert a block IF-ELSE-ENDIF around a (possibly empty) set of statements with the conditional expression cond_exp and return the IfStmt.

The THEN block encloses all statements from the statement lexically following ref_stmt to last_of_then_clause (an empty THEN block is inserted if last_of_then_clause == 0 and if ref_stmt == 0 then the THEN block begins with the first statement) The ELSE-ENDIF part of the block encloses all statements from the next of last_of_then_clause (if it exists) to last (an empty ELSE_ENDIF part is inserted if last == 0).

Parameters:
cond_exp  conditional expr. of if-stmt
ref_stmt  IF after this stmt
last_of_then_clause  ELSE after this stmt

Statement& StmtList::ins_IF_after Expression cond_exp,
Statement ref_stmt = 0,
Statement last = 0
 

Same as ins_IF_ELSE_after(), except no ELSE part is inserted.

Parameters:
cond_exp  conditional expr of if-stmt
ref_stmt  IF after this stmt

Statement& StmtList::ins_ELSEIF_after Expression cond_expr,
Statement if_stmt,
Statement last_of_then_clause = 0
 

No additional ENDIF is added.

Add an ELSEIF clause to an IF-STMT and return the ElseIfStmt. If the last_of_then_clause is not used, the ELSEIF block is inserted immediately before the ENDIF of the existing IF block. The last_of_then_clause can be specified to place the ELSEIF around existing code, however it must point to a statement which is not part of the IF structure (i.e., not IMPLIED_GOTO, ENDIF, ELSEIF, etc....).

Parameters:
cond_expr  conditional expr of elseif-stmt
if_stmt  IF statement to augment

Statement& StmtList::ins_ELSE_after Statement if_stmt,
Statement last_of_then_clause = 0
 

No additional ENDIF is added.

Add an ELSE clause to an IF-STMT and return the ElseStmt. Inserts an ELSE block immediately before the ENDIF of an existing IF block by default, but last_of_then_clause can be specified as defined above.

Parameters:
if_stmt  IF statement to augment

Statement& StmtList::ins_DO_after Expression index_exp,
Expression init_exp,
Expression limit_exp,
Expression step_exp,
Statement ref_stmt = 0,
Statement last = 0
 

Insert a DO block around a set of statements with the specifications given by index_exp, init_exp, limit_exp and step_exp.

It will enclose all statements from the successor of ref_stmt to last (an empty DO loop is inserted if last == 0).

Parameters:
index_exp  DO stmt specifications
ref_stmt  DO after this stmt

Statement& StmtList::ins_WHILE_after Expression cond_exp,
Statement ref_stmt = 0,
Statement last = 0
 

Insert a WHILE block around a set of statements with the specifications given by cond_exp.

It will enclose all statements from the successor of ref_stmt to last (an empty DO loop is inserted if last == 0).

Parameters:
cond_exp  conditional_expression
ref_stmt  WHILE after this stmt

Statement& StmtList::ins_DO_END_after Statement do_stmt,
Statement ref_stmt = 0,
Statement last = 0
 

Insert a DO..ENDDO block around a set of statements with the specifications given by do_stmt(either DoStmt or WhileStmt).

It will enclose all statements from the successor of ref_stmt to last (an empty DO loop is inserted if last == 0).

Parameters:
do_stmt  conditional_expression
ref_stmt  DO after this stmt

Statement& StmtList::ins_BLOCK_after Statement ref_stmt = 0,
Statement last = 0
 

Insert a BLOCK_ENTRY/EXIT around a set of statements.

It will enclose all statements from the successor of ref_stmt to last (an empty BLOCK is inserted if last == 0).

Parameters:
ref_stmt  DO after this stmt

void StmtList::move_block_before Statement first_stmt,
Statement last_stmt,
Statement ref_stmt = 0
 

Move all statements from first_stmt to last_stmt, inclusive, to before ref_stmt.

The block must be well formed. As always, if ref_stmt == 0, the block is inserted at the end of the statement list

Definition at line 1946 of file StmtList.cc.

References DONT_RELABEL, grab(), and ins_before().

void StmtList::move_block_after Statement first_stmt,
Statement last_stmt,
Statement ref_stmt = 0
 

Move all statements from first_stmt to last_stmt, inclusive, to after ref_stmt (or beginging if !ref).

The block must be well formed.

void StmtList::move_before Statement stmt,
Statement ref_stmt = 0
 

Move statement to before ref_stmt.

The statement may not be DO, ENDDO, IF, ENDIF, or any other type of multi-line control structure statement.

void StmtList::move_after Statement stmt,
Statement ref_stmt = 0
 

Move statement to after ref_stmt.

stmt may not be any type of multi-line control structure statement.

void StmtList::del Statement s  )  [virtual]
 

Delete a single statement.

... delete WHILE and matching ENDDO

... delete DO and matching ENDDO

... can not delete an ENDIF_STMT or an IMPLIED_GOTO_STMT by itself ... it must be deleted by removing it's controling statement.

... Delete only the ELSE statement and fix up the links.

... don't need to reset block structure if this was done correctly

... Delete the entire IF-ELSEIF-ELSE-ENDIF and IMPLIED_GOTOs

... Will be set to the final end_if

... Continue following the _follow pointers ... This annoying case statement could be replaced by ... protected virtual follow methods

... end_if is now the ENDIF_STMT

... traverse if structure using if_stmt, deleting all parts ... (including IMPLIED_GOTO stmts).

... part to be deleted

... next part to be deleted

... delete IMPLIED_GOTO

... don't need to reset block structure if this was done correctly

... Fall through into default case

... Don't need to reset block structure

Reimplemented from List< Statement >.

Definition at line 2067 of file StmtList.cc.

References LabelDB::_grab_ref(), Statement::_tag, BLOCK_ENTRY_STMT, BLOCK_EXIT_STMT, Iterator< T >::current(), List< T >::del(), Dictionary< T >::del(), Statement::del_flow(), DO_STMT, ELSE_STMT, ELSEIF_STMT, ENDDO_STMT, ENDIF_STMT, Statement::follow_ref(), IF_STMT, IMPLIED_GOTO_STMT, RefSet< T >::ins(), LABEL_STMT, Statement::next_ref(), Statement::pred(), Listable::prev_ref(), Statement::prev_ref(), Statement::stmt_class(), RefSet< T >::valid(), Iterator< T >::valid(), and WHILE_STMT.

Referenced by SSAProgramUnit::convert_to_standard(), del(), modify(), remove_dummy_assignments(), split_multiple_entries(), and TranslateObject::translate_GSA_symbol_refs().

void StmtList::del RefSet< Statement > &  stmt_list  )  [virtual]
 

Delete a set of statements.

... Deleting this statement will also delete its _follow, ... so mark that statement as already deleted.

... It's hard to tell if we have already deleted this because ... of another deletion, so we will be careful.

... Don't do anything yet. We will take care of LABEL stmts ... in a second pass.

... A single statement so go ahead and delete it.

... After all of the GOTO's have been removed we can safely remove the ... LABELS which were the targets of the GOTO's

Definition at line 1986 of file StmtList.cc.

References LabelDB::_grab_ref(), BLOCK_ENTRY_STMT, BLOCK_EXIT_STMT, Iterator< T >::current(), Iterator< T >::current_valid(), del(), DO_STMT, ELSE_STMT, ELSEIF_STMT, ENDDO_STMT, ENDIF_STMT, Listable::fingerprint_ok(), Statement::follow_ref(), IF_STMT, IMPLIED_GOTO_STMT, LABEL_STMT, labels(), Iterator< T >::reset(), Statement::stmt_class(), Iterator< T >::valid(), Statement::value(), and WHILE_STMT.

void StmtList::del Statement first_stmt,
Statement last_stmt
 

Delete the block delimited by first_stmt and last_stmt.

... check if block is well-formed

Definition at line 2307 of file StmtList.cc.

References LabelDB::_grab_ref(), Statement::_tag, Iterator< T >::current(), Iterator< T >::current_valid(), List< T >::del(), Dictionary< T >::del(), RefSet< T >::del(), Statement::del_flow(), Statement::fix_flow(), RefSet< T >::ins(), iterator(), LABEL_STMT, RefSet< T >::member(), Statement::stmt_class(), Iterator< T >::valid(), and Statement::value().

void StmtList::clear  )  [virtual]
 

Delete the entire StmtList.

Reimplemented from List< Statement >.

Definition at line 2344 of file StmtList.cc.

References LabelDB::_clear(), BaseMapRoot::clear(), and List< T >::clear().

Referenced by convert(), and operator=().

List<Statement>* StmtList::copy const Statement first_stmt,
const Statement last_stmt,
RE_LABEL  relabel = RELABEL
const
 

Return a copied list of statements between first_stmt and last_stmt, inclusive.

All labels within the block are renumbered and, for all GOTO_type statements within the block, any targets which refer to labels within the block are changed to the new labels.

List<Statement>* StmtList::grab Statement first_stmt,
Statement last_stmt,
RE_LABEL  relabel = RELABEL
 

Remove and return the statements between first_stmt and last_stmt, inclusive.

All labels within the block are renumbered and, for all GOTO_type statements within the block, any targets which refer to labels within the block are changed to the new labels. The removed block must be well-formed.

Referenced by grab(), modify_and_grab(), and move_block_before().

Statement * StmtList::grab Statement el  )  [virtual]
 

The equivalent of calling grab( , RELABEL) on a single statement block.

Reimplemented from List< Statement >.

Definition at line 2829 of file StmtList.cc.

References List< T >::grab(), and RELABEL.

Statement * StmtList::grab int  loc  )  [virtual]
 

Grab the locth statement.

Reimplemented from List< Statement >.

Definition at line 2823 of file StmtList.cc.

References grab().

void StmtList::modify Statement el,
Statement replacement
[virtual]
 

Replace 'el' with 'replacement'. 'el' is deleted.

Reimplemented from List< Statement >.

Definition at line 2841 of file StmtList.cc.

References del(), and ins_after().

Referenced by modify().

void StmtList::modify int  loc,
Statement replacement
[virtual]
 

Replace the locth statement with replacement.

Reimplemented from List< Statement >.

Definition at line 2848 of file StmtList.cc.

References modify().

Statement * StmtList::modify_and_grab Statement el,
Statement replacement
[virtual]
 

Replace 'el' with 'replacement'. 'el' is returned.

Reimplemented from List< Statement >.

Definition at line 2854 of file StmtList.cc.

References grab(), and ins_after().

Boolean StmtList::contains_DO Statement st  ) 
 

Checks whether there is an inner DO in the given DO loop "st".

... Bypass the initial DO header

Definition at line 2923 of file StmtList.cc.

References Iterator< T >::current(), DO_STMT, False, iterate_loop_body(), Statement::stmt_class(), True, and Iterator< T >::valid().

int StmtList::number_of_stmts_in_DO Statement st  ) 
 

Returns the number of statements in the loop, excluding ENDDO, BLOCK_ENTRY, BLOCK_EXIT, FLOW_ENTRY, FLOW_EXIT, ENDIF, IMPLIED_GOTO, and LABEL stmts.

... Count the DO headers, but not the END_DOs

Definition at line 2945 of file StmtList.cc.

References BLOCK_ENTRY_STMT, BLOCK_EXIT_STMT, DO_STMT, ELSE_STMT, ENDDO_STMT, ENDIF_STMT, ENTRY_STMT, FLOW_ENTRY_STMT, FLOW_EXIT_STMT, IMPLIED_GOTO_STMT, iterate_loop_body(), LABEL_STMT, and Iterator< T >::valid().

Iterator< Statement > StmtList::stmts_of_type STMT_TYPE  type  )  const
 

Return a list of all statements of the given type The list will be in textual order of statements.

silvius: avoid memory leak, as class BaseIter does not STMT_TYPE *holdtype = new STMT_TYPE;

*holdtype = type;

Definition at line 2874 of file StmtList.cc.

References check_type().

Referenced by add_dummy_eta_assignments_after_loops(), ProgramUnit::create_program_unit(), iterate_entry_points(), main(), modify_dummy_eta_assignments_after_loops(), process(), ProgramUnit::routine_name_ref(), split_multiple_entries(), and ProgramUnit::write().

Iterator<Statement> StmtList::stmts_of_type STMT_TYPE  type1,
STMT_TYPE  type2,
STMT_TYPE  type3 = UNDEFINED_STMT,
STMT_TYPE  type4 = UNDEFINED_STMT,
STMT_TYPE  type5 = UNDEFINED_STMT
const
 

Return a list of all statements of any of the given types (up to five types may be specified for this method) The list will be in textual order of statements.

Iterator< Statement > StmtList::iterate_loop_body const Statement do_stmt  )  const
 

Return a list of statement pointers to each statement in a DO loop, including the DO and ENDDO statements.

... p_assert(do_stmt && (do_stmt->stmt_class() == DO_STMT), "not a loop");

Definition at line 2977 of file StmtList.cc.

References DO_STMT.

Referenced by add_dummy_eta_assignments_after_loops(), contains_DO(), and number_of_stmts_in_DO().

Iterator< Statement > StmtList::iterator const Statement first_stmt,
const Statement last_stmt
const
 

Return an iterator for first_stmt to last_stmt, inclusive.

Definition at line 3009 of file StmtList.cc.

Referenced by _find_call_sites(), _ipcp_build_jump_functions(), _ipcp_propagate_constants(), DDgraphTester::add(), DDgraphTester::add_dditerator(), add_dummy_eta_assignments_after_loops(), ProgramUnit::clean_workspace(), Program::compute_call_lists(), SSAProgramUnit::convert_to_SSA(), SSAProgramUnit::convert_to_standard(), generate_maymods(), main(), remove_maymod_assertions(), DDgraphTester::show_arcs(), split_multiple_entries(), SSAFullRangeDict::touch(), GSAFullRangeDict::touch(), TranslateObject::translate_GSA_symbol_refs(), and InlineObject::translate_symbol_refs().

Iterator< Statement > StmtList::iterator  )  const [inline]
 

Return an iterator for the entire StmtList.

Definition at line 600 of file StmtList.h.

References List< Statement >::first_ref(), and List< Statement >::last_ref().

Referenced by build_all_refs(), create_assertions(), create_directives(), create_flow_graph(), del(), delete_flow_graph(), display(), exchange_convert(), remove_directives(), and split_elseif().

const LabelDB & StmtList::labels  )  const [inline]
 

Definition at line 606 of file StmtList.h.

Referenced by del().

LabelDB & StmtList::labels  )  [inline]
 

Return a reference to the label database.

Definition at line 612 of file StmtList.h.

void StmtList::relabel const int  value,
const int  new_value
 

Change the label of statement within the StmtList from value to new_value.

Find existing label statement in data base

WARNING: this is a private member access!

Insert new label into database (failing if it is a duplicate)

Definition at line 3211 of file StmtList.cc.

References LabelDB::_grab_ref(), and LabelStmt::_value.

char * StmtList::new_tag  ) 
 

Return a new statement tag.

Definition at line 1168 of file StmtList.cc.

Referenced by add_dummy_eta_assignments_after_loops(), add_dummy_global_assignments_at_calls(), convert(), ProgramUnit::create_program_unit(), main(), move_saved_vars(), process(), retag(), and split_elseif().

void StmtList::retag const char *  old_tag,
const char *  new_tag
 

Change the statement tag of old_tag into new tag;.

... Find new tag number (ignoring exceptional tags)

... Update tag counter to prevent a duplicate tag assignment

... Change statement's existing tag

Definition at line 1178 of file StmtList.cc.

References Statement::_tag, Dictionary< T >::del(), Dictionary< T >::find_ref(), get_tag_num(), Dictionary< T >::ins(), and new_tag().

int StmtList::new_label int  target = 0  )  const
 

Return a new value for a LABEL statement.

void StmtList::split_elseif Statement s  ) 
 

Change the program from ELSEIF to ELSE;IF.

... What is the outermost ENDIF at the end of this block.

... What is the outmost IF at the begining of this block.

... What is the IF compoment immediately prior to the ELSEIF.

... do not delete predecessor

Definition at line 3331 of file StmtList.cc.

References ImpliedGotoStmt::_follow, ElseStmt::_follow, IfStmt::_follow, Statement::_tag, IfStmt::build_refs(), RefSet< T >::clear(), Iterator< T >::current(), List< T >::del(), Dictionary< T >::del(), ELSEIF_STMT, ENDIF_STMT, IfStmt::expr(), Statement::fix_flow(), Statement::follow_ref(), IF_STMT, Dictionary< T >::ins(), List< T >::ins_after(), List< T >::ins_before(), iterator(), Statement::lead_ref(), Statement::matching_if_ref(), Statement::modify_pred(), Statement::modify_succ(), new_tag(), Statement::prev_ref(), Iterator< T >::reset(), Statement::stmt_class(), and Iterator< T >::valid().

void StmtList::build_all_refs  ) 
 

Call build_refs() to create the in/out/act _refs sets for each Statement in the ProgramUnit.

Definition at line 3024 of file StmtList.cc.

References Statement::build_refs(), Iterator< T >::current(), iterator(), Iterator< T >::reset(), and Iterator< T >::valid().

void StmtList::create_directives  ) 
 

Create the pre- & post- directives from the assertions.

Definition at line 3140 of file StmtList.cc.

References Statement::assertions(), Iterator< T >::current(), List< T >::entries(), iterator(), switch_value(), and Iterator< T >::valid().

void StmtList::remove_directives  ) 
 

Remove all pre- & post- directives.

Definition at line 3154 of file StmtList.cc.

References List< T >::clear(), Iterator< T >::current(), iterator(), Statement::post_directives(), Statement::pre_directives(), and Iterator< T >::valid().

void StmtList::create_assertions  ) 
 

Remove all pre- & post- directives and create Directive statements.

Definition at line 3296 of file StmtList.cc.

References List< T >::clear(), Iterator< T >::current(), List< T >::entries(), List< Statement >::first_ref(), iterator(), List< Statement >::last_ref(), Statement::next_ref(), parse_directives(), Statement::post_directives(), Statement::pre_directives(), Statement::prev_ref(), and Iterator< T >::valid().

Referenced by Program::read().

void StmtList::create_flow_graph  ) 
 

Erase the old flow graph and rebuild it.

This might be useful when a program is read in from an external source.

... First remove any existing flow graph

... (Re)Build the flow graph

Definition at line 3038 of file StmtList.cc.

References Iterator< T >::current(), delete_flow_graph(), Statement::fix_flow(), iterator(), and Iterator< T >::valid().

Referenced by ProgramUnit::create_program_unit(), and operator=().

void StmtList::delete_flow_graph  ) 
 

Erase the old flow graph.

... WARNING: this is a private member access!

Definition at line 3056 of file StmtList.cc.

References RefSet< T >::clear(), Iterator< T >::current(), iterator(), Statement::modify_pred(), Statement::modify_succ(), and Iterator< T >::valid().

Referenced by convert(), create_flow_graph(), operator=(), and ~StmtList().

void StmtList::exchange_convert VDL vdl  ) 
 

Convert the Statement list into the exchange format.

Definition at line 3396 of file StmtList.cc.

References Iterator< T >::current(), Statement::exchange_convert(), List< Statement >::first_ref(), Set< T >::ins(), List< T >::ins_last(), iterator(), List< Statement >::last_ref(), BinRep::put_set(), BinRep::put_string(), BinRep::put_tuple(), BinRep::to_set(), and Iterator< T >::valid().

Referenced by ProgramUnit::exchange().

void StmtList::display ostream &  o  )  const
 

Definition at line 3166 of file StmtList.cc.

References iterator(), and Iterator< T >::valid().

Referenced by ProgramUnit::display(), print(), and structures_OK().

void StmtList::write ostream &  o  )  const
 

Definition at line 3173 of file StmtList.cc.

References print_stmt_list().

Referenced by ProgramUnit::write().

void StmtList::print ostream &  o  )  const [virtual]
 

Methods to be used in conjuntion with ProgramUnit's display and write.

Reimplemented from List< Statement >.

Definition at line 3183 of file StmtList.cc.

References display().

int StmtList::structures_OK  )  const [virtual]
 

StmtList consistant and correct?

Reimplemented from List< Statement >.

Definition at line 3189 of file StmtList.cc.

References display(), and Collection::structures_OK().

Referenced by ProgramUnit::structures_OK().


Friends And Related Function Documentation

friend class ProgramUnit [friend]
 

Definition at line 129 of file StmtList.h.

friend class Program [friend]
 

Definition at line 130 of file StmtList.h.

friend class Directive [friend]
 

Definition at line 131 of file StmtList.h.

friend class StopStmt [friend]
 

Definition at line 132 of file StmtList.h.

friend class ReturnStmt [friend]
 

Definition at line 133 of file StmtList.h.


The documentation for this class was generated from the following files:
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:08:21 2005