/* This function searches whether one of the states in the list of statepool id's * of a symbol exists in any other statepool id's of the same function; it also * verifies that all definitions of the symbol are in the same automaton. */ SC_FUNC void state_conflict(symbol *root) { statepool *psrc,*ptgt; statelist *srcptr,*tgtptr; symbol *sym; assert(root!=NULL); for (sym=root->next; sym!=NULL; sym=sym->next) { if (sym->parent!=NULL || sym->ident!=iFUNCTN) continue; /* hierarchical data type or no function */ if (sym->states==NULL) continue; /* this function has no states */ for (srcptr=sym->states->next; srcptr!=NULL; srcptr=srcptr->next) { if (srcptr->id==-1) continue; /* state list id -1 is a special case */ psrc=state_getlist_ptr(srcptr->id); assert(psrc!=NULL); for (tgtptr=srcptr->next; tgtptr!=NULL; tgtptr=tgtptr->next) { if (tgtptr->id==-1) continue; /* state list id -1 is a special case */ ptgt=state_getlist_ptr(tgtptr->id); assert(ptgt!=NULL); if (psrc->fsa!=ptgt->fsa && strcmp(sym->name,uENTRYFUNC)!=0) error(83,sym->name); /* this function is part of another machine */ if (checkconflict(psrc,ptgt)) error(84,sym->name); /* state conflict */ } /* for (tgtptr) */ } /* for (srcptr) */ } /* for (sym) */ }
/* check whether the two state lists (whose ids are passed in) share any * states */ SC_FUNC int state_conflict_id(int listid1,int listid2) { statepool *psrc,*ptgt; psrc=state_getlist_ptr(listid1); assert(psrc!=NULL); ptgt=state_getlist_ptr(listid2); assert(ptgt!=NULL); return checkconflict(psrc,ptgt); }
SC_FUNC int state_count(int listid) { statepool *ptr=state_getlist_ptr(listid); if (ptr==NULL) return 0; /* unknown list, no states in it */ return ptr->numstates; }
SC_FUNC int state_listitem(int listid,int index) { statepool *ptr; ptr=state_getlist_ptr(listid); assert(ptr!=NULL); assert(index>=0 && index<ptr->numstates); return ptr->states[index]; }
SC_FUNC int state_getfsa(int listid) { statepool *ptr; assert(listid>=0); if (listid==0) return -1; ptr=state_getlist_ptr(listid); return (ptr!=NULL) ? ptr->fsa : -1; /* fsa 0 exists */ }
SC_FUNC int state_inlist(int listid,int state) { statepool *ptr; int i; ptr=state_getlist_ptr(listid); if (ptr==NULL) return FALSE; /* unknown list, state not in it */ for (i=0; i<ptr->numstates; i++) if (ptr->states[i]==state) return TRUE; return FALSE; }
SC_FUNC int state_getfsa(int listid) { statelist *ptr=state_getlist_ptr(listid); return (ptr!=NULL) ? ptr->fsa : -1; /* fsa 0 exists */ }