2 |
7u83 |
1 |
/*
|
|
|
2 |
Copyright (c) 1993 Open Software Foundation, Inc.
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
All Rights Reserved
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
Permission to use, copy, modify, and distribute this software
|
|
|
9 |
and its documentation for any purpose and without fee is hereby
|
|
|
10 |
granted, provided that the above copyright notice appears in all
|
|
|
11 |
copies and that both the copyright notice and this permission
|
|
|
12 |
notice appear in supporting documentation.
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING
|
|
|
16 |
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
|
17 |
PARTICULAR PURPOSE.
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
|
|
|
21 |
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
22 |
LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
|
|
|
23 |
NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
|
|
24 |
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
25 |
*/
|
|
|
26 |
|
|
|
27 |
/*
|
|
|
28 |
Crown Copyright (c) 1997
|
|
|
29 |
|
|
|
30 |
This TenDRA(r) Computer Program is subject to Copyright
|
|
|
31 |
owned by the United Kingdom Secretary of State for Defence
|
|
|
32 |
acting through the Defence Evaluation and Research Agency
|
|
|
33 |
(DERA). It is made available to Recipients with a
|
|
|
34 |
royalty-free licence for its use, reproduction, transfer
|
|
|
35 |
to other parties and amendment for any purpose not excluding
|
|
|
36 |
product development provided that any such use et cetera
|
|
|
37 |
shall be deemed to be acceptance of the following conditions:-
|
|
|
38 |
|
|
|
39 |
(1) Its Recipients shall ensure that this Notice is
|
|
|
40 |
reproduced upon any copies or amended versions of it;
|
|
|
41 |
|
|
|
42 |
(2) Any amended version of it shall be clearly marked to
|
|
|
43 |
show both the nature of and the organisation responsible
|
|
|
44 |
for the relevant amendment or amendments;
|
|
|
45 |
|
|
|
46 |
(3) Its onward transfer from a recipient to another
|
|
|
47 |
party shall be deemed to be that party's acceptance of
|
|
|
48 |
these conditions;
|
|
|
49 |
|
|
|
50 |
(4) DERA gives no warranty or assurance as to its
|
|
|
51 |
quality or suitability for any purpose and DERA accepts
|
|
|
52 |
no liability whatsoever in relation to any use to which
|
|
|
53 |
it may be put.
|
|
|
54 |
*/
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
/**********************************************************************
|
|
|
59 |
$Author: release $
|
|
|
60 |
$Date: 1998/02/04 15:49:09 $
|
|
|
61 |
$Revision: 1.2 $
|
|
|
62 |
$Log: spec_tok.c,v $
|
|
|
63 |
* Revision 1.2 1998/02/04 15:49:09 release
|
|
|
64 |
* Added OSF copyright message.
|
|
|
65 |
*
|
|
|
66 |
* Revision 1.1.1.1 1998/01/17 15:55:58 release
|
|
|
67 |
* First version to be checked into rolling release.
|
|
|
68 |
*
|
|
|
69 |
* Revision 1.2 1996/10/04 16:04:23 pwe
|
|
|
70 |
* add banners and mod for PWE ownership
|
|
|
71 |
*
|
|
|
72 |
**********************************************************************/
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
/*
|
|
|
76 |
^^^ 21/12/92 jmf Added ~div as special token
|
|
|
77 |
^^^ 26/03/93 jmf Changes for new spec 2.1
|
|
|
78 |
^^^ 24/05/93 jmf Added ~alloca as special token, not alloc
|
|
|
79 |
^^^ 10/06/93 jmf Change long to int, remove extern declarations.
|
|
|
80 |
^^^ 19/08/93 jmf Put arith_type, promote, sign_promote, convert
|
|
|
81 |
^^^ into c_arith-type.h in machine directories.
|
|
|
82 |
^^^ 19/08/93 jmf Set crt_lno in exp_to_source
|
|
|
83 |
^^^ 23/09/93 jmf Use natmacs.h
|
|
|
84 |
*/
|
|
|
85 |
|
|
|
86 |
#include "config.h"
|
|
|
87 |
#include "common_types.h"
|
|
|
88 |
#include "basicread.h"
|
|
|
89 |
#include "tags.h"
|
|
|
90 |
#include "exp.h"
|
|
|
91 |
#include "expmacs.h"
|
|
|
92 |
#include "diag_fns.h"
|
|
|
93 |
#include "flags.h"
|
|
|
94 |
#include "check.h"
|
|
|
95 |
#include "me_fns.h"
|
|
|
96 |
#include "externs.h"
|
|
|
97 |
#include "installglob.h"
|
|
|
98 |
#include "messages_r.h"
|
|
|
99 |
#include "main_reads.h"
|
|
|
100 |
#include "install_fns.h"
|
|
|
101 |
#include "c_arith_type.h"
|
|
|
102 |
#include "natmacs.h"
|
|
|
103 |
#include "spec_tok.h"
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
/* intercepts specially defined tokens */
|
|
|
107 |
|
|
|
108 |
tokval special_token PROTO_N ((t, pars, sortcode, done)) PROTO_T (token t X bitstream pars X int sortcode X int * done)
|
|
|
109 |
{
|
|
|
110 |
tokval tkv;
|
|
|
111 |
UNUSED(sortcode);
|
|
|
112 |
|
|
|
113 |
if (t -> tok_name == (char*)0) {
|
|
|
114 |
SET(tkv); /* call looks at done to see if result is meaningful */
|
|
|
115 |
return tkv;
|
|
|
116 |
};
|
|
|
117 |
|
|
|
118 |
#if is80x86
|
|
|
119 |
if (!strcmp(t -> tok_name, "~div")) {
|
|
|
120 |
exp arg1, arg2;
|
|
|
121 |
place old_place;
|
|
|
122 |
old_place = keep_place();
|
|
|
123 |
set_place(pars);
|
|
|
124 |
arg1 = hold_check(d_exp());
|
|
|
125 |
arg2 = hold_check(d_exp());
|
|
|
126 |
|
|
|
127 |
set_place(old_place);
|
|
|
128 |
tkv.tk_exp = me_b2(arg1, arg2, div0_tag);
|
|
|
129 |
*done = 1;
|
|
|
130 |
return tkv;
|
|
|
131 |
};
|
|
|
132 |
if (!strcmp(t -> tok_name, "~arith_type")) {
|
|
|
133 |
int a, b;
|
|
|
134 |
place old_place;
|
|
|
135 |
signed_nat sn;
|
|
|
136 |
old_place = keep_place();
|
|
|
137 |
set_place(pars);
|
|
|
138 |
sn = d_signed_nat();
|
|
|
139 |
a = snatint(sn);
|
|
|
140 |
sn = d_signed_nat();
|
|
|
141 |
b = snatint(sn);
|
|
|
142 |
set_place(old_place);
|
|
|
143 |
snatint(sn) = arith_type(a, b);
|
|
|
144 |
tkv.tk_signed_nat = sn;
|
|
|
145 |
*done = 1;
|
|
|
146 |
return tkv;
|
|
|
147 |
};
|
|
|
148 |
if (!strcmp(t -> tok_name, "~promote")) {
|
|
|
149 |
int a;
|
|
|
150 |
place old_place;
|
|
|
151 |
signed_nat sn;
|
|
|
152 |
old_place = keep_place();
|
|
|
153 |
set_place(pars);
|
|
|
154 |
sn = d_signed_nat();
|
|
|
155 |
a = snatint(sn);
|
|
|
156 |
set_place(old_place);
|
|
|
157 |
snatint(sn) = promote(a);
|
|
|
158 |
tkv.tk_signed_nat = sn;
|
|
|
159 |
*done = 1;
|
|
|
160 |
return tkv;
|
|
|
161 |
};
|
|
|
162 |
if (!strcmp(t -> tok_name, "~sign_promote")) {
|
|
|
163 |
int a;
|
|
|
164 |
place old_place;
|
|
|
165 |
signed_nat sn;
|
|
|
166 |
old_place = keep_place();
|
|
|
167 |
set_place(pars);
|
|
|
168 |
sn = d_signed_nat();
|
|
|
169 |
a = snatint(sn);
|
|
|
170 |
set_place(old_place);
|
|
|
171 |
snatint(sn) = sign_promote(a);
|
|
|
172 |
tkv.tk_signed_nat = sn;
|
|
|
173 |
*done = 1;
|
|
|
174 |
return tkv;
|
|
|
175 |
};
|
|
|
176 |
if (!strcmp(t -> tok_name, "~convert")) {
|
|
|
177 |
int a;
|
|
|
178 |
place old_place;
|
|
|
179 |
signed_nat sn;
|
|
|
180 |
old_place = keep_place();
|
|
|
181 |
set_place(pars);
|
|
|
182 |
sn = d_signed_nat();
|
|
|
183 |
a = snatint(sn);
|
|
|
184 |
set_place(old_place);
|
|
|
185 |
tkv.tk_variety = convert((unsigned)a);
|
|
|
186 |
*done = 1;
|
|
|
187 |
return tkv;
|
|
|
188 |
};
|
|
|
189 |
#endif
|
|
|
190 |
if (!strcmp(t -> tok_name, "~alloca")) {
|
|
|
191 |
exp arg1;
|
|
|
192 |
place old_place;
|
|
|
193 |
old_place = keep_place();
|
|
|
194 |
set_place(pars);
|
|
|
195 |
arg1 = hold_check(d_exp());
|
|
|
196 |
set_place(old_place);
|
|
|
197 |
tkv.tk_exp = hold_check(me_u3(f_pointer(long_to_al(8)),
|
|
|
198 |
arg1, alloca_tag));
|
|
|
199 |
*done = 1;
|
|
|
200 |
has_alloca = 1;
|
|
|
201 |
return tkv;
|
|
|
202 |
};
|
|
|
203 |
|
|
|
204 |
if (!strcmp(t -> tok_name, "~exp_to_source") ||
|
|
|
205 |
!strcmp(t -> tok_name, "~diag_id_scope") ||
|
|
|
206 |
!strcmp(t -> tok_name, "~diag_type_scope") ||
|
|
|
207 |
!strcmp(t -> tok_name, "~diag_tag_scope")) {
|
|
|
208 |
|
|
|
209 |
place old_place;
|
|
|
210 |
old_place = keep_place();
|
|
|
211 |
set_place(pars);
|
|
|
212 |
tkv.tk_exp = hold_check(d_exp());
|
|
|
213 |
*done = 1;
|
|
|
214 |
|
|
|
215 |
if (!diagnose)
|
|
|
216 |
{
|
|
|
217 |
set_place(old_place);
|
|
|
218 |
return tkv;
|
|
|
219 |
};
|
|
|
220 |
|
|
|
221 |
if (!strcmp(t -> tok_name, "~exp_to_source"))
|
|
|
222 |
{exp r;
|
|
|
223 |
diag_info * di = read_exp_to_source();
|
|
|
224 |
crt_lno = natint(di -> data.source.end.line_no);
|
|
|
225 |
crt_charno = natint(di -> data.source.end.char_off);
|
|
|
226 |
crt_flnm = di -> data.source.beg.file->file.ints.chars;
|
|
|
227 |
r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
|
|
|
228 |
1, 0, diagnose_tag);
|
|
|
229 |
setfather(r, tkv.tk_exp);
|
|
|
230 |
dno(r) = di;
|
|
|
231 |
tkv.tk_exp = r;
|
|
|
232 |
set_place(old_place);
|
|
|
233 |
return tkv;
|
|
|
234 |
};
|
|
|
235 |
|
|
|
236 |
if (!strcmp(t -> tok_name, "~diag_id_scope"))
|
|
|
237 |
{exp r;
|
|
|
238 |
diag_info * di = read_diag_id_scope();
|
|
|
239 |
r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
|
|
|
240 |
2, 0, diagnose_tag);
|
|
|
241 |
setfather(r, tkv.tk_exp);
|
|
|
242 |
dno(r) = di;
|
|
|
243 |
tkv.tk_exp = r;
|
|
|
244 |
set_place(old_place);
|
|
|
245 |
return tkv;
|
|
|
246 |
};
|
|
|
247 |
|
|
|
248 |
if (!strcmp(t -> tok_name, "~diag_type_scope"))
|
|
|
249 |
{exp r;
|
|
|
250 |
diag_info * di = read_diag_type_scope();
|
|
|
251 |
r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
|
|
|
252 |
3, 0, diagnose_tag);
|
|
|
253 |
setfather(r, tkv.tk_exp);
|
|
|
254 |
dno(r) = di;
|
|
|
255 |
tkv.tk_exp = r;
|
|
|
256 |
set_place(old_place);
|
|
|
257 |
return tkv;
|
|
|
258 |
};
|
|
|
259 |
|
|
|
260 |
if (!strcmp(t -> tok_name, "~diag_tag_scope"))
|
|
|
261 |
{exp r;
|
|
|
262 |
diag_info * di = read_diag_tag_scope();
|
|
|
263 |
r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
|
|
|
264 |
4, 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 |
|
|
|
272 |
|
|
|
273 |
};
|
|
|
274 |
|
|
|
275 |
SET(tkv); /* call looks at done to see if result is meaningful */
|
|
|
276 |
return tkv;
|
|
|
277 |
}
|