]>
Commit | Line | Data |
---|---|---|
616915dd | 1 | /* |
11db3170 | 2 | ** Splint - annotation-assisted static program checker |
77d37419 | 3 | ** Copyright (C) 1994-2002 University of Virginia, |
616915dd | 4 | ** Massachusetts Institute of Technology |
5 | ** | |
6 | ** This program is free software; you can redistribute it and/or modify it | |
7 | ** under the terms of the GNU General Public License as published by the | |
8 | ** Free Software Foundation; either version 2 of the License, or (at your | |
9 | ** option) any later version. | |
10 | ** | |
11 | ** This program is distributed in the hope that it will be useful, but | |
12 | ** WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | ** General Public License for more details. | |
15 | ** | |
16 | ** The GNU General Public License is available from http://www.gnu.org/ or | |
17 | ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, | |
18 | ** MA 02111-1307, USA. | |
19 | ** | |
155af98d | 20 | ** For information on splint: info@splint.org |
21 | ** To report a bug: splint-bug@splint.org | |
11db3170 | 22 | ** For more information: http://www.splint.org |
616915dd | 23 | */ |
24 | /* | |
25 | ** globSet.c | |
26 | */ | |
27 | ||
1b8ae690 | 28 | # include "splintMacros.nf" |
616915dd | 29 | # include "basic.h" |
30 | ||
31 | globSet | |
32 | globSet_new () | |
33 | { | |
34 | return (globSet_undefined); | |
35 | } | |
36 | ||
37 | void | |
38 | globSet_clear (globSet g) | |
39 | { | |
40 | sRefSet_clear (g); | |
41 | } | |
42 | ||
43 | globSet | |
28bf4b0b | 44 | globSet_insert (/*@returned@*/ globSet s, /*@exposed@*/ sRef el) |
616915dd | 45 | { |
46 | if (sRef_isKnown (el) && !sRef_isConst (el) && !sRef_isType (el)) | |
47 | { | |
28bf4b0b | 48 | llassertprint (sRef_isFileOrGlobalScope (el) || sRef_isKindSpecial (el), |
616915dd | 49 | ("el: %s", sRef_unparse (el))); |
50 | ||
51 | return (sRefSet_insert (s, el)); | |
52 | } | |
53 | else | |
54 | { | |
55 | return s; | |
56 | } | |
57 | } | |
58 | ||
59 | globSet | |
28bf4b0b | 60 | globSet_single (/*@exposed@*/ sRef el) |
616915dd | 61 | { |
28bf4b0b | 62 | globSet res = globSet_new (); |
63 | return globSet_insert (res, el); | |
64 | } | |
65 | ||
66 | void | |
67 | globSet_markImmutable (globSet g) | |
68 | { | |
69 | sRefSet_markImmutable (g); | |
70 | } | |
71 | ||
72 | globSet | |
73 | globSet_copyInto (/*@returned@*/ globSet s1, /*@exposed@*/ globSet s2) | |
74 | { | |
75 | return (sRefSet_copyInto (s1, s2)); | |
616915dd | 76 | } |
77 | ||
78 | /*@only@*/ globSet | |
79 | globSet_newCopy (globSet s) | |
80 | { | |
81 | return (sRefSet_newCopy (s)); | |
82 | } | |
83 | ||
84 | bool | |
85 | globSet_member (globSet s, sRef el) | |
86 | { | |
87 | return (sRefSet_member (s, el)); | |
88 | } | |
89 | ||
90 | /*@exposed@*/ sRef globSet_lookup (globSet s, sRef el) | |
91 | { | |
92 | sRefSet_allElements (s, e) | |
93 | { | |
94 | if (sRef_similar (e, el)) | |
95 | { | |
96 | return e; | |
97 | } | |
98 | } end_sRefSet_allElements; | |
99 | ||
100 | return sRef_undefined; | |
101 | } | |
102 | ||
103 | bool | |
104 | globSet_hasStatic (globSet s) | |
105 | { | |
106 | sRefSet_allElements (s, el) | |
107 | { | |
108 | if (sRef_isFileStatic (el)) | |
109 | { | |
110 | return TRUE; | |
111 | } | |
112 | } end_sRefSet_allElements; | |
113 | ||
114 | return FALSE; | |
115 | } | |
116 | ||
117 | void | |
118 | globSet_free (/*@only@*/ globSet s) | |
119 | { | |
120 | sRefSet_free (s); | |
121 | } | |
122 | ||
123 | /*@only@*/ cstring | |
124 | globSet_dump (globSet lset) | |
125 | { | |
126 | cstring st = cstring_undefined; | |
127 | bool first = TRUE; | |
128 | ||
129 | ||
130 | sRefSet_allElements (lset, el) | |
131 | { | |
132 | if (!first) | |
133 | { | |
134 | st = cstring_appendChar (st, ','); | |
135 | } | |
136 | else | |
137 | { | |
138 | first = FALSE; | |
139 | } | |
140 | ||
141 | st = cstring_concatFree (st, sRef_dumpGlobal (el)); | |
142 | } end_sRefSet_allElements; | |
143 | ||
144 | return st; | |
145 | } | |
146 | ||
147 | globSet | |
148 | globSet_undump (char **s) | |
149 | { | |
150 | char c; | |
151 | sRefSet sl = sRefSet_new (); | |
152 | ||
153 | while ((c = **s) != '#' && c != '@' && c != '$' && c != '&') | |
154 | { | |
155 | sl = sRefSet_insert (sl, sRef_undumpGlobal (s)); | |
156 | ||
157 | ||
158 | if (**s == ',') | |
159 | { | |
160 | (*s)++; | |
161 | } | |
162 | } | |
163 | ||
164 | return sl; | |
165 | } | |
166 | ||
167 | /*@only@*/ cstring | |
168 | globSet_unparse (globSet ll) | |
169 | { | |
28bf4b0b | 170 | return (sRefSet_unparseFull (ll)); |
171 | /* return (sRefSet_unparsePlain (ll)); */ | |
616915dd | 172 | } |
173 | ||
174 | int | |
175 | globSet_compare (globSet l1, globSet l2) | |
176 | { | |
177 | return (sRefSet_compare (l1, l2)); | |
178 | } | |
179 |