Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
 
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
Line 24... Line 54...
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
29
 
59
 
30
 
60
 
31
/**********************************************************************
61
/**********************************************************************
32
$Author: release $
62
$Author: release $
33
$Date: 1998/01/17 15:55:46 $
63
$Date: 1998/01/17 15:55:46 $
34
$Revision: 1.1.1.1 $
64
$Revision: 1.1.1.1 $
35
$Log: mark_scope.c,v $
65
$Log: mark_scope.c,v $
Line 54... Line 84...
54
Revision 1.3  1997/03/20 17:04:53  currie
84
Revision 1.3  1997/03/20 17:04:53  currie
55
Dwarf2 diags
85
Dwarf2 diags
56
 
86
 
57
Revision 1.2  1997/02/18 12:55:52  currie
87
Revision 1.2  1997/02/18 12:55:52  currie
58
NEW DIAG STRUCTURE
88
NEW DIAG STRUCTURE
59
 
89
 
60
 * Revision 1.1  1995/04/06  10:42:55  currie
90
 * Revision 1.1  1995/04/06  10:42:55  currie
61
 * Initial revision
91
 * Initial revision
62
 *
92
 *
63
***********************************************************************/
93
***********************************************************************/
64
 
94
 
Line 75... Line 105...
75
 
105
 
76
#ifdef NEWDIAGS
106
#ifdef NEWDIAGS
77
 
107
 
78
int doing_mark_scope = 0;
108
int doing_mark_scope = 0;
79
 
109
 
80
void mark_scope
110
void
81
    PROTO_N ( (e) )
-
 
82
    PROTO_T ( exp e )
111
mark_scope(exp e)
83
{
112
{
84
	/* called by read_diag_id_scope; dgf(e) holds DIAG_INFO_ID */
113
	/* called by read_diag_id_scope; dgf(e) holds DIAG_INFO_ID */
85
  dg_info d = dgf(e);
114
	dg_info d = dgf(e);
86
  dg_info * ptr;
115
	dg_info *ptr;
87
  exp id;
116
	exp id;
-
 
117
	if (!d || d->key != DGA_NAME ||
88
  if (!d || d->key != DGA_NAME || d->data.i_nam.dnam->key != DGN_OBJECT)
118
	    d->data.i_nam.dnam->key != DGN_OBJECT) {
89
    return;
119
		return;
-
 
120
	}
90
  id = son(d->data.i_nam.dnam->data.n_obj.obtain_val);
121
	id = son(d->data.i_nam.dnam->data.n_obj.obtain_val);
91
  if (name(id) == cont_tag)
122
	if (name(id) == cont_tag) {
92
    id = son(id);
123
		id = son(id);
-
 
124
	}
93
  if (name(id) != name_tag)
125
	if (name(id) != name_tag) {
94
    return;
126
		return;
-
 
127
	}
95
  id = son(id);
128
	id = son(id);
96
  if (isparam(id))
129
	if (isparam(id)) {
97
    return;
130
		return;
-
 
131
	}
98
  ptr = &(d->more);
132
	ptr = &(d->more);
99
  d = nildiag;
133
	d = nildiag;
100
  while (*ptr && (*ptr)->key != DGA_SCOPE)
134
	while (*ptr && (*ptr)->key != DGA_SCOPE) {
101
    ptr = &((*ptr)->more);
135
		ptr = &((*ptr)->more);
-
 
136
	}
102
  if (!*ptr && name(e) == seq_tag && name(son(son(e))) == ass_tag
137
	if (!*ptr && name(e) == seq_tag && name(son(son(e))) == ass_tag &&
103
		&& last(son(son(e))) && name(bro(son(e))) != ident_tag ) {
138
	    last(son(son(e))) && name(bro(son(e))) != ident_tag) {
104
    ptr = &dgf(bro(son(e)));
139
		ptr = &dgf(bro(son(e)));
105
    while (*ptr && (*ptr)->key != DGA_SCOPE)
140
		while (*ptr && (*ptr)->key != DGA_SCOPE) {
106
      ptr = &((*ptr)->more);
141
			ptr = &((*ptr)->more);
107
  }
142
		}
-
 
143
	}
108
  if (*ptr) {
144
	if (*ptr) {
109
    d = *ptr;
145
		d = *ptr;
110
    *ptr = d->more;
146
		*ptr = d->more;
111
  }
-
 
112
  else {
147
	} else {
113
    d = f_lexical_block_dg (no_dg_idname_option, no_dg_sourcepos_option);
148
		d = f_lexical_block_dg(no_dg_idname_option,
-
 
149
				       no_dg_sourcepos_option);
114
    d->data.i_scope.begin_st = (long)(-1);
150
		d->data.i_scope.begin_st = (long)(-1);
115
    doing_mark_scope = 1;
151
		doing_mark_scope = 1;
116
  }
152
	}
117
  /* if (isglob(id)) */ {
153
	/* if (isglob(id)) */ {
118
    d->more = dgf(e);
154
		d->more = dgf(e);
119
    dgf(e) = d;
155
		dgf(e) = d;
120
  }
156
	}
121
#if 0
157
#if 0
122
  else {
158
	else {
123
    exp def = son(id);
159
		exp def = son(id);
124
    if (dgf(def) && dgf(def)->key == DGA_SRC)
160
		if (dgf(def) && dgf(def)->key == DGA_SRC)
-
 
161
			dgf(e)->data.i_nam.dnam->whence =
125
      dgf(e)->data.i_nam.dnam->whence = dgf(def)->data.i_src.startpos;
162
			    dgf(def)->data.i_src.startpos;
126
    d->more = dgf(id);
163
		d->more = dgf(id);
127
    dgf(id) = d;
164
		dgf(id) = d;
128
  }
165
	}
129
#endif
166
#endif
130
  return;
167
	return;
131
}
168
}
132
 
169
 
-
 
170
 
133
void mark_scope2
171
void
134
    PROTO_N ( (e) )
-
 
135
    PROTO_T ( exp e )
172
mark_scope2(exp e)
136
{
173
{
137
	/* called by read_diag_type_scope; dgf(e) holds DIAG_INFO_ID */
174
	/* called by read_diag_type_scope; dgf(e) holds DIAG_INFO_ID */
138
  dg_info d = dgf(e);
175
	dg_info d = dgf(e);
139
  dg_info * ptr;
176
	dg_info *ptr;
140
  if (!d || d->key != DGA_NAME || d->data.i_nam.dnam->key != DGN_TYPE)
177
	if (!d || d->key != DGA_NAME || d->data.i_nam.dnam->key != DGN_TYPE) {
141
    return;
178
		return;
-
 
179
	}
142
  ptr = &(d->more);
180
	ptr = &(d->more);
143
  d = nildiag;
181
	d = nildiag;
144
  while (*ptr && (*ptr)->key != DGA_SCOPE)
182
	while (*ptr && (*ptr)->key != DGA_SCOPE) {
145
    ptr = &((*ptr)->more);
183
		ptr = &((*ptr)->more);
-
 
184
	}
146
  if (*ptr) {
185
	if (*ptr) {
147
    d = *ptr;
186
		d = *ptr;
148
    *ptr = d->more;
187
		*ptr = d->more;
149
  }
-
 
150
  else {
188
	} else {
151
    d = f_lexical_block_dg (no_dg_idname_option, no_dg_sourcepos_option);
189
		d = f_lexical_block_dg(no_dg_idname_option,
-
 
190
				       no_dg_sourcepos_option);
152
    d->data.i_scope.begin_st = (long)(-1);
191
		d->data.i_scope.begin_st = (long)(-1);
153
    doing_mark_scope = 1;
192
		doing_mark_scope = 1;
154
  }
193
	}
155
  d->more = dgf(e);
194
	d->more = dgf(e);
156
  dgf(e) = d;
195
	dgf(e) = d;
157
  return;
-
 
158
}
-
 
159
 
-
 
160
void correct_mark_scope
-
 
161
    PROTO_N ( (e) )
-
 
162
    PROTO_T ( exp e )
-
 
163
{
-
 
164
  dg_info d = nildiag;
-
 
165
  dg_info * ptr = &(dgf(bro(son(e))));
-
 
166
  while (*ptr && (*ptr)->key != DGA_SCOPE)
-
 
167
    ptr = &((*ptr)->more);
-
 
168
  if (*ptr) {
-
 
169
    d = *ptr;
-
 
170
    *ptr = d->more;
-
 
171
  }
-
 
172
  if (d) {
-
 
173
    d->more = dgf(e);
-
 
174
    dgf(e) = d;
-
 
175
  }
-
 
176
  return;
196
	return;
177
}
197
}
178
 
198
 
179
 
199
 
-
 
200
void
-
 
201
correct_mark_scope(exp e)
-
 
202
{
-
 
203
	dg_info d = nildiag;
-
 
204
	dg_info *ptr = &(dgf(bro(son(e))));
-
 
205
	while (*ptr && (*ptr)->key != DGA_SCOPE) {
-
 
206
		ptr = &((*ptr)->more);
-
 
207
	}
-
 
208
	if (*ptr) {
-
 
209
		d = *ptr;
-
 
210
		*ptr = d->more;
-
 
211
	}
-
 
212
	if (d) {
-
 
213
		d->more = dgf(e);
-
 
214
		dgf(e) = d;
-
 
215
	}
-
 
216
	return;
-
 
217
}
-
 
218
 
-
 
219
 
180
#else
220
#else
-
 
221
 
-
 
222
 
-
 
223
/* PROCEDURES */
-
 
224
 
-
 
225
static exp
-
 
226
previous_scope(exp e)
-
 
227
{
-
 
228
	if (!last(e) || bro(e) == nilexp) {
-
 
229
		return nilexp;
-
 
230
	}
-
 
231
 
-
 
232
	if (name(bro(e)) == diagnose_tag && (props(bro(e)) & 0x7) == 1) {
-
 
233
		return previous_scope(bro(e));
-
 
234
	}
-
 
235
 
-
 
236
	if (name(bro(e)) == diagnose_tag) {
-
 
237
		return bro(e);
-
 
238
	}
-
 
239
 
-
 
240
	if (name(bro(e)) == ident_tag && last(bro(e))) {
-
 
241
		if (bro(bro(e)) == nilexp) {
-
 
242
			return nilexp;
-
 
243
		}
-
 
244
 
-
 
245
		if (name(bro(bro(e))) == diagnose_tag &&
-
 
246
		    (props(bro(bro(e))) & 0x7) == 1) {
-
 
247
			return previous_scope(bro(bro(e)));
-
 
248
		}
-
 
249
 
-
 
250
		if (name(bro(bro(e))) == diagnose_tag) {
-
 
251
			return bro(bro(e));
-
 
252
		}
-
 
253
 
-
 
254
		return nilexp;
-
 
255
	}
-
 
256
 
-
 
257
	return nilexp;
-
 
258
}
-
 
259
 
-
 
260
 
-
 
261
static int
-
 
262
param_scope(exp e)
-
 
263
{
-
 
264
	diag_info *d = dno(e);
-
 
265
	if (d->key == DIAG_INFO_ID) {
-
 
266
		return isparam(son(d->data.id_scope.access));
-
 
267
	}
-
 
268
	return 0;
-
 
269
}
-
 
270
 
181
 
271
 
182
 
-
 
183
/* PROCEDURES */
-
 
184
 
-
 
185
static exp previous_scope
272
static int
186
    PROTO_N ( (e) )
-
 
187
    PROTO_T ( exp e )
273
needs_hiding(exp a, exp b)
188
{
274
{
189
  if (!last(e) || bro(e) == nilexp)
-
 
190
    return nilexp;
-
 
191
 
-
 
192
  if (name(bro(e)) == diagnose_tag && (props(bro(e)) & 0x7) == 1)
-
 
193
    return previous_scope(bro(e));
-
 
194
 
-
 
195
  if (name(bro(e)) == diagnose_tag)
275
	diag_info *da = dno(a);
196
    return bro(e);
276
	diag_info *db = dno(b);
197
 
-
 
198
  if (name(bro(e)) == ident_tag && last(bro(e)))
-
 
199
   {
-
 
200
     if (bro(bro(e)) == nilexp)
-
 
201
       return nilexp;
-
 
202
 
277
 
203
     if (name(bro(bro(e))) == diagnose_tag &&
278
	if (da->key != db->key) {
204
           (props(bro(bro(e))) & 0x7) == 1)
-
 
205
       return previous_scope(bro(bro(e)));
279
		return 0;
-
 
280
	}
206
 
281
 
-
 
282
	switch (da->key) {
-
 
283
	case DIAG_INFO_ID:
-
 
284
		return !strcmp(da->data.id_scope.nme.ints.chars,
-
 
285
			       db->data.id_scope.nme.ints.chars);
-
 
286
	case DIAG_INFO_TYPE:
-
 
287
		return !strcmp(da->data.type_scope.nme.ints.chars,
-
 
288
			       db->data.type_scope.nme.ints.chars);
-
 
289
	case DIAG_INFO_TAG:
-
 
290
		return !strcmp(da->data.tag_scope.nme.ints.chars,
207
     if (name(bro(bro(e))) == diagnose_tag)
291
			       db->data.tag_scope.nme.ints.chars);
-
 
292
	default:
208
       return bro(bro(e));
293
		return 0;
-
 
294
	}
-
 
295
}
209
 
296
 
210
     return nilexp;
-
 
211
   };
-
 
212
 
-
 
213
  return nilexp;
-
 
214
}
-
 
215
 
-
 
216
 
-
 
217
static int param_scope
-
 
218
    PROTO_N ( (e) )
-
 
219
    PROTO_T ( exp e )
-
 
220
{
-
 
221
  diag_info * d = dno(e);
-
 
222
  if (d -> key == DIAG_INFO_ID)
-
 
223
    return isparam(son(d -> data.id_scope.access));
-
 
224
  return 0;
-
 
225
}
-
 
226
 
-
 
227
static int needs_hiding
-
 
228
    PROTO_N ( (a, b) )
-
 
229
    PROTO_T ( exp a X exp b )
-
 
230
{
-
 
231
  diag_info * da = dno(a);
-
 
232
  diag_info * db = dno(b);
-
 
233
 
-
 
234
  if (da -> key != db -> key)
-
 
235
    return 0;
-
 
236
 
-
 
237
  switch (da -> key)
-
 
238
    {
-
 
239
      case DIAG_INFO_ID:
-
 
240
         return !strcmp(da -> data.id_scope.nme.ints.chars,
-
 
241
                        db -> data.id_scope.nme.ints.chars);
-
 
242
      case DIAG_INFO_TYPE:
-
 
243
         return !strcmp(da -> data.type_scope.nme.ints.chars,
-
 
244
                        db -> data.type_scope.nme.ints.chars);
-
 
245
      case DIAG_INFO_TAG:
-
 
246
         return !strcmp(da -> data.tag_scope.nme.ints.chars,
-
 
247
                        db -> data.tag_scope.nme.ints.chars);
-
 
248
      default: return 0;
-
 
249
    };
-
 
250
}
-
 
251
 
297
 
252
void mark_scope
298
void
253
    PROTO_N ( (e) )
-
 
254
    PROTO_T ( exp e )
299
mark_scope(exp e)
255
{
300
{
256
  exp scope = e;
301
	exp scope = e;
257
 
302
 
258
  if (param_scope(e))
303
	if (param_scope(e)) {
259
     return;
304
		return;
-
 
305
	}
260
 
306
 
261
  while (1)
307
	while (1) {
262
   {
-
 
263
      scope = previous_scope(scope);
308
		scope = previous_scope(scope);
264
 
309
 
265
      if (scope == nilexp || param_scope(scope) ||
310
		if (scope == nilexp || param_scope(scope) ||
266
             needs_hiding(e, scope))
311
		    needs_hiding(e, scope)) {
267
       {
-
 
268
         props(e) = (prop)(props(e) | 0x80);
312
			props(e) = (prop)(props(e) | 0x80);
269
         return;
313
			return;
270
       };
314
		}
271
 
315
 
272
      if (props(scope) & 0x80)
316
		if (props(scope) & 0x80) {
273
         return;
317
			return;
-
 
318
		}
274
 
319
 
275
   };
320
	}
276
}
321
}
277
 
322
 
278
#endif
323
#endif