next up previous
Next: simplify()ing the rhs Up: Code Examples Previous: Code Examples

instrumenter

	// ------------------------------------------------------------
	// Place the "call exit_intervals (program.sum) " at all exits:
	//
	// ----------------------------------
	// Make an iterator over all exit stmts
	// ----------------------------------
		
	for (Iterator<Statement> exit_stmts = 
	     pgm.stmts().stmts_of_type(RETURN_STMT, STOP_STMT);
	     exit_stmts.valid();
	     ++exit_stmts) {
	    Statement *call_exit;
	    Statement &this_exit = exit_stmts.current();

	    if (_mode == TIMING) {
		if (first_exit) {
		    call_exit =
			new CallStmt(pgm.stmts().new_tag(),
				     exit_intervals,
				     comma(constant(_fortran_sumfile)));
		    first_exit = 0;
		}
		else {
		    call_exit =
			new CallStmt(pgm.stmts().new_tag(),
				     exit_intervals->clone(),
				     comma(constant(_fortran_sumfile)));
		}
	    }    //  end if mode == TIMING
	    else {  // mode == TRIPCOUNT
		if (first_exit) {
		    call_exit =
			new CallStmt(pgm.stmts().new_tag(),
				     exit_intervals,
				     comma(constant(_fortran_tcntfile)));
		    first_exit = 0;
		}
		else {
		    call_exit =
			new CallStmt(pgm.stmts().new_tag(),
				     exit_intervals->clone(),
				     comma(constant(_fortran_tcntfile)));
		}
	    }  //  end else  [mode == TRIPCOUNT]
	    // Add before the exit		    
	    pgm.stmts().ins_before(call_exit, &this_exit);
	}
    }



Jay Hoeflinger
Mon Apr 21 11:52:18 CDT 1997