Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

usymIdSet.c File Reference

#include "lclintMacros.nf"
#include "basic.h"

Go to the source code of this file.

Functions

usymIdSet usymIdSet_new ()
usymIdSet usymIdSet_single (usymId t)
usymIdSet usymIdSet_add (usymIdSet s, usymId el)
usymIdSet usymIdSet_removeFresh ( usymIdSet s, usymId el)
usymIdSet usymIdSet_newUnion (usymIdSet s1, usymIdSet s2)
usymIdSet usymIdSet_subtract (usymIdSet s, usymIdSet t)
bool usymIdSet_member (usymIdSet s, usymId el)
void usymIdSet_free ( usymIdSet s)
cstring usymIdSet_dump (usymIdSet lset)
usymIdSet usymIdSet_undump (char **s)
cstring usymIdSet_unparse (usymIdSet ll)
int usymIdSet_compare (usymIdSet l1, usymIdSet l2)


Function Documentation

usymIdSet usymIdSet_add ( usymIdSet s,
usymId el )
 

Definition at line 127 of file usymIdSet.c.

00128 {
00129   if (usymIdSet_isDefined (s))
00130     {
00131       llassert (!usymIdSet_member (s, el));
00132       
00133       return (usymIdSet_insert (usymIdSet_copy (s), el));
00134     }
00135   else
00136     {
00137       return (usymIdSet_single (el));
00138     }
00139 }

int usymIdSet_compare ( usymIdSet l1,
usymIdSet l2 )
 

Definition at line 349 of file usymIdSet.c.

00350 {
00351   if (usymIdSet_isUndefined (l1))
00352     {
00353       return (usymIdSet_size (l2) == 0 ? 0 : 1);
00354     }
00355   
00356   if (usymIdSet_isUndefined (l2))
00357     {
00358       return (usymIdSet_size (l1) == 0 ? 0 : 1);
00359     }
00360   
00361   {
00362     int li1 = l1->entries;
00363     int li2 = l2->entries;
00364     int leastelements = (li1 < li2) ? li1 : li2;
00365     int i = 0;
00366     
00367     while (i < leastelements)
00368       {
00369         if (usymId_equal (l1->elements[i], l2->elements[i]))
00370           {
00371             i++;
00372           }
00373         else
00374           {
00375             if (l1->elements[i] > l2->elements[i]) 
00376               {
00377                 return 1;
00378               }
00379             else
00380               {
00381                 return -1;
00382               }
00383           }
00384       }
00385 
00386     return (int_compare (li1, li2));
00387   }
00388 }

cstring usymIdSet_dump ( usymIdSet lset )
 

Definition at line 240 of file usymIdSet.c.

Referenced by typeIdSet_dumpTable().

00241 {
00242   cstring st = cstring_undefined;
00243   
00244   if (!usymIdSet_isUndefined (lset))
00245     {
00246       bool first = TRUE;
00247       int i;
00248       
00249       for (i = 0; i < lset->entries; i++)
00250         {
00251           usymId current = lset->elements[i];
00252           
00253           if (!usymId_isInvalid (current))
00254             {
00255               current = usymtab_convertId (current);
00256 
00257               if (first)
00258                 {
00259                   st = message ("%d", current);
00260                   first = FALSE;
00261                 }
00262               else
00263                 {
00264                   st = message ("%q,%d", st, current);
00265                 }
00266             }
00267         }
00268     }
00269   return (st);
00270 }

void usymIdSet_free ( usymIdSet s )
 

Definition at line 225 of file usymIdSet.c.

Referenced by typeIdSet_destroyMod().

00226 {
00227   if (!usymIdSet_isUndefined (s))
00228     {
00229       int i;
00230       for (i = 0; i < s->entries; i++)
00231         {
00232           /*      usymId_free (s->elements[i]); */
00233         }
00234       
00235       sfree (s->elements); 
00236       sfree (s);
00237     }
00238 }

bool usymIdSet_member ( usymIdSet s,
usymId el )
 

Definition at line 205 of file usymIdSet.c.

Referenced by typeIdSet_insert(), typeIdSet_member(), and usymIdSet_subtract().

00206 {
00207   if (usymIdSet_isUndefined (s))
00208     {
00209       return FALSE;
00210     }
00211   else
00212     {
00213       int i;
00214       
00215       for (i = 0; i < s->entries; i++)
00216         {
00217           if (usymId_equal (el, s->elements[i]))
00218             return TRUE;
00219         }
00220       return FALSE;
00221     }
00222 }

usymIdSet usymIdSet_new ( )
 

Definition at line 36 of file usymIdSet.c.

Referenced by usymIdSet_newUnion(), usymIdSet_subtract(), and usymIdSet_undump().

00037 {
00038   return usymIdSet_undefined;
00039 }

usymIdSet usymIdSet_newUnion ( usymIdSet s1,
usymIdSet s2 )
 

Definition at line 166 of file usymIdSet.c.

00167 {
00168   usymIdSet t = usymIdSet_new ();
00169 
00170   usymIdSet_elements (s1, current)
00171     {
00172       t = usymIdSet_insert (t, current);
00173     } end_usymIdSet_elements;
00174 
00175   usymIdSet_elements (s2, current)
00176     {
00177       t = usymIdSet_insert (t, current);
00178     } end_usymIdSet_elements;
00179 
00180   return t;
00181 }

usymIdSet usymIdSet_removeFresh ( usymIdSet s,
usymId el )
 

Definition at line 142 of file usymIdSet.c.

00143 {
00144   if (usymIdSet_isDefined (s))
00145     {
00146       usymIdSet t = usymIdSet_newEmpty ();
00147       int i;
00148       
00149       for (i = 0; i < s->entries; i++)
00150         {
00151           if (!usymId_equal (el, s->elements[i]))
00152             {
00153               t = usymIdSet_insert (t, s->elements[i]);
00154             }
00155         }
00156       
00157       return t;
00158     }
00159   else
00160     {
00161       return usymIdSet_undefined;
00162     }
00163 }

usymIdSet usymIdSet_single ( usymId t )
 

Definition at line 72 of file usymIdSet.c.

Referenced by usymIdSet_add().

00073 {
00074   usymIdSet s = (usymIdSet) dmalloc (sizeof (*s));
00075    
00076   s->entries = 1;
00077   s->nspace = usymIdSetBASESIZE - 1;
00078   s->elements = (usymId *) dmalloc (sizeof (*s->elements) * usymIdSetBASESIZE);
00079   s->elements[0] = t;
00080 
00081   return (s);
00082 }

usymIdSet usymIdSet_subtract ( usymIdSet s,
usymIdSet t )
 

Definition at line 189 of file usymIdSet.c.

00190 {
00191   usymIdSet r = usymIdSet_new ();
00192 
00193   usymIdSet_elements (s, current)
00194     {
00195       if (!usymIdSet_member (t, current))
00196         {
00197           r = usymIdSet_insert (r, current);
00198         }
00199     } end_usymIdSet_elements;
00200 
00201   return r;
00202 }

usymIdSet usymIdSet_undump ( char ** s )
 

Definition at line 277 of file usymIdSet.c.

Referenced by typeIdSet_loadTable().

00278 {
00279   usymIdSet t = usymIdSet_new ();
00280   char *olds = *s;
00281   char c;
00282 
00283   
00284   while ((c = **s) != '\0' && c != '@' && c != '#' && c != '\n')
00285     {
00286       int tid = 0;
00287 
00288       while (c != '@' && c != '#' && c != ',' && c != '\0' && c != '\n')
00289         {
00290           while (c >= '0' && c <= '9')
00291             {
00292               tid *= 10;
00293               tid += (int) (c - '0');
00294               (*s)++;
00295               c = **s;
00296             }
00297 
00298           if (*s == olds)
00299             {
00300               llcontbug (message ("usymIdSet_undump: loop: %s", 
00301                                   cstring_fromChars (*s)));
00302 
00303               while (**s != '\0') 
00304                 {
00305                   (*s)++;
00306                 }
00307 
00308               /*@innerbreak@*/ break;
00309             }
00310 
00311           olds = *s;
00312           
00313           t = usymIdSet_insert (t, usymId_fromInt (tid));
00314         }
00315 
00316       if (c == ',')
00317         {
00318           (*s)++;
00319         }
00320     }
00321 
00322   return t;
00323 }

cstring usymIdSet_unparse ( usymIdSet ll )
 

Definition at line 326 of file usymIdSet.c.

Referenced by typeIdSet_unparse().

00327 {
00328   cstring s = cstring_undefined;
00329 
00330   if (!usymIdSet_isUndefined (ll))
00331     {
00332       int i;
00333       
00334       for (i = 0; i < ll->entries; i++)
00335         {
00336           usymId current = ll->elements[i];
00337 
00338           if (i == 0)
00339             s = uentry_getName (usymtab_getGlobalEntry (current));
00340           else
00341             s = message ("%q, %q", s, uentry_getName (usymtab_getGlobalEntry (current)));
00342         }
00343     }
00344   
00345   return s;
00346 }


Generated at Fri Nov 3 18:58:19 2000 for LCLint by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000