func_iter.h File Reference

Contains functions for dealing with functional unit iterators. More...

#include "defines.h"

Go to the source code of this file.

Data Structures

struct  func_iter_s

Typedefs

typedef struct func_iter_s func_iter

Functions

void func_iter_init (func_iter *fi, func_unit *funit, bool stmts, bool sigs)
 Initializes the values in the given structure.
statementfunc_iter_get_next_statement (func_iter *fi)
 Provides the next statement iterator in the functional unit statement iterator.
vsignalfunc_iter_get_next_signal (func_iter *fi)
 Provides the next signal in the functional unit signal iterator.
void func_iter_dealloc (func_iter *fi)
 Deallocates functional unit iterator.

Detailed Description

Contains functions for dealing with functional unit iterators.

Author:
Trevor Williams (phase1geo@gmail.com)
Date:
4/2/2007

Typedef Documentation

typedef struct func_iter_s func_iter

Structure for iterating through a functional unit and its unnamed scopes.


Function Documentation

void func_iter_dealloc ( func_iter fi  ) 

Deallocates functional unit iterator.

Deallocates all allocated memory for the given functional unit iterator.

Parameters:
fi Pointer to functional unit iterator to deallocate

References free_safe, PROFILE, PROFILE_END, func_iter_s::scopes, func_iter_s::sigs, and func_iter_s::sls.

Referenced by combination_collect(), combination_display_verbose(), combination_get_stats(), exclude_is_assert_excluded(), exclude_is_comb_excluded(), exclude_is_line_excluded(), exclude_is_toggle_excluded(), exclude_set_assert_exclude(), exclude_set_comb_exclude(), exclude_set_line_exclude(), exclude_set_toggle_exclude(), line_collect(), line_display_verbose(), line_get_stats(), memory_collect(), memory_display_verbose(), memory_get_coverage(), memory_get_stats(), ovl_collect(), ovl_display_verbose(), ovl_get_coverage(), ovl_get_funit_stats(), rank_gather_comp_cdd_cov(), toggle_collect(), toggle_display_verbose(), toggle_get_coverage(), and toggle_get_stats().

00335   { PROFILE(FUNC_ITER_DEALLOC);
00336 
00337   int i;  /* Loop iterator */
00338   
00339   if( fi != NULL ) {
00340 
00341     /* Deallocate statement iterators */
00342     if( fi->sls != NULL ) {
00343 
00344       /* Deallocate all statement iterators */
00345       for( i=0; i<fi->scopes; i++ ) {
00346         free_safe( fi->sls[i], sizeof( stmt_link ) );
00347       }
00348 
00349       /* Deallocate array of statement iterators */
00350       free_safe( fi->sls, (sizeof( stmt_link* ) * fi->scopes) );
00351 
00352     }
00353 
00354     /* Deallocate signal array */
00355     if( fi->sigs != NULL ) {
00356 
00357       /* Deallocate array of signals */
00358       free_safe( fi->sigs, (sizeof( sig_link* ) * fi->scopes) );
00359 
00360     }
00361 
00362   }
00363 
00364   PROFILE_END;
00365   
00366 }

vsignal* func_iter_get_next_signal ( func_iter fi  ) 

Provides the next signal in the functional unit signal iterator.

Returns:
Returns pointer to next signal in order (or NULL if there are no more signals in the given functional unit)
Parameters:
fi Pointer to functional unit iterator to use

References func_iter_s::curr_sigl, sig_link_s::next, PROFILE, PROFILE_END, func_iter_s::scopes, sig_link_s::sig, func_iter_s::sig_num, and func_iter_s::sigs.

Referenced by exclude_is_toggle_excluded(), exclude_set_toggle_exclude(), memory_collect(), memory_display_verbose(), memory_get_coverage(), memory_get_stats(), toggle_collect(), toggle_display_verbose(), toggle_get_coverage(), and toggle_get_stats().

00297   { PROFILE(FUNC_ITER_GET_NEXT_SIGNAL);
00298 
00299   vsignal* sig;
00300 
00301   assert( fi != NULL );
00302 
00303   if( fi->curr_sigl != NULL ) {
00304 
00305     sig           = fi->curr_sigl->sig;
00306     fi->curr_sigl = fi->curr_sigl->next;
00307 
00308   } else {
00309 
00310     do {
00311       fi->sig_num++;
00312     } while( (fi->sig_num < fi->scopes) && (fi->sigs[fi->sig_num] == NULL) );
00313 
00314     if( fi->sig_num < fi->scopes ) {
00315       sig           = fi->sigs[fi->sig_num]->sig;
00316       fi->curr_sigl = fi->sigs[fi->sig_num]->next;
00317     } else {
00318       sig           = NULL;
00319       fi->curr_sigl = NULL;
00320     }
00321 
00322   }
00323 
00324   PROFILE_END;
00325 
00326   return( sig );
00327 
00328 }

statement* func_iter_get_next_statement ( func_iter fi  ) 

Provides the next statement iterator in the functional unit statement iterator.

Returns:
Returns pointer to next statement in line order (or NULL if there are no more statements in the given functional unit)
Parameters:
fi Pointer to functional unit iterator to use

References func_iter_sort(), stmt_link_s::next, PROFILE, PROFILE_END, func_iter_s::sl_num, func_iter_s::sls, and stmt_link_s::stmt.

Referenced by combination_collect(), combination_display_verbose(), combination_get_stats(), exclude_is_assert_excluded(), exclude_is_comb_excluded(), exclude_is_line_excluded(), exclude_set_assert_exclude(), exclude_set_comb_exclude(), exclude_set_line_exclude(), line_collect(), line_display_verbose(), line_get_stats(), ovl_collect(), ovl_display_verbose(), ovl_get_coverage(), ovl_get_funit_stats(), and rank_gather_comp_cdd_cov().

00260   { PROFILE(FUNC_ITER_GET_NEXT_STATEMENT);
00261 
00262   statement* stmt;  /* Pointer to next statement in line order */
00263 
00264   assert( fi != NULL );
00265 
00266   if( fi->sl_num == 0 ) {
00267 
00268     stmt = NULL;
00269 
00270   } else {
00271 
00272     assert( fi->sls[0] != NULL );
00273 
00274     /* Get the statement at the head of the sorted list */
00275     stmt = fi->sls[0]->stmt;
00276 
00277     /* Go to the next statement in the current statement list */
00278     fi->sls[0] = fi->sls[0]->next;
00279 
00280     /* Resort */
00281     func_iter_sort( fi );
00282 
00283   }
00284 
00285   PROFILE_END;
00286 
00287   return( stmt );
00288 
00289 }

void func_iter_init ( func_iter fi,
func_unit funit,
bool  stmts,
bool  sigs 
)

Initializes the values in the given structure.

Initializes the contents of the functional unit iterator structure. This should be called before the functional unit iterator structure is populated with either statement iterator or signal information.

Parameters:
fi Pointer to functional unit iterator to initializes
funit Pointer to main functional unit to create iterator for (must be named)
stmts Set to TRUE if we want statements to be included in the iterator
sigs Set to TRUE if we want signals to be included in the iterator

References func_iter_s::curr_sigl, func_iter_add_sig_links(), func_iter_add_stmt_links(), func_iter_count_scopes(), malloc_safe, PROFILE, PROFILE_END, func_iter_s::scopes, func_iter_s::sig_num, func_iter_s::sigs, func_iter_s::sl_num, and func_iter_s::sls.

Referenced by combination_collect(), combination_display_verbose(), combination_get_stats(), exclude_is_assert_excluded(), exclude_is_comb_excluded(), exclude_is_line_excluded(), exclude_is_toggle_excluded(), exclude_set_assert_exclude(), exclude_set_comb_exclude(), exclude_set_line_exclude(), exclude_set_toggle_exclude(), line_collect(), line_display_verbose(), line_get_stats(), memory_collect(), memory_display_verbose(), memory_get_coverage(), memory_get_stats(), ovl_collect(), ovl_display_verbose(), ovl_get_coverage(), ovl_get_funit_stats(), rank_gather_comp_cdd_cov(), toggle_collect(), toggle_display_verbose(), toggle_get_coverage(), and toggle_get_stats().

00223   { PROFILE(FUNC_ITER_INIT);
00224 
00225   assert( fi != NULL );
00226   assert( funit != NULL );
00227 
00228   /* Count the number of scopes that are within the functional unit iterator */
00229   fi->scopes  = func_iter_count_scopes( funit );
00230   fi->sls     = NULL;
00231   fi->sigs    = NULL;
00232   fi->sig_num = 0;
00233 
00234   /* Add statement iterators */
00235   if( stmts ) {
00236     fi->sls    = (stmt_link**)malloc_safe( sizeof( stmt_link* ) * fi->scopes );
00237     fi->sl_num = 0;
00238     func_iter_add_stmt_links( fi, funit );
00239   }
00240 
00241   /* Add signal lists */
00242   if( sigs ) {
00243     fi->sigs      = (sig_link**)malloc_safe( sizeof( sig_link* ) * fi->scopes );
00244     fi->sig_num   = 0;
00245     func_iter_add_sig_links( fi, funit );
00246     fi->sig_num   = 0;
00247     fi->curr_sigl = fi->sigs[0];
00248   }
00249 
00250   PROFILE_END;
00251 
00252 }

Generated on Sun Nov 21 00:55:39 2010 for Covered by  doxygen 1.6.3