Subversion Repositories tendra.SVN

Rev

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

Rev 5 Rev 6
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 93... Line 123...
93
 
123
 
94
 
124
 
95
/* intercepts specially defined tokens */
125
/* intercepts specially defined tokens */
96
 
126
 
97
tokval special_token
127
tokval special_token
98
    PROTO_N ( (t, pars, sortcode, done) )
-
 
99
    PROTO_T ( token t X bitstream pars X int sortcode X int * done )
128
(token t, bitstream pars, int sortcode, int * done)
100
{
129
{
101
  tokval tkv;
130
  tokval tkv;
102
  UNUSED(sortcode);
131
  UNUSED(sortcode);
103
 
132
 
104
  if (t -> tok_name == (char*)0) {
133
  if (t -> tok_name == (char*)0) {
105
    SET(tkv); /* call looks at done to see if result is meaningful */
134
    SET(tkv); /* call looks at done to see if result is meaningful */
106
    return tkv;
135
    return tkv;
107
  };
136
  };
108
 
137
 
109
  if (!strcmp(t -> tok_name, "JMFprofile"))  {
138
  if (!strcmp(t -> tok_name, "JMFprofile")) {
110
      nat n;
139
      nat n;
111
      place old_place;
140
      place old_place;
112
      old_place = keep_place();
141
      old_place = keep_place();
113
      set_place(pars);
142
      set_place(pars);
114
      n = d_nat();
143
      n = d_nat();
Line 116... Line 145...
116
      set_place(old_place);
145
      set_place(old_place);
117
      tkv.tk_exp = f_profile(n);
146
      tkv.tk_exp = f_profile(n);
118
      *done = 1;
147
      *done = 1;
119
      return tkv;
148
      return tkv;
120
  };
149
  };
121
  if (!strcmp(t -> tok_name, "JMFinline"))  {
150
  if (!strcmp(t -> tok_name, "JMFinline")) {
122
      exp s;
151
      exp s;
123
      place old_place;
152
      place old_place;
124
      old_place = keep_place();
153
      old_place = keep_place();
125
      set_place(pars);
154
      set_place(pars);
126
      IGNORE d_shape();
155
      IGNORE d_shape();
Line 138... Line 167...
138
      set_place(old_place);
167
      set_place(old_place);
139
      tkv.tk_exp = s;
168
      tkv.tk_exp = s;
140
      *done = 1;
169
      *done = 1;
141
      return tkv;
170
      return tkv;
142
  };
171
  };
143
  if (!strcmp(t -> tok_name, "~div"))  {
172
  if (!strcmp(t -> tok_name, "~div")) {
144
      exp arg1, arg2;
173
      exp arg1, arg2;
145
      place old_place;
174
      place old_place;
146
      old_place = keep_place();
175
      old_place = keep_place();
147
      set_place(pars);
176
      set_place(pars);
148
      arg1 = hold_check(d_exp());
177
      arg1 = hold_check(d_exp());
Line 151... Line 180...
151
      set_place(old_place);
180
      set_place(old_place);
152
      tkv.tk_exp = me_b2(arg1, arg2, div0_tag);
181
      tkv.tk_exp = me_b2(arg1, arg2, div0_tag);
153
      *done = 1;
182
      *done = 1;
154
      return tkv;
183
      return tkv;
155
  };
184
  };
156
  if (!strcmp(t -> tok_name, "~rem"))  {
185
  if (!strcmp(t -> tok_name, "~rem")) {
157
      exp arg1, arg2;
186
      exp arg1, arg2;
158
      place old_place;
187
      place old_place;
159
      old_place = keep_place();
188
      old_place = keep_place();
160
      set_place(pars);
189
      set_place(pars);
161
      arg1 = hold_check(d_exp());
190
      arg1 = hold_check(d_exp());
Line 177... Line 206...
177
    a = snatint(sn);
206
    a = snatint(sn);
178
    sn = d_signed_nat();
207
    sn = d_signed_nat();
179
    b = snatint(sn);
208
    b = snatint(sn);
180
    set_place(old_place);
209
    set_place(old_place);
181
    snatint(sn) = arith_type(a, b);
210
    snatint(sn) = arith_type(a, b);
182
    tkv.tk_signed_nat = sn;
211
    tkv.tk_signed_nat = sn;
183
    *done = 1;
212
    *done = 1;
184
    return tkv;
213
    return tkv;
185
  };
214
  };
186
  if (!strcmp(t -> tok_name, "~promote")) {
215
  if (!strcmp(t -> tok_name, "~promote")) {
187
    int a;
216
    int a;
188
    place old_place;
217
    place old_place;
189
    signed_nat sn;
218
    signed_nat sn;
190
    old_place = keep_place();
219
    old_place = keep_place();
191
    set_place(pars);
220
    set_place(pars);
192
    sn = d_signed_nat();
221
    sn = d_signed_nat();
193
    a = snatint(sn);
222
    a = snatint(sn);
194
    set_place(old_place);
223
    set_place(old_place);
195
    snatint(sn) = promote(a);
224
    snatint(sn) = promote(a);
196
    tkv.tk_signed_nat = sn;
225
    tkv.tk_signed_nat = sn;
197
    *done = 1;
226
    *done = 1;
198
    return tkv;
227
    return tkv;
199
  };
228
  };
200
  if (!strcmp(t -> tok_name, "~sign_promote")) {
229
  if (!strcmp(t -> tok_name, "~sign_promote")) {
201
    int a;
230
    int a;
202
    place old_place;
231
    place old_place;
203
    signed_nat sn;
232
    signed_nat sn;
204
    old_place = keep_place();
233
    old_place = keep_place();
205
    set_place(pars);
234
    set_place(pars);
206
    sn = d_signed_nat();
235
    sn = d_signed_nat();
207
    a = snatint(sn);
236
    a = snatint(sn);
208
    set_place(old_place);
237
    set_place(old_place);
209
    snatint(sn) = sign_promote(a);
238
    snatint(sn) = sign_promote(a);
Line 221... Line 250...
221
    a = snatint(sn);
250
    a = snatint(sn);
222
    set_place(old_place);
251
    set_place(old_place);
223
    tkv.tk_variety = convert((unsigned)a);
252
    tkv.tk_variety = convert((unsigned)a);
224
    *done = 1;
253
    *done = 1;
225
    return tkv;
254
    return tkv;
226
  };
255
  };
227
#endif
256
#endif
228
  if (!strcmp(t -> tok_name, "~alloca"))  {
257
  if (!strcmp(t -> tok_name, "~alloca")) {
229
      exp arg1;
258
      exp arg1;
230
      place old_place;
259
      place old_place;
231
      old_place = keep_place();
260
      old_place = keep_place();
232
      set_place(pars);
261
      set_place(pars);
233
      arg1 = hold_check(d_exp());
262
      arg1 = hold_check(d_exp());
234
      set_place(old_place);
263
      set_place(old_place);
235
      tkv.tk_exp = hold_check(me_u3(f_pointer(long_to_al(8)),
264
      tkv.tk_exp = hold_check(me_u3(f_pointer(long_to_al(8)),
236
			   arg1, alloca_tag));
265
			   arg1, alloca_tag));
237
      *done = 1;
266
      *done = 1;
238
      has_alloca = 1;
267
      has_alloca = 1;
239
      return tkv;
268
      return tkv;
240
  };
269
  };
241
 
270
 
242
  if (!strcmp(t -> tok_name, "~exp_to_source") ||
271
  if (!strcmp(t -> tok_name, "~exp_to_source") ||
Line 244... Line 273...
244
      !strcmp(t -> tok_name, "~diag_type_scope") ||
273
      !strcmp(t -> tok_name, "~diag_type_scope") ||
245
      !strcmp(t -> tok_name, "~diag_tag_scope")
274
      !strcmp(t -> tok_name, "~diag_tag_scope")
246
#ifdef NEWDIAGS
275
#ifdef NEWDIAGS
247
	|| !strcmp(t -> tok_name, "~dg_exp")
276
	|| !strcmp(t -> tok_name, "~dg_exp")
248
#endif
277
#endif
249
     )  {
278
    ) {
250
 
279
 
251
      place old_place;
280
      place old_place;
252
      old_place = keep_place();
281
      old_place = keep_place();
253
      set_place(pars);
282
      set_place(pars);
254
      tkv.tk_exp = hold_check(d_exp());
283
      tkv.tk_exp = hold_check(d_exp());
Line 261... Line 290...
261
        };
290
        };
262
 
291
 
263
     if (!strcmp(t -> tok_name, "~exp_to_source"))
292
     if (!strcmp(t -> tok_name, "~exp_to_source"))
264
       {
293
       {
265
#ifdef NEWDIAGS
294
#ifdef NEWDIAGS
266
	tkv.tk_exp = read_exp_to_source (tkv.tk_exp);
295
	tkv.tk_exp = read_exp_to_source(tkv.tk_exp);
267
#else
296
#else
268
        diag_info * di = read_exp_to_source();
297
        diag_info * di = read_exp_to_source();
269
        exp r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
298
        exp r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
270
                   1, 0, diagnose_tag);
299
                   1, 0, diagnose_tag);
271
        setfather(r, tkv.tk_exp);
300
        setfather(r, tkv.tk_exp);
272
        dno(r) = di;
301
        dno(r) = di;
273
        tkv.tk_exp = r;
302
        tkv.tk_exp = r;
274
	crt_lno = natint(di -> data.source.end.line_no);
303
	crt_lno = natint(di -> data.source.end.line_no);
275
	crt_charno = natint(di -> data.source.end.char_off);
304
	crt_charno = natint(di -> data.source.end.char_off);
276
	crt_flnm = di -> data.source.beg.file->file.ints.chars;
305
	crt_flnm = di -> data.source.beg.file->file.ints.chars;
277
#endif
306
#endif
Line 280... Line 309...
280
       };
309
       };
281
 
310
 
282
     if (!strcmp(t -> tok_name, "~diag_id_scope"))
311
     if (!strcmp(t -> tok_name, "~diag_id_scope"))
283
       {
312
       {
284
#ifdef NEWDIAGS
313
#ifdef NEWDIAGS
285
        tkv.tk_exp = read_diag_id_scope (tkv.tk_exp);
314
        tkv.tk_exp = read_diag_id_scope(tkv.tk_exp);
286
#else
315
#else
287
        diag_info * di = read_diag_id_scope();
316
        diag_info * di = read_diag_id_scope();
288
        exp r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
317
        exp r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
289
                   2, 0, diagnose_tag);
318
                   2, 0, diagnose_tag);
290
        setfather(r, tkv.tk_exp);
319
        setfather(r, tkv.tk_exp);
Line 296... Line 325...
296
       };
325
       };
297
 
326
 
298
     if (!strcmp(t -> tok_name, "~diag_type_scope"))
327
     if (!strcmp(t -> tok_name, "~diag_type_scope"))
299
       {
328
       {
300
#ifdef NEWDIAGS
329
#ifdef NEWDIAGS
301
        tkv.tk_exp = read_diag_type_scope (tkv.tk_exp);
330
        tkv.tk_exp = read_diag_type_scope(tkv.tk_exp);
302
#else
331
#else
303
        diag_info * di = read_diag_type_scope();
332
        diag_info * di = read_diag_type_scope();
304
        exp r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
333
        exp r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
305
                   3, 0, diagnose_tag);
334
                   3, 0, diagnose_tag);
306
        setfather(r, tkv.tk_exp);
335
        setfather(r, tkv.tk_exp);
Line 326... Line 355...
326
       };
355
       };
327
 
356
 
328
#ifdef NEWDIAGS
357
#ifdef NEWDIAGS
329
     if (!strcmp(t -> tok_name, "~dg_exp"))
358
     if (!strcmp(t -> tok_name, "~dg_exp"))
330
       {
359
       {
331
        tkv.tk_exp = read_dg_exp (tkv.tk_exp);
360
        tkv.tk_exp = read_dg_exp(tkv.tk_exp);
332
        set_place(old_place);
361
        set_place(old_place);
333
        return tkv;
362
        return tkv;
334
       };
363
       };
335
#endif
364
#endif
336
 
365
 
Line 341... Line 370...
341
    exp arg1;
370
    exp arg1;
342
    place old_place;
371
    place old_place;
343
    old_place = keep_place();
372
    old_place = keep_place();
344
    if (!strcmp(t -> tok_name, "~asm")) {
373
    if (!strcmp(t -> tok_name, "~asm")) {
345
      set_place(pars);
374
      set_place(pars);
346
      arg1 = hold_check (f_make_nof_int (ucharsh, d_string()));
375
      arg1 = hold_check(f_make_nof_int(ucharsh, d_string()));
347
      prp = 1;
376
      prp = 1;
348
    }
377
    }
349
    else {
378
    else {
350
      if (!strcmp(t -> tok_name, "~asm_sequence"))
379
      if (!strcmp(t -> tok_name, "~asm_sequence"))
351
	prp = 0;
380
	prp = 0;
Line 359... Line 388...
359
      if (!strcmp(t -> tok_name, "~asm_exp_address"))
388
      if (!strcmp(t -> tok_name, "~asm_exp_address"))
360
	prp = 8;
389
	prp = 8;
361
      else
390
      else
362
	return tkv;
391
	return tkv;
363
      set_place(pars);
392
      set_place(pars);
364
      arg1 = hold_check (d_exp());
393
      arg1 = hold_check(d_exp());
365
    }
394
    }
366
    set_place(old_place);
395
    set_place(old_place);
367
    tkv.tk_exp = getexp (f_top, nilexp, 0, arg1, nilexp, prp, 0, asm_tag);
396
    tkv.tk_exp = getexp(f_top, nilexp, 0, arg1, nilexp, prp, 0, asm_tag);
368
    setfather (tkv.tk_exp, arg1);
397
    setfather(tkv.tk_exp, arg1);
369
    *done = 1;
398
    *done = 1;
370
    return tkv;
399
    return tkv;
371
  }
400
  }
372
 
401
 
373
  SET(tkv); /* call looks at done to see if result is meaningful */
402
  SET(tkv); /* call looks at done to see if result is meaningful */