]> andersk Git - splint.git/blame - src/globSet.c
noexpand always false.
[splint.git] / src / globSet.c
CommitLineData
616915dd 1/*
11db3170 2** Splint - annotation-assisted static program checker
c59f5181 3** Copyright (C) 1994-2003 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
31globSet
32globSet_new ()
33{
34 return (globSet_undefined);
35}
36
37void
38globSet_clear (globSet g)
39{
40 sRefSet_clear (g);
41}
42
43globSet
28bf4b0b 44globSet_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
59globSet
28bf4b0b 60globSet_single (/*@exposed@*/ sRef el)
616915dd 61{
28bf4b0b 62 globSet res = globSet_new ();
63 return globSet_insert (res, el);
64}
65
66void
67globSet_markImmutable (globSet g)
68{
69 sRefSet_markImmutable (g);
70}
71
72globSet
73globSet_copyInto (/*@returned@*/ globSet s1, /*@exposed@*/ globSet s2)
74{
75 return (sRefSet_copyInto (s1, s2));
616915dd 76}
77
78/*@only@*/ globSet
79globSet_newCopy (globSet s)
80{
81 return (sRefSet_newCopy (s));
82}
83
84bool
85globSet_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
103bool
104globSet_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
117void
118globSet_free (/*@only@*/ globSet s)
119{
120 sRefSet_free (s);
121}
122
123/*@only@*/ cstring
124globSet_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
147globSet
148globSet_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
168globSet_unparse (globSet ll)
169{
928377c6 170 /* return (sRefSet_unparseFull (ll)); */
171 return (sRefSet_unparsePlain (ll));
616915dd 172}
173
174int
175globSet_compare (globSet l1, globSet l2)
176{
177 return (sRefSet_compare (l1, l2));
178}
179
This page took 0.10677 seconds and 5 git commands to generate.