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: spec_tok.c,v 1.1.1.1 1998/01/17 15:56:01 release Exp $ */
|
|
|
32 |
|
|
|
33 |
#ifndef lint
|
|
|
34 |
static char vcid[] = "$Id: spec_tok.c,v 1.1.1.1 1998/01/17 15:56:01 release Exp $";
|
|
|
35 |
#endif /* lint */
|
|
|
36 |
|
|
|
37 |
/*
|
|
|
38 |
$Log: spec_tok.c,v $
|
|
|
39 |
* Revision 1.1.1.1 1998/01/17 15:56:01 release
|
|
|
40 |
* First version to be checked into rolling release.
|
|
|
41 |
*
|
|
|
42 |
* Revision 1.5 1995/09/15 16:23:48 john
|
|
|
43 |
* New exception handling
|
|
|
44 |
*
|
|
|
45 |
* Revision 1.4 1995/09/13 11:03:49 john
|
|
|
46 |
* Fix
|
|
|
47 |
*
|
|
|
48 |
* Revision 1.3 1995/09/13 08:23:16 john
|
|
|
49 |
* Addition for exception handling
|
|
|
50 |
*
|
|
|
51 |
* Revision 1.2 1995/05/16 10:55:42 john
|
|
|
52 |
* Removed unused code.
|
|
|
53 |
*
|
|
|
54 |
* Revision 1.1.1.1 1995/03/23 10:39:36 john
|
|
|
55 |
* Entered into CVS
|
|
|
56 |
*
|
|
|
57 |
* Revision 1.8 1995/01/26 13:49:51 john
|
|
|
58 |
* Removed unused variable
|
|
|
59 |
*
|
|
|
60 |
*/
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
#include "config.h"
|
|
|
64 |
#include "common_types.h"
|
|
|
65 |
#include "basicread.h"
|
|
|
66 |
#include "tags.h"
|
|
|
67 |
#include "exp.h"
|
|
|
68 |
#include "expmacs.h"
|
|
|
69 |
#include "diag_fns.h"
|
|
|
70 |
#include "flags.h"
|
|
|
71 |
#include "check.h"
|
|
|
72 |
#include "me_fns.h"
|
|
|
73 |
#include "externs.h"
|
|
|
74 |
#include "installglob.h"
|
|
|
75 |
#include "messages_r.h"
|
|
|
76 |
#include "main_reads.h"
|
|
|
77 |
#include "install_fns.h"
|
|
|
78 |
#include "c_arith_type.h"
|
|
|
79 |
#include "natmacs.h"
|
|
|
80 |
|
|
|
81 |
#include "spec_tok.h"
|
|
|
82 |
#include "shapemacs.h"
|
|
|
83 |
#include "szs_als.h"
|
|
|
84 |
#include "new_tags.h"
|
|
|
85 |
/* intercepts specially defined tokens */
|
|
|
86 |
|
|
|
87 |
#define MAX_INT 2147483647
|
|
|
88 |
#define MIN_INT (-MAX_INT-1)
|
|
|
89 |
#define UMAX_INT 4294967295U
|
|
|
90 |
extern shape f_off64_64;
|
|
|
91 |
extern shape f_off32_32;
|
|
|
92 |
|
|
|
93 |
/*
|
|
|
94 |
This function returns a component at offset 'align' from the
|
|
|
95 |
compound given in e.
|
|
|
96 |
*/
|
|
|
97 |
exp get_component
|
|
|
98 |
PROTO_N ( ( e,shc,align,size,nm,offshape,offset ) )
|
|
|
99 |
PROTO_T ( exp e X alignment shc X alignment align X int size X int nm X shape offshape X int offset )
|
|
|
100 |
{
|
|
|
101 |
|
|
|
102 |
exp offsetexp /* offset in compound for required component */
|
|
|
103 |
= getexp(offshape,nilexp,0,nilexp,nilexp,0,offset,val_tag);
|
|
|
104 |
|
|
|
105 |
shape resshape /* shape of component */
|
|
|
106 |
= getshape(1,shc,shc,align,size,nm);
|
|
|
107 |
|
|
|
108 |
return hold_check(f_component(resshape,hold_check(me_u3(sh(son(son(e))),e,cont_tag)),offsetexp));
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
tokval special_token
|
|
|
113 |
PROTO_N ( ( t, pars, sortcode, done ) )
|
|
|
114 |
PROTO_T ( token t X bitstream pars X int sortcode X int *done )
|
|
|
115 |
{
|
|
|
116 |
tokval tkv;
|
|
|
117 |
UNUSED(sortcode);
|
|
|
118 |
if (t -> tok_name == (char*)0) {
|
|
|
119 |
SET(tkv); /* call looks at done to see if result is meaningful */
|
|
|
120 |
return tkv;
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
if (!strcmp(t -> tok_name, "~alloca")) {
|
|
|
124 |
exp arg1;
|
|
|
125 |
place old_place;
|
|
|
126 |
old_place = keep_place();
|
|
|
127 |
set_place(pars);
|
|
|
128 |
arg1 = hold_check(d_exp());
|
|
|
129 |
set_place(old_place);
|
|
|
130 |
tkv.tk_exp = hold_check(me_u3(f_pointer(long_to_al(8)),
|
|
|
131 |
arg1, alloca_tag));
|
|
|
132 |
*done = 1;
|
|
|
133 |
has_alloca = 1;
|
|
|
134 |
return tkv;
|
|
|
135 |
}
|
|
|
136 |
if(!strcmp(t->tok_name,"__builtin_isfloat")){
|
|
|
137 |
/* builtin function taking a TYPE argument and returning
|
|
|
138 |
TRUE if the argument is float,double or long double and FALSE
|
|
|
139 |
otherwise */
|
|
|
140 |
place old_place;
|
|
|
141 |
shape arg;
|
|
|
142 |
signed_nat lower,upper,resval;
|
|
|
143 |
old_place=keep_place();
|
|
|
144 |
set_place(pars);
|
|
|
145 |
arg = d_shape();
|
|
|
146 |
resval.issmall=lower.issmall=upper.issmall=1;
|
|
|
147 |
resval.negative=lower.negative=upper.negative=0;
|
|
|
148 |
lower.signed_nat_val.small_s_nat=MIN_INT;
|
|
|
149 |
upper.signed_nat_val.small_s_nat=MAX_INT;
|
|
|
150 |
if(is_floating(name(arg))){
|
|
|
151 |
resval.signed_nat_val.small_s_nat=1;
|
|
|
152 |
}
|
|
|
153 |
else{
|
|
|
154 |
resval.signed_nat_val.small_s_nat=0;
|
|
|
155 |
}
|
|
|
156 |
tkv.tk_exp = f_make_int(slongsh,resval);
|
|
|
157 |
set_place(old_place);
|
|
|
158 |
*done=1;
|
|
|
159 |
return tkv;
|
|
|
160 |
}
|
|
|
161 |
if(!strcmp(t->tok_name, "__builtin_va_token")){
|
|
|
162 |
tkv.tk_exp = getexp(f_off32_32,nilexp,0,nilexp,nilexp,0,0,val_tag);
|
|
|
163 |
set_vararg(tkv.tk_exp);
|
|
|
164 |
*done = 1;
|
|
|
165 |
return tkv;
|
|
|
166 |
}
|
|
|
167 |
|
|
|
168 |
if(!strcmp(t->tok_name, "~Sync_handler")){
|
|
|
169 |
tkv.tk_exp = getexp(f_top,nilexp,0,nilexp,nilexp,0,0,special_tag);
|
|
|
170 |
*done = 1;
|
|
|
171 |
return tkv;
|
|
|
172 |
}
|
|
|
173 |
|
|
|
174 |
if(!strcmp(t->tok_name, "__alpha_special")){
|
|
|
175 |
/* This is a means of invoking alpha assembler instructions from a
|
|
|
176 |
TDF file */
|
|
|
177 |
exp arg;
|
|
|
178 |
place old_place = keep_place();
|
|
|
179 |
set_place(pars);
|
|
|
180 |
arg = d_exp();
|
|
|
181 |
Assert(name(arg) == val_tag);
|
|
|
182 |
if(no(arg) == 0){
|
|
|
183 |
/* trapb : used to ensure that all pending execptions have been raised
|
|
|
184 |
before continuing */
|
|
|
185 |
tkv.tk_exp = getexp(f_top,nilexp,0,nilexp,nilexp,0,0,special_tag);
|
|
|
186 |
*done = 1;
|
|
|
187 |
}
|
|
|
188 |
else{
|
|
|
189 |
failer("Unsupported argument to token __alpha_special");
|
|
|
190 |
tkv.tk_exp = getexp(f_top,nilexp,0,nilexp,nilexp,0,0,null_tag);
|
|
|
191 |
*done = 1;
|
|
|
192 |
}
|
|
|
193 |
set_place(old_place);
|
|
|
194 |
return tkv;
|
|
|
195 |
}
|
|
|
196 |
|
|
|
197 |
if(!strcmp(t->tok_name, "__builtin_va_start")){
|
|
|
198 |
/* builtin function taking 3 arguments: a va_list, a va_alist,
|
|
|
199 |
and an integer i.e a compound(ptrhd,slonghd),
|
|
|
200 |
an integer(s64shd) and an integer(slonghd).
|
|
|
201 |
The pointer field of the compound is set equal to the 64
|
|
|
202 |
bit integer, and the integer field is set to 8.
|
|
|
203 |
*/
|
|
|
204 |
place old_place;
|
|
|
205 |
exp arg1,arg2,arg3; /* parameters of the token */
|
|
|
206 |
exp_list list; /* list of exps used to construct the
|
|
|
207 |
result sequence */
|
|
|
208 |
exp res = f_make_top(); /* the result part of the sequence */
|
|
|
209 |
exp assignment1,assignment2; /* the two assignment operations */
|
|
|
210 |
exp component1;
|
|
|
211 |
exp component2; /* the components of the exp */
|
|
|
212 |
exp copy_of_compound;
|
|
|
213 |
old_place = keep_place();
|
|
|
214 |
set_place(pars);
|
|
|
215 |
arg1 = d_exp();
|
|
|
216 |
arg2 = d_exp();
|
|
|
217 |
arg3 = d_exp(); /* don't care */
|
|
|
218 |
/* here we start to perform the transformation. We must obtain
|
|
|
219 |
the compound variable of arg1 and apply the component
|
|
|
220 |
operation to separate out the pointer and integer for use
|
|
|
221 |
in subsequent assignments.
|
|
|
222 |
*/
|
|
|
223 |
set_vararg(arg1);
|
|
|
224 |
copy_of_compound = copyexp(arg1);
|
|
|
225 |
component1 = get_component(arg1,const_al64,PTR_ALIGN,PTR_SZ,
|
|
|
226 |
ptrhd,f_off64_64,0);
|
|
|
227 |
component2 = get_component(copy_of_compound,const_al32,SLONG_ALIGN,
|
|
|
228 |
SLONG_SZ,slonghd,f_off32_32,64);
|
|
|
229 |
assignment1 = f_assign(component1,arg2);
|
|
|
230 |
assignment2 = f_assign(component2,getexp(f_off32_32,nilexp,0,nilexp,nilexp,
|
|
|
231 |
0,0,val_tag));
|
|
|
232 |
bro(assignment1)=assignment2;
|
|
|
233 |
list.start = assignment1;
|
|
|
234 |
list.end = assignment2;
|
|
|
235 |
list.number = 2;
|
|
|
236 |
tkv.tk_exp = f_sequence(list,res);
|
|
|
237 |
kill_exp(arg3,arg3);
|
|
|
238 |
set_place(old_place);
|
|
|
239 |
*done=1;
|
|
|
240 |
return tkv;
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
if (!strcmp(t -> tok_name, "~exp_to_source") ||
|
|
|
244 |
!strcmp(t -> tok_name, "~diag_id_scope") ||
|
|
|
245 |
!strcmp(t -> tok_name, "~diag_type_scope") ||
|
|
|
246 |
!strcmp(t -> tok_name, "~diag_tag_scope")) {
|
|
|
247 |
place old_place;
|
|
|
248 |
old_place = keep_place();
|
|
|
249 |
set_place(pars);
|
|
|
250 |
tkv.tk_exp = hold_check(d_exp());
|
|
|
251 |
*done = 1;
|
|
|
252 |
|
|
|
253 |
if (!diagnose){
|
|
|
254 |
set_place(old_place);
|
|
|
255 |
return tkv;
|
|
|
256 |
}
|
|
|
257 |
if (!strcmp(t -> tok_name, "~exp_to_source")){
|
|
|
258 |
exp r;
|
|
|
259 |
diag_info * di = read_exp_to_source();
|
|
|
260 |
crt_lno = natint(di -> data.source.end.line_no);
|
|
|
261 |
crt_charno = natint(di -> data.source.end.char_off);
|
|
|
262 |
crt_flnm = di -> data.source.beg.file->file.ints.chars;
|
|
|
263 |
r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
|
|
|
264 |
1, 0, diagnose_tag);
|
|
|
265 |
setfather(r, tkv.tk_exp);
|
|
|
266 |
dno(r) = di;
|
|
|
267 |
tkv.tk_exp = r;
|
|
|
268 |
set_place(old_place);
|
|
|
269 |
return tkv;
|
|
|
270 |
}
|
|
|
271 |
if (!strcmp(t -> tok_name, "~diag_id_scope")){
|
|
|
272 |
exp r;
|
|
|
273 |
diag_info * di = read_diag_id_scope();
|
|
|
274 |
r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
|
|
|
275 |
2, 0, diagnose_tag);
|
|
|
276 |
setfather(r, tkv.tk_exp);
|
|
|
277 |
dno(r) = di;
|
|
|
278 |
tkv.tk_exp = r;
|
|
|
279 |
set_place(old_place);
|
|
|
280 |
return tkv;
|
|
|
281 |
}
|
|
|
282 |
if (!strcmp(t -> tok_name, "~diag_type_scope")){
|
|
|
283 |
exp r;
|
|
|
284 |
diag_info * di = read_diag_type_scope();
|
|
|
285 |
r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
|
|
|
286 |
3, 0, diagnose_tag);
|
|
|
287 |
setfather(r, tkv.tk_exp);
|
|
|
288 |
dno(r) = di;
|
|
|
289 |
tkv.tk_exp = r;
|
|
|
290 |
set_place(old_place);
|
|
|
291 |
return tkv;
|
|
|
292 |
}
|
|
|
293 |
if (!strcmp(t -> tok_name, "~diag_tag_scope")){
|
|
|
294 |
exp r;
|
|
|
295 |
diag_info * di = read_diag_tag_scope();
|
|
|
296 |
r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
|
|
|
297 |
4, 0, diagnose_tag);
|
|
|
298 |
setfather(r, tkv.tk_exp);
|
|
|
299 |
dno(r) = di;
|
|
|
300 |
tkv.tk_exp = r;
|
|
|
301 |
set_place(old_place);
|
|
|
302 |
return tkv;
|
|
|
303 |
}
|
|
|
304 |
}
|
|
|
305 |
SET(tkv); /* call looks at done to see if result is meaningful */
|
|
|
306 |
return tkv;
|
|
|
307 |
}
|
|
|
308 |
|
|
|
309 |
|
|
|
310 |
|
|
|
311 |
|
|
|
312 |
|
|
|
313 |
|
|
|
314 |
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
|
|
|
318 |
|