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

filelocList.c File Reference

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

Go to the source code of this file.

Functions

filelocList filelocList_new ()
filelocList filelocList_append ( filelocList s, filelocList t)
filelocList filelocList_addUndefined ( filelocList s)
filelocList filelocList_addDifferentFile ( filelocList s, fileloc where, fileloc loc)
filelocList filelocList_add ( filelocList s, fileloc el)
cstring filelocList_unparse (filelocList s)
int filelocList_realSize (filelocList s)
cstring filelocList_unparseUses (filelocList s)
void filelocList_free ( filelocList s)


Function Documentation

filelocList filelocList_add ( filelocList s,
fileloc el )
 

Definition at line 152 of file filelocList.c.

Referenced by filelocList_addDifferentFile(), filelocList_addUndefined(), filelocList_append(), and uentry_setUsed().

00153 {
00154   if (filelocList_isUndefined (s))
00155     {
00156       s = filelocList_newEmpty ();
00157     }
00158 
00159   if (s->free <= 0)
00160     {
00161       filelocList_grow (s);
00162     }
00163   
00164   s->free--;
00165   s->elements[s->nelements] = el;
00166 
00167   if (fileloc_isUndefined (el))
00168     {
00169       s->elements[s->nelements] = s->elements[0];
00170       s->elements[0] = fileloc_undefined;
00171     }
00172 
00173   s->nelements++;
00174   return s;
00175 }

filelocList filelocList_addDifferentFile ( filelocList s,
fileloc where,
fileloc loc )
 

Definition at line 123 of file filelocList.c.

00126 {
00127   if (filelocList_hasUndefinedLoc (s) || filelocList_size (s) >= 2)
00128     {
00129       return s;
00130     }
00131   else
00132     {
00133       if (fileloc_sameModule (where, loc))
00134         {
00135           if (filelocList_isEmpty (s))
00136             {
00137               return filelocList_add (s, fileloc_copy (loc));
00138             }
00139           else
00140             {
00141               return s;
00142             }
00143         }
00144       else
00145         {
00146           return filelocList_addUndefined (s);
00147         }
00148     }
00149 }

filelocList filelocList_addUndefined ( filelocList s )
 

Definition at line 101 of file filelocList.c.

Referenced by filelocList_addDifferentFile(), and uentry_setUsed().

00102 {
00103   if (filelocList_isUndefined (s) 
00104       || s->nelements == 0
00105       || fileloc_isDefined (s->elements[0]))
00106     {
00107       return (filelocList_add (s, fileloc_undefined));
00108     }
00109   else
00110     {
00111       return s;
00112     }
00113 }

filelocList filelocList_append ( filelocList s,
filelocList t )
 

Definition at line 74 of file filelocList.c.

Referenced by uentry_mergeDefinition(), uentry_mergeState(), and uentry_mergeUses().

00075 {
00076   llassert (NOALIAS (s, t));
00077 
00078   if (filelocList_isUndefined (t) || filelocList_isEmpty (t)) return s;
00079 
00080   if (filelocList_isUndefined (s)) 
00081     {
00082       s = filelocList_newEmpty ();
00083     }
00084 
00085   filelocList_elements (t, fl)
00086     {
00087       /* Okay to use exposed storage here, t is begin eaten. */
00088 
00089       /*@-exposetrans@*/ /*@-dependenttrans@*/
00090       s = filelocList_add (s, fl);
00091       /*@=exposetrans@*/ /*@=dependenttrans@*/
00092     } end_filelocList_elements;
00093 
00094   sfree (t->elements);
00095   sfree (t);
00096 
00097   return s;
00098 }

void filelocList_free ( filelocList s )
 

Definition at line 275 of file filelocList.c.

Referenced by uentry_setState().

00276 {
00277   if (filelocList_isDefined (s))
00278     {
00279       int i;
00280       for (i = 0; i < s->nelements; i++)
00281         {
00282           fileloc_free (s->elements[i]); 
00283         }
00284       
00285       sfree (s->elements); 
00286       sfree (s);
00287     }
00288 }

filelocList filelocList_new ( )
 

Definition at line 38 of file filelocList.c.

Referenced by uentry_makeConstantAux(), uentry_makeDatatypeAux(), uentry_makeElipsisMarker(), and uentry_nameCopy().

00039 {
00040   return (filelocList_undefined);
00041 }

int filelocList_realSize ( filelocList s )
 

Definition at line 200 of file filelocList.c.

Referenced by usymtab_displayAllUses().

00201 {
00202   int size = 0;
00203 
00204   filelocList_elements (s, el)
00205     {
00206       if (fileloc_isDefined (el))
00207         {
00208           size++;
00209         }
00210     } end_filelocList_elements;
00211 
00212   return size;
00213 }

cstring filelocList_unparse ( filelocList s )
 

Definition at line 178 of file filelocList.c.

00179 {
00180    int i;
00181    cstring st = cstring_makeLiteral ("[");
00182 
00183    if (filelocList_isDefined (s))
00184      {
00185        for (i = 0; i < filelocList_size (s); i++)
00186          {
00187            if (i == 0)
00188              {
00189                st = message ("%q %q", st, fileloc_unparse (s->elements[i]));
00190              }
00191            else
00192              st = message ("%q, %q", st, fileloc_unparse (s->elements[i]));
00193          }
00194      }
00195    
00196    st = message ("%q ]", st);
00197    return st;
00198 }

cstring filelocList_unparseUses ( filelocList s )
 

Definition at line 215 of file filelocList.c.

Referenced by usymtab_displayAllUses().

00216 {
00217   int i;
00218   int linelen = 0;
00219   int maxlen = context_getLineLen () - 3;
00220   cstring st = cstring_undefined;
00221   fileId lastFile = fileId_invalid;
00222 
00223   if (filelocList_isDefined (s))
00224     {
00225       bool firstone = TRUE;
00226 
00227       for (i = 0; i < filelocList_size (s); i++)
00228         {
00229           if (fileloc_isDefined (s->elements[i]))
00230             {
00231               if (firstone)
00232                 {
00233                   st = fileloc_unparse (s->elements[i]);
00234                   lastFile = fileloc_fileId (s->elements[i]);
00235                   linelen = 3 + cstring_length (st);
00236                   firstone = FALSE;
00237                 }
00238               else
00239                 {
00240                   if (fileId_equal (fileloc_fileId (s->elements[i]), lastFile))
00241                     {
00242                       if (linelen + 7 > maxlen)
00243                         {
00244                           st = message ("%q\n      ", st);
00245                           linelen = 6;
00246                         }
00247                       else
00248                         {
00249                           st = message ("%q, ", st);
00250                         }
00251                       
00252                       st = message ("%q%d,%d", 
00253                                     st, fileloc_lineno (s->elements[i]), 
00254                                     fileloc_column (s->elements[i]));
00255                       linelen += 3 + int_log (fileloc_lineno (s->elements[i])) 
00256                         + int_log (fileloc_column (s->elements[i]));
00257                     }
00258                   else
00259                     {
00260                       cstring fl = fileloc_unparse (s->elements[i]);
00261                       st = message ("%q\n   %s", st, fl);
00262                       lastFile = fileloc_fileId (s->elements[i]);
00263                       linelen = 3 + cstring_length (fl);
00264                       cstring_free (fl);
00265                     }
00266                 }
00267             }
00268         }
00269     }
00270   
00271   return st;
00272 }


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