#include <stdlib.h>
#include <assert.h>
#include "defines.h"
#include "iter.h"
#include "profiler.h"
Functions | |
| void | stmt_iter_reset (stmt_iter *si, stmt_link *start) |
| Resets the specified statement iterator at start point. | |
| void | stmt_iter_copy (stmt_iter *si, stmt_iter *orig) |
| Copies the given statement iterator. | |
| void | stmt_iter_next (stmt_iter *si) |
| Moves to the next statement link. | |
| void | stmt_iter_reverse (stmt_iter *si) |
| Reverses iterator flow and advances to next statement link. | |
| void | stmt_iter_find_head (stmt_iter *si, bool skip) |
| Sets specified iterator to start with statement head for ordering. | |
| void | stmt_iter_get_next_in_order (stmt_iter *si) |
| Sets current iterator to next statement in order. | |
| void | stmt_iter_get_line_before (stmt_iter *si, int lnum) |
| Sets current iterator to statement just prior to the given line number. | |
|
||||||||||||
|
Copies the given statement iterator.
|
|
||||||||||||
|
Sets specified iterator to start with statement head for ordering.
00106 { PROFILE(STMT_ITER_FIND_HEAD);
00107
00108 while( (si->curr != NULL) && ((si->curr->stmt->suppl.part.head == 0) || skip) ) {
00109 if( si->curr->stmt->suppl.part.head == 1 ) {
00110 skip = FALSE;
00111 }
00112 stmt_iter_next( si );
00113 }
00114
00115 if( si->curr != NULL ) {
00116 stmt_iter_next( si );
00117 stmt_iter_reverse( si );
00118 }
00119
00120 PROFILE_END;
00121
00122 }
|
|
||||||||||||
|
Sets current iterator to statement just prior to the given line number.
00192 { PROFILE(STMT_ITER_GET_LINE_BEFORE);
00193
00194 if( si->curr != NULL ) {
00195
00196 if( si->curr->stmt->ppline < lnum ) {
00197 while( (si->curr != NULL) && (si->curr->stmt->ppline < lnum) ) {
00198 stmt_iter_next( si );
00199 }
00200 } else {
00201 while( (si->curr != NULL) && (si->curr->stmt->ppline > lnum) ) {
00202 stmt_iter_next( si );
00203 }
00204 }
00205
00206 }
00207
00208 PROFILE_END;
00209
00210 }
|
|
|
Sets current iterator to next statement in order.
00133 { PROFILE(STMT_ITER_GET_NEXT_IN_ORDER);
00134
00135 stmt_iter lsi; /* Points to lowest statement iterator */
00136 int lowest = 0x7fffffff; /* Line number of the lowest statement */
00137
00138 /* If the current statement is not a head, go back to the head */
00139 if( si->curr->stmt->suppl.part.head == 0 ) {
00140 stmt_iter_reverse( si );
00141 stmt_iter_find_head( si, FALSE );
00142 }
00143
00144 /* Capture the lowest statement iterator */
00145 lsi.curr = NULL;
00146 lsi.last = NULL;
00147
00148 /* Advance to the next statement */
00149 stmt_iter_next( si );
00150
00151 /* Search for a statement that has not been traversed yet within this statement block */
00152 while( (si->curr != NULL) && (si->curr->stmt->suppl.part.head == 0) ) {
00153 if( (si->curr->stmt->suppl.part.added == 0) &&
00154 (si->curr->stmt->ppline != 0) &&
00155 (si->curr->stmt->ppline < lowest) ) {
00156 lowest = si->curr->stmt->ppline;
00157 lsi.curr = si->curr;
00158 lsi.last = si->last;
00159 }
00160 stmt_iter_next( si );
00161 }
00162
00163 /*
00164 If we were unable to find an untraversed statement, go to the next statement block,
00165 resetting the added supplemental value as we go.
00166 */
00167 if( (lsi.curr == NULL) && (lsi.last == NULL) ) {
00168 stmt_iter_reverse( si );
00169 while( (si->curr != NULL) && (si->curr->stmt->suppl.part.head == 0) ) {
00170 si->curr->stmt->suppl.part.added = 0;
00171 stmt_iter_next( si );
00172 }
00173 stmt_iter_find_head( si, TRUE );
00174 } else {
00175 si->curr = lsi.curr;
00176 si->last = lsi.last;
00177 si->curr->stmt->suppl.part.added = 1;
00178 }
00179
00180 PROFILE_END;
00181
00182 }
|
|
|
Moves to the next statement link.
|
|
||||||||||||
|
Resets the specified statement iterator at start point.
00036 { PROFILE(STMT_ITER_RESET);
00037
00038 si->curr = start;
00039 si->last = NULL;
00040
00041 PROFILE_END;
00042
00043 }
|
|
|
Reverses iterator flow and advances to next statement link.
|
1.3.4