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

globSet.c

Go to the documentation of this file.
00001 /*
00002 ** LCLint - annotation-assisted static program checker
00003 ** Copyright (C) 1994-2000 University of Virginia,
00004 **         Massachusetts Institute of Technology
00005 **
00006 ** This program is free software; you can redistribute it and/or modify it
00007 ** under the terms of the GNU General Public License as published by the
00008 ** Free Software Foundation; either version 2 of the License, or (at your
00009 ** option) any later version.
00010 ** 
00011 ** This program is distributed in the hope that it will be useful, but
00012 ** WITHOUT ANY WARRANTY; without even the implied warranty of
00013 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 ** General Public License for more details.
00015 ** 
00016 ** The GNU General Public License is available from http://www.gnu.org/ or
00017 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00018 ** MA 02111-1307, USA.
00019 **
00020 ** For information on lclint: lclint-request@cs.virginia.edu
00021 ** To report a bug: lclint-bug@cs.virginia.edu
00022 ** For more information: http://lclint.cs.virginia.edu
00023 */
00024 /*
00025 ** globSet.c
00026 */
00027 
00028 # include "lclintMacros.nf"
00029 # include "basic.h"
00030 
00031 globSet
00032 globSet_new ()
00033 {
00034   return (globSet_undefined);
00035 }
00036 
00037 void
00038 globSet_clear (globSet g)
00039 {
00040   sRefSet_clear (g);
00041 }
00042 
00043 globSet
00044 globSet_insert (/*@returned@*/ globSet s, sRef el)
00045 {
00046   if (sRef_isKnown (el) && !sRef_isConst (el) && !sRef_isType (el))
00047     {
00048       llassertprint (sRef_isGlobal (el) || sRef_isKindSpecial (el),
00049                      ("el: %s", sRef_unparse (el)));
00050       
00051       return (sRefSet_insert (s, el));
00052     }
00053   else
00054     {
00055       return s;
00056     }
00057 }
00058 
00059 globSet
00060   globSet_copy (/*@returned@*/ globSet s1, /*@exposed@*/ globSet s2)
00061 {
00062   return (sRefSet_copy (s1, s2));
00063 }
00064 
00065 /*@only@*/ globSet
00066 globSet_newCopy (globSet s)
00067 {
00068   return (sRefSet_newCopy (s));
00069 }
00070 
00071 bool
00072 globSet_member (globSet s, sRef el)
00073 {
00074   return (sRefSet_member (s, el));
00075 }
00076 
00077 /*@exposed@*/ sRef globSet_lookup (globSet s, sRef el)
00078 {
00079   sRefSet_allElements (s, e)
00080     {
00081       if (sRef_similar (e, el))
00082         {
00083           return e;
00084         }
00085     } end_sRefSet_allElements;
00086 
00087   return sRef_undefined;
00088 }
00089 
00090 bool
00091 globSet_hasStatic (globSet s)
00092 {
00093   sRefSet_allElements (s, el)
00094     {
00095       if (sRef_isFileStatic (el))
00096         {
00097           return TRUE;
00098         }
00099     } end_sRefSet_allElements;
00100 
00101   return FALSE;
00102 }
00103 
00104 void
00105 globSet_free (/*@only@*/ globSet s)
00106 {
00107   sRefSet_free (s);
00108 }
00109 
00110 /*@only@*/ cstring
00111 globSet_dump (globSet lset)
00112 {
00113   cstring st = cstring_undefined;
00114   bool first = TRUE;
00115 
00116   
00117   sRefSet_allElements (lset, el)
00118     {
00119       if (!first)
00120         {
00121           st = cstring_appendChar (st, ',');
00122         }
00123       else
00124         {
00125           first = FALSE;
00126         }
00127 
00128       st = cstring_concatFree (st, sRef_dumpGlobal (el));
00129     } end_sRefSet_allElements;
00130 
00131   return st;
00132 }
00133 
00134 globSet
00135 globSet_undump (char **s)
00136 {
00137   char c;
00138   sRefSet sl = sRefSet_new ();
00139 
00140   while ((c = **s) != '#' && c != '@' && c != '$' && c != '&')
00141     {
00142       sl = sRefSet_insert (sl, sRef_undumpGlobal (s));
00143 
00144       
00145       if (**s == ',')
00146         {
00147           (*s)++;
00148         }
00149     }
00150 
00151     return sl;
00152 }
00153 
00154 /*@only@*/ cstring
00155 globSet_unparse (globSet ll)
00156 {
00157   return (sRefSet_unparse (ll));
00158 }
00159 
00160 int 
00161 globSet_compare (globSet l1, globSet l2)
00162 {
00163   return (sRefSet_compare (l1, l2));
00164 }
00165 

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