Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/**********************************************************************
32
$Author: release $
33
$Date: 1998/01/17 15:55:46 $
34
$Revision: 1.1.1.1 $
35
$Log: mark_scope.c,v $
36
 * Revision 1.1.1.1  1998/01/17  15:55:46  release
37
 * First version to be checked into rolling release.
38
 *
39
 * Revision 1.8  1998/01/09  09:30:07  pwe
40
 * prep restructure
41
 *
42
 * Revision 1.7  1997/10/28  10:12:38  pwe
43
 * local location support
44
 *
45
 * Revision 1.6  1997/10/23  09:21:26  pwe
46
 * ANDF-DE V1.7 and extra diags
47
 *
48
 * Revision 1.5  1997/08/23  13:27:24  pwe
49
 * initial ANDF-DE
50
 *
51
 * Revision 1.4  1997/04/02  12:55:05  currie
52
 * includes before ifdef
53
 *
54
Revision 1.3  1997/03/20 17:04:53  currie
55
Dwarf2 diags
56
 
57
Revision 1.2  1997/02/18 12:55:52  currie
58
NEW DIAG STRUCTURE
59
 
60
 * Revision 1.1  1995/04/06  10:42:55  currie
61
 * Initial revision
62
 *
63
***********************************************************************/
64
 
65
 
66
#include "config.h"
67
#include "common_types.h"
68
#include "expmacs.h"
69
#include "tags.h"
70
#include "xalloc.h"
71
#include "externs.h"
72
#include "dg_aux.h"
73
#include "mark_scope.h"
74
 
75
 
76
#ifdef NEWDIAGS
77
 
78
int doing_mark_scope = 0;
79
 
80
void mark_scope
81
    PROTO_N ( (e) )
82
    PROTO_T ( exp e )
83
{
84
	/* called by read_diag_id_scope; dgf(e) holds DIAG_INFO_ID */
85
  dg_info d = dgf(e);
86
  dg_info * ptr;
87
  exp id;
88
  if (!d || d->key != DGA_NAME || d->data.i_nam.dnam->key != DGN_OBJECT)
89
    return;
90
  id = son(d->data.i_nam.dnam->data.n_obj.obtain_val);
91
  if (name(id) == cont_tag)
92
    id = son(id);
93
  if (name(id) != name_tag)
94
    return;
95
  id = son(id);
96
  if (isparam(id))
97
    return;
98
  ptr = &(d->more);
99
  d = nildiag;
100
  while (*ptr && (*ptr)->key != DGA_SCOPE)
101
    ptr = &((*ptr)->more);
102
  if (!*ptr && name(e) == seq_tag && name(son(son(e))) == ass_tag
103
		&& last(son(son(e))) && name(bro(son(e))) != ident_tag ) {
104
    ptr = &dgf(bro(son(e)));
105
    while (*ptr && (*ptr)->key != DGA_SCOPE)
106
      ptr = &((*ptr)->more);
107
  }
108
  if (*ptr) {
109
    d = *ptr;
110
    *ptr = d->more;
111
  }
112
  else {
113
    d = f_lexical_block_dg (no_dg_idname_option, no_dg_sourcepos_option);
114
    d->data.i_scope.begin_st = (long)(-1);
115
    doing_mark_scope = 1;
116
  }
117
  /* if (isglob(id)) */ {
118
    d->more = dgf(e);
119
    dgf(e) = d;
120
  }
121
#if 0
122
  else {
123
    exp def = son(id);
124
    if (dgf(def) && dgf(def)->key == DGA_SRC)
125
      dgf(e)->data.i_nam.dnam->whence = dgf(def)->data.i_src.startpos;
126
    d->more = dgf(id);
127
    dgf(id) = d;
128
  }
129
#endif
130
  return;
131
}
132
 
133
void mark_scope2
134
    PROTO_N ( (e) )
135
    PROTO_T ( exp e )
136
{
137
	/* called by read_diag_type_scope; dgf(e) holds DIAG_INFO_ID */
138
  dg_info d = dgf(e);
139
  dg_info * ptr;
140
  if (!d || d->key != DGA_NAME || d->data.i_nam.dnam->key != DGN_TYPE)
141
    return;
142
  ptr = &(d->more);
143
  d = nildiag;
144
  while (*ptr && (*ptr)->key != DGA_SCOPE)
145
    ptr = &((*ptr)->more);
146
  if (*ptr) {
147
    d = *ptr;
148
    *ptr = d->more;
149
  }
150
  else {
151
    d = f_lexical_block_dg (no_dg_idname_option, no_dg_sourcepos_option);
152
    d->data.i_scope.begin_st = (long)(-1);
153
    doing_mark_scope = 1;
154
  }
155
  d->more = dgf(e);
156
  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;
177
}
178
 
179
 
180
#else
181
 
182
 
183
/* PROCEDURES */
184
 
185
static exp previous_scope
186
    PROTO_N ( (e) )
187
    PROTO_T ( exp e )
188
{
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)
196
    return bro(e);
197
 
198
  if (name(bro(e)) == ident_tag && last(bro(e)))
199
   {
200
     if (bro(bro(e)) == nilexp)
201
       return nilexp;
202
 
203
     if (name(bro(bro(e))) == diagnose_tag &&
204
           (props(bro(bro(e))) & 0x7) == 1)
205
       return previous_scope(bro(bro(e)));
206
 
207
     if (name(bro(bro(e))) == diagnose_tag)
208
       return bro(bro(e));
209
 
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
 
252
void mark_scope
253
    PROTO_N ( (e) )
254
    PROTO_T ( exp e )
255
{
256
  exp scope = e;
257
 
258
  if (param_scope(e))
259
     return;
260
 
261
  while (1)
262
   {
263
      scope = previous_scope(scope);
264
 
265
      if (scope == nilexp || param_scope(scope) ||
266
             needs_hiding(e, scope))
267
       {
268
         props(e) = (prop)(props(e) | 0x80);
269
         return;
270
       };
271
 
272
      if (props(scope) & 0x80)
273
         return;
274
 
275
   };
276
}
277
 
278
#endif