Subversion Repositories tendra.SVN

Rev

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
/* 	$Id: syms.c,v 1.2 1998/02/04 10:43:33 release Exp $	 */
32
 
33
#ifndef lint
34
static char vcid[] = "$Id: syms.c,v 1.2 1998/02/04 10:43:33 release Exp $";
35
#endif /* lint */
36
 
37
/*  
38
syms.c   - produce symbol numbers for binasm (dense numbers)
39
*/
40
 
41
/*
42
$Log: syms.c,v $
43
 * Revision 1.2  1998/02/04  10:43:33  release
44
 * Changes during testing.
45
 *
46
 * Revision 1.1.1.1  1998/01/17  15:56:01  release
47
 * First version to be checked into rolling release.
48
 *
49
 * Revision 1.3  1995/06/28  10:27:21  john
50
 * Changed type of currentfile
51
 *
52
 * Revision 1.2  1995/05/16  10:56:09  john
53
 * Changes for spec 3.1
54
 *
55
 * Revision 1.1.1.1  1995/03/23  10:39:29  john
56
 * Entered into CVS
57
 *
58
 * Revision 1.4  1995/03/23  10:15:53  john
59
 * Various fixes
60
 *
61
 * Revision 1.3  1995/01/26  13:51:42  john
62
 * Added include files and removed unused variable
63
 *
64
*/
65
 
66
#include "config.h"
67
#include "xalloc.h"
68
#include "flags.h"
69
#include "common_types.h"
70
#include "expmacs.h"
71
#include "shapemacs.h"
72
#include "syms.h"
73
#include "tags.h"
74
#include "common_types.h"
75
#include "main.h"
76
#include "alphadiags.h"
77
#include "symbol.h"
78
#include "cross_config.h"
79
extern int currentfile;
80
 
81
#ifndef CROSS_INCLUDE
82
#include <symconst.h>
83
#include <sym.h>
84
#else
85
#include CROSS_INCLUDE/symconst.h>
86
#include CROSS_INCLUDE/sym.h>
87
#endif
88
 
89
 
90
int  *symnos;
91
int  *tempsnos = (int *) 0;
92
 
93
int   next_temps = 0;
94
int   no_temps = 0;
95
 
96
/* 
97
   produce a symbolno for global given by ex in file filen 
98
*/
99
int symnoforext
100
    PROTO_N ( ( ex,filen ) )
101
    PROTO_T ( dec *ex X int filen )
102
{
103
  exp tg = ex -> dec_u.dec_val.dec_exp;
104
  shape s = ex -> dec_u.dec_val.dec_shape;
105
  diag_type dt = (diag_type)0; 
106
  short   symtype;
107
  short   symclass;
108
  long  v = 0;
109
  char *id = ex -> dec_u.dec_val.dec_id;
110
  if (diagnose) {		
111
    diag_descriptor * t = ex ->dec_u.dec_val.diag_info;
112
    if (t != (diag_descriptor *) 0) {
113
      id = t -> data.id.nme.ints.chars;
114
      dt = t -> data.id.new_type;
115
      filen = find_file(t ->data.id.whence.file);
116
    }
117
  }
118
  if (ex -> dec_u.dec_val.extnamed) {/* it is global */
119
    if (name (s) == prokhd && !isvar (tg) && (son(tg)==nilexp || 
120
					      name(son(tg))==proc_tag ||
121
					      name(son(tg))==general_proc_tag
122
					      )) {
123
    /* a declared procedure */
124
      symtype = stProc;
125
      if (son (tg) != nilexp){	/* a defined procedure will be output
126
				   later with this symbolno */
127
	return add_dense_no (0, 0);
128
      }
129
      symclass = scUndefined;
130
    }
131
    else {			/* some other global */
132
      ash a;
133
      symtype = stGlobal;
134
      symclass =
135
	(son (tg) != nilexp) ?
136
	((name (son (tg))) != clear_tag ? scData : scCommon)
137
	: scNil;
138
      a = ashof (s);
139
      v = (a.ashsize + 7) >> 3;
140
    }
141
    return new_esym_d (id, v, symtype, symclass, dt, filen);
142
  }
143
  else {			/* statics */
144
    if (name (s) == prokhd && !isvar (tg) && (son(tg)==nilexp||
145
					      name(son(tg))==proc_tag ||
146
					      name(son(tg))==general_proc_tag
147
					      )) {
148
/* a procedure */
149
      symtype = stStaticProc;
150
/*      if (son (tg) != nilexp)*/
151
	return add_dense_no (0, 0);
152
      /* a defined procedure will be output later with this symbolno */
153
/*      failer ("Static procs should have bodies ");*/
154
      symclass = scNil;
155
    }
156
    else {			/* other statics */
157
      symtype = stStatic;
158
      symclass = (son(tg)== nilexp || name (son (tg)) != clear_tag) 
159
                     ? scData : scCommon;
160
    }
161
    return new_lsym_d (id, v, symtype, symclass, dt, filen);
162
  }
163
}
164
 
165
 
166
/* 
167
   output symbolno for start of proc 
168
*/
169
int symnoforstart
170
    PROTO_N ( ( i,filen ) )
171
    PROTO_T ( int i X int filen )
172
{
173
  dec * ex = main_globals[i];
174
  short   symtype = (ex -> dec_u.dec_val.extnamed) ? stProc : stStaticProc;
175
  char *id = ex -> dec_u.dec_val.dec_id;
176
  diag_type dt = (diag_type)0;
177
  if (diagnose) {		
178
    diag_descriptor * t = ex ->dec_u.dec_val.diag_info;
179
    if (t != (diag_descriptor *) 0) {
180
      id = t ->data.id.nme.ints.chars;
181
      dt = t -> data.id.new_type;
182
      filen = find_file(t ->data.id.whence.file);
183
    }
184
  }
185
 
186
  return new_lsym (id, symnos[i], symtype, scText, dt, filen);
187
}
188
 
189
 
190
/* output symbolno for end of proc */
191
int symnoforend
192
    PROTO_N ( ( ex,filen ) )
193
    PROTO_T ( dec *ex X int filen )
194
{
195
  char *id = ex -> dec_u.dec_val.dec_id;
196
  diag_type dt = (diag_type)0;  
197
  if (diagnose) {		
198
    diag_descriptor * t = ex ->dec_u.dec_val.diag_info;
199
    if (t != (diag_descriptor *) 0) {
200
      id = t -> data.id.nme.ints.chars;
201
      dt = t -> data.id.new_type;
202
      filen = find_file(t -> data.id.whence.file);
203
    }
204
  }
205
 
206
  return new_lsym_d (id, 0, stEnd, scText, dt, filen);
207
}
208
 
209
 
210
/* 
211
   output symbol number for data_lab and remember it in tempsnos 
212
*/
213
int symnofordata
214
    PROTO_N ( ( data_lab ) )
215
    PROTO_T ( int data_lab )
216
{
217
  int   a = data_lab - 32;
218
  if (a >= no_temps) {
219
    tempsnos = (int *) xrealloc ((char *) tempsnos, (100 + a) * sizeof (int));
220
    no_temps = a + 100;
221
  }
222
 
223
  return (tempsnos[a] = add_dense_no (currentfile, 1048575 /* ???? */ ));
224
}
225
 
226
 
227
 
228
 
229
 
230
 
231
 
232
 
233
 
234