#include "defines.h"
Go to the source code of this file.
Functions | |
| str_link * | str_link_add (char *str, str_link **head, str_link **tail) |
| Adds specified string to str_link element at the end of the list. | |
| void | stmt_link_add_head (statement *stmt, stmt_link **head, stmt_link **tail) |
| Adds specified statement to stmt_link element at the beginning of the list. | |
| void | stmt_link_add_tail (statement *stmt, stmt_link **head, stmt_link **tail) |
| Adds specified statement to stmt_link element at the end of the list. | |
| void | stmt_link_merge (stmt_link **base_head, stmt_link **base_tail, stmt_link *other_head, stmt_link *other_tail) |
| Joins two statement links together. | |
| void | exp_link_add (expression *expr, exp_link **head, exp_link **tail) |
| Adds specified expression to exp_link element at the end of the list. | |
| void | sig_link_add (vsignal *sig, sig_link **head, sig_link **tail) |
| Adds specified signal to sig_link element at the end of the list. | |
| void | fsm_link_add (fsm *table, fsm_link **head, fsm_link **tail) |
| Adds specified FSM to fsm_link element at the end of the list. | |
| void | funit_link_add (func_unit *funit, funit_link **head, funit_link **tail) |
| Adds specified functional unit to funit_link element at the end of the list. | |
| void | gitem_link_add (gen_item *gi, gitem_link **head, gitem_link **tail) |
| Adds specified generate item to the end of specified gitem list. | |
| inst_link * | inst_link_add (funit_inst *inst, inst_link **head, inst_link **tail) |
| Adds specified functional unit instance to inst_link element at the end of the list. | |
| void | str_link_display (str_link *head) |
| Displays specified string list to standard output. | |
| void | stmt_link_display (stmt_link *head) |
| Displays specified statement list to standard output. | |
| void | exp_link_display (exp_link *head) |
| Displays specified expression list to standard output. | |
| void | sig_link_display (sig_link *head) |
| Displays specified signal list to standard output. | |
| void | funit_link_display (funit_link *head) |
| Displays specified functional unit list to standard output. | |
| void | gitem_link_display (gitem_link *head) |
| Displays specified generate item list to standard output. | |
| void | inst_link_display (inst_link *head) |
| Displays specified instance list to standard output. | |
| str_link * | str_link_find (const char *value, str_link *head) |
| Finds specified string in the given str_link list. | |
| stmt_link * | stmt_link_find (int id, stmt_link *head) |
| Finds specified statement in the given stmt_link list. | |
| exp_link * | exp_link_find (int id, exp_link *head) |
| Finds specified expression in the given exp_link list. | |
| sig_link * | sig_link_find (const char *name, sig_link *head) |
| Finds specified signal in given sig_link list. | |
| fsm_link * | fsm_link_find (const char *name, fsm_link *head) |
| Finds specified FSM structure in fsm_link list. | |
| funit_link * | funit_link_find (const char *name, int type, funit_link *head) |
| Finds specified functional unit in given funit_link list. | |
| gitem_link * | gitem_link_find (gen_item *gi, gitem_link *head) |
| Finds specified generate item in given gitem_link list. | |
| funit_inst * | inst_link_find_by_scope (char *scope, inst_link *head) |
| Finds specified functional unit instance in given inst_link list. | |
| funit_inst * | inst_link_find_by_funit (const func_unit *funit, inst_link *head, int *ignore) |
| Finds specified functional unit instance in given inst_link list. | |
| void | str_link_remove (char *str, str_link **head, str_link **tail) |
| Searches for and removes specified string link from list. | |
| void | exp_link_remove (expression *exp, exp_link **head, exp_link **tail, bool recursive) |
| Searches for and removes specified expression link from list. | |
| void | gitem_link_remove (gen_item *gi, gitem_link **head, gitem_link **tail) |
| Searches for and removes specified generate item link from list. | |
| void | funit_link_remove (func_unit *funit, funit_link **head, funit_link **tail, bool rm_funit) |
| Searches for and removes specified functional unit link from list. | |
| void | str_link_delete_list (str_link *head) |
| Deletes entire list specified by head pointer. | |
| void | stmt_link_unlink (statement *stmt, stmt_link **head, stmt_link **tail) |
| Unlinks the stmt_link specified by the specified statement. | |
| void | stmt_link_delete_list (stmt_link *head) |
| Deletes entire list specified by head pointer. | |
| void | exp_link_delete_list (exp_link *head, bool del_exp) |
| Deletes entire list specified by head pointer. | |
| void | sig_link_delete_list (sig_link *head, bool del_sig) |
| Deletes entire list specified by head pointer. | |
| void | fsm_link_delete_list (fsm_link *head) |
| Deletes entire list specified by head pointer. | |
| void | funit_link_delete_list (funit_link **head, funit_link **tail, bool rm_funit) |
| Deletes entire list specified by head pointer. | |
| void | gitem_link_delete_list (gitem_link *head, bool rm_elems) |
| Deletes entire list specified by head pointer. | |
| void | inst_link_delete_list (inst_link *head) |
| Deletes entire list specified by head pointer. | |
|
||||||||||||||||
|
Adds specified expression to exp_link element at the end of the list. Creates a new exp_link element with the value specified for expr. Sets next pointer of element to NULL, sets the tail element to point to the new element and sets the tail value to the new element.
00237 { PROFILE(EXP_LINK_ADD);
00238
00239 exp_link* tmp; /* Temporary pointer to newly created exp_link element */
00240
00241 tmp = (exp_link*)malloc_safe( sizeof( exp_link ) );
00242
00243 tmp->exp = expr;
00244 tmp->next = NULL;
00245
00246 if( *head == NULL ) {
00247 *head = *tail = tmp;
00248 } else {
00249 (*tail)->next = tmp;
00250 *tail = tmp;
00251 }
00252
00253 PROFILE_END;
00254
00255 }
|
|
||||||||||||
|
Deletes entire list specified by head pointer. Deletes each element of the specified list.
01114 { PROFILE(EXP_LINK_DELETE_LIST);
01115
01116 exp_link* tmp; /* Pointer to current expression link to remove */
01117
01118 while( head != NULL ) {
01119
01120 tmp = head;
01121 head = head->next;
01122
01123 /* Deallocate expression */
01124 if( del_exp ) {
01125 expression_dealloc( tmp->exp, TRUE );
01126 tmp->exp = NULL;
01127 }
01128
01129 /* Deallocate exp_link element itself */
01130 free_safe( tmp, sizeof( exp_link ) );
01131
01132 }
01133
01134 PROFILE_END;
01135
01136 }
|
|
|
Displays specified expression list to standard output. Displays the string contents of the exp_link list pointed to by head to standard output. This function is mainly used for debugging purposes.
00460 {
00461
00462 exp_link* curr; /* Pointer to current expression link */
00463
00464 printf( "Expression list:\n" );
00465
00466 curr = head;
00467 while( curr != NULL ) {
00468 printf( " id: %d, op: %s, line: %d\n", curr->exp->id, expression_string_op( curr->exp->op ), curr->exp->line );
00469 curr = curr->next;
00470 }
00471
00472 }
|
|
||||||||||||
|
Finds specified expression in the given exp_link list.
|
|
||||||||||||||||||||
|
Searches for and removes specified expression link from list. Searches specified list for expression that matches the specified expression. If a match is found, remove it from the list and deallocate the link memory.
00846 { PROFILE(EXP_LINK_REMOVE);
00847
00848 exp_link* curr; /* Pointer to current expression link */
00849 exp_link* last; /* Pointer to last expression link */
00850
00851 assert( exp != NULL );
00852
00853 /* If recursive mode is set, remove children first */
00854 if( recursive ) {
00855 if( (exp->left != NULL) && EXPR_LEFT_DEALLOCABLE( exp ) ) {
00856 exp_link_remove( exp->left, head, tail, recursive );
00857 }
00858 if( (exp->right != NULL) && EXPR_RIGHT_DEALLOCABLE( exp ) ) {
00859 exp_link_remove( exp->right, head, tail, recursive );
00860 }
00861 }
00862
00863 curr = *head;
00864 last = NULL;
00865 while( (curr != NULL) && (curr->exp->id != exp->id) ) {
00866 last = curr;
00867 curr = curr->next;
00868 if( curr != NULL ) {
00869 assert( curr->exp != NULL );
00870 }
00871 }
00872
00873 if( curr != NULL ) {
00874
00875 if( (curr == *head) && (curr == *tail) ) {
00876 *head = *tail = NULL;
00877 } else if( curr == *head ) {
00878 *head = curr->next;
00879 } else if( curr == *tail ) {
00880 last->next = NULL;
00881 *tail = last;
00882 } else {
00883 last->next = curr->next;
00884 }
00885
00886 free_safe( curr, sizeof( exp_link ) );
00887
00888 }
00889
00890 /* If recursive flag set, remove expression as well */
00891 if( recursive ) {
00892 expression_dealloc( exp, TRUE );
00893 }
00894
00895 PROFILE_END;
00896
00897 }
|
|
||||||||||||||||
|
Adds specified FSM to fsm_link element at the end of the list. Creates a new fsm_link element with the value specified for table. Sets next pointer of element to NULL, sets the tail element to point to the new element and sets the tail value to the new element.
00295 { PROFILE(FSM_LINK_ADD);
00296
00297 fsm_link* tmp; /* Temporary pointer to newly created fsm_link element */
00298
00299 tmp = (fsm_link*)malloc_safe( sizeof( fsm_link ) );
00300
00301 tmp->table = table;
00302 tmp->next = NULL;
00303
00304 if( *head == NULL ) {
00305 *head = *tail = tmp;
00306 } else {
00307 (*tail)->next = tmp;
00308 *tail = tmp;
00309 }
00310
00311 PROFILE_END;
00312
00313 }
|
|
|
Deletes entire list specified by head pointer. Deletes each element of the specified list.
01173 { PROFILE(FSM_LINK_DELETE_LIST);
01174
01175 fsm_link* tmp; /* Temporary pointer to current link in list */
01176
01177 while( head != NULL ) {
01178
01179 tmp = head;
01180 head = tmp->next;
01181
01182 /* Deallocate FSM structure */
01183 fsm_dealloc( tmp->table );
01184 tmp->table = NULL;
01185
01186 /* Deallocate fsm_link element itself */
01187 free_safe( tmp, sizeof( fsm_link ) );
01188
01189 }
01190
01191 PROFILE_END;
01192
01193 }
|
|
||||||||||||
|
Finds specified FSM structure in fsm_link list.
00668 { PROFILE(FSM_LINK_FIND);
00669
00670 fsm_link* curr; /* Pointer to current fsm_link element */
00671
00672 curr = head;
00673 while( (curr != NULL) && (strcmp( curr->table->name, name ) != 0) ) {
00674 curr = curr->next;
00675 }
00676
00677 PROFILE_END;
00678
00679 return( curr );
00680
00681 }
|
|
||||||||||||||||
|
Adds specified functional unit to funit_link element at the end of the list. Creates a new funit_link element with the value specified for functional unit. Sets next pointer of element to NULL, sets the tail element to point to the new element and sets the tail value to the new element.
00324 { PROFILE(FUNIT_LINK_ADD);
00325
00326 funit_link* tmp; /* Temporary pointer to newly created funit_link element */
00327
00328 tmp = (funit_link*)malloc_safe( sizeof( funit_link ) );
00329
00330 tmp->funit = funit;
00331 tmp->next = NULL;
00332
00333 if( *head == NULL ) {
00334 *head = *tail = tmp;
00335 } else {
00336 (*tail)->next = tmp;
00337 *tail = tmp;
00338 }
00339
00340 PROFILE_END;
00341
00342 }
|
|
||||||||||||||||
|
Deletes entire list specified by head pointer. Deletes each element of the specified list.
01202 { PROFILE(FUNIT_LINK_DELETE_LIST);
01203
01204 funit_link* tmp; /* Temporary pointer to current link in list */
01205
01206 while( *head != NULL ) {
01207
01208 tmp = *head;
01209 *head = tmp->next;
01210
01211 /* Deallocate signal */
01212 if( rm_funit ) {
01213 funit_dealloc( tmp->funit );
01214 tmp->funit = NULL;
01215 }
01216
01217 /* Deallocate funit_link element itself */
01218 free_safe( tmp, sizeof( funit_link ) );
01219
01220 }
01221
01222 *tail = NULL;
01223
01224 PROFILE_END;
01225
01226 }
|
|
|
Displays specified functional unit list to standard output. Displays the string contents of the funit_link list pointed to by head to standard output. This function is mainly used for debugging purposes.
00500 {
00501
00502 funit_link* curr; /* Pointer to current funit_link link to display */
00503
00504 printf( "Functional unit list:\n" );
00505
00506 curr = head;
00507 while( curr != NULL ) {
00508 printf( " name: %s, type: %s\n", obf_funit( curr->funit->name ), get_funit_type( curr->funit->type ) );
00509 curr = curr->next;
00510 }
00511
00512 }
|
|
||||||||||||||||
|
Finds specified functional unit in given funit_link list.
00694 { PROFILE(FUNIT_LINK_FIND);
00695
00696 funit_link* curr; /* Pointer to current funit_link link */
00697
00698 curr = head;
00699 while( (curr != NULL) && (!scope_compare( curr->funit->name, name ) || (curr->funit->type != type)) ) {
00700 curr = curr->next;
00701 }
00702
00703 PROFILE_END;
00704
00705 return( curr );
00706
00707 }
|
|
||||||||||||||||||||
|
Searches for and removes specified functional unit link from list. Searches for and removes the given functional unit from the given list and adjusts list as necessary.
00950 { PROFILE(FUNIT_LINK_REMOVE);
00951
00952 funit_link* curr = *head; /* Pointer to current functional unit link */
00953 funit_link* last = NULL; /* Pointer to last functional unit link traversed */
00954
00955 assert( funit != NULL );
00956
00957 /* Search for matching functional unit */
00958 while( (curr != NULL) && (curr->funit != funit) ) {
00959 last = curr;
00960 curr = curr->next;
00961 }
00962
00963 if( curr != NULL ) {
00964
00965 /* Remove the functional unit from the list */
00966 if( (curr == *head) && (curr == *tail) ) {
00967 *head = *tail = NULL;
00968 } else if( curr == *head ) {
00969 *head = curr->next;
00970 } else if( curr == *tail ) {
00971 last->next = NULL;
00972 *tail = last;
00973 } else {
00974 last->next = curr->next;
00975 }
00976
00977 /* Remove the functional unit, if necessary */
00978 if( rm_funit ) {
00979 funit_dealloc( curr->funit );
00980 }
00981
00982 /* Deallocate the link */
00983 free_safe( curr, sizeof( funit_link ) );
00984
00985 }
00986
00987 PROFILE_END;
00988
00989 }
|
|
||||||||||||||||
|
Adds specified generate item to the end of specified gitem list. Creates a new gitem_link element with the value specified for generate item. Sets next pointer of element to NULL, sets the tail element to point to the new element and sets the tail value to the new element.
00354 { PROFILE(GITEM_LINK_ADD);
00355
00356 gitem_link* tmp; /* Temporary pointer to newly created gitem_link element */
00357
00358 tmp = (gitem_link*)malloc_safe( sizeof( gitem_link ) );
00359
00360 tmp->gi = gi;
00361 tmp->next = NULL;
00362
00363 if( *head == NULL ) {
00364 *head = *tail = tmp;
00365 } else {
00366 (*tail)->next = tmp;
00367 *tail = tmp;
00368 }
00369
00370 PROFILE_END;
00371
00372 }
|
|
||||||||||||
|
Deletes entire list specified by head pointer. Deletes each element of the specified list.
01235 { PROFILE(GITEM_LINK_DELETE_LIST);
01236
01237 gitem_link* tmp; /* Temporary pointer to current link in list */
01238
01239 while( head != NULL ) {
01240
01241 tmp = head;
01242 head = tmp->next;
01243
01244 /* Deallocate generate item */
01245 gen_item_dealloc( tmp->gi, rm_elems );
01246
01247 /* Deallocate gitem_link element itself */
01248 free_safe( tmp, sizeof( gitem_link ) );
01249
01250 }
01251
01252 PROFILE_END;
01253
01254 }
|
|
|
Displays specified generate item list to standard output. Displays the contents of the gitem_link list pointed to by head to standard output. This function is mainly used for debugging purposes.
00521 {
00522
00523 gitem_link* curr; /* Pointer to current gitem_link to display */
00524
00525 printf( "Generate item list:\n" );
00526
00527 curr = head;
00528 while( curr != NULL ) {
00529 gen_item_display_block( curr->gi );
00530 curr = curr->next;
00531 }
00532
00533 }
|
|
||||||||||||
|
Finds specified generate item in given gitem_link list.
00720 { PROFILE(GITEM_LINK_FIND);
00721
00722 gitem_link* curr; /* Pointer to current gitem_link */
00723
00724 curr = head;
00725 while( (curr != NULL) && (gen_item_find( curr->gi, gi ) == NULL) ) {
00726 curr = curr->next;
00727 }
00728
00729 PROFILE_END;
00730
00731 return( curr );
00732
00733 }
|
|
||||||||||||||||
|
Searches for and removes specified generate item link from list. Deletes specified generate item from the given list, adjusting the head and tail pointers accordingly.
00908 { PROFILE(GITEM_LINK_REMOVE);
00909
00910 gitem_link* gil; /* Pointer to current generate item link */
00911 gitem_link* last; /* Pointer to last generate item link traversed */
00912
00913 gil = *head;
00914 while( (gil != NULL) && (gil->gi != gi) ) {
00915 last = gil;
00916 gil = gil->next;
00917 }
00918
00919 if( gil != NULL ) {
00920
00921 if( (gil == *head) && (gil == *tail) ) {
00922 *head = *tail = NULL;
00923 } else if( gil == *head ) {
00924 *head = gil->next;
00925 } else if( gil == *tail ) {
00926 last->next = NULL;
00927 *tail = last;
00928 } else {
00929 last->next = gil->next;
00930 }
00931
00932 free_safe( gil, sizeof( gitem_link ) );
00933
00934 }
00935
00936 PROFILE_END;
00937
00938 }
|
|
||||||||||||||||
|
Adds specified functional unit instance to inst_link element at the end of the list.
00386 { PROFILE(INST_LINK_ADD);
00387
00388 inst_link* tmp; /* Temporary pointer to newly created inst_link element */
00389
00390 tmp = (inst_link*)malloc_safe( sizeof( inst_link ) );
00391
00392 tmp->inst = inst;
00393 tmp->ignore = FALSE;
00394 tmp->base = FALSE;
00395 tmp->next = NULL;
00396
00397 if( *head == NULL ) {
00398 *head = *tail = tmp;
00399 } else {
00400 (*tail)->next = tmp;
00401 *tail = tmp;
00402 }
00403
00404 PROFILE_END;
00405
00406 return( tmp );
00407
00408 }
|
|
|
Deletes entire list specified by head pointer. Deletes each element of the specified list.
01262 { PROFILE(INST_LINK_DELETE_LIST);
01263
01264 inst_link* tmp; /* Temporary pointer to current link in list */
01265
01266 while( head != NULL ) {
01267
01268 tmp = head;
01269 head = tmp->next;
01270
01271 /* Deallocate instance item */
01272 instance_dealloc( tmp->inst, tmp->inst->name );
01273
01274 /* Deallocate inst_link element itself */
01275 free_safe( tmp, sizeof( inst_link ) );
01276
01277 }
01278
01279 PROFILE_END;
01280
01281 }
|
|
|
Displays specified instance list to standard output. Displays the contents of the inst_link list pointed to by head to standard output. This function is mainly used for debugging purposes.
00542 {
00543
00544 inst_link* curr; /* Pointer to current inst_link to display */
00545
00546 printf( "Instance list:\n" );
00547
00548 curr = head;
00549 while( curr != NULL ) {
00550 instance_display_tree( curr->inst );
00551 curr = curr->next;
00552 }
00553
00554 }
|
|
||||||||||||||||
|
Finds specified functional unit instance in given inst_link list.
00773 { PROFILE(INST_LINK_FIND_BY_FUNIT);
00774
00775 inst_link* curr; /* Pointer to current inst_link */
00776 funit_inst* inst = NULL; /* Pointer to found instance */
00777
00778 curr = head;
00779 while( (curr != NULL) && ((inst = instance_find_by_funit( curr->inst, funit, ignore )) == NULL) ) {
00780 curr = curr->next;
00781 }
00782
00783 PROFILE_END;
00784
00785 return( inst );
00786
00787 }
|
|
||||||||||||
|
Finds specified functional unit instance in given inst_link list.
00746 { PROFILE(INST_LINK_FIND_BY_SCOPE);
00747
00748 inst_link* curr; /* Pointer to current inst_link */
00749 funit_inst* inst = NULL; /* Pointer to found instance */
00750
00751 curr = head;
00752 while( (curr != NULL) && ((inst = instance_find_scope( curr->inst, scope, TRUE )) == NULL) ) {
00753 curr = curr->next;
00754 }
00755
00756 PROFILE_END;
00757
00758 return( inst );
00759
00760 }
|
|
||||||||||||||||
|
Adds specified signal to sig_link element at the end of the list. Creates a new sig_link element with the value specified for sig. Sets next pointer of element to NULL, sets the tail element to point to the new element and sets the tail value to the new element.
00266 { PROFILE(SIG_LINK_ADD);
00267
00268 sig_link* tmp; /* Temporary pointer to newly created sig_link element */
00269
00270 tmp = (sig_link*)malloc_safe( sizeof( sig_link ) );
00271
00272 tmp->sig = sig;
00273 tmp->next = NULL;
00274
00275 if( *head == NULL ) {
00276 *head = *tail = tmp;
00277 } else {
00278 (*tail)->next = tmp;
00279 *tail = tmp;
00280 }
00281
00282 PROFILE_END;
00283
00284 }
|
|
||||||||||||
|
Deletes entire list specified by head pointer. Deletes each element of the specified list.
01144 { PROFILE(SIG_LINK_DELETE_LIST);
01145
01146 sig_link* tmp; /* Temporary pointer to current link in list */
01147
01148 while( head != NULL ) {
01149
01150 tmp = head;
01151 head = tmp->next;
01152
01153 /* Deallocate signal */
01154 if( del_sig ) {
01155 vsignal_dealloc( tmp->sig );
01156 tmp->sig = NULL;
01157 }
01158
01159 /* Deallocate sig_link element itself */
01160 free_safe( tmp, sizeof( sig_link ) );
01161
01162 }
01163
01164 PROFILE_END;
01165
01166 }
|
|
|
Displays specified signal list to standard output. Displays the string contents of the sig_link list pointed to by head to standard output. This function is mainly used for debugging purposes.
|
|
||||||||||||
|
Finds specified signal in given sig_link list.
00643 { PROFILE(SIG_LINK_FIND);
00644
00645 sig_link* curr; /* Pointer to current sig_link link */
00646
00647 curr = head;
00648 while( (curr != NULL) && !scope_compare( curr->sig->name, name ) ) {
00649 curr = curr->next;
00650 }
00651
00652 PROFILE_END;
00653
00654 return( curr );
00655
00656 }
|
|
||||||||||||||||
|
Adds specified statement to stmt_link element at the beginning of the list. Creates a new stmt_link element with the value specified for stmt. Sets next pointer of element to head, sets the head element to point to the new element and (possibly) sets the tail value to the new element.
00094 { PROFILE(STMT_LINK_ADD_HEAD);
00095
00096 stmt_link* tmp; /* Temporary pointer to newly created stmt_link element */
00097
00098 tmp = (stmt_link*)malloc_safe( sizeof( stmt_link ) );
00099
00100 tmp->stmt = stmt;
00101
00102 if( *head == NULL ) {
00103 *head = *tail = tmp;
00104 tmp->ptr = NULL;
00105 } else {
00106 tmp->ptr = (stmt_link*)((long int)(*head) ^ (long int)NULL);
00107 (*head)->ptr = (stmt_link*)((long int)((*head)->ptr) ^ (long int)tmp);
00108 *head = tmp;
00109 }
00110
00111 PROFILE_END;
00112
00113 }
|
|
||||||||||||||||
|
Adds specified statement to stmt_link element at the end of the list. Creates a new stmt_link element with the value specified for stmt. Sets next pointer of element to NULL and sets the tail value to the new element.
00123 { PROFILE(STMT_LINK_ADD_TAIL);
00124
00125 stmt_link* tmp; /* Temporary pointer to newly created stmt_link element */
00126
00127 tmp = (stmt_link*)malloc_safe( sizeof( stmt_link ) );
00128
00129 tmp->stmt = stmt;
00130
00131 if( *head == NULL ) {
00132 *head = *tail = tmp;
00133 tmp->ptr = NULL;
00134 } else {
00135 tmp->ptr = (stmt_link*)((long int)(*tail) ^ (long int)NULL);
00136 (*tail)->ptr = (stmt_link*)((long int)((*tail)->ptr) ^ (long int)tmp);
00137 *tail = tmp;
00138 }
00139
00140 PROFILE_END;
00141
00142 }
|
|
|
Deletes entire list specified by head pointer. Deletes each element of the specified list.
01080 { PROFILE(STMT_LINK_DELETE_LIST);
01081
01082 stmt_iter curr; /* Statement list iterator */
01083
01084 stmt_iter_reset( &curr, head );
01085
01086 while( curr.curr != NULL ) {
01087
01088 /* Deallocate statement */
01089 statement_dealloc( curr.curr->stmt );
01090 curr.curr->stmt = NULL;
01091
01092 head = (stmt_link*)((long int)(curr.curr->ptr) ^ (long int)(curr.last));
01093 if( head != NULL ) {
01094 head->ptr = (stmt_link*)((long int)(curr.curr) ^ (long int)(head->ptr));
01095 }
01096
01097 /* Deallocate stmt_link element itself */
01098 free_safe( curr.curr, sizeof( stmt_link ) );
01099
01100 stmt_iter_reset( &curr, head );
01101
01102 }
01103
01104 PROFILE_END;
01105
01106 }
|
|
|
Displays specified statement list to standard output. Displays the string contents of the stmt_link list pointed to by head to standard output. This function is mainly used for debugging purposes.
00438 {
00439
00440 stmt_iter curr; /* Statement list iterator */
00441
00442 printf( "Statement list:\n" );
00443
00444 stmt_iter_reset( &curr, head );
00445 while( curr.curr != NULL ) {
00446 assert( curr.curr->stmt != NULL );
00447 assert( curr.curr->stmt->exp != NULL );
00448 printf( " id: %d, line: %d, stmt_head: %u\n", curr.curr->stmt->exp->id, curr.curr->stmt->exp->line, curr.curr->stmt->suppl.part.head );
00449 stmt_iter_next( &curr );
00450 }
00451
00452 }
|
|
||||||||||||
|
Finds specified statement in the given stmt_link list.
00593 { PROFILE(STMT_LINK_FIND);
00594
00595 stmt_iter curr; /* Statement list iterator */
00596
00597 stmt_iter_reset( &curr, head );
00598 while( (curr.curr != NULL) && (curr.curr->stmt->exp->id != id) ) {
00599 stmt_iter_next( &curr );
00600 }
00601
00602 PROFILE_END;
00603
00604 return( curr.curr );
00605
00606 }
|
|
||||||||||||||||||||
|
Joins two statement links together. Joins two statement links together such that the statements are stored in line order. Assumes that the base list contains at least one statement link.
00153 { PROFILE(STMT_LINK_MERGE);
00154
00155 stmt_iter si_base; /* Statement iterator for the base list */
00156 stmt_iter si_base2; /* Statement iterator for the base list */
00157 stmt_iter si_other; /* Statement iterator for the other list */
00158
00159 /* Get next to last statement link in tail list */
00160 stmt_iter_reset( &si_base, *base_head );
00161 stmt_iter_get_line_before( &si_base, other_head->stmt->exp->line );
00162 stmt_iter_reset( &si_other, other_head );
00163
00164 /* The other list should succeed the base list */
00165 if( si_base.curr == NULL ) {
00166
00167 stmt_iter_reverse( &si_base );
00168 stmt_iter_next( &si_base );
00169 stmt_iter_reverse( &si_base );
00170 stmt_iter_next( &si_other );
00171
00172 si_base.curr->ptr = (stmt_link*)((long int)(si_base.last) ^ (long int)si_other.last);
00173 si_other.last->ptr = (stmt_link*)((long int)(si_other.curr) ^ (long int)si_base.curr);
00174
00175 *base_tail = other_tail;
00176
00177 /* The other list should precede the base list */
00178 } else if( si_base.last == NULL ) {
00179
00180 stmt_iter_next( &si_base );
00181 stmt_iter_next( &si_base );
00182 while( si_other.curr != NULL ) {
00183 stmt_iter_next( &si_other );
00184 }
00185 stmt_iter_reverse( &si_other );
00186 stmt_iter_next( &si_other );
00187 stmt_iter_reverse( &si_other );
00188
00189 si_base.last->ptr = (stmt_link*)((long int)(si_base.curr) ^ (long int)si_other.curr);
00190 si_other.curr->ptr = (stmt_link*)((long int)(si_other.last) ^ (long int)si_base.last);
00191
00192 *base_head = other_head;
00193
00194 /* Otherwise, the other list needs to be merged into the base list */
00195 } else {
00196
00197 stmt_iter_next( &si_other );
00198 stmt_iter_copy( &si_base2, &si_base );
00199 stmt_iter_next( &si_base2 );
00200 stmt_iter_reverse( &si_base );
00201 stmt_iter_next( &si_base );
00202 stmt_iter_reverse( &si_base );
00203
00204 /* Tie up the front of the other list */
00205 si_base.curr->ptr = (stmt_link*)((long int)(si_base.last) ^ (long int)si_other.last);
00206 si_other.last->ptr = (stmt_link*)((long int)(si_other.curr) ^ (long int)si_base.curr);
00207
00208 while( si_other.curr != NULL ) {
00209 stmt_iter_next( &si_other );
00210 }
00211 stmt_iter_reverse( &si_other );
00212 stmt_iter_next( &si_other );
00213 stmt_iter_reverse( &si_other );
00214
00215 /* Now tie up the tail */
00216 si_other.curr->ptr = (stmt_link*)((long int)(si_base2.last) ^ (long int)si_other.last);
00217 si_base2.last->ptr = (stmt_link*)((long int)(si_other.curr) ^ (long int)si_base2.curr);
00218
00219 }
00220
00221 /* Finally, clear the IS_STMT_HEAD bit */
00222 other_head->stmt->suppl.part.head = 0;
00223
00224 PROFILE_END;
00225
00226 }
|
|
||||||||||||||||
|
Unlinks the stmt_link specified by the specified statement. Iterates through given statement list searching for the given statement. When the statement link is found that matches, removes that link from the list and repairs the list.
01032 { PROFILE(STMT_LINK_UNLINK);
01033
01034 stmt_iter curr; /* Statement list iterator */
01035 stmt_link* next; /* Pointer to next stmt_link in list */
01036 stmt_link* next2; /* Pointer to next after next stmt_link in list */
01037 stmt_link* last2; /* Pointer to last before last stmt_link in list */
01038
01039 stmt_iter_reset( &curr, *head );
01040
01041 while( (curr.curr != NULL) && (curr.curr->stmt != stmt) ) {
01042 stmt_iter_next( &curr );
01043 }
01044
01045 if( curr.curr != NULL ) {
01046
01047 if( (curr.curr == *head) && (curr.curr == *tail) ) {
01048 *head = *tail = NULL;
01049 } else if( curr.curr == *head ) {
01050 next = (stmt_link*)((long int)curr.curr->ptr ^ (long int)curr.last);
01051 next2 = (stmt_link*)((long int)next->ptr ^ (long int)curr.curr);
01052 next->ptr = next2;
01053 *head = next;
01054 } else if( curr.curr == *tail ) {
01055 last2 = (stmt_link*)((long int)curr.last->ptr ^ (long int)curr.curr);
01056 curr.last->ptr = last2;
01057 *tail = curr.last;
01058 } else {
01059 next = (stmt_link*)((long int)curr.curr->ptr ^ (long int)curr.last);
01060 next2 = (stmt_link*)((long int)next->ptr ^ (long int)curr.curr);
01061 last2 = (stmt_link*)((long int)curr.last->ptr ^ (long int)curr.curr);
01062 next->ptr = (stmt_link*)((long int)curr.last ^ (long int)next2);
01063 curr.last->ptr = (stmt_link*)((long int)last2 ^ (long int)next);
01064 }
01065
01066 /* Deallocate the stmt_link */
01067 free_safe( curr.curr, sizeof( stmt_link ) );
01068
01069 }
01070
01071 PROFILE_END;
01072
01073 }
|
|
||||||||||||||||
|
Adds specified string to str_link element at the end of the list.
00058 { PROFILE(STR_LINK_ADD);
00059
00060 str_link* tmp; /* Temporary pointer to newly created str_link element */
00061
00062 tmp = (str_link*)malloc_safe( sizeof( str_link ) );
00063
00064 tmp->str = str;
00065 tmp->str2 = NULL;
00066 tmp->suppl = 0x0;
00067 tmp->suppl2 = 0x0;
00068 tmp->suppl3 = 0x0;
00069 tmp->range = NULL;
00070 tmp->next = NULL;
00071
00072 if( *head == NULL ) {
00073 *head = *tail = tmp;
00074 } else {
00075 (*tail)->next = tmp;
00076 *tail = tmp;
00077 }
00078
00079 PROFILE_END;
00080
00081 return( tmp );
00082
00083 }
|
|
|
Deletes entire list specified by head pointer. Deletes each element of the specified list.
00998 { PROFILE(STR_LINK_DELETE_LIST);
00999
01000 str_link* tmp; /* Temporary pointer to current link in list */
01001
01002 while( head != NULL ) {
01003
01004 tmp = head;
01005 head = tmp->next;
01006
01007 /* Deallocate memory for stored string(s) */
01008 free_safe( tmp->str, (strlen( tmp->str ) + 1) );
01009 free_safe( tmp->str2, (strlen( tmp->str2 ) + 1) );
01010
01011 tmp->str = NULL;
01012 tmp->str2 = NULL;
01013
01014 /* Deallocate str_link element itself */
01015 free_safe( tmp, sizeof( str_link ) );
01016
01017 }
01018
01019 PROFILE_END;
01020
01021 }
|
|
|
Displays specified string list to standard output. Displays the string contents of the str_link list pointed to by head to standard output. This function is mainly used for debugging purposes.
|
|
||||||||||||
|
Finds specified string in the given str_link list.
00568 { PROFILE(STR_LINK_FIND);
00569
00570 str_link* curr; /* Pointer to current str_link link */
00571
00572 curr = head;
00573 while( (curr != NULL) && (strcmp( curr->str, value ) != 0) ) {
00574 curr = curr->next;
00575 }
00576
00577 PROFILE_END;
00578
00579 return( curr );
00580
00581 }
|
|
||||||||||||||||
|
Searches for and removes specified string link from list. Searches specified list for string that matches the specified string. If a match is found, remove it from the list and deallocate the link memory.
00799 { PROFILE(STR_LINK_REMOVE);
00800
00801 str_link* curr; /* Pointer to current string link */
00802 str_link* last; /* Pointer to last string link */
00803
00804 curr = *head;
00805 last = NULL;
00806 while( (curr != NULL) && (strcmp( str, curr->str ) != 0) ) {
00807 last = curr;
00808 curr = curr->next;
00809 assert( (curr == NULL) || (curr->str != NULL) );
00810 }
00811
00812 if( curr != NULL ) {
00813
00814 if( (curr == *head) && (curr == *tail) ) {
00815 *head = *tail = NULL;
00816 } else if( curr == *head ) {
00817 *head = curr->next;
00818 } else if( curr == *tail ) {
00819 last->next = NULL;
00820 *tail = last;
00821 } else {
00822 last->next = curr->next;
00823 }
00824
00825 /* Deallocate associated string */
00826 free_safe( curr->str, (strlen( curr->str ) + 1) );
00827
00828 /* Now deallocate this link itself */
00829 free_safe( curr, sizeof( str_link ) );
00830
00831 }
00832
00833 PROFILE_END;
00834
00835 }
|
1.3.4