Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251
WebSVN – tendra.SVN – Diff – /trunk/src/installers/common/construct/install_fns.c – Rev 2 and 7

Subversion Repositories tendra.SVN

Rev

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

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2006 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 73... Line 103...
73
 * unsigned cases
103
 * unsigned cases
74
 *
104
 *
75
 * Revision 1.78  1996/11/11  10:05:39  currie
105
 * Revision 1.78  1996/11/11  10:05:39  currie
76
 * current_env on hppa
106
 * current_env on hppa
77
 *
107
 *
78
Revision 1.77  1996/10/29 10:10:46  currie
108
 * Revision 1.77  1996/10/29 10:10:46  currie
79
512 bit alignment for hppa
109
 * 512 bit alignment for hppa
80
 
110
 *
81
 * Revision 1.76  1996/10/21  08:53:55  currie
111
 * Revision 1.76  1996/10/21  08:53:55  currie
82
 * long_jump_access
112
 * long_jump_access
83
 *
113
 *
84
Revision 1.75  1996/10/01 08:59:22  currie
114
 * Revision 1.75  1996/10/01 08:59:22  currie
85
correct chvar exceptions ADA
115
 * correct chvar exceptions ADA
86
 
116
 *
87
Revision 1.74  1996/09/04 14:44:40  currie
117
 * Revision 1.74  1996/09/04 14:44:40  currie
88
mis-spelling
118
 * mis-spelling
89
 
119
 *
90
Revision 1.73  1996/09/04 14:19:55  currie
120
 * Revision 1.73  1996/09/04 14:19:55  currie
91
mis-spelling
121
 * mis-spelling
92
 
122
 *
93
Revision 1.71  1996/07/05 15:45:09  currie
123
 * Revision 1.71  1996/07/05 15:45:09  currie
94
initial values
124
 * initial values
95
 
125
 *
96
Revision 1.70  1996/06/19 11:50:36  currie
126
 * Revision 1.70  1996/06/19 11:50:36  currie
97
Parameter alignments in make_coumpound
127
 * Parameter alignments in make_coumpound
98
 
128
 *
99
Revision 1.69  1996/06/18 09:20:55  currie
129
 * Revision 1.69  1996/06/18 09:20:55  currie
100
C torture long nats
130
 * C torture long nats
101
 
131
 *
102
Revision 1.68  1996/06/05 15:29:54  currie
132
 * Revision 1.68  1996/06/05 15:29:54  currie
103
parameter alignment in make_cmpd
133
 * parameter alignment in make_cmpd
104
 
134
 *
105
Revision 1.67  1996/05/14 10:39:14  currie
135
 * Revision 1.67  1996/05/14 10:39:14  currie
106
Long unsigned div2
136
 * Long unsigned div2
107
 
137
 *
108
Revision 1.66  1996/05/02 09:34:44  currie
138
 * Revision 1.66  1996/05/02 09:34:44  currie
109
Empty caselim list
139
 * Empty caselim list
110
 
140
 *
111
Revision 1.65  1996/04/02 10:34:16  currie
141
 * Revision 1.65  1996/04/02 10:34:16  currie
112
volatile & trap_on_nil
142
 * volatile & trap_on_nil
113
 
143
 *
114
 * Revision 1.63  1996/03/28  11:33:48  currie
144
 * Revision 1.63  1996/03/28  11:33:48  currie
115
 * Hppa struct params + outpar+init names
145
 * Hppa struct params + outpar+init names
116
 *
146
 *
117
 * Revision 1.62  1996/03/12  09:45:20  currie
147
 * Revision 1.62  1996/03/12  09:45:20  currie
118
 * promote pars
148
 * promote pars
Line 120... Line 150...
120
 * Revision 1.60  1996/02/28  11:36:20  currie
150
 * Revision 1.60  1996/02/28  11:36:20  currie
121
 * assign to promoted pars
151
 * assign to promoted pars
122
 *
152
 *
123
 * Revision 1.59  1996/02/26  11:54:22  currie
153
 * Revision 1.59  1996/02/26  11:54:22  currie
124
 * Various odds and ends
154
 * Various odds and ends
125
 *
155
 *
126
 * Revision 1.58  1996/02/21  09:39:02  currie
156
 * Revision 1.58  1996/02/21  09:39:02  currie
127
 * hppa var_callers + inlined bug
157
 * hppa var_callers + inlined bug
128
 *
158
 *
129
 * Revision 1.57  1996/01/25  17:02:53  currie
159
 * Revision 1.57  1996/01/25  17:02:53  currie
130
 * Struct params in sparc + postludes
160
 * Struct params in sparc + postludes
Line 223... Line 253...
223
 * mjg mods
253
 * mjg mods
224
 *
254
 *
225
 * Revision 1.23  1995/08/21  09:38:35  currie
255
 * Revision 1.23  1995/08/21  09:38:35  currie
226
 * no_trap_on_nill_contents
256
 * no_trap_on_nill_contents
227
 *
257
 *
228
 * Revision 1.23  1995/08/21  09:38:35  currie
258
 * Revision 1.23  1995/08/21  09:38:35  currie
229
 * no_trap_on_nill_contents
259
 * no_trap_on_nill_contents
230
 *
260
 *
231
 * Revision 1.22  1995/08/18  09:03:28  currie
261
 * Revision 1.22  1995/08/18  09:03:28  currie
232
 * Float variety adjusted
262
 * Float variety adjusted
233
 *
263
 *
234
 * Revision 1.21  1995/08/15  08:25:31  currie
264
 * Revision 1.21  1995/08/15  08:25:31  currie
Line 290... Line 320...
290
 *
320
 *
291
***********************************************************************/
321
***********************************************************************/
292
 
322
 
293
 
323
 
294
 
324
 
295
  /* This file defines procedures called from decoder which make up
325
/* This file defines procedures called from decoder which make up
296
     the internal representations of the various sorts of value.
326
   the internal representations of the various sorts of value.
297
     In most cases the construction of these is evident from the
327
   In most cases the construction of these is evident from the
298
     specification and the document describing the in-store
328
   specification and the document describing the in-store
299
     representation: the function merely creates the corresponding value.
329
   representation: the function merely creates the corresponding value.
300
     In some cases processing is performed: it is only these which are
330
   In some cases processing is performed: it is only these which are
301
     commented.
331
   commented.
302
     Many constructions have the shape of their arguments checked by
332
   Many constructions have the shape of their arguments checked by
303
     check_shape. These checks are implied by the specification and are
333
   check_shape. These checks are implied by the specification and are
304
     not commented.
334
   not commented.
305
  */
335
*/
306
 
336
 
307
 
337
 
308
#include "config.h"
338
#include "config.h"
309
#include <ctype.h>
339
#include <ctype.h>
310
#include <time.h>
340
#include <time.h>
Line 341... Line 371...
341
#ifdef NEWDIAGS
371
#ifdef NEWDIAGS
342
#include "dg_fns.h"
372
#include "dg_fns.h"
343
#include "mark_scope.h"
373
#include "mark_scope.h"
344
#endif
374
#endif
345
 
375
 
346
#define NOTYETDONE(x) failer(x)
376
#define NOTYETDONE(x)	failer(x)
347
 
377
 
348
 
378
 
349
#define MAX_ST_LENGTH 25
379
#define MAX_ST_LENGTH 25
350
 
380
 
351
/* All variables initialised */
381
/* All variables initialised */
Line 405... Line 435...
405
procprops f_no_long_jump_dest = 16;
435
procprops f_no_long_jump_dest = 16;
406
procprops f_inline = 32;
436
procprops f_inline = 32;
407
 
437
 
408
static proc_props initial_value_pp;
438
static proc_props initial_value_pp;
409
 
439
 
410
procprops f_add_procprops
440
procprops
411
    PROTO_N ( (t,e) )
-
 
412
    PROTO_T ( procprops t X procprops e )
441
f_add_procprops(procprops t, procprops e)
413
{
442
{
414
     return (t|e);
443
	return (t | e);
415
}
444
}
416
 
445
 
417
procprops no_procprops_option = 0;
-
 
418
 
446
 
419
procprops yes_procprops_option
447
procprops no_procprops_option = 0;
-
 
448
 
420
    PROTO_N ( (p) )
449
procprops
421
    PROTO_T ( procprops p )
450
yes_procprops_option(procprops p)
422
{
451
{
423
	return p;
452
	return p;
424
}
453
}
-
 
454
 
425
 
455
 
-
 
456
void
426
void init_procprops_option
457
init_procprops_option(void)
427
    PROTO_Z ()
-
 
428
{
458
{
429
	return;
459
	return;
430
}
460
}
-
 
461
 
431
 
462
 
432
error_code f_overflow  = 7;
463
error_code f_overflow  = 7;
433
error_code f_nil_access = 19;
464
error_code f_nil_access = 19;
434
error_code f_stack_overflow = 35;
465
error_code f_stack_overflow = 35;
435
 
466
 
436
error_code_list add_error_code_list
467
error_code_list
437
    PROTO_N ( (t, e, i) )
-
 
438
    PROTO_T ( error_code_list t X error_code e X int i )
468
add_error_code_list(error_code_list t, error_code e, int i)
439
{
469
{
440
	UNUSED (i);
470
	UNUSED(i);
441
	return(t | e);
471
	return (t | e);
442
}
472
}
-
 
473
 
443
 
474
 
444
error_code_list new_error_code_list
475
error_code_list
445
    PROTO_N ( (n) )
-
 
446
    PROTO_T ( int n )
476
new_error_code_list(int n)
447
{
477
{
448
	UNUSED (n);
478
	UNUSED(n);
449
	return 0;
479
	return 0;
450
}
480
}
-
 
481
 
451
 
482
 
452
transfer_mode f_trap_on_nil = 8;
483
transfer_mode f_trap_on_nil = 8;
453
 
484
 
454
shape containedshape
485
shape
455
    PROTO_N ( (a, s) )
-
 
456
    PROTO_T ( int a X int s )
486
containedshape(int a, int s)
457
{
487
{
458
	switch((a+7)&~7) {
488
	switch ((a + 7) & ~7) {
-
 
489
	case 8:
-
 
490
	case 0:
459
	case 8: case 0: return ((s)?scharsh:ucharsh);
491
		return ((s) ? scharsh : ucharsh);
-
 
492
	case 16:
460
	case 16: return ((s)?swordsh:uwordsh);
493
		return ((s) ? swordsh : uwordsh);
-
 
494
	case 32:
-
 
495
	case 24:
461
	case 32: case 24: return ((s)?slongsh:ulongsh);
496
		return ((s) ? slongsh : ulongsh);
-
 
497
	case 64:
-
 
498
	case 40:
-
 
499
	case 48:
-
 
500
	case 56:
462
	case 64: case 40: case 48: case 56: return ((s)?s64sh:u64sh);
501
		return ((s) ? s64sh : u64sh);
-
 
502
	default:
463
	default: failer("Illegal pointer for bitfield operations");
503
		failer("Illegal pointer for bitfield operations");
464
		return scharsh;
504
		return scharsh;
465
	}
505
	}
466
}
506
}
-
 
507
 
467
 
508
 
468
dec * make_extra_dec
509
dec *
469
    PROTO_N ( (nme, v, g, init, s) )
-
 
470
    PROTO_T ( char * nme X int v X int g X exp init X shape s )
510
make_extra_dec(char *nme, int v, int g, exp init, shape s)
471
{
511
{
472
    dec * extra_dec = (dec *)calloc(1, sizeof(dec));
512
	dec *extra_dec = (dec *)calloc(1, sizeof(dec));
473
    exp e = getexp(s, nilexp, 0, init, nilexp, 0, 0, ident_tag);
513
	exp e = getexp(s, nilexp, 0, init, nilexp, 0, 0, ident_tag);
474
    setglob(e);
514
	setglob(e);
-
 
515
	if (v) {
475
    if (v) setvar(e);
516
		setvar(e);
-
 
517
	}
476
    brog(e) = extra_dec;
518
	brog(e) = extra_dec;
477
    extra_dec -> def_next = (dec *)0;
519
	extra_dec->def_next = (dec *)0;
478
    *deflist_end = extra_dec;
520
	*deflist_end = extra_dec;
479
    deflist_end = &((*deflist_end) -> def_next);
521
	deflist_end = &((*deflist_end)->def_next);
480
    extra_dec -> dec_u.dec_val.dec_id = nme;
522
	extra_dec->dec_u.dec_val.dec_id = nme;
481
    extra_dec -> dec_u.dec_val.dec_shape = s;
523
	extra_dec->dec_u.dec_val.dec_shape = s;
482
    extra_dec -> dec_u.dec_val.dec_exp = e;
524
	extra_dec->dec_u.dec_val.dec_exp = e;
483
    extra_dec -> dec_u.dec_val.unit_number = crt_tagdef_unit_no;
525
	extra_dec->dec_u.dec_val.unit_number = crt_tagdef_unit_no;
484
    extra_dec -> dec_u.dec_val.diag_info = (diag_global *)0;
526
	extra_dec->dec_u.dec_val.diag_info = (diag_global *)0;
485
    extra_dec -> dec_u.dec_val.extnamed = (unsigned int) g;
527
	extra_dec->dec_u.dec_val.extnamed = (unsigned int)g;
486
    extra_dec -> dec_u.dec_val.dec_var = (unsigned int) v;
528
	extra_dec->dec_u.dec_val.dec_var = (unsigned int)v;
487
    extra_dec -> dec_u.dec_val.dec_outermost = 0;
529
	extra_dec->dec_u.dec_val.dec_outermost = 0;
488
    extra_dec -> dec_u.dec_val.have_def = init != nilexp;
530
	extra_dec->dec_u.dec_val.have_def = init != nilexp;
489
    extra_dec -> dec_u.dec_val.processed = 0;
531
	extra_dec->dec_u.dec_val.processed = 0;
490
    extra_dec -> dec_u.dec_val.isweak = 0;
532
	extra_dec->dec_u.dec_val.isweak = 0;
491
    extra_dec -> dec_u.dec_val.is_common = 0;
533
	extra_dec->dec_u.dec_val.is_common = 0;
492
    if (init != nilexp) { setfather(e, init); }
534
	if (init != nilexp) {
-
 
535
		setfather(e, init);
-
 
536
	}
493
    return extra_dec;
537
	return extra_dec;
494
}
538
}
-
 
539
 
495
 
540
 
496
dec * find_named_dec
541
dec *
497
    PROTO_N ( (n) )
-
 
498
    PROTO_T ( char * n )
542
find_named_dec(char *n)
499
{
543
{
500
  /* find a global with name n */
544
	/* find a global with name n */
501
  dec * my_def = top_def;
545
	dec *my_def = top_def;
502
 
546
 
503
  while (my_def != (dec *) 0){
547
	while (my_def != (dec *)0) {
504
    char *id = my_def -> dec_u.dec_val.dec_id;
548
		char *id = my_def->dec_u.dec_val.dec_id;
505
    if (strcmp(id+strlen(name_prefix), n) == 0) return my_def;
549
		if (strcmp(id + strlen(name_prefix), n) == 0) {
-
 
550
			return my_def;
-
 
551
		}
506
    my_def = my_def->def_next;
552
		my_def = my_def->def_next;
507
  }
553
	}
508
  return (dec*)0;
554
	return (dec *)0;
509
}
555
}
-
 
556
 
510
 
557
 
511
exp find_named_tg
558
exp
512
    PROTO_N ( (n, s) )
-
 
513
    PROTO_T ( char * n X shape s )
559
find_named_tg(char *n, shape s)
514
{
560
{
515
  /* find a global with name n */
561
	/* find a global with name n */
516
  dec * my_def = find_named_dec(n);
562
	dec *my_def = find_named_dec(n);
517
  if (my_def != (dec*)0) {
563
	if (my_def != (dec*)0) {
518
	return my_def -> dec_u.dec_val.dec_exp;
564
		return my_def->dec_u.dec_val.dec_exp;
519
  }
565
	}
520
  my_def = make_extra_dec(add_prefix(n), 0, 1, nilexp, s);
566
	my_def = make_extra_dec(add_prefix(n), 0, 1, nilexp, s);
521
  return my_def -> dec_u.dec_val.dec_exp;
567
	return my_def->dec_u.dec_val.dec_exp;
522
}
568
}
523
 
569
 
524
 
570
 
525
#if !has64bits
571
#if !has64bits
526
 
-
 
527
 
-
 
528
 
-
 
529
char * fn_of_op
572
char *
530
    PROTO_N ( (nm, sngd) )
-
 
531
    PROTO_T ( int nm X int sngd )
573
fn_of_op(int nm, int sngd)
532
{
574
{
533
	/* Find a run-time library fn corresponding to nm */
575
	/* Find a run-time library fn corresponding to nm */
534
 
576
 
535
#define CSU(x,y) return (sngd)?x:y
577
#define CSU(x, y)	return (sngd) ? x : y
536
	switch (nm) {
578
	switch (nm) {
-
 
579
	case plus_tag:
537
	  case plus_tag: CSU("__TDFUs_plus","__TDFUu_plus");
580
		CSU("__TDFUs_plus", "__TDFUu_plus");
-
 
581
	case minus_tag:
538
	  case minus_tag: CSU("__TDFUs_minus","__TDFUu_minus");
582
		CSU("__TDFUs_minus", "__TDFUu_minus");
-
 
583
	case mult_tag:
539
	  case mult_tag: CSU("__TDFUs_mult","__TDFUu_mult");
584
		CSU("__TDFUs_mult", "__TDFUu_mult");
-
 
585
	case div0_tag:
-
 
586
	case div2_tag:
540
	  case div0_tag:case div2_tag: CSU("__TDFUs_div2","__TDFUu_div2");
587
		CSU("__TDFUs_div2", "__TDFUu_div2");
-
 
588
	case div1_tag:
541
	  case div1_tag: CSU("__TDFUs_div1","__TDFUu_div2");
589
		CSU("__TDFUs_div1", "__TDFUu_div2");
-
 
590
	case rem0_tag:
-
 
591
	case rem2_tag:
542
	  case rem0_tag:case rem2_tag: CSU("__TDFUs_rem2","__TDFUu_rem2");
592
		CSU("__TDFUs_rem2", "__TDFUu_rem2");
-
 
593
	case mod_tag:
543
	  case mod_tag: CSU("__TDFUs_rem1","__TDFUu_rem2");
594
		CSU("__TDFUs_rem1", "__TDFUu_rem2");
-
 
595
	case shl_tag:
544
	  case shl_tag: CSU("__TDFUs_shl","__TDFUu_shl");
596
		CSU("__TDFUs_shl", "__TDFUu_shl");
-
 
597
	case shr_tag:
545
	  case shr_tag: CSU("__TDFUs_shr","__TDFUu_shr");
598
		CSU("__TDFUs_shr", "__TDFUu_shr");
-
 
599
	case neg_tag:
546
	  case neg_tag: return "__TDFUneg";
600
		return "__TDFUneg";
-
 
601
	case abs_tag:
547
	  case abs_tag: return "__TDFUabs";
602
		return "__TDFUabs";
-
 
603
	case chvar_tag:
548
	  case chvar_tag:CSU("__TDFUs_chvar","__TDFUu_chvar");
604
		CSU("__TDFUs_chvar", "__TDFUu_chvar");
-
 
605
	case max_tag:
549
	  case max_tag:	CSU("__TDFUs_max","__TDFUu_max");
606
		CSU("__TDFUs_max", "__TDFUu_max");
-
 
607
	case min_tag:
550
	  case min_tag:	CSU("__TDFUs_min","__TDFUu_min");
608
		CSU("__TDFUs_min", "__TDFUu_min");
-
 
609
	case test_tag:
551
	  case test_tag:CSU("__TDFUs_test","__TDFUu_test");
610
		CSU("__TDFUs_test", "__TDFUu_test");
-
 
611
	case float_tag:
552
	  case float_tag: CSU("__TDFUs_float","__TDFUu_float");
612
		CSU("__TDFUs_float", "__TDFUu_float");
-
 
613
	case and_tag:
553
	  case and_tag: return "__TDFUand";
614
		return "__TDFUand";
-
 
615
	case or_tag:
554
	  case or_tag: return "__TDFUor";
616
		return "__TDFUor";
-
 
617
	case xor_tag:
555
	  case xor_tag: return "__TDFUxor";
618
		return "__TDFUxor";
-
 
619
	case not_tag:
556
	  case not_tag: return "__TDFUnot";
620
		return "__TDFUnot";
-
 
621
	default:
557
	  default: failer("No fn for long op");
622
		failer("No fn for long op");
558
	}
623
	}
559
	return "__TDFerror";
624
	return "__TDFerror";
560
}
625
}
-
 
626
 
561
 
627
 
562
exp TDFcallop3
628
exp
563
    PROTO_N ( (arg1, arg2, n) )
-
 
564
    PROTO_T ( exp arg1 X exp arg2 X int n )
629
TDFcallop3(exp arg1, exp arg2, int n)
565
{
630
{
566
	/* construct proc call for binary op corresponding to n */
631
	/* construct proc call for binary op corresponding to n */
567
	char * nm = fn_of_op(n, is_signed(sh(arg1)));
632
	char *nm = fn_of_op(n, is_signed(sh(arg1)));
568
	exp dc;
633
	exp dc;
569
	exp ob;
634
	exp ob;
570
	exp_list pars;
635
	exp_list pars;
571
	exp_option novar;
636
	exp_option novar;
572
	exp res;
637
	exp res;
573
	novar.present = 0;
638
	novar.present = 0;
574
	dc = find_named_tg(nm, f_proc);
639
	dc = find_named_tg(nm, f_proc);
575
	ob = me_obtain(dc);
640
	ob = me_obtain(dc);
576
	pars.number = 2;
641
	pars.number = 2;
577
	pars.start = arg1;
642
	pars.start = arg1;
578
	pars.end = arg2;
643
	pars.end = arg2;
579
	bro(arg1) = arg2; clearlast(arg1);
644
	bro(arg1) = arg2;
-
 
645
	clearlast(arg1);
580
 
646
 
581
	res = f_apply_proc(sh(arg1), ob, pars, novar);
647
	res = f_apply_proc(sh(arg1), ob, pars, novar);
582
	res = hold_check(res);
648
	res = hold_check(res);
583
	return res;
649
	return res;
584
}
650
}
585
 
651
 
-
 
652
 
586
exp TDFwithet
653
exp
587
    PROTO_N ( (ov_err, e) )
-
 
588
    PROTO_T ( error_treatment ov_err X exp e )
654
TDFwithet(error_treatment ov_err, exp e)
589
{
655
{
590
	exp id;
656
	exp id;
591
	exp c;
657
	exp c;
592
	exp_list el;
658
	exp_list el;
593
	exp Te;
659
	exp Te;
594
	if (ov_err.err_code <= 2) return e;
660
	if (ov_err.err_code <= 2) {
-
 
661
		return e;
-
 
662
	}
595
	Te = find_named_tg("__TDFerror",slongsh);
663
	Te = find_named_tg("__TDFerror", slongsh);
596
	brog(Te) -> dec_u.dec_val.dec_var = 1;
664
	brog(Te)->dec_u.dec_val.dec_var = 1;
597
#if keep_PIC_vars
665
#if keep_PIC_vars
598
        setvar(Te);
666
	setvar(Te);
599
#else
667
#else
600
        if (PIC_code)
668
	if (PIC_code) {
601
          sh(Te) = f_pointer(f_alignment(slongsh));
669
		sh(Te) = f_pointer(f_alignment(slongsh));
602
        else
670
	} else {
603
          setvar(Te);
671
		setvar(Te);
-
 
672
	}
604
#endif
673
#endif
605
	id = me_startid(sh(e), e, 0);
674
	id = me_startid(sh(e), e, 0);
606
	c = f_contents(slongsh, me_obtain(Te));
675
	c = f_contents(slongsh, me_obtain(Te));
607
	el = new_exp_list(1);
676
	el = new_exp_list(1);
608
	el = add_exp_list(el, f_plus(ov_err,
677
	el = add_exp_list(el, f_plus(ov_err, me_shint(slongsh, (int)0x80000000),
609
			me_shint(slongsh, (int)0x80000000), c), 0);
678
				     c), 0);
610
	return me_complete_id(id, f_sequence(el, me_obtain(id)));
679
	return me_complete_id(id, f_sequence(el, me_obtain(id)));
611
}
680
}
612
 
681
 
613
 
682
 
614
exp TDFcallop2
683
exp
615
    PROTO_N ( (ov_err,arg1, arg2, n) )
-
 
616
    PROTO_T ( error_treatment ov_err X exp arg1 X exp arg2 X int n )
684
TDFcallop2(error_treatment ov_err, exp arg1, exp arg2, int n)
617
{
685
{
618
	/* construct proc call for binary op corresponding to n */
686
	/* construct proc call for binary op corresponding to n */
619
	/* ignore error treatment for the moment */
687
	/* ignore error treatment for the moment */
620
	char * nm = fn_of_op(n, is_signed(sh(arg1)));
688
	char *nm = fn_of_op(n, is_signed(sh(arg1)));
621
	exp dc;
689
	exp dc;
622
	exp ob;
690
	exp ob;
623
	exp_list pars;
691
	exp_list pars;
624
	exp_option novar;
692
	exp_option novar;
625
	exp res;
693
	exp res;
Line 627... Line 695...
627
	dc = find_named_tg(nm, f_proc);
695
	dc = find_named_tg(nm, f_proc);
628
	ob = me_obtain(dc);
696
	ob = me_obtain(dc);
629
	pars.number = 2;
697
	pars.number = 2;
630
	pars.start = arg1;
698
	pars.start = arg1;
631
	pars.end = arg2;
699
	pars.end = arg2;
632
	bro(arg1) = arg2; clearlast(arg1);
700
	bro(arg1) = arg2;
-
 
701
	clearlast(arg1);
633
 
702
 
634
	res = f_apply_proc((n==test_tag)?slongsh:sh(arg1), ob, pars, novar);
703
	res = f_apply_proc((n==test_tag)?slongsh:sh(arg1), ob, pars, novar);
635
 
704
 
636
	return TDFwithet(ov_err,res);
705
	return TDFwithet(ov_err, res);
637
}
706
}
638
 
707
 
639
 
708
 
640
exp TDFcallaux
709
exp
641
    PROTO_N ( (ov_err,arg1, nm, s) )
-
 
642
    PROTO_T ( error_treatment ov_err X exp arg1 X char * nm X shape s )
710
TDFcallaux(error_treatment ov_err, exp arg1, char *nm, shape s)
643
{
711
{
644
	exp dc;
712
	exp dc;
645
	exp ob;
713
	exp ob;
646
	exp_list pars;
714
	exp_list pars;
647
	exp_option novar;
715
	exp_option novar;
Line 653... Line 721...
653
	pars.start = arg1;
721
	pars.start = arg1;
654
	pars.end = arg1;
722
	pars.end = arg1;
655
 
723
 
656
	res = f_apply_proc(s, ob, pars, novar);
724
	res = f_apply_proc(s, ob, pars, novar);
657
	res = hold_check(res);
725
	res = hold_check(res);
658
	return TDFwithet(ov_err,res);
726
	return TDFwithet(ov_err, res);
659
}
727
}
660
 
728
 
661
 
729
 
662
exp TDFcallop1
730
exp TDFcallop1
663
    PROTO_N ( (ov_err,arg1, n) )
-
 
664
    PROTO_T ( error_treatment ov_err X exp arg1 X int n )
731
(error_treatment ov_err, exp arg1, int n)
665
{
732
{
666
	/* construct proc call for unary op corresponding to n */
733
	/* construct proc call for unary op corresponding to n */
667
	/* ignore error treatment for the moment */
734
	/* ignore error treatment for the moment */
668
	char * nm = fn_of_op(n, is_signed(sh(arg1)));
735
	char *nm = fn_of_op(n, is_signed(sh(arg1)));
669
	return TDFcallaux(ov_err,arg1,nm, sh(arg1));
736
	return TDFcallaux(ov_err, arg1, nm, sh(arg1));
670
}
737
}
-
 
738
 
671
 
739
 
672
exp TDFcallop4
740
exp
673
    PROTO_N ( (arg1, n) )
-
 
674
    PROTO_T ( exp arg1 X int n )
741
TDFcallop4(exp arg1, int n)
675
{
742
{
676
	/* construct proc call for unary op corresponding to n */
743
	/* construct proc call for unary op corresponding to n */
677
 
744
 
678
	char * nm = fn_of_op(n, is_signed(sh(arg1)));
745
	char *nm = fn_of_op(n, is_signed(sh(arg1)));
679
	exp dc;
746
	exp dc;
680
	exp ob;
747
	exp ob;
681
	exp_list pars;
748
	exp_list pars;
682
	exp_option novar;
749
	exp_option novar;
683
	exp res;
750
	exp res;
Line 685... Line 752...
685
	dc = find_named_tg(nm, f_proc);
752
	dc = find_named_tg(nm, f_proc);
686
	ob = me_obtain(dc);
753
	ob = me_obtain(dc);
687
	pars.number = 1;
754
	pars.number = 1;
688
	pars.start = arg1;
755
	pars.start = arg1;
689
	pars.end = arg1;
756
	pars.end = arg1;
690
 
757
 
691
	res = f_apply_proc(sh(arg1), ob, pars, novar);
758
	res = f_apply_proc(sh(arg1), ob, pars, novar);
692
 
759
 
693
	return res;
760
	return res;
694
}
761
}
695
 
-
 
696
#endif
762
#endif /* !has64bits */
697
 
-
 
698
 
-
 
699
 
763
 
700
 
764
 
701
error_treatment f_wrap;
765
error_treatment f_wrap;
702
error_treatment f_impossible;
766
error_treatment f_impossible;
703
error_treatment f_continue;
767
error_treatment f_continue;
704
 
768
 
705
 
769
 
706
#ifdef promote_pars
770
#ifdef promote_pars
707
static void promote_actuals
771
static void
708
    PROTO_N ( (par) )
-
 
709
    PROTO_T ( exp par )
772
promote_actuals(exp par)
710
{
773
{
711
    for(;;) {
774
	for (;;) {
712
	shape s = sh(par);
775
		shape s = sh(par);
713
	if (name(s)>=scharhd && name(s)<=uwordhd) {
776
		if (name(s) >= scharhd && name(s) <= uwordhd) {
714
	    shape ns = (is_signed(s))? slongsh:ulongsh;
777
			shape ns = (is_signed(s)) ? slongsh : ulongsh;
715
	    exp w = hold_check(f_change_variety(f_wrap,ns, copy(par)));
778
			exp w = hold_check(f_change_variety(f_wrap, ns,
716
	    replace(par, w, nilexp);
-
 
717
	    kill_exp(par, nilexp);
-
 
718
	    par = w;
-
 
719
	}
-
 
720
	if (last(par)) break;
-
 
721
	par = bro(par);
779
							    copy(par)));
722
    }
-
 
723
}
-
 
724
 
-
 
725
static void promote_formals
-
 
726
    PROTO_N ( (bdy) )
-
 
727
    PROTO_T ( exp bdy )
-
 
728
{
-
 
729
	while ((name(bdy) == ident_tag && isparam(bdy))
-
 
730
#ifndef NEWDIAGS
-
 
731
		|| name(bdy) == diagnose_tag
-
 
732
#endif
-
 
733
		) {
-
 
734
	    shape spar = sh(son(bdy));
-
 
735
	    if (name(bdy)!=ident_tag) { bdy = son(bdy); continue; }
-
 
736
	    if (name(spar)>=scharhd && name(spar)<= uwordhd) {
-
 
737
		shape ns = (is_signed(spar))? slongsh: ulongsh;
-
 
738
		exp u = pt(bdy);
-
 
739
		exp w;
-
 
740
		sh(son(bdy)) = ns;
-
 
741
		if (!isvar(bdy)) {
-
 
742
		    while (u != nilexp) {
-
 
743
			exp nextu = pt(u);
-
 
744
			sh(u) = ns;
-
 
745
		    	w = f_change_variety(f_wrap, spar, copy(u));
-
 
746
			replace(u, w, nilexp);
780
			replace(par, w, nilexp);
747
			kill_exp(u, nilexp);
781
			kill_exp(par, nilexp);
748
			u = nextu;
782
			par = w;
749
		    }
-
 
750
		}
783
		}
751
		else {
-
 
752
		   shape ps = f_pointer(f_alignment(ns));
-
 
753
		   while (u != nilexp) {
-
 
754
			exp nextu = pt(u);
-
 
755
			if (last(u) && name(bro(u)) == cont_tag) {
-
 
756
			   if (little_end) {
784
		if (last(par)) {
757
				exp con = bro(u);
-
 
758
			        sh(u) = ps;
-
 
759
				sh(con) = ns;
-
 
760
				w = f_change_variety(f_wrap, spar, copy(con));
-
 
761
				replace(con, w, nilexp);
-
 
762
				kill_exp(con,nilexp);
-
 
763
			   }
-
 
764
			}
-
 
765
			else {
785
			break;
766
				setvis(bdy);
-
 
767
				if (!little_end) {
-
 
768
				   sh(u) = ps;
-
 
769
				   no(u) = shape_size(ns)-shape_size(spar);
-
 
770
				}
-
 
771
			}
-
 
772
			u = nextu;
-
 
773
		   }
-
 
774
		}
786
		}
775
	     }
-
 
776
	     bdy = bro(son(bdy));
787
		par = bro(par);
777
	}
788
	}
778
 
-
 
779
 
-
 
780
 
-
 
781
}
789
}
782
 
790
 
783
#endif
-
 
784
 
791
 
-
 
792
static void
-
 
793
promote_formals(exp bdy)
-
 
794
{
-
 
795
	while ((name(bdy) == ident_tag && isparam(bdy))
-
 
796
#ifndef NEWDIAGS
-
 
797
	       || name(bdy) == diagnose_tag
-
 
798
#endif
-
 
799
	      ) {
-
 
800
		shape spar = sh(son(bdy));
-
 
801
		if (name(bdy) != ident_tag) {
-
 
802
			bdy = son(bdy);
-
 
803
			continue;
-
 
804
		}
-
 
805
		if (name(spar) >= scharhd && name(spar) <= uwordhd) {
-
 
806
			shape ns = (is_signed(spar)) ? slongsh : ulongsh;
-
 
807
			exp u = pt(bdy);
-
 
808
			exp w;
-
 
809
			sh(son(bdy)) = ns;
-
 
810
			if (!isvar(bdy)) {
-
 
811
				while (u != nilexp) {
-
 
812
					exp nextu = pt(u);
-
 
813
					sh(u) = ns;
-
 
814
					w = f_change_variety(f_wrap, spar,
-
 
815
							     copy(u));
-
 
816
					replace(u, w, nilexp);
-
 
817
					kill_exp(u, nilexp);
-
 
818
					u = nextu;
-
 
819
				}
-
 
820
			} else {
-
 
821
				shape ps = f_pointer(f_alignment(ns));
-
 
822
				while (u != nilexp) {
-
 
823
					exp nextu = pt(u);
-
 
824
					if (last(u) && name(bro(u)) == cont_tag) {
-
 
825
						if (little_end) {
-
 
826
							exp con = bro(u);
-
 
827
							sh(u) = ps;
-
 
828
							sh(con) = ns;
-
 
829
							w = f_change_variety(
-
 
830
							    f_wrap, spar,
-
 
831
							    copy(con));
-
 
832
							replace(con, w, nilexp);
-
 
833
							kill_exp(con, nilexp);
-
 
834
						}
-
 
835
					} else {
-
 
836
						setvis(bdy);
-
 
837
						if (!little_end) {
-
 
838
							sh(u) = ps;
-
 
839
							no(u) = shape_size(ns) -
-
 
840
							    shape_size(spar);
-
 
841
						}
-
 
842
					}
-
 
843
					u = nextu;
-
 
844
				}
-
 
845
			}
-
 
846
		}
-
 
847
		bdy = bro(son(bdy));
-
 
848
	}
-
 
849
}
-
 
850
#endif /* promote_pars */
-
 
851
 
785
 
852
 
786
aldef frame_als[32];
853
aldef frame_als[32];
787
 
854
 
788
alignment f_locals_alignment = &frame_als[0];
855
alignment f_locals_alignment = &frame_als[0];
789
alignment nv_callers_alignment = &frame_als[1];
856
alignment nv_callers_alignment = &frame_als[1];
790
alignment var_callers_alignment = &frame_als[3];
857
alignment var_callers_alignment = &frame_als[3];
791
alignment nv_callees_alignment = &frame_als[7];
858
alignment nv_callees_alignment = &frame_als[7];
792
alignment var_callees_alignment = &frame_als[15];
859
alignment var_callees_alignment = &frame_als[15];
793
 
860
 
794
void init_frame_als
861
void
795
    PROTO_Z ()
862
init_frame_als(void)
796
{
863
{
797
   int i;
864
	int i;
798
   for(i=0; i<32; i++) {
865
	for (i = 0; i < 32; i++) {
799
	frame_als[i].al.sh_hd = 0;
866
		frame_als[i].al.sh_hd = 0;
800
   	frame_als[i].al.al_n = 1;
867
		frame_als[i].al.al_n = 1;
801
   	frame_als[i].al.al_val.al = 64;
868
		frame_als[i].al.al_val.al = 64;
802
   	frame_als[i].al.al_val.al_frame = i+1;
869
		frame_als[i].al.al_val.al_frame = i + 1;
803
   }
870
	}
804
}
871
}
-
 
872
 
805
 
873
 
806
error_treatment f_trap
874
error_treatment
807
    PROTO_N ( (ec) )
-
 
808
    PROTO_T ( error_code_list ec )
875
f_trap(error_code_list ec)
809
{
876
{
810
  error_treatment res;
877
	error_treatment res;
811
  res.err_code = ec;
878
	res.err_code = ec;
812
  return res;
879
	return res;
-
 
880
}
-
 
881
 
-
 
882
 
-
 
883
alignment
-
 
884
f_callers_alignment(bool var)
-
 
885
{
-
 
886
	return ((var) ? var_callers_alignment : nv_callers_alignment);
-
 
887
}
-
 
888
 
-
 
889
 
-
 
890
alignment
-
 
891
f_callees_alignment(bool var)
-
 
892
{
-
 
893
	return ((var) ? var_callees_alignment : nv_callees_alignment);
813
}
894
}
814
 
895
 
815
alignment f_callers_alignment
-
 
816
    PROTO_N ( (var) )
-
 
817
    PROTO_T ( bool var )
-
 
818
{
-
 
819
    return ((var)?var_callers_alignment:nv_callers_alignment);
-
 
820
}
-
 
821
 
896
 
822
alignment f_callees_alignment
-
 
823
    PROTO_N ( (var) )
-
 
824
    PROTO_T ( bool var )
-
 
825
{
-
 
826
    return ((var)?var_callees_alignment:nv_callees_alignment);
-
 
827
}
-
 
828
 
-
 
829
 
-
 
830
otagexp f_make_otagexp
897
otagexp
831
    PROTO_N ( (tagopt, e) )
-
 
832
    PROTO_T ( tag_option tagopt X exp e )
898
f_make_otagexp(tag_option tagopt, exp e)
833
{
899
{
834
	exp init;
900
	exp init;
835
	if (!tagopt.present) return e;
901
	if (!tagopt.present) {
-
 
902
		return e;
-
 
903
	}
836
	e = getexp(sh(e), nilexp, 0, e, nilexp, 0, 0, caller_tag);
904
	e = getexp(sh(e), nilexp, 0, e, nilexp, 0, 0, caller_tag);
837
	init = getexp(sh(e), nilexp, 0, nilexp , nilexp, 0, 0, caller_name_tag);
905
	init = getexp(sh(e), nilexp, 0, nilexp , nilexp, 0, 0, caller_name_tag);
838
	pt(e) = getexp(f_top, nilexp, 0, init, nilexp, 0, 0, ident_tag);
906
	pt(e) = getexp(f_top, nilexp, 0, init, nilexp, 0, 0, ident_tag);
839
/*  	setvar(pt(e));   - NOT ACCORDING TO SPEC */
907
	/*  	setvar(pt(e));   - NOT ACCORDING TO SPEC */
840
	setfather(e,son(e));
908
	setfather(e, son(e));
841
	set_tag(tagopt.val, pt(e));
909
	set_tag(tagopt.val, pt(e));
842
	return e;
910
	return e;
843
}
911
}
844
 
912
 
-
 
913
 
845
otagexp_list new_otagexp_list
914
otagexp_list
846
    PROTO_N ( (n) )
-
 
847
    PROTO_T ( int n )
915
new_otagexp_list(int n)
848
{
916
{
849
	otagexp_list res;
917
	otagexp_list res;
850
	res.number =0;
918
	res.number =0;
851
	res.start = nilexp;
919
	res.start = nilexp;
852
	res.end = nilexp;
920
	res.end = nilexp;
853
	res.id = nilexp;
921
	res.id = nilexp;
854
	UNUSED (n);
922
	UNUSED(n);
855
	return res;
923
	return res;
856
}
924
}
857
 
925
 
-
 
926
 
858
otagexp_list add_otagexp_list
927
otagexp_list
859
    PROTO_N ( (list, ote, n) )
-
 
860
    PROTO_T ( otagexp_list list X otagexp ote X int n )
928
add_otagexp_list(otagexp_list list, otagexp ote, int n)
861
{
929
{
862
	if (list.number++ == 0) {
930
	if (list.number++ == 0) {
863
	  	list.start = list.end = ote;
931
		list.start = list.end = ote;
864
	}
-
 
865
	else {
932
	} else {
866
		bro(list.end) = ote;
933
		bro(list.end) = ote;
867
		clearlast(list.end);
934
		clearlast(list.end);
868
		list.end = ote;
935
		list.end = ote;
869
	}
936
	}
870
	setlast(ote);
937
	setlast(ote);
871
	if (name(ote)== caller_tag) {
938
	if (name(ote) == caller_tag) {
872
		exp id = pt(ote);
939
		exp id = pt(ote);
873
		exp lid = list.id;
940
		exp lid = list.id;
874
		bro(son(id)) = lid;
941
		bro(son(id)) = lid;
875
		if (lid != nilexp) {
942
		if (lid != nilexp) {
876
			bro(lid) = id; setlast(lid);
943
			bro(lid) = id;
-
 
944
			setlast(lid);
877
		}
945
		}
878
		no(son(id)) = n;
946
		no(son(id)) = n;
879
		list.id = id;
947
		list.id = id;
880
		pt(ote) = nilexp; /* this pt is a temp link */
948
		pt(ote) = nilexp; /* this pt is a temp link */
881
	}
949
	}
882
	return list;
950
	return list;
883
}
951
}
-
 
952
 
884
 
953
 
885
callees f_make_callee_list
954
callees
886
    PROTO_N ( (args) )
-
 
887
    PROTO_T ( exp_list args )
955
f_make_callee_list(exp_list args)
888
{
956
{
889
	exp e = getexp(f_top, nilexp, 0, args.start, nilexp, 0,
957
	exp e = getexp(f_top, nilexp, 0, args.start, nilexp, 0, args.number,
890
			args.number, make_callee_list_tag);
958
		       make_callee_list_tag);
891
	if(args.number!=0) {
959
	if (args.number != 0) {
892
		 setfather(e,args.end);
960
		setfather(e, args.end);
893
#ifdef promote_pars
961
#ifdef promote_pars
894
		promote_actuals(args.start);
962
		promote_actuals(args.start);
895
#endif
963
#endif
896
	 }
964
	}
897
	return e;
965
	return e;
898
}
966
}
899
 
967
 
-
 
968
 
900
callees f_make_dynamic_callees
969
callees
901
    PROTO_N ( (ptr,sze) )
-
 
902
    PROTO_T ( exp ptr X exp sze )
970
f_make_dynamic_callees(exp ptr, exp sze)
903
{
971
{
904
	exp e = getexp(f_top, nilexp, 0, ptr, nilexp, 0, 0,
972
	exp e = getexp(f_top, nilexp, 0, ptr, nilexp, 0, 0,
905
				make_dynamic_callee_tag);
973
		       make_dynamic_callee_tag);
906
	bro(ptr) = sze; clearlast(ptr);
974
	bro(ptr) = sze;
-
 
975
	clearlast(ptr);
907
	setfather(e, sze);
976
	setfather(e, sze);
908
	return e;
977
	return e;
909
}
978
}
910
 
-
 
911
 
-
 
912
 
-
 
913
 
979
 
914
 
980
 
915
  /* exps waiting to be used have the parked flag set in props,
981
/* exps waiting to be used have the parked flag set in props,
916
     so that used_in need not look at their context.
982
   so that used_in need not look at their context.
917
     This procedure removes the parked flag from each member of an
983
   This procedure removes the parked flag from each member of an
918
     exp list, in preparation for putting them into their
984
   exp list, in preparation for putting them into their
919
     proper context.
985
   proper context.
920
  */
986
 */
921
void clear_exp_list
987
void
922
    PROTO_N ( (el) )
-
 
923
    PROTO_T ( exp_list el )
988
clear_exp_list(exp_list el)
924
{
989
{
925
  exp t = el.start;
990
	exp t = el.start;
926
  if (t == nilexp)
991
	if (t == nilexp) {
927
    return;
992
		return;
-
 
993
	}
928
  while (1)
994
	while (1) {
929
   {
-
 
930
     parked(t) = 0;
995
		parked(t) = 0;
931
     if (t == el.end)
996
		if (t == el.end) {
932
       return;
997
			return;
-
 
998
		}
933
     t = bro(t);
999
		t = bro(t);
934
   };
1000
	}
935
}
1001
}
936
 
1002
 
937
 
1003
 
938
alignment frame_alignment;
1004
alignment frame_alignment;
939
 
1005
 
940
  /* ntest codes */
1006
/* ntest codes */
941
ntest f_equal = 5;
1007
ntest f_equal = 5;
942
ntest f_greater_than = 1;
1008
ntest f_greater_than = 1;
943
ntest f_greater_than_or_equal = 2;
1009
ntest f_greater_than_or_equal = 2;
944
ntest f_less_than = 3;
1010
ntest f_less_than = 3;
945
ntest f_less_than_or_equal = 4;
1011
ntest f_less_than_or_equal = 4;
Line 955... Line 1021...
955
ntest f_not_comparable = 14;
1021
ntest f_not_comparable = 14;
956
 
1022
 
957
static ntest convert_ntest[] = {0, 1, 2, 3, 4, 5, 6,
1023
static ntest convert_ntest[] = {0, 1, 2, 3, 4, 5, 6,
958
				1, 2, 3, 4, 6, 5, 13, 14};
1024
				1, 2, 3, 4, 6, 5, 13, 14};
959
 
1025
 
960
static exp replace_ntest
1026
static exp
961
    PROTO_N ( (nt, dest, arg1, arg2) )
-
 
962
    PROTO_T ( ntest nt X label dest X exp arg1 X exp arg2 )
1027
replace_ntest(ntest nt, label dest, exp arg1, exp arg2)
963
{
1028
{
964
  exp res;
1029
	exp res;
965
  exp_list el;
1030
	exp_list el;
966
  el = new_exp_list(2);
1031
	el = new_exp_list(2);
967
  el = add_exp_list(el, arg1, 0);
1032
	el = add_exp_list(el, arg1, 0);
968
  el = add_exp_list(el, arg2, 1);
1033
	el = add_exp_list(el, arg2, 1);
969
 
1034
 
970
  if (nt == f_comparable)
1035
	if (nt == f_comparable) {
971
    res = f_make_top();
1036
		res = f_make_top();
972
  else
1037
	} else {
973
    res = f_goto(dest);
1038
		res = f_goto(dest);
-
 
1039
	}
974
 
1040
 
975
  return f_sequence(el, res);
1041
	return f_sequence(el, res);
976
}
1042
}
977
 
1043
 
978
 
1044
 
979
  /* rounding mode codes */
1045
/* rounding mode codes */
980
rounding_mode f_to_nearest = R2NEAR;
1046
rounding_mode f_to_nearest = R2NEAR;
981
rounding_mode f_toward_larger = R2PINF;
1047
rounding_mode f_toward_larger = R2PINF;
982
rounding_mode f_toward_smaller = R2NINF;
1048
rounding_mode f_toward_smaller = R2NINF;
983
rounding_mode f_toward_zero = R2ZERO;
1049
rounding_mode f_toward_zero = R2ZERO;
984
rounding_mode f_round_as_state = 4;
1050
rounding_mode f_round_as_state = 4;
985
 
1051
 
986
transfer_mode f_standard_transfer_mode = 0;
1052
transfer_mode f_standard_transfer_mode = 0;
987
transfer_mode f_volatile = 1;
1053
transfer_mode f_volatile = 1;
988
transfer_mode f_overlap = 2;
1054
transfer_mode f_overlap = 2;
989
transfer_mode f_complete = 4;
1055
transfer_mode f_complete = 4;
990
 
1056
 
991
#define max(x,y) ((x)>(y)) ? (x) : (y)
1057
#define max(x, y)	((x) > (y)) ? (x) : (y)
992
   /* careful: use simple arguments! */
1058
/* careful: use simple arguments! */
993
 
-
 
994
 
-
 
995
 
1059
 
996
alignment f_alignment
1060
alignment
997
    PROTO_N ( (sha) )
-
 
998
    PROTO_T ( shape sha )
1061
f_alignment(shape sha)
999
{
1062
{
1000
  return align_of(sha);
1063
	return align_of(sha);
1001
}
1064
}
-
 
1065
 
1002
 
1066
 
1003
  /* we may not yet know the actual values for the alignments,
1067
  /* we may not yet know the actual values for the alignments,
1004
     merely that they are computed from other alignments by unite.
1068
     merely that they are computed from other alignments by unite.
1005
     So we have to set up equations which are solved at the end of aldefs
1069
     So we have to set up equations which are solved at the end of aldefs
1006
  */
1070
  */
1007
alignment f_obtain_al_tag
1071
alignment
1008
    PROTO_N ( (a1) )
-
 
1009
    PROTO_T ( al_tag a1 )
1072
f_obtain_al_tag(al_tag a1)
1010
{
1073
{
1011
  alignment j;
1074
	alignment j;
1012
  if (a1->al.al_n == 1)
1075
	if (a1->al.al_n == 1) {
1013
      return long_to_al(a1->al.al_val.al);
1076
		return long_to_al(a1->al.al_val.al);
-
 
1077
	}
1014
  j = (alignment)calloc(1, sizeof(aldef));
1078
	j = (alignment)calloc(1, sizeof(aldef));
1015
  j -> al.al_n = 3;
1079
	j->al.al_n = 3;
1016
  j -> al.al_val.al_join.a = a1;
1080
	j->al.al_val.al_join.a = a1;
1017
  j -> next_aldef = top_aldef;
1081
	j->next_aldef = top_aldef;
1018
  top_aldef = j;
1082
	top_aldef = j;
1019
  return j;
1083
	return j;
1020
}
1084
}
-
 
1085
 
1021
 
1086
 
1022
alignment f_unite_alignments
1087
alignment
1023
    PROTO_N ( (a1, a2) )
-
 
1024
    PROTO_T ( alignment a1 X alignment a2 )
1088
f_unite_alignments(alignment a1, alignment a2)
1025
{
1089
{
1026
  alignment j;
1090
	alignment j;
1027
  if (a1->al.al_n == 1 && a2->al.al_n == 1)
1091
	if (a1->al.al_n == 1 && a2->al.al_n == 1) {
1028
   {
-
 
1029
    if (a1->al.al_val.al_frame == a2->al.al_val.al_frame) {
1092
		if (a1->al.al_val.al_frame == a2->al.al_val.al_frame) {
1030
    	if (a1->al.al_val.al > a2->al.al_val.al)
1093
			if (a1->al.al_val.al > a2->al.al_val.al) {
1031
      	{ return a1; }
1094
				return a1;
1032
    	else
1095
			} else {
1033
      	{ return a2; }
1096
				return a2;
1034
    }
1097
			}
1035
    else
-
 
1036
    if (a1->al.al_val.al_frame ==0) { return a2; }
1098
		} else if (a1->al.al_val.al_frame ==0) {
1037
    else
1099
			return a2;
1038
    if (a2->al.al_val.al_frame == 0) { return a1; }
1100
		} else if (a2->al.al_val.al_frame == 0) {
-
 
1101
			return a1;
1039
    else {
1102
		} else {
1040
    	return (&frame_als[(a1->al.al_val.al_frame | a2->al.al_val.al_frame)-1]);
1103
			return (&frame_als[(a1->al.al_val.al_frame |
-
 
1104
					    a2->al.al_val.al_frame) -1]);
1041
    }
1105
		}
1042
 
1106
	}
1043
   };
-
 
1044
 
1107
 
1045
  j = (alignment)calloc(1, sizeof(aldef));
1108
	j = (alignment)calloc(1, sizeof(aldef));
1046
  j -> al.al_n = 2;
1109
	j->al.al_n = 2;
1047
  j -> al.al_val.al_join.a = a1;
1110
	j->al.al_val.al_join.a = a1;
1048
  j -> al.al_val.al_join.b = a2;
1111
	j->al.al_val.al_join.b = a2;
1049
  j -> next_aldef = top_aldef;
1112
	j->next_aldef = top_aldef;
1050
  top_aldef = j;
1113
	top_aldef = j;
1051
  return j;
1114
	return j;
1052
}
1115
}
1053
 
1116
 
1054
 
1117
 
1055
 
1118
void
1056
void init_access
1119
init_access(void)
1057
    PROTO_Z ()
-
 
1058
{
1120
{
1059
  return;
1121
	return;
1060
}
1122
}
1061
 
-
 
1062
access f_dummy_access;
-
 
1063
 
1123
 
-
 
1124
 
-
 
1125
access f_dummy_access;
1064
 
1126
 
1065
access f_visible = 1;
1127
access f_visible = 1;
1066
access f_standard_access = 0;
1128
access f_standard_access = 0;
1067
access f_long_jump_access = 2;
1129
access f_long_jump_access = 2;
1068
access f_constant = 4;
1130
access f_constant = 4;
Line 1070... Line 1132...
1070
access f_no_other_write = 16;
1132
access f_no_other_write = 16;
1071
access f_register = 32;
1133
access f_register = 32;
1072
access f_out_par = 64;
1134
access f_out_par = 64;
1073
access f_used_as_volatile = 128;
1135
access f_used_as_volatile = 128;
1074
access f_preserve = 256;
1136
access f_preserve = 256;
1075
 
1137
 
1076
access f_add_accesses
1138
access
1077
    PROTO_N ( (a1, a2) )
-
 
1078
    PROTO_T ( access a1 X access a2 )
1139
f_add_accesses(access a1, access a2)
1079
{
1140
{
1080
  return a1 | a2;
1141
	return a1 | a2;
1081
}
1142
}
1082
 
1143
 
1083
 
1144
 
1084
alignment f_alloca_alignment;
1145
alignment f_alloca_alignment;
1085
alignment f_var_param_alignment;
1146
alignment f_var_param_alignment;
1086
alignment f_code_alignment;
1147
alignment f_code_alignment;
1087
 
1148
 
1088
static struct CAL { short sh_hd; short al; alignment res; struct CAL * rest;}*
1149
static struct CAL {
-
 
1150
	short sh_hd;
-
 
1151
	short al;
-
 
1152
	alignment res;
-
 
1153
	struct CAL *rest;
1089
		cache_pals;
1154
} *cache_pals;
1090
 
1155
 
1091
 
1156
void
1092
void init_alignment
1157
init_alignment(void)
1093
    PROTO_Z ()
-
 
1094
{
1158
{
1095
  const_al1->al.al_n = 1;
1159
	const_al1->al.al_n = 1;
1096
  const_al1->al.al_val.al = 1;
1160
	const_al1->al.al_val.al = 1;
1097
  const_al1->al.al_val.al_frame = 0;
1161
	const_al1->al.al_val.al_frame = 0;
1098
  const_al1->al.sh_hd = 0;
1162
	const_al1->al.sh_hd = 0;
1099
  const_al8->al.al_n = 1;
1163
	const_al8->al.al_n = 1;
1100
  const_al8->al.al_val.al = 8;
1164
	const_al8->al.al_val.al = 8;
1101
  const_al8->al.al_val.al_frame = 0;
1165
	const_al8->al.al_val.al_frame = 0;
1102
  const_al8->al.sh_hd = 0;
1166
	const_al8->al.sh_hd = 0;
1103
  const_al16->al.al_n = 1;
1167
	const_al16->al.al_n = 1;
1104
  const_al16->al.al_val.al = 16;
1168
	const_al16->al.al_val.al = 16;
1105
  const_al16->al.al_val.al_frame = 0;
1169
	const_al16->al.al_val.al_frame = 0;
1106
  const_al16->al.sh_hd = 0;
1170
	const_al16->al.sh_hd = 0;
1107
  const_al32->al.al_n = 1;
1171
	const_al32->al.al_n = 1;
1108
  const_al32->al.al_val.al = 32;
1172
	const_al32->al.al_val.al = 32;
1109
  const_al32->al.al_val.al_frame = 0;
1173
	const_al32->al.al_val.al_frame = 0;
1110
  const_al32->al.sh_hd = 0;
1174
	const_al32->al.sh_hd = 0;
1111
  const_al64->al.al_n = 1;
1175
	const_al64->al.al_n = 1;
1112
  const_al64->al.al_val.al = 64;
1176
	const_al64->al.al_val.al = 64;
1113
  const_al64->al.al_val.al_frame = 0;
1177
	const_al64->al.al_val.al_frame = 0;
1114
  const_al64->al.sh_hd = 0;
1178
	const_al64->al.sh_hd = 0;
1115
  const_al512->al.al_n = 1;
1179
	const_al512->al.al_n = 1;
1116
  const_al512->al.al_val.al = 512;
1180
	const_al512->al.al_val.al = 512;
1117
  const_al512->al.al_val.al_frame = 0;
1181
	const_al512->al.al_val.al_frame = 0;
1118
  const_al512->al.sh_hd = 0;
1182
	const_al512->al.sh_hd = 0;
-
 
1183
 
-
 
1184
	cache_pals = (struct CAL *)0;
-
 
1185
 
-
 
1186
	init_frame_als();
-
 
1187
	f_alloca_alignment = ALLOCA_ALIGN;
-
 
1188
	f_var_param_alignment = VAR_PARAM_ALIGN;
-
 
1189
	f_code_alignment = CODE_ALIGN;
-
 
1190
	stack_align = max(param_align, double_align);
-
 
1191
	return;
-
 
1192
}
1119
 
1193
 
1120
  cache_pals = (struct CAL *)0;
-
 
1121
 
-
 
1122
  init_frame_als();
-
 
1123
  f_alloca_alignment = ALLOCA_ALIGN;
-
 
1124
  f_var_param_alignment = VAR_PARAM_ALIGN;
-
 
1125
  f_code_alignment = CODE_ALIGN;
-
 
1126
  stack_align = max(param_align, double_align);
-
 
1127
  return;
-
 
1128
}
-
 
1129
 
1194
 
1130
alignment f_dummy_alignment;
1195
alignment f_dummy_alignment;
1131
 
1196
 
1132
 
-
 
1133
static alignment get_pal
1197
static alignment
1134
    PROTO_N ( (a, sh_hd, al) )
-
 
1135
    PROTO_T ( alignment a X int sh_hd X int al )
1198
get_pal(alignment a, int sh_hd, int al)
1136
{
1199
{
1137
	struct CAL * c = cache_pals;
1200
	struct CAL *c = cache_pals;
1138
	alignment res;
1201
	alignment res;
1139
	while (c != (struct CAL*)0) {
1202
	while (c != (struct CAL *)0) {
1140
		if (c->sh_hd == sh_hd && c->al == al) return c->res;
1203
		if (c->sh_hd == sh_hd && c->al == al) {
-
 
1204
			return c->res;
-
 
1205
		}
1141
		c = c->rest;
1206
		c = c->rest;
1142
	}
1207
	}
1143
	res = (alignment)xmalloc(sizeof(aldef));
1208
	res = (alignment)xmalloc(sizeof(aldef));
1144
	*res = *a;
1209
	*res = *a;
1145
	res -> al.sh_hd = sh_hd;
1210
	res->al.sh_hd = sh_hd;
1146
	c = (struct CAL*)xmalloc(sizeof(struct CAL));
1211
	c = (struct CAL *)xmalloc(sizeof(struct CAL));
-
 
1212
	c->sh_hd = sh_hd;
-
 
1213
	c->al = al;
-
 
1214
	c->res = res;
1147
	c->sh_hd = sh_hd; c->al = al; c->res = res; c->rest = cache_pals;
1215
	c->rest = cache_pals;
1148
	cache_pals = c;
1216
	cache_pals = c;
1149
	return res;
1217
	return res;
1150
}
1218
}
-
 
1219
 
1151
 
1220
 
1152
alignment f_parameter_alignment
1221
alignment
1153
    PROTO_N ( (sha) )
-
 
1154
    PROTO_T ( shape sha )
1222
f_parameter_alignment(shape sha)
1155
{
1223
{
1156
	int n = name(sha);
1224
	int n = name(sha);
1157
	alignment t =
1225
	alignment t =
1158
#if issparc
1226
#if issparc
1159
	  MIN_PAR_ALIGNMENT;
1227
	    MIN_PAR_ALIGNMENT;
1160
#else
1228
#else
1161
          f_unite_alignments(MIN_PAR_ALIGNMENT, f_alignment(sha));
1229
	f_unite_alignments(MIN_PAR_ALIGNMENT, f_alignment(sha));
1162
#endif
1230
#endif
1163
#if ishppa
1231
#if ishppa
1164
	if (shape_size(sha) > 64)
1232
	if (shape_size(sha) > 64) {
1165
		n = nofhd+1;
1233
		n = nofhd + 1;
-
 
1234
	}
1166
#endif
1235
#endif
1167
#if issparc
1236
#if issparc
1168
	if (sparccpd(sha))
1237
	if (sparccpd(sha)) {
1169
		n = nofhd+1;
1238
		n = nofhd + 1;
-
 
1239
	}
1170
#endif
1240
#endif
1171
 
1241
 
1172
	return get_pal(t,n,shape_align(sha));
1242
	return get_pal(t, n, shape_align(sha));
1173
}
1243
}
1174
 
1244
 
-
 
1245
 
-
 
1246
bitfield_variety
-
 
1247
f_bfvar_bits(bool issigned, nat bits)
-
 
1248
{
1175
bitfield_variety f_bfvar_bits
1249
	bitfield_variety res;
1176
    PROTO_N ( (issigned, bits) )
1250
	if (!nat_issmall(bits)) {
-
 
1251
		failer(TOO_MANY_BITS);
-
 
1252
	}
-
 
1253
	res.has_sign = issigned;
-
 
1254
	res.bits = natint(bits);
1177
    PROTO_T ( bool issigned X nat bits )
1255
	if (extra_checks && res.bits > SLONG_SZ) {
-
 
1256
		failer(TOO_MANY_BITS);
-
 
1257
	}
-
 
1258
	return res;
-
 
1259
}
-
 
1260
 
-
 
1261
 
-
 
1262
void
-
 
1263
init_bitfield_variety(void)
1178
{
1264
{
1179
  bitfield_variety res;
-
 
1180
  if (!nat_issmall(bits))
-
 
1181
   failer(TOO_MANY_BITS);
-
 
1182
  res.has_sign = issigned;
-
 
1183
  res.bits = natint(bits);
-
 
1184
  if (extra_checks && res.bits > SLONG_SZ)
-
 
1185
   failer(TOO_MANY_BITS);
-
 
1186
  return res;
1265
	return;
1187
}
1266
}
1188
 
1267
 
1189
void init_bitfield_variety
-
 
1190
    PROTO_Z ()
-
 
1191
{
-
 
1192
  return;
-
 
1193
}
-
 
1194
 
1268
 
1195
bitfield_variety f_dummy_bitfield_variety;
1269
bitfield_variety f_dummy_bitfield_variety;
1196
 
-
 
1197
 
1270
 
1198
bool f_false = 0;
1271
bool f_false = 0;
1199
bool f_true = 1;
1272
bool f_true = 1;
1200
 
1273
 
1201
void init_bool
-
 
1202
    PROTO_Z ()
-
 
1203
{
-
 
1204
  return;
-
 
1205
}
1274
void
1206
 
-
 
1207
bool f_dummy_bool;
1275
init_bool(void)
1208
 
-
 
1209
caselim f_make_caselim
-
 
1210
    PROTO_N ( (branch, lower, upper) )
-
 
1211
    PROTO_T ( label branch X signed_nat lower X signed_nat upper )
-
 
1212
{
1276
{
1213
  caselim c;
-
 
1214
  c.lab = branch;
-
 
1215
  c.low = lower;
-
 
1216
  c.high = upper;
-
 
1217
  return c;
1277
	return;
1218
}
1278
}
-
 
1279
 
-
 
1280
 
-
 
1281
bool f_dummy_bool;
-
 
1282
 
-
 
1283
caselim
-
 
1284
f_make_caselim(label branch, signed_nat lower, signed_nat upper)
-
 
1285
{
-
 
1286
	caselim c;
-
 
1287
	c.lab = branch;
-
 
1288
	c.low = lower;
-
 
1289
	c.high = upper;
-
 
1290
	return c;
-
 
1291
}
-
 
1292
 
1219
 
1293
 
1220
callees f_dummy_callees;
1294
callees f_dummy_callees;
1221
 
1295
 
1222
callees f_same_callees;
1296
callees f_same_callees;
1223
 
1297
 
1224
void init_callees
1298
void
1225
    PROTO_Z ()
1299
init_callees(void)
1226
{
1300
{
1227
	f_same_callees = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0,
1301
	f_same_callees = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0,
1228
			same_callees_tag);
1302
				same_callees_tag);
1229
	return;
1303
	return;
1230
}
1304
}
-
 
1305
 
1231
 
1306
 
1232
void init_caselim
1307
void
1233
    PROTO_Z ()
1308
init_caselim(void)
1234
{
1309
{
1235
  return;
1310
	return;
1236
}
1311
}
-
 
1312
 
1237
 
1313
 
1238
error_treatment f_error_jump
1314
error_treatment
1239
    PROTO_N ( (lab) )
-
 
1240
    PROTO_T ( label lab )
1315
f_error_jump(label lab)
1241
{
1316
{
1242
  error_treatment e;
1317
	error_treatment e;
1243
  e.err_code = 4;
1318
	e.err_code = 4;
1244
  e.jmp_dest = lab;
1319
	e.jmp_dest = lab;
1245
  return e;
1320
	return e;
1246
}
1321
}
1247
 
-
 
1248
 
1322
 
1249
 
1323
 
1250
error_code f_dummy_error_code;
1324
error_code f_dummy_error_code;
1251
 
1325
 
-
 
1326
void
1252
void init_error_code
1327
init_error_code(void)
-
 
1328
{
-
 
1329
	return;
-
 
1330
}
-
 
1331
 
-
 
1332
 
-
 
1333
void
1253
    PROTO_Z ()
1334
init_error_treatment(void)
1254
{
1335
{
-
 
1336
	f_wrap.err_code = 1;
-
 
1337
	f_impossible.err_code = 0;
-
 
1338
	f_continue.err_code = 2;
1255
	return;
1339
	return;
1256
}
1340
}
1257
 
1341
 
1258
void init_error_treatment
-
 
1259
    PROTO_Z ()
-
 
1260
{
-
 
1261
  f_wrap.err_code = 1;
-
 
1262
  f_impossible.err_code = 0;
-
 
1263
  f_continue.err_code = 2;
-
 
1264
  return;
-
 
1265
}
-
 
1266
 
1342
 
1267
error_treatment f_dummy_error_treatment;
1343
error_treatment f_dummy_error_treatment;
1268
 
-
 
1269
 
1344
 
1270
exp f_abs
1345
exp
1271
    PROTO_N ( (ov_err, arg1) )
-
 
1272
    PROTO_T ( error_treatment ov_err X exp arg1 )
1346
f_abs(error_treatment ov_err, exp arg1)
1273
{
1347
{
1274
  if (name(sh(arg1)) == bothd || !is_signed(sh(arg1)) )
1348
	if (name(sh(arg1)) == bothd || !is_signed(sh(arg1))) {
1275
    return arg1;
1349
		return arg1;
1276
 
-
 
1277
#if check_shape
-
 
1278
  if (!is_integer(sh(arg1)))
-
 
1279
    failer(CHSH_ABS);
-
 
1280
#endif
-
 
1281
#if !has64bits
-
 
1282
	if (name(sh(arg1)) >= s64hd &&
-
 
1283
		(name(arg1)!=val_tag || ov_err.err_code > 2)) {
-
 
1284
		return TDFcallop1(ov_err,arg1,abs_tag);
-
 
1285
	}
1350
	}
1286
#endif
-
 
1287
 
-
 
1288
  return me_u1(ov_err, arg1, abs_tag);
-
 
1289
}
-
 
1290
 
-
 
1291
exp f_add_to_ptr
-
 
1292
    PROTO_N ( (arg1, arg2) )
-
 
1293
    PROTO_T ( exp arg1 X exp arg2 )
-
 
1294
{
-
 
1295
  if (name(sh(arg1)) == bothd)
-
 
1296
    { kill_exp(arg2,arg2); return arg1; }
-
 
1297
  if (name(sh(arg2)) == bothd)
-
 
1298
    { kill_exp(arg1,arg1); return arg2; }
-
 
1299
 
-
 
1300
#if check_shape
-
 
1301
  if (!doing_aldefs &&
-
 
1302
	(name(sh(arg1)) != ptrhd || name(sh(arg2)) != offsethd ||
-
 
1303
        (al1(sh(arg1)) < al1(sh(arg2))
-
 
1304
#if issparc
-
 
1305
		&& al1_of(sh(arg2)) != REAL_ALIGN
-
 
1306
#endif
-
 
1307
	) ))
-
 
1308
     failer(CHSH_ADDPTR);
-
 
1309
#endif
-
 
1310
 
-
 
1311
#if issparc || ishppa
-
 
1312
if ((al1_of(sh(arg2))->al.al_val.al_frame & 6) != 0 &&
-
 
1313
#else
-
 
1314
if ((al1_of(sh(arg2))->al.al_val.al_frame &4) != 0 &&
-
 
1315
#endif
-
 
1316
	al2_of(sh(arg2))->al.sh_hd > nofhd) {
-
 
1317
	/* indirect varargs param */
-
 
1318
	exp z = me_b3(f_pointer(f_alignment(sh(arg1))), arg1, arg2, addptr_tag);
-
 
1319
	return f_contents(sh(arg1), z);
-
 
1320
}
-
 
1321
 
-
 
1322
 
-
 
1323
  return(me_b3(f_pointer(al2_of(sh(arg2))), arg1, arg2,
-
 
1324
               addptr_tag));
-
 
1325
}
-
 
1326
 
-
 
1327
exp f_and
-
 
1328
    PROTO_N ( (arg1, arg2) )
-
 
1329
    PROTO_T ( exp arg1 X exp arg2 )
-
 
1330
{
-
 
1331
  if (name(sh(arg1)) == bothd)
-
 
1332
    { kill_exp(arg2,arg2); return arg1; }
-
 
1333
  if (name(sh(arg2)) == bothd)
-
 
1334
    { kill_exp(arg1,arg1); return arg2; }
-
 
1335
 
1351
 
1336
#if check_shape
1352
#if check_shape
1337
  if (!eq_shape(sh(arg1), sh(arg2)) || !is_integer(sh(arg1)))
1353
	if (!is_integer(sh(arg1))) {
1338
    failer(CHSH_AND);
1354
		failer(CHSH_ABS);
-
 
1355
	}
1339
#endif
1356
#endif
1340
#if !has64bits
1357
#if !has64bits
1341
	if (name(sh(arg1)) >= s64hd &&
1358
	if (name(sh(arg1)) >= s64hd &&
1342
		(name(arg1)!=val_tag || name(arg2) != val_tag)){
1359
	    (name(arg1) != val_tag || ov_err.err_code > 2)) {
1343
		return TDFcallop3(arg1,arg2,and_tag);
1360
		return TDFcallop1(ov_err, arg1, abs_tag);
-
 
1361
	}
-
 
1362
#endif
-
 
1363
 
-
 
1364
	return me_u1(ov_err, arg1, abs_tag);
-
 
1365
}
-
 
1366
 
-
 
1367
 
-
 
1368
exp
-
 
1369
f_add_to_ptr(exp arg1, exp arg2)
-
 
1370
{
-
 
1371
	if (name(sh(arg1)) == bothd) {
-
 
1372
		kill_exp(arg2, arg2);
-
 
1373
		return arg1;
-
 
1374
	}
-
 
1375
	if (name(sh(arg2)) == bothd) {
-
 
1376
		kill_exp(arg1, arg1);
-
 
1377
		return arg2;
-
 
1378
	}
-
 
1379
 
-
 
1380
#if check_shape
-
 
1381
	if (!doing_aldefs && (name(sh(arg1)) != ptrhd ||
-
 
1382
			      name(sh(arg2)) != offsethd ||
-
 
1383
			      (al1(sh(arg1)) < al1(sh(arg2))
-
 
1384
#if issparc
-
 
1385
			       && al1_of(sh(arg2)) != REAL_ALIGN
-
 
1386
#endif
-
 
1387
			       ))) {
-
 
1388
		failer(CHSH_ADDPTR);
1344
	}
1389
	}
1345
#endif
1390
#endif
1346
 
1391
 
-
 
1392
#if issparc || ishppa
-
 
1393
	if ((al1_of(sh(arg2))->al.al_val.al_frame & 6) != 0 &&
-
 
1394
#else
-
 
1395
	if ((al1_of(sh(arg2))->al.al_val.al_frame & 4) != 0 &&
-
 
1396
#endif
-
 
1397
	    al2_of(sh(arg2))->al.sh_hd > nofhd) {
-
 
1398
		/* indirect varargs param */
-
 
1399
		exp z = me_b3(f_pointer(f_alignment(sh(arg1))), arg1, arg2,
-
 
1400
			      addptr_tag);
-
 
1401
		return f_contents(sh(arg1), z);
-
 
1402
	}
-
 
1403
 
-
 
1404
	return (me_b3(f_pointer(al2_of(sh(arg2))), arg1, arg2, addptr_tag));
-
 
1405
}
-
 
1406
 
-
 
1407
 
-
 
1408
exp
-
 
1409
f_and(exp arg1, exp arg2)
-
 
1410
{
-
 
1411
	if (name(sh(arg1)) == bothd) {
-
 
1412
		kill_exp(arg2, arg2);
-
 
1413
		return arg1;
-
 
1414
	}
-
 
1415
	if (name(sh(arg2)) == bothd) {
-
 
1416
		kill_exp(arg1, arg1);
-
 
1417
		return arg2;
-
 
1418
	}
-
 
1419
 
-
 
1420
#if check_shape
-
 
1421
	if (!eq_shape(sh(arg1), sh(arg2)) || !is_integer(sh(arg1))) {
-
 
1422
		failer(CHSH_AND);
-
 
1423
	}
-
 
1424
#endif
-
 
1425
#if !has64bits
-
 
1426
	if (name(sh(arg1)) >= s64hd &&
-
 
1427
	    (name(arg1) != val_tag || name(arg2) != val_tag)) {
-
 
1428
		return TDFcallop3(arg1, arg2, and_tag);
-
 
1429
	}
-
 
1430
#endif
-
 
1431
 
1347
  return me_b2( arg1, arg2, and_tag);
1432
	return me_b2(arg1, arg2, and_tag);
1348
}
1433
}
1349
 
1434
 
-
 
1435
 
1350
exp f_apply_proc
1436
exp
1351
    PROTO_N ( (result_shape, arg1, arg2, varparam) )
-
 
1352
    PROTO_T ( shape result_shape X exp arg1 X exp_list arg2 X exp_option varparam )
1437
f_apply_proc(shape result_shape, exp arg1, exp_list arg2, exp_option varparam)
1353
{
1438
{
1354
  exp res = getexp(result_shape, nilexp, 0, arg1, nilexp,
1439
	exp res = getexp(result_shape, nilexp, 0, arg1, nilexp, 0, 0,
1355
                     0, 0, apply_tag);
1440
			 apply_tag);
1356
  int varhack = 0;
1441
	int varhack = 0;
1357
  if (name(sh(arg1)) == bothd)
1442
	if (name(sh(arg1)) == bothd) {
1358
    return arg1;
1443
		return arg1;
-
 
1444
	}
1359
 
1445
 
1360
#if check_shape
1446
#if check_shape
1361
  if (name(sh(arg1)) != prokhd)
1447
	if (name(sh(arg1)) != prokhd) {
1362
    failer(CHSH_APPLY);
1448
		failer(CHSH_APPLY);
-
 
1449
	}
1363
#endif
1450
#endif
1364
 
1451
 
1365
  if (varparam.present) {
1452
	if (varparam.present) {
1366
   	 /* add a declaration for variable parameters */
1453
		/* add a declaration for variable parameters */
1367
     arg2 = add_exp_list(arg2, varparam.val, arg2.number+1);
1454
		arg2 = add_exp_list(arg2, varparam.val, arg2.number + 1);
1368
     varhack =1;
1455
		varhack =1;
1369
  }
1456
	}
1370
 
1457
 
1371
  clear_exp_list(arg2);
1458
	clear_exp_list(arg2);
1372
 
-
 
1373
 
-
 
1374
  if (name(arg1) == name_tag && isglob(son(arg1)) &&
-
 
1375
             !isvar(son(arg1)))
-
 
1376
    {speci sp;
-
 
1377
       /* check for substitutions for certain global procedures */
-
 
1378
     sp = special_fn(arg1, arg2.start, result_shape);
-
 
1379
     if (sp.is_special)
-
 
1380
       return sp.special_exp;
-
 
1381
    };
-
 
1382
 
1459
 
-
 
1460
	if (name(arg1) == name_tag && isglob(son(arg1)) && !isvar(son(arg1))) {
-
 
1461
		speci sp;
-
 
1462
		/* check for substitutions for certain global procedures */
-
 
1463
		sp = special_fn(arg1, arg2.start, result_shape);
-
 
1464
		if (sp.is_special) {
-
 
1465
			return sp.special_exp;
-
 
1466
		}
-
 
1467
	}
-
 
1468
 
1383
  if (arg2.number==0)
1469
	if (arg2.number==0) {
1384
     {setfather(res, arg1);}
1470
		setfather(res, arg1);
1385
  else
1471
	} else {
1386
   {
-
 
1387
     clearlast(arg1);
1472
		clearlast(arg1);
1388
     bro(arg1) = arg2.start;
1473
		bro(arg1) = arg2.start;
1389
     setfather(res, arg2.end);
1474
		setfather(res, arg2.end);
1390
#ifdef promote_pars
1475
#ifdef promote_pars
1391
    promote_actuals(bro(son(res)));
1476
		promote_actuals(bro(son(res)));
1392
#endif
1477
#endif
1393
   };
1478
	}
1394
 
1479
 
1395
  /* rewrite struct/union value parameters as pointer-to-copy */
1480
	/* rewrite struct/union value parameters as pointer-to-copy */
1396
  if (redo_structparams && arg2.number > 0)       /* has >0 params */
1481
	if (redo_structparams && arg2.number > 0) {
1397
  {
-
 
1398
    exp param, prev;
1482
		/* has >0 params */
1399
 
-
 
1400
    prev = arg1;
-
 
1401
    param = bro(arg1);
1483
		exp param, prev;
1402
 
1484
 
-
 
1485
		prev = arg1;
-
 
1486
		param = bro(arg1);
-
 
1487
 
1403
    while (1 /*"break" below*/)
1488
		while (1 /*"break" below*/) {
1404
    {
-
 
1405
      if ((varhack && last(param)) ||
1489
			if ((varhack && last(param)) ||
1406
#if ishppa
1490
#if ishppa
1538
 
1627
 
-
 
1628
exp
1539
  return me_b3( f_top, arg1, arg2, ass_tag);
1629
f_assign(exp arg1, exp arg2)
-
 
1630
{
-
 
1631
	if (name(sh(arg1)) == bothd) {
-
 
1632
		kill_exp(arg2, arg2);
-
 
1633
		return arg1;
-
 
1634
	}
-
 
1635
	if (name(sh(arg2)) == bothd) {
-
 
1636
		kill_exp(arg1, arg1);
-
 
1637
		return arg2;
1540
}
1638
	}
1541
 
1639
 
1542
exp f_assign_with_mode
-
 
1543
    PROTO_N ( (md, arg1, arg2) )
1640
	return me_b3(f_top, arg1, arg2, ass_tag);
-
 
1641
}
-
 
1642
 
-
 
1643
 
-
 
1644
exp
1544
    PROTO_T ( transfer_mode md X exp arg1 X exp arg2 )
1645
f_assign_with_mode(transfer_mode md, exp arg1, exp arg2)
1545
{
1646
{
1546
  if (name(sh(arg1)) == bothd)
1647
	if (name(sh(arg1)) == bothd) {
1547
    { kill_exp(arg2,arg2); return arg1; }
1648
		kill_exp(arg2, arg2);
-
 
1649
		return arg1;
-
 
1650
	}
1548
  if (name(sh(arg2)) == bothd)
1651
	if (name(sh(arg2)) == bothd) {
1549
    { kill_exp(arg1,arg1); return arg2; }
1652
		kill_exp(arg1, arg1);
-
 
1653
		return arg2;
-
 
1654
	}
1550
 
1655
 
1551
  if (md & f_complete) {
1656
	if (md & f_complete) {
1552
	exp d = me_startid(f_top, arg2, 0);
1657
		exp d = me_startid(f_top, arg2, 0);
1553
	return me_complete_id(d,
1658
		return me_complete_id(d, f_assign_with_mode(md & ~f_complete,
-
 
1659
							    arg1,
1554
		f_assign_with_mode(md & ~f_complete,arg1, me_obtain(d)) );
1660
							    me_obtain(d)));
1555
  }
1661
	}
1556
#ifdef no_trap_on_nil_contents
1662
#ifdef no_trap_on_nil_contents
1557
  if ((md & f_trap_on_nil) != 0) {
1663
	if ((md & f_trap_on_nil) != 0) {
1558
    exp d = me_startid(f_top, arg1, 0);
1664
		exp d = me_startid(f_top, arg1, 0);
1559
		exp hldr = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, 0);
1665
		exp hldr = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, 0);
1560
     		exp lb = getexp(f_top, nilexp, 0, hldr, nilexp, 0, 0, labst_tag);
1666
		exp lb = getexp(f_top, nilexp, 0, hldr, nilexp, 0, 0,
-
 
1667
				labst_tag);
1561
		exp_list el;
1668
		exp_list el;
1562
		exp test = me_q1(no_nat_option, f_equal, &lb, me_obtain(d),
1669
		exp test = me_q1(no_nat_option, f_equal, &lb, me_obtain(d),
1563
				f_make_null_ptr(al1_of(sh(arg1))), test_tag);
1670
				 f_make_null_ptr(al1_of(sh(arg1))), test_tag);
1564
		exp trp = getexp(f_bottom, nilexp, 0, nilexp, nilexp,
1671
		exp trp = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0,
1565
				    0 , f_nil_access, trap_tag);
1672
				 f_nil_access, trap_tag);
1566
		md &= ~f_trap_on_nil;
1673
		md &= ~f_trap_on_nil;
1567
     		el = new_exp_list(1);
1674
		el = new_exp_list(1);
1568
     		el = add_exp_list(el, test, 1);
1675
		el = add_exp_list(el, test, 1);
1569
     		return me_complete_id(d,
1676
		return me_complete_id(d, f_conditional(&lb, f_sequence(el, trp),
1570
		   f_conditional(&lb, f_sequence(el, trp),
1677
						       f_assign_with_mode(md,
1571
				f_assign_with_mode(md, me_obtain(d), arg2)) );
1678
						       me_obtain(d), arg2)));
1572
 
-
 
1573
   	};
1679
	}
1574
#endif
1680
#endif
1575
  if ((md & f_volatile)!=0)
1681
	if ((md & f_volatile) != 0) {
1576
    return me_b3(f_top, arg1, arg2, assvol_tag);
1682
		return me_b3(f_top, arg1, arg2, assvol_tag);
1577
  else
-
 
1578
  if ( (md & f_overlap) &&
1683
	} else if ((md & f_overlap) &&
1579
	(name(arg2) == cont_tag || name(arg2) == contvol_tag) &&
1684
		   (name(arg2) == cont_tag || name(arg2) == contvol_tag) &&
1580
	! reg_result(sh(arg2)) )
1685
		   !reg_result(sh(arg2))) {
1581
    return f_move_some(md, son(arg2), arg1,f_shape_offset(sh(arg2)));
1686
		return f_move_some(md, son(arg2), arg1,
-
 
1687
				   f_shape_offset(sh(arg2)));
-
 
1688
	} else {
1582
  else return me_b3(f_top, arg1, arg2, ass_tag);
1689
		return me_b3(f_top, arg1, arg2, ass_tag);
-
 
1690
	}
1583
}
1691
}
1584
 
1692
 
-
 
1693
 
1585
exp f_bitfield_assign
1694
exp
1586
    PROTO_N ( (p, off, val) )
-
 
1587
    PROTO_T ( exp p X exp off X exp val )
1695
f_bitfield_assign(exp p, exp off, exp val)
1588
{
1696
{
1589
  exp res;
1697
	exp res;
1590
  if (name(sh(p)) == bothd)
1698
	if (name(sh(p)) == bothd) {
1591
    return p;
1699
		return p;
-
 
1700
	}
1592
  if (name(sh(val)) == bothd)
1701
	if (name(sh(val)) == bothd) {
1593
    return val;
1702
		return val;
-
 
1703
	}
1594
 
1704
 
1595
#if check_shape
1705
#if check_shape
1596
  if (name(sh(p)) != ptrhd || name(sh(off)) != offsethd )
1706
	if (name(sh(p)) != ptrhd || name(sh(off)) != offsethd) {
1597
    failer(CHSH_BFASS);
1707
		failer(CHSH_BFASS);
-
 
1708
	}
1598
#endif
1709
#endif
1599
  if (name(off) == val_tag) {
1710
	if (name(off) == val_tag) {
1600
  	res = me_b3(f_top, p, val, bfass_tag);
1711
		res = me_b3(f_top, p, val, bfass_tag);
1601
  	no(res) = no(off);
1712
		no(res) = no(off);
1602
  	return res;
1713
		return res;
1603
  }
-
 
1604
  else {
1714
	} else {
1605
	int alofptr = al1(sh(p));
1715
		int alofptr = al1(sh(p));
1606
	shape s = containedshape(alofptr, 0);
1716
		shape s = containedshape(alofptr, 0);
1607
	shape bfs = sh(val);
1717
		shape bfs = sh(val);
1608
	int nbits = shape_size(sh(val));
1718
		int nbits = shape_size(sh(val));
1609
	alignment als = f_alignment(s);
1719
		alignment als = f_alignment(s);
1610
        alignment alb = long_to_al(1);
1720
		alignment alb = long_to_al(1);
1611
	shape os = f_offset(als,als);
1721
		shape os = f_offset(als, als);
1612
	shape bos = f_offset(alb,alb);
1722
		shape bos = f_offset(alb, alb);
1613
        exp mask0 = getexp(s, nilexp, 0, nilexp, nilexp, 0,
1723
		exp mask0 = getexp(s, nilexp, 0, nilexp, nilexp, 0,
1614
			((1 << nbits)-1), val_tag);
1724
				   ((1 << nbits) -1), val_tag);
1615
 
1725
 
1616
	exp noff1 = getexp(sh(off), nilexp, 0, nilexp, nilexp, 0, 0,
1726
		exp noff1 = getexp(sh(off), nilexp, 0, nilexp, nilexp, 0, 0,
1617
			name_tag);
1727
				   name_tag);
1618
	exp noff2 = getexp(sh(off), nilexp, 0, nilexp, noff1, 0, 0,
1728
		exp noff2 = getexp(sh(off), nilexp, 0, nilexp, noff1, 0, 0,
1619
			name_tag);
1729
				   name_tag);
1620
	exp idoff = getexp(f_top, nilexp, 0, off, noff2, 0, 2, ident_tag);
1730
		exp idoff = getexp(f_top, nilexp, 0, off, noff2, 0, 2,
-
 
1731
				   ident_tag);
1621
	son(noff1) = idoff; son(noff2) = idoff;
1732
		son(noff1) = idoff; son(noff2) = idoff;
1622
      {
1733
		{
1623
     	exp addbf = f_offset_add( noff1,f_shape_offset(bfs) );
1734
			exp addbf = f_offset_add(noff1, f_shape_offset(bfs));
1624
	exp byteoffinit = f_offset_subtract(hold_check(f_offset_pad(als, addbf)),
1735
			exp byteoffinit = f_offset_subtract(hold_check(
-
 
1736
					  f_offset_pad(als, addbf)),
1625
			hold_check(f_offset_pad(als, f_shape_offset(s))) );
1737
					  hold_check(f_offset_pad(als,
-
 
1738
					  f_shape_offset(s))));
1626
	exp v1bit = getexp(bos, nilexp, 0, nilexp, nilexp, 0, 1, val_tag);
1739
			exp v1bit = getexp(bos, nilexp, 0, nilexp, nilexp, 0, 1,
-
 
1740
					   val_tag);
1627
	exp nby1 = getexp(os, nilexp, 0, nilexp, nilexp, 0, 0, name_tag);
1741
			exp nby1 = getexp(os, nilexp, 0, nilexp, nilexp, 0, 0,
-
 
1742
					  name_tag);
1628
	exp nby2 = getexp(os, nilexp, 0, nilexp, nby1, 0, 0, name_tag);
1743
			exp nby2 = getexp(os, nilexp, 0, nilexp, nby1, 0, 0,
-
 
1744
					  name_tag);
1629
	exp nby3 = getexp(os, nilexp, 0, nilexp, nby2, 0, 0, name_tag);
1745
			exp nby3 = getexp(os, nilexp, 0, nilexp, nby2, 0, 0,
-
 
1746
					  name_tag);
1630
	exp idby = getexp(f_top, idoff, 1, byteoffinit, nby3, 0,
1747
			exp idby = getexp(f_top, idoff, 1, byteoffinit, nby3, 0,
1631
		3, ident_tag);
1748
					  3, ident_tag);
1632
        exp bitoffinit = f_offset_div(ulongsh,
1749
			exp bitoffinit = f_offset_div(ulongsh,
-
 
1750
					 f_offset_subtract(noff2,
1633
		   f_offset_subtract(noff2,f_offset_pad(f_alignment(bfs), nby2)),
1751
					 f_offset_pad(f_alignment(bfs), nby2)),
1634
					v1bit);
1752
					 v1bit);
1635
	exp bnt1 = getexp(ulongsh, nilexp,0, nilexp, nilexp, 0,
1753
			exp bnt1 = getexp(ulongsh, nilexp, 0, nilexp, nilexp, 0,
1636
			0, name_tag);
1754
					  0, name_tag);
1637
 	exp bnt2 = getexp(ulongsh, nilexp,0, nilexp, bnt1, 0, 0, name_tag);
1755
			exp bnt2 = getexp(ulongsh, nilexp, 0, nilexp, bnt1, 0,
-
 
1756
					  0, name_tag);
1638
#if little_end
1757
#if little_end
1639
	exp idbnt = getexp(f_top, idby, 1, bitoffinit, bnt2, 0, 2, ident_tag);
1758
			exp idbnt = getexp(f_top, idby, 1, bitoffinit, bnt2, 0,
-
 
1759
					   2, ident_tag);
1640
#else
1760
#else
1641
	exp v = getexp(ulongsh, nilexp, 0, nilexp, nilexp, 0,
1761
			exp v = getexp(ulongsh, nilexp, 0, nilexp, nilexp, 0,
1642
				shape_size(s)-nbits, val_tag);
1762
				       shape_size(s) - nbits, val_tag);
1643
	exp idbnt = getexp(f_top, idby, 1, f_minus(f_wrap, v, bitoffinit),
1763
			exp idbnt = getexp(f_top, idby, 1, f_minus(f_wrap, v,
-
 
1764
								   bitoffinit),
1644
				 bnt2, 0, 2, ident_tag);
1765
					   bnt2, 0, 2, ident_tag);
1645
#endif
1766
#endif
1646
	exp pn1 = getexp(sh(p), nilexp,0, nilexp, nilexp, 0, 0, name_tag);
1767
			exp pn1 = getexp(sh(p), nilexp, 0, nilexp, nilexp, 0, 0,
-
 
1768
					 name_tag);
1647
 	exp pn2 = getexp(sh(p), nilexp,0, nilexp, pn1, 0, 0, name_tag);
1769
			exp pn2 = getexp(sh(p), nilexp, 0, nilexp, pn1, 0, 0,
-
 
1770
					 name_tag);
1648
	exp idpn = getexp(f_top, idbnt, 1, f_add_to_ptr(p, nby1), pn2, 0,
1771
			exp idpn = getexp(f_top, idbnt, 1,
-
 
1772
					  f_add_to_ptr(p, nby1), pn2, 0, 2,
1649
			 2, ident_tag);
1773
					  ident_tag);
1650
 
1774
 
1651
	exp cnt; exp mask1; exp orit; exp asit;
1775
			exp cnt; exp mask1; exp orit; exp asit;
1652
 	son(nby1) = idby; son(nby2) = idby; son(nby3) = idby;
1776
			son(nby1) = idby; son(nby2) = idby; son(nby3) = idby;
1653
        son(bnt1) = idbnt; son(bnt2) = idbnt;
1777
			son(bnt1) = idbnt; son(bnt2) = idbnt;
1654
	son(pn1) = idpn; son(pn2) = idpn;
1778
			son(pn1) = idpn; son(pn2) = idpn;
1655
	bro(son(idby)) = idbnt; clearlast(son(idby));
1779
			bro(son(idby)) = idbnt; clearlast(son(idby));
1656
	bro(son(idbnt)) = idpn; clearlast(son(idbnt));
1780
			bro(son(idbnt)) = idpn; clearlast(son(idbnt));
1657
        bro(son(idoff)) = idby; clearlast(son(idoff));
1781
			bro(son(idoff)) = idby; clearlast(son(idoff));
1658
 
1782
 
1659
	mask1 = f_not(f_shift_left(f_wrap, mask0, bnt1));
1783
			mask1 = f_not(f_shift_left(f_wrap, mask0, bnt1));
1660
	cnt = f_and(f_contents(s, pn1), mask1);
1784
			cnt = f_and(f_contents(s, pn1), mask1);
1661
	orit = f_or(cnt, f_shift_left(f_wrap, f_change_bitfield_to_int(s, val),
1785
			orit = f_or(cnt, f_shift_left(f_wrap,
1662
					 bnt2));
1786
			    f_change_bitfield_to_int(s, val), bnt2));
1663
	asit = f_assign(pn2, orit);
1787
			asit = f_assign(pn2, orit);
1664
	bro(son(idpn)) = asit; clearlast(son(idpn));
1788
			bro(son(idpn)) = asit; clearlast(son(idpn));
1665
	bro(asit) = idpn; setlast(asit);
1789
			bro(asit) = idpn; setlast(asit);
1666
 
1790
 
1667
        return idoff;
1791
			return idoff;
1668
      }
1792
		}
1669
  }
1793
	}
1670
 
1794
}
1671
}
1795
 
1672
 
1796
 
1673
exp f_bitfield_assign_with_mode
1797
exp
1674
    PROTO_N ( (md, p, off, val) )
-
 
1675
    PROTO_T ( transfer_mode md X exp p X exp off X exp val )
1798
f_bitfield_assign_with_mode(transfer_mode md, exp p, exp off, exp val)
1676
{
1799
{
1677
  exp res;
1800
	exp res;
1678
  if (name(sh(p)) == bothd)
1801
	if (name(sh(p)) == bothd) {
1679
    return p;
1802
		return p;
-
 
1803
	}
1680
  if (name(sh(val)) == bothd)
1804
	if (name(sh(val)) == bothd) {
1681
    return val;
1805
		return val;
-
 
1806
	}
1682
 
1807
 
1683
  if (md == f_standard_transfer_mode)
1808
	if (md == f_standard_transfer_mode) {
1684
    return f_bitfield_assign (p, off, val);
1809
		return f_bitfield_assign(p, off, val);
-
 
1810
	}
1685
 
1811
 
1686
#if check_shape
1812
#if check_shape
1687
  if (name(sh(p)) != ptrhd || name(sh(off)) != offsethd ||
1813
	if (name(sh(p)) != ptrhd || name(sh(off)) != offsethd ||
1688
	name(off) != val_tag)
1814
	    name(off) != val_tag) {
1689
    failer(CHSH_BFASS);
1815
		failer(CHSH_BFASS);
-
 
1816
	}
1690
#endif
1817
#endif
1691
#ifdef no_trap_on_nil_contents
1818
#ifdef no_trap_on_nil_contents
1692
  if ((md & f_trap_on_nil) != 0) {
1819
	if ((md & f_trap_on_nil) != 0) {
1693
		exp d = me_startid(f_top, p, 0);
1820
		exp d = me_startid(f_top, p, 0);
1694
		exp hldr = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, 0);
1821
		exp hldr = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, 0);
1695
     		exp lb = getexp(f_top, nilexp, 0, hldr, nilexp, 0, 0, labst_tag);
1822
		exp lb = getexp(f_top, nilexp, 0, hldr, nilexp, 0, 0,
-
 
1823
				labst_tag);
1696
		exp_list el;
1824
		exp_list el;
1697
		exp test = me_q1(no_nat_option, f_equal, &lb, me_obtain(d),
1825
		exp test = me_q1(no_nat_option, f_equal, &lb, me_obtain(d),
1698
				f_make_null_ptr(al1_of(sh(p))), test_tag);
1826
				 f_make_null_ptr(al1_of(sh(p))), test_tag);
1699
		exp trp = getexp(f_bottom, nilexp, 0, nilexp, nilexp,
1827
		exp trp = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0,
1700
				    0 , f_nil_access, trap_tag);
1828
				 f_nil_access, trap_tag);
1701
		md &= ~f_trap_on_nil;
1829
		md &= ~f_trap_on_nil;
1702
     		el = new_exp_list(1);
1830
		el = new_exp_list(1);
1703
     		el = add_exp_list(el, test, 1);
1831
		el = add_exp_list(el, test, 1);
1704
     		return me_complete_id(d,
-
 
1705
		   f_conditional(&lb, f_sequence(el, trp),
1832
		return me_complete_id(d, f_conditional(&lb, f_sequence(el, trp),
1706
				f_bitfield_assign_with_mode(md, me_obtain(d), off, val)) );
1833
		    f_bitfield_assign_with_mode(md, me_obtain(d), off, val)));
1707
 
-
 
1708
   	};
1834
	}
1709
#endif
1835
#endif
1710
  if (md & f_volatile)
1836
	if (md & f_volatile) {
1711
    res = me_b3(f_top, p, val, bfassvol_tag);
1837
		res = me_b3(f_top, p, val, bfassvol_tag);
1712
  else
1838
	} else {
1713
    res = me_b3(f_top, p, val, bfass_tag);
1839
		res = me_b3(f_top, p, val, bfass_tag);
-
 
1840
	}
1714
  no(res) = no(off);
1841
	no(res) = no(off);
1715
  return res;
1842
	return res;
1716
}
1843
}
1717
 
1844
 
1718
exp f_bitfield_contents
1845
exp
1719
    PROTO_N ( (bf, p, off) )
-
 
1720
    PROTO_T ( bitfield_variety bf X exp p X exp off )
1846
f_bitfield_contents(bitfield_variety bf, exp p, exp off)
1721
{
1847
{
1722
  exp res;
1848
	exp res;
1723
  if (name(sh(p)) == bothd)
1849
	if (name(sh(p)) == bothd) {
1724
    return off;
1850
		return off;
-
 
1851
	}
1725
  if (name(sh(off)) == bothd)
1852
	if (name(sh(off)) == bothd) {
1726
    return p;
1853
		return p;
-
 
1854
	}
1727
 
1855
 
1728
#if check_shape
1856
#if check_shape
1729
  if (name(sh(p)) != ptrhd || name(sh(off)) != offsethd )
1857
	if (name(sh(p)) != ptrhd || name(sh(off)) != offsethd)
1730
    failer(CHSH_BFCONT);
1858
		failer(CHSH_BFCONT);
1731
#endif
1859
#endif
1732
 
-
 
1733
 
1860
 
1734
  if (name(off) == val_tag) {
1861
	if (name(off) == val_tag) {
1735
  	res = me_u3(f_bitfield(bf), p, bfcont_tag);
1862
		res = me_u3(f_bitfield(bf), p, bfcont_tag);
1736
  	no(res) = no(off);
1863
		no(res) = no(off);
1737
  	return res;
1864
		return res;
1738
  }
-
 
1739
  else {
1865
	} else {
1740
	int alofptr = al1(sh(p));
1866
		int alofptr = al1(sh(p));
1741
	shape s = containedshape(alofptr, bf.has_sign);
1867
		shape s = containedshape(alofptr, bf.has_sign);
1742
	shape bfs = f_bitfield(bf);
1868
		shape bfs = f_bitfield(bf);
1743
	alignment als = f_alignment(s);
1869
		alignment als = f_alignment(s);
1744
	alignment alb = long_to_al(1);
1870
		alignment alb = long_to_al(1);
1745
	shape ob = f_offset(alb,alb);
1871
		shape ob = f_offset(alb, alb);
1746
	shape os = f_offset(als,als);
1872
		shape os = f_offset(als, als);
1747
	exp noff1 = getexp(sh(off), nilexp, 0, nilexp, nilexp, 0, 0,
1873
		exp noff1 = getexp(sh(off), nilexp, 0, nilexp, nilexp, 0, 0,
1748
			name_tag);
1874
				   name_tag);
1749
	exp noff2 = getexp(sh(off), nilexp, 0, nilexp, noff1, 0, 0,
1875
		exp noff2 = getexp(sh(off), nilexp, 0, nilexp, noff1, 0, 0,
1750
			name_tag);
1876
				   name_tag);
1751
	exp idoff = getexp(s, nilexp, 0, off, noff2, 0, 2, ident_tag);
1877
		exp idoff = getexp(s, nilexp, 0, off, noff2, 0, 2, ident_tag);
1752
	son(noff1) = idoff; son(noff2) = idoff;
1878
		son(noff1) = idoff; son(noff2) = idoff;
1753
      {
1879
		{
1754
	exp addbf = f_offset_add( noff1, f_shape_offset(bfs) );
1880
			exp addbf = f_offset_add(noff1, f_shape_offset(bfs));
-
 
1881
			exp byteoffinit =
1755
	exp byteoffinit = f_offset_subtract(hold_check(f_offset_pad(als, addbf)),
1882
			    f_offset_subtract(hold_check(f_offset_pad(als,
-
 
1883
			    addbf)), hold_check(f_offset_pad(als,
1756
			hold_check(f_offset_pad(als, f_shape_offset(s))) );
1884
			    f_shape_offset(s))));
1757
	exp nby1 = getexp(os, nilexp, 0, nilexp, nilexp, 0, 0, name_tag);
1885
			exp nby1 = getexp(os, nilexp, 0, nilexp, nilexp, 0, 0,
-
 
1886
					  name_tag);
1758
	exp nby2 = getexp(os, nilexp, 0, nilexp, nby1, 0, 0, name_tag);
1887
			exp nby2 = getexp(os, nilexp, 0, nilexp, nby1, 0, 0,
-
 
1888
					  name_tag);
1759
	exp idby = getexp(s, nilexp, 0, byteoffinit, nby2, 0, 2, ident_tag);
1889
			exp idby = getexp(s, nilexp, 0, byteoffinit, nby2, 0, 2,
-
 
1890
					  ident_tag);
1760
	exp cnt; exp sh1; exp sh2; exp bitoff; exp shl;
1891
			exp cnt; exp sh1; exp sh2; exp bitoff; exp shl;
1761
	exp v = getexp(ulongsh, nilexp, 0, nilexp, nilexp, 0,
1892
			exp v = getexp(ulongsh, nilexp, 0, nilexp, nilexp, 0,
1762
			shape_size(s) - bf.bits, val_tag);
1893
				       shape_size(s) - bf.bits, val_tag);
1763
        exp v1bit = getexp(ob, nilexp, 0, nilexp, nilexp, 0, 1, val_tag);
1894
			exp v1bit = getexp(ob, nilexp, 0, nilexp, nilexp, 0, 1,
-
 
1895
					   val_tag);
1764
	son(nby1) = idby; son(nby2) = idby;
1896
			son(nby1) = idby; son(nby2) = idby;
1765
	cnt = f_contents(s, f_add_to_ptr(p, nby1));
1897
			cnt = f_contents(s, f_add_to_ptr(p, nby1));
-
 
1898
			bitoff =
1766
        bitoff = f_offset_div(ulongsh,
1899
			    f_offset_div(ulongsh, f_offset_subtract(noff2,
1767
	f_offset_subtract(noff2,f_offset_pad(f_alignment(bfs), nby2)),
1900
			    f_offset_pad(f_alignment(bfs), nby2)), v1bit);
1768
					v1bit);
-
 
1769
#if (little_end)
1901
#if (little_end)
1770
	shl = f_minus(f_wrap, copy(v), bitoff);
1902
			shl = f_minus(f_wrap, copy(v), bitoff);
1771
#else
1903
#else
1772
	shl = bitoff;
1904
			shl = bitoff;
1773
#endif
1905
#endif
1774
        sh1 = f_shift_left(f_wrap,cnt, shl);
1906
			sh1 = f_shift_left(f_wrap, cnt, shl);
1775
	sh2 = f_shift_right(sh1, v);
1907
			sh2 = f_shift_right(sh1, v);
1776
	bro(byteoffinit) = sh2; clearlast(byteoffinit);
1908
			bro(byteoffinit) = sh2; clearlast(byteoffinit);
1777
	bro(sh2) = idby; setlast(sh2);
1909
			bro(sh2) = idby; setlast(sh2);
1778
	bro(off) = idby; clearlast(off);
1910
			bro(off) = idby; clearlast(off);
1779
	bro(idby) = idoff; setlast(idby);
1911
			bro(idby) = idoff; setlast(idby);
1780
        return(f_change_int_to_bitfield(bf, idoff));
1912
			return (f_change_int_to_bitfield(bf, idoff));
1781
      }
-
 
1782
  }
1913
		}
1783
 
1914
	}
1784
}
1915
}
-
 
1916
 
1785
 
1917
 
-
 
1918
exp
1786
exp f_bitfield_contents_with_mode
1919
f_bitfield_contents_with_mode(transfer_mode md, bitfield_variety bf, exp p,
1787
    PROTO_N ( (md, bf, p, off) )
1920
			      exp off)
1788
    PROTO_T ( transfer_mode md X bitfield_variety bf X exp p X exp off )
-
 
1789
{
1921
{
1790
  exp res;
1922
	exp res;
1791
  if (name(sh(p)) == bothd)
1923
	if (name(sh(p)) == bothd) {
1792
    return p;
1924
		return p;
-
 
1925
	}
1793
 
1926
 
1794
#if check_shape
1927
#if check_shape
1795
  if (name(sh(p)) != ptrhd || name(sh(off)) != offsethd ||
1928
	if (name(sh(p)) != ptrhd || name(sh(off)) != offsethd ||
1796
	name(off) != val_tag)
1929
	    name(off) != val_tag) {
1797
    failer(CHSH_BFCONT);
1930
		failer(CHSH_BFCONT);
-
 
1931
	}
1798
#endif
1932
#endif
1799
#ifdef no_trap_on_nil_contents
1933
#ifdef no_trap_on_nil_contents
1800
	if ((md & f_trap_on_nil) != 0) {
1934
	if ((md & f_trap_on_nil) != 0) {
1801
		exp d = me_startid(f_bitfield(bf), p, 0);
1935
		exp d = me_startid(f_bitfield(bf), p, 0);
1802
		exp hldr = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, 0);
1936
		exp hldr = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, 0);
1803
     		exp lb = getexp(f_top, nilexp, 0, hldr, nilexp, 0, 0, labst_tag);
1937
		exp lb = getexp(f_top, nilexp, 0, hldr, nilexp, 0, 0,
-
 
1938
				labst_tag);
1804
		exp_list el;
1939
		exp_list el;
1805
		exp test = me_q1(no_nat_option, f_equal, &lb, me_obtain(d),
1940
		exp test = me_q1(no_nat_option, f_equal, &lb, me_obtain(d),
1806
				f_make_null_ptr(al1_of(sh(p))), test_tag);
1941
				 f_make_null_ptr(al1_of(sh(p))), test_tag);
1807
		exp trp = getexp(f_bottom, nilexp, 0, nilexp, nilexp,
1942
		exp trp = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0,
1808
				    0 , f_nil_access, trap_tag);
1943
				 f_nil_access, trap_tag);
1809
		md &= ~f_trap_on_nil;
1944
		md &= ~f_trap_on_nil;
1810
     		el = new_exp_list(1);
1945
		el = new_exp_list(1);
1811
     		el = add_exp_list(el, test, 1);
1946
		el = add_exp_list(el, test, 1);
1812
     		return me_complete_id(d,
-
 
1813
		   f_conditional(&lb, f_sequence(el, trp),
1947
		return me_complete_id(d, f_conditional(&lb, f_sequence(el, trp),
1814
			f_bitfield_contents_with_mode(md, bf, me_obtain(d), off)) );
1948
		    f_bitfield_contents_with_mode(md, bf, me_obtain(d), off)));
1815
 
-
 
1816
   	};
-
 
1817
#endif
-
 
1818
 
-
 
1819
  if (md == f_volatile)
-
 
1820
    res = me_u3(f_bitfield(bf), p, bfcontvol_tag);
-
 
1821
  else
-
 
1822
    res = me_u3(f_bitfield(bf), p, bfcont_tag);
-
 
1823
  no(res) = no(off);
-
 
1824
  return res;
-
 
1825
}
-
 
1826
 
-
 
1827
 
-
 
1828
#if do_case_transforms
-
 
1829
 
-
 
1830
exp f_case
-
 
1831
    PROTO_N ( (exhaustive, control, branches) )
-
 
1832
    PROTO_T ( bool exhaustive X exp control X caselim_list branches )
-
 
1833
{
-
 
1834
  exp r, ht;
-
 
1835
  shape case_shape;
-
 
1836
  exp changer;
-
 
1837
  exp body_of_ident;
-
 
1838
  exp control_expression;
-
 
1839
  exp body_of_case;
-
 
1840
  exp id;
-
 
1841
  exp copy_ce;
-
 
1842
  shape changer_shape = (shape_size(sh(control)) >= SLONG_SZ) ? sh(control)
-
 
1843
	: is_signed(sh(control)) ? slongsh : ulongsh;
-
 
1844
 
-
 
1845
/*  UNUSED(branches);
-
 
1846
*/
-
 
1847
  if (name(sh(control)) == bothd)
-
 
1848
    return control;
-
 
1849
 
-
 
1850
 
-
 
1851
 
-
 
1852
  bro(global_case) = nilexp;
-
 
1853
  while(branches != nilexp) {
-
 
1854
	exp hd = branches;
-
 
1855
	branches = bro(branches);
-
 
1856
	bro(hd) = nilexp;
-
 
1857
	sh(hd) = sh(control);
-
 
1858
	if (son(hd) != nilexp) {
-
 
1859
		sh(son(hd)) = sh(control);
-
 
1860
	}
1949
	}
1861
	if (son(hd) != nilexp && docmp_f((int)f_less_than, son(hd), hd)){
-
 
1862
	 	--no (son (pt(hd)));
-
 
1863
	 	retcell(son(hd));
-
 
1864
	 	retcell(hd);
-
 
1865
     	}
-
 
1866
	else
-
 
1867
		case_item(hd);
-
 
1868
  }
-
 
1869
 
-
 
1870
  if (bro(global_case) == nilexp)
-
 
1871
    return control;
-
 
1872
  case_shape = (exhaustive) ? f_bottom : f_top;
-
 
1873
 
-
 
1874
  if (PIC_code)
-
 
1875
    proc_externs = 1;
-
 
1876
 
-
 
1877
#if check_shape
-
 
1878
  if (!is_integer(sh(control)))
-
 
1879
    failer(CHSH_CASE);
-
 
1880
#endif
-
 
1881
 
-
 
1882
  r = getexp (case_shape, nilexp, 0, control, nilexp, 0,
-
 
1883
               0, case_tag);
-
 
1884
  clearlast(control);
-
 
1885
  bro(control) = bro(global_case);
-
 
1886
  ht = control;
-
 
1887
  while (bro (ht) != nilexp) {
-
 
1888
    ht = bro (ht);
-
 
1889
    sh(ht) = changer_shape;
-
 
1890
    if (son(ht) != nilexp)
-
 
1891
      sh(son(ht)) = changer_shape;
-
 
1892
  };
-
 
1893
  setlast (ht);
-
 
1894
  bro (ht) = r;
-
 
1895
 
-
 
1896
  control_expression = son (r);
-
 
1897
  body_of_case = bro (son (r));
-
 
1898
 
-
 
1899
  copy_ce = copy(control_expression);
-
 
1900
  changer = hold_check(me_u3 (changer_shape, control_expression, chvar_tag));
-
 
1901
  id = me_startid (sh (changer), changer, 1);
-
 
1902
	/* the shape of the ident will be overwritten by me_complete_id */
-
 
1903
  body_of_ident = case_optimisation (body_of_case, id, sh (r),
-
 
1904
  					copy_ce);
-
 
1905
  id = me_complete_id (id, body_of_ident);
-
 
1906
 
-
 
1907
#ifdef NEWDIAGS
-
 
1908
  if (extra_diags)
-
 
1909
    id = f_dg_exp (id, f_branch_dg (f_dg_null_sourcepos));
-
 
1910
#endif
1950
#endif
1911
 
1951
 
-
 
1952
	if (md == f_volatile) {
-
 
1953
		res = me_u3(f_bitfield(bf), p, bfcontvol_tag);
-
 
1954
	} else {
-
 
1955
		res = me_u3(f_bitfield(bf), p, bfcont_tag);
-
 
1956
	}
-
 
1957
	no(res) = no(off);
1912
  return (hold_check(id));
1958
	return res;
1913
}
1959
}
1914
 
1960
 
1915
#else
-
 
1916
 
1961
 
-
 
1962
#if do_case_transforms
-
 
1963
 
1917
exp f_case
1964
exp
1918
    PROTO_N ( (exhaustive, control, branches) )
-
 
1919
    PROTO_T ( bool exhaustive X exp control X caselim_list branches )
1965
f_case(bool exhaustive, exp control, caselim_list branches)
1920
{
1966
{
-
 
1967
	exp r, ht;
-
 
1968
	shape case_shape;
-
 
1969
	exp changer;
-
 
1970
	exp body_of_ident;
-
 
1971
	exp control_expression;
-
 
1972
	exp body_of_case;
-
 
1973
	exp id;
-
 
1974
	exp copy_ce;
-
 
1975
	shape changer_shape = (shape_size(sh(control)) >= SLONG_SZ) ?
-
 
1976
	    sh(control) : is_signed(sh(control)) ? slongsh : ulongsh;
-
 
1977
 
-
 
1978
	/*  UNUSED(branches);
-
 
1979
	 */
-
 
1980
	if (name(sh(control)) == bothd) {
-
 
1981
		return control;
-
 
1982
	}
-
 
1983
 
-
 
1984
	bro(global_case) = nilexp;
-
 
1985
	while (branches != nilexp) {
-
 
1986
		exp hd = branches;
-
 
1987
		branches = bro(branches);
-
 
1988
		bro(hd) = nilexp;
-
 
1989
		sh(hd) = sh(control);
-
 
1990
		if (son(hd) != nilexp) {
-
 
1991
			sh(son(hd)) = sh(control);
-
 
1992
		}
-
 
1993
		if (son(hd) != nilexp &&
-
 
1994
		    docmp_f((int)f_less_than, son(hd), hd)) {
-
 
1995
			--no(son(pt(hd)));
-
 
1996
			retcell(son(hd));
-
 
1997
			retcell(hd);
-
 
1998
		} else {
-
 
1999
			case_item(hd);
-
 
2000
		}
-
 
2001
	}
-
 
2002
 
-
 
2003
	if (bro(global_case) == nilexp) {
-
 
2004
		return control;
-
 
2005
	}
-
 
2006
	case_shape = (exhaustive)? f_bottom : f_top;
-
 
2007
 
-
 
2008
	if (PIC_code) {
-
 
2009
		proc_externs = 1;
-
 
2010
	}
-
 
2011
 
-
 
2012
#if check_shape
-
 
2013
	if (!is_integer(sh(control))) {
-
 
2014
		failer(CHSH_CASE);
-
 
2015
	}
-
 
2016
#endif
-
 
2017
 
-
 
2018
	r = getexp(case_shape, nilexp, 0, control, nilexp, 0, 0, case_tag);
-
 
2019
	clearlast(control);
-
 
2020
	bro(control) = bro(global_case);
-
 
2021
	ht = control;
-
 
2022
	while (bro(ht) != nilexp) {
-
 
2023
		ht = bro(ht);
-
 
2024
		sh(ht) = changer_shape;
-
 
2025
		if (son(ht) != nilexp) {
-
 
2026
			sh(son(ht)) = changer_shape;
-
 
2027
		}
-
 
2028
	}
-
 
2029
	setlast(ht);
-
 
2030
	bro(ht) = r;
-
 
2031
 
-
 
2032
	control_expression = son(r);
-
 
2033
	body_of_case = bro(son(r));
-
 
2034
 
-
 
2035
	copy_ce = copy(control_expression);
-
 
2036
	changer = hold_check(me_u3(changer_shape, control_expression,
-
 
2037
				   chvar_tag));
-
 
2038
	id = me_startid(sh(changer), changer, 1);
-
 
2039
	/* the shape of the ident will be overwritten by me_complete_id */
-
 
2040
	body_of_ident = case_optimisation(body_of_case, id, sh(r), copy_ce);
-
 
2041
	id = me_complete_id(id, body_of_ident);
-
 
2042
 
-
 
2043
#ifdef NEWDIAGS
-
 
2044
	if (extra_diags) {
-
 
2045
		id = f_dg_exp(id, f_branch_dg(f_dg_null_sourcepos));
-
 
2046
	}
-
 
2047
#endif
-
 
2048
 
-
 
2049
	return (hold_check(id));
-
 
2050
}
-
 
2051
 
-
 
2052
#else /* do_case_transforms */
-
 
2053
 
-
 
2054
exp
-
 
2055
f_case(bool exhaustive, exp control, caselim_list branches)
-
 
2056
{
1921
  exp r, ht;
2057
	exp r, ht;
1922
  shape case_shape;
2058
	shape case_shape;
1923
/*  UNUSED(branches);
2059
	/*  UNUSED(branches);
1924
  if (name(sh(control)) == bothd || bro(global_case) == nilexp)
2060
	    if (name(sh(control)) == bothd || bro(global_case) == nilexp)
1925
    return control;
2061
	    return control;
1926
*/
2062
	 */
1927
  if (name(sh(control)) == bothd)
2063
	if (name(sh(control)) == bothd) {
1928
    return control;
2064
		return control;
-
 
2065
	}
1929
 
2066
 
1930
  bro(global_case) = nilexp;
2067
	bro(global_case) = nilexp;
1931
  while(branches != nilexp) {
2068
	while (branches != nilexp) {
1932
	exp hd = branches;
2069
		exp hd = branches;
1933
	branches = bro(branches);
2070
		branches = bro(branches);
1934
	bro(hd) = nilexp;
2071
		bro(hd) = nilexp;
1935
	sh(hd) = sh(control);
2072
		sh(hd) = sh(control);
1936
	if (son(hd) != nilexp) {
2073
		if (son(hd) != nilexp) {
1937
		sh(son(hd)) = sh(control);
2074
			sh(son(hd)) = sh(control);
1938
	}
2075
		}
-
 
2076
		if (son(hd) != nilexp &&
1939
	if (son(hd) != nilexp && docmp_f((int)f_less_than, son(hd), hd)){
2077
		    docmp_f((int)f_less_than, son(hd), hd)) {
1940
	 	--no (son (pt(hd)));
2078
			--no(son(pt(hd)));
1941
	 	retcell(son(hd));
2079
			retcell(son(hd));
1942
	 	retcell(hd);
2080
			retcell(hd);
1943
     	}
-
 
1944
	else
2081
		} else {
1945
		case_item(hd);
2082
			case_item(hd);
1946
  }
2083
		}
-
 
2084
	}
1947
  if (bro(global_case) == nilexp)
2085
	if (bro(global_case) == nilexp) {
1948
    return control;
2086
		return control;
-
 
2087
	}
1949
  case_shape = (exhaustive) ? f_bottom : f_top;
2088
	case_shape = (exhaustive) ? f_bottom : f_top;
1950
 
2089
 
1951
  if (PIC_code)
2090
	if (PIC_code) {
1952
    proc_externs = 1;
2091
		proc_externs = 1;
-
 
2092
	}
1953
 
2093
 
1954
#if check_shape
2094
#if check_shape
1955
  if (!is_integer(sh(control)))
2095
	if (!is_integer(sh(control))) {
1956
    failer(CHSH_CASE);
2096
		failer(CHSH_CASE);
-
 
2097
	}
1957
#endif
2098
#endif
1958
 
2099
 
1959
  r = getexp (case_shape, nilexp, 0, control, nilexp, 0,
2100
	r = getexp(case_shape, nilexp, 0, control, nilexp, 0, 0, case_tag);
1960
               0, case_tag);
-
 
1961
  clearlast(control);
2101
	clearlast(control);
1962
  bro(control) = bro(global_case);
2102
	bro(control) = bro(global_case);
1963
  ht = control;
2103
	ht = control;
1964
  while (bro (ht) != nilexp) {
2104
	while (bro(ht) != nilexp) {
1965
    ht = bro (ht);
2105
		ht = bro(ht);
1966
    sh(ht) = sh(control);
2106
		sh(ht) = sh(control);
1967
    if (son(ht) != nilexp)
2107
		if (son(ht) != nilexp) {
1968
      sh(son(ht)) = sh(control);
2108
			sh(son(ht)) = sh(control);
1969
  };
2109
		}
-
 
2110
	}
1970
  setlast (ht);
2111
	setlast(ht);
1971
  bro (ht) = r;
2112
	bro(ht) = r;
1972
 
2113
 
1973
#ifdef NEWDIAGS
2114
#ifdef NEWDIAGS
1974
  if (extra_diags)
2115
	if (extra_diags) {
1975
    r = f_dg_exp (r, f_branch_dg (f_dg_null_sourcepos));
2116
		r = f_dg_exp(r, f_branch_dg(f_dg_null_sourcepos));
-
 
2117
	}
1976
#endif
2118
#endif
1977
 
2119
 
1978
  return (r);
2120
	return (r);
1979
}
2121
}
-
 
2122
#endif /* do_case_transforms */
1980
 
2123
 
1981
#endif
-
 
1982
 
2124
 
1983
exp f_change_bitfield_to_int
2125
exp
1984
    PROTO_N ( (x, arg1) )
-
 
1985
    PROTO_T ( variety x X exp arg1 )
2126
f_change_bitfield_to_int(variety x, exp arg1)
1986
{
2127
{
1987
  if (name(sh(arg1)) == bothd)
2128
	if (name(sh(arg1)) == bothd) {
1988
    return arg1;
2129
		return arg1;
-
 
2130
	}
1989
 
2131
 
1990
#if check_shape
2132
#if check_shape
1991
  if (name(sh(arg1)) != bitfhd)
2133
	if (name(sh(arg1)) != bitfhd) {
1992
    failer(CHSH_CHBITFIELD);
2134
		failer(CHSH_CHBITFIELD);
-
 
2135
	}
1993
#endif
2136
#endif
1994
#if !has64bits
2137
#if !has64bits
1995
	if (shape_size(x)>32) {
2138
	if (shape_size(x) >32) {
1996
		shape n32 = (is_signed(x))?slongsh:ulongsh;
2139
		shape n32 = (is_signed(x)) ? slongsh : ulongsh;
1997
		exp z = hold_check(me_c2(n32, arg1, bitf_to_int_tag));
2140
		exp z = hold_check(me_c2(n32, arg1, bitf_to_int_tag));
1998
		return f_change_variety(f_impossible, x, z);
2141
		return f_change_variety(f_impossible, x, z);
1999
	}
2142
	}
2000
#endif
2143
#endif
2001
  return me_c2(f_integer(x), arg1, bitf_to_int_tag);
2144
	return me_c2(f_integer(x), arg1, bitf_to_int_tag);
2002
}
2145
}
2003
 
2146
 
2004
 
2147
 
2005
 
2148
exp
2006
exp f_change_int_to_bitfield
-
 
2007
    PROTO_N ( (x, arg1) )
-
 
2008
    PROTO_T ( bitfield_variety x X exp arg1 )
2149
f_change_int_to_bitfield(bitfield_variety x, exp arg1)
2009
{
2150
{
2010
  if (name(sh(arg1)) == bothd)
2151
	if (name(sh(arg1)) == bothd) {
2011
    return arg1;
2152
		return arg1;
-
 
2153
	}
2012
 
2154
 
2013
#if check_shape
2155
#if check_shape
2014
  if (!is_integer(sh(arg1)))
2156
	if (!is_integer(sh(arg1))) {
2015
    failer(CHSH_CHINTBF);
2157
		failer(CHSH_CHINTBF);
-
 
2158
	}
2016
#endif
2159
#endif
2017
#if !has64bits
2160
#if !has64bits
2018
	if (shape_size(sh(arg1))>32) {
2161
	if (shape_size(sh(arg1)) >32) {
2019
		shape n32 = (is_signed(sh(arg1)))?slongsh:ulongsh;
2162
		shape n32 = (is_signed(sh(arg1))) ? slongsh : ulongsh;
2020
		arg1 = hold_check(f_change_variety(f_wrap, n32, arg1));
2163
		arg1 = hold_check(f_change_variety(f_wrap, n32, arg1));
2021
	}
2164
	}
2022
#endif
2165
#endif
2023
 
2166
 
2024
  return me_c2(f_bitfield(x), arg1, int_to_bitf_tag);
2167
	return me_c2(f_bitfield(x), arg1, int_to_bitf_tag);
2025
}
2168
}
-
 
2169
 
-
 
2170
 
2026
 
2171
 
2027
exp f_change_variety
2172
exp
2028
    PROTO_N ( (ov_err, r, arg1) )
-
 
2029
    PROTO_T ( error_treatment ov_err X variety r X exp arg1 )
2173
f_change_variety(error_treatment ov_err, variety r, exp arg1)
2030
{
2174
{
2031
  if (name(sh(arg1)) == bothd)
2175
	if (name(sh(arg1)) == bothd) {
2032
    return arg1;
2176
		return arg1;
-
 
2177
	}
2033
 
2178
 
2034
#if check_shape
2179
#if check_shape
2035
  if (!is_integer(sh(arg1)))
2180
	if (!is_integer(sh(arg1))) {
2036
    failer(CHSH_CHVAR);
2181
		failer(CHSH_CHVAR);
-
 
2182
	}
2037
#endif
2183
#endif
2038
#if !has64bits
2184
#if !has64bits
2039
  if ((name(arg1)!=val_tag || ov_err.err_code >2)
2185
	if ((name(arg1) != val_tag || ov_err.err_code > 2) &&
2040
		&&( shape_size(sh(arg1))> 32 || name(r)>=s64hd)
2186
	    (shape_size(sh(arg1)) > 32 || name(r) >=s64hd) &&
2041
		&& name(sh(arg1)) != name(r) ){
2187
	    name(sh(arg1)) != name(r)) {
2042
	   exp e = arg1;
2188
		exp e = arg1;
2043
	   int ss = is_signed(sh(arg1));
2189
		int ss = is_signed(sh(arg1));
2044
	   int sd = is_signed(r);
2190
		int sd = is_signed(r);
2045
	   shape x =(ss)?slongsh:ulongsh;
2191
		shape x = (ss)?slongsh:ulongsh;
2046
	   if (shape_size(sh(arg1)) <=32) {
2192
		if (shape_size(sh(arg1)) <= 32) {
2047
		exp e = hold_check(me_c1(x,ov_err, arg1, chvar_tag));
2193
			exp e = hold_check(me_c1(x, ov_err, arg1, chvar_tag));
2048
		exp z = TDFcallaux(ov_err, e,
2194
			exp z = TDFcallaux(ov_err, e, (sd) ? ((ss) ?
2049
				(sd)?((ss)?"__TDFUsswiden":"__TDFUuswiden"):
2195
			    "__TDFUsswiden" : "__TDFUuswiden") : (ss) ?
2050
				      (ss)?"__TDFUsuwiden":"__TDFUuuwiden", r);
2196
			    "__TDFUsuwiden" : "__TDFUuuwiden", r);
2051
		return z;
2197
			return z;
2052
	   }
-
 
2053
	   else
-
 
2054
	   if (name(r) >= s64hd) {
2198
		} else if (name(r) >= s64hd) {
2055
		return TDFcallaux(ov_err, e, (sd)?"__TDFUu642s64":"__TDFUs642u64", r);
2199
			return TDFcallaux(ov_err, e, (sd) ? "__TDFUu642s64" :
2056
	   }
2200
					  "__TDFUs642u64", r);
2057
	   else {
2201
		} else {
2058
		exp e = TDFcallaux(ov_err, arg1,
2202
			exp e = TDFcallaux(ov_err, arg1, (sd) ?
2059
				(sd)?((ss)?"__TDFUssshorten":"__TDFUusshorten"):
2203
			    ((ss) ? "__TDFUssshorten" : "__TDFUusshorten") :
2060
					(ss)?"__TDFUsushorten":"__TDFUuushorten",
2204
			    (ss) ?  "__TDFUsushorten" : "__TDFUuushorten",
2061
					(sd)?slongsh:ulongsh);
2205
			    (sd) ? slongsh : ulongsh);
2062
		return 	hold_check(me_c1(f_integer(r),ov_err, e, chvar_tag));
2206
			return hold_check(me_c1(f_integer(r), ov_err, e,
-
 
2207
						chvar_tag));
2063
	   }
2208
		} 
-
 
2209
	}
-
 
2210
#endif
-
 
2211
	return me_c1(f_integer(r), ov_err, arg1, chvar_tag);
-
 
2212
}
-
 
2213
 
-
 
2214
 
-
 
2215
exp
-
 
2216
f_component(shape sha, exp arg1, exp arg2)
-
 
2217
{
-
 
2218
	if (name(sh(arg1)) == bothd) {
-
 
2219
		kill_exp(arg2, arg2);
-
 
2220
		return arg1;
-
 
2221
	}
-
 
2222
	if (name(sh(arg2)) == bothd) {
-
 
2223
		kill_exp(arg1, arg1);
-
 
2224
		return arg2;
-
 
2225
	}
2064
 
2226
 
-
 
2227
#if check_shape
-
 
2228
	if (!doing_aldefs &&
-
 
2229
	    (name(sh(arg2)) != offsethd || name(sh(arg1)) != cpdhd ||
-
 
2230
	     shape_align(sh(arg1)) < al1(sh(arg2)) ||
-
 
2231
	     shape_align(sha) > al2(sh(arg2)))) {
-
 
2232
		failer(CHSH_COMPONENT);
2065
  }
2233
	}
2066
#endif
2234
#endif
-
 
2235
 
2067
  return me_c1(f_integer(r), ov_err, arg1, chvar_tag);
2236
	return me_b3(sha, arg1, arg2, component_tag);
2068
}
2237
}
2069
 
2238
 
2070
 
-
 
2071
 
2239
 
2072
 
2240
exp
2073
exp f_component
-
 
2074
    PROTO_N ( (sha, arg1, arg2) )
-
 
2075
    PROTO_T ( shape sha X exp arg1 X exp arg2 )
2241
f_concat_nof(exp arg1, exp arg2)
2076
{
2242
{
2077
  if (name(sh(arg1)) == bothd)
-
 
2078
    { kill_exp(arg2,arg2); return arg1; }
2243
	shape sha = getshape(0, const_al1, al2_of(sh(arg1)), align_of(sh(arg1)),
2079
  if (name(sh(arg2)) == bothd)
-
 
2080
    { kill_exp(arg1,arg1); return arg2; }
2244
			     shape_size(sh(arg1)) + shape_size(sh(arg2)),
2081
 
-
 
2082
#if check_shape
2245
			     nofhd);
2083
  if (!doing_aldefs &&
-
 
2084
	(name(sh(arg2)) != offsethd || name(sh(arg1)) != cpdhd ||
-
 
2085
       shape_align(sh(arg1)) < al1(sh(arg2)) ||
2246
	if (name(sh(arg1)) == bothd) {
2086
       shape_align(sha) > al2(sh(arg2))))
-
 
2087
    failer(CHSH_COMPONENT);
2247
		kill_exp(arg2, arg2);
2088
#endif
2248
		return arg1;
2089
 
-
 
2090
   return me_b3(sha, arg1, arg2, component_tag);
-
 
2091
}
2249
	}
2092
 
-
 
2093
exp f_concat_nof
2250
	if (name(sh(arg2)) == bothd) {
2094
    PROTO_N ( (arg1, arg2) )
2251
		kill_exp(arg1, arg1);
2095
    PROTO_T ( exp arg1 X exp arg2 )
2252
		return arg2;
2096
{
2253
	}
2097
  shape sha = getshape(0, const_al1, al2_of(sh(arg1)),
-
 
2098
			align_of(sh(arg1)),
-
 
2099
                        shape_size(sh(arg1)) + shape_size(sh(arg2)),
-
 
2100
                       nofhd);
-
 
2101
  if (name(sh(arg1)) == bothd)
-
 
2102
    { kill_exp(arg2,arg2); return arg1; }
-
 
2103
  if (name(sh(arg2)) == bothd)
-
 
2104
    { kill_exp(arg1,arg1); return arg2; }
-
 
2105
 
2254
 
2106
	/* al2_of(sh(arg1)) is the shapemacs.h hd of the nof shape */
2255
	/* al2_of(sh(arg1)) is the shapemacs.h hd of the nof shape */
2107
#if check_shape
2256
#if check_shape
2108
  if (!doing_aldefs &&
-
 
2109
	(shape_align(sh(arg1)) != shape_align(sh(arg2))))
2257
	if (!doing_aldefs && (shape_align(sh(arg1)) != shape_align(sh(arg2)))) {
2110
    failer(CHSH_CONCATNOF);
2258
		failer(CHSH_CONCATNOF);
2111
#endif
-
 
2112
 
-
 
2113
  return me_b3(sha, arg1, arg2, concatnof_tag);
-
 
2114
}
-
 
2115
 
-
 
2116
exp f_conditional
-
 
2117
    PROTO_N ( (alt_label_intro, first, alt) )
-
 
2118
    PROTO_T ( label alt_label_intro X exp first X exp alt )
-
 
2119
{
-
 
2120
   shape res_shape;
-
 
2121
   exp r, labst, def;
-
 
2122
   labst = get_lab(alt_label_intro);
-
 
2123
 
-
 
2124
   res_shape = lub_shape (sh (first), sh (alt));
-
 
2125
   r = getexp (res_shape, nilexp, 0, first, nilexp, 0,
-
 
2126
                   0, cond_tag);
-
 
2127
   def = son(labst);
-
 
2128
   setbro(first, labst);
-
 
2129
   clearlast(first);
-
 
2130
   setbro(def, alt);
-
 
2131
   clearlast(def);
-
 
2132
   setbro(alt, labst);
-
 
2133
   setlast(alt);
-
 
2134
   setsh(labst, sh(alt));
-
 
2135
   setfather (r, labst);
-
 
2136
   default_freq = (float) (2.0 * default_freq);
-
 
2137
   return r;
-
 
2138
}
-
 
2139
 
-
 
2140
void start_conditional
-
 
2141
    PROTO_N ( (alt_label_intro) )
-
 
2142
    PROTO_T ( label alt_label_intro )
-
 
2143
{
-
 
2144
  exp tg;
-
 
2145
  exp labst;
-
 
2146
  tg = getexp (f_top, nilexp, 0, nilexp, nilexp, 0, 0,
-
 
2147
                    clear_tag);
-
 
2148
  labst = getexp (f_bottom, nilexp, 0, tg, nilexp,
-
 
2149
                  0, 0, labst_tag);
-
 
2150
  default_freq = (float) (default_freq / 2.0);
-
 
2151
  fno(labst) = default_freq;
-
 
2152
  ++proc_label_count;
-
 
2153
  set_lab(alt_label_intro, labst);
-
 
2154
  return;
-
 
2155
}
2259
	}
2156
 
-
 
2157
exp f_contents
-
 
2158
    PROTO_N ( (s, arg1) )
-
 
2159
    PROTO_T ( shape s X exp arg1 )
-
 
2160
{
-
 
2161
  if (name(sh(arg1)) == bothd)
-
 
2162
    return arg1;
-
 
2163
 
-
 
2164
#if check_shape
-
 
2165
  if (!doing_aldefs &&
-
 
2166
	(name(sh(arg1)) != ptrhd ||
-
 
2167
	   (al1(sh(arg1)) < shape_align(s)
-
 
2168
#if issparc
-
 
2169
		&& align_of(s) != REAL_ALIGN
-
 
2170
#endif
2260
#endif
2171
	   ) )) {
-
 
2172
    failer(CHSH_CONTENTS);
-
 
2173
  }
-
 
2174
#endif
-
 
2175
 
-
 
2176
 
2261
 
-
 
2262
	return me_b3(sha, arg1, arg2, concatnof_tag);
-
 
2263
}
-
 
2264
 
2177
 
2265
 
-
 
2266
exp
-
 
2267
f_conditional(label alt_label_intro, exp first, exp alt)
-
 
2268
{
-
 
2269
	shape res_shape;
-
 
2270
	exp r, labst, def;
2178
  return me_c2(s, arg1, cont_tag);
2271
	labst = get_lab(alt_label_intro);
-
 
2272
 
-
 
2273
	res_shape = lub_shape(sh(first), sh(alt));
-
 
2274
	r = getexp(res_shape, nilexp, 0, first, nilexp, 0, 0, cond_tag);
-
 
2275
	def = son(labst);
-
 
2276
	setbro(first, labst);
-
 
2277
	clearlast(first);
-
 
2278
	setbro(def, alt);
-
 
2279
	clearlast(def);
-
 
2280
	setbro(alt, labst);
-
 
2281
	setlast(alt);
-
 
2282
	setsh(labst, sh(alt));
-
 
2283
	setfather(r, labst);
-
 
2284
	default_freq = (float)(2.0 * default_freq);
-
 
2285
	return r;
-
 
2286
}
-
 
2287
 
-
 
2288
 
-
 
2289
void
-
 
2290
start_conditional(label alt_label_intro)
-
 
2291
{
-
 
2292
	exp tg;
-
 
2293
	exp labst;
-
 
2294
	tg = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, clear_tag);
-
 
2295
	labst = getexp(f_bottom, nilexp, 0, tg, nilexp, 0, 0, labst_tag);
-
 
2296
	default_freq = (float)(default_freq / 2.0);
-
 
2297
	fno(labst) = default_freq;
-
 
2298
	++proc_label_count;
-
 
2299
	set_lab(alt_label_intro, labst);
-
 
2300
	return;
2179
}
2301
}
-
 
2302
 
2180
 
2303
 
-
 
2304
exp
2181
exp f_contents_with_mode
2305
f_contents(shape s, exp arg1)
-
 
2306
{
-
 
2307
	if (name(sh(arg1)) == bothd) {
-
 
2308
		return arg1;
-
 
2309
	}
-
 
2310
 
-
 
2311
#if check_shape
-
 
2312
	if (!doing_aldefs &&
2182
    PROTO_N ( (md, s, arg1) )
2313
	    (name(sh(arg1)) != ptrhd ||
-
 
2314
	     (al1(sh(arg1)) < shape_align(s)
-
 
2315
#if issparc
-
 
2316
	      && align_of(s) != REAL_ALIGN
-
 
2317
#endif
-
 
2318
	      ))) {
-
 
2319
		failer(CHSH_CONTENTS);
-
 
2320
	}
-
 
2321
#endif
-
 
2322
 
-
 
2323
	return me_c2(s, arg1, cont_tag);
-
 
2324
}
-
 
2325
 
-
 
2326
 
-
 
2327
exp
2183
    PROTO_T ( transfer_mode md X shape s X exp arg1 )
2328
f_contents_with_mode(transfer_mode md, shape s, exp arg1)
2184
{
2329
{
2185
  if (name(sh(arg1)) == bothd)
2330
	if (name(sh(arg1)) == bothd) {
2186
    return arg1;
2331
		return arg1;
-
 
2332
	}
2187
 
2333
 
2188
#if check_shape
2334
#if check_shape
2189
  if (!doing_aldefs &&
2335
	if (!doing_aldefs &&
2190
	(name(sh(arg1)) != ptrhd ||
2336
	    (name(sh(arg1)) != ptrhd ||
2191
	   (al1(sh(arg1)) < shape_align(s)
2337
	     (al1(sh(arg1)) < shape_align(s) &&
2192
		&& al1_of(sh(arg1))-> al.sh_hd != doublehd) ))
2338
	      al1_of(sh(arg1))->al.sh_hd != doublehd))) {
2193
    failer(CHSH_CONTENTS_VOL);
2339
		failer(CHSH_CONTENTS_VOL);
-
 
2340
	}
2194
#endif
2341
#endif
2195
#ifdef no_trap_on_nil_contents
2342
#ifdef no_trap_on_nil_contents
2196
	if ((md & f_trap_on_nil) != 0) {
2343
	if ((md & f_trap_on_nil) != 0) {
2197
		exp d = me_startid(s, arg1, 0);
2344
		exp d = me_startid(s, arg1, 0);
2198
		exp hldr = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, 0);
2345
		exp hldr = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, 0);
2199
     		exp lb = getexp(f_top, nilexp, 0, hldr, nilexp, 0, 0, labst_tag);
2346
		exp lb = getexp(f_top, nilexp, 0, hldr, nilexp, 0, 0,
-
 
2347
				labst_tag);
2200
		exp_list el;
2348
		exp_list el;
2201
		exp test = me_q1(no_nat_option, f_equal, &lb, me_obtain(d),
2349
		exp test = me_q1(no_nat_option, f_equal, &lb, me_obtain(d),
2202
				f_make_null_ptr(f_alignment(s)), test_tag);
2350
				 f_make_null_ptr(f_alignment(s)), test_tag);
2203
		exp trp = getexp(f_bottom, nilexp, 0, nilexp, nilexp,
2351
		exp trp = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0,
2204
				    0 , f_nil_access, trap_tag);
2352
				 f_nil_access, trap_tag);
2205
		md &= ~f_trap_on_nil;
2353
		md &= ~f_trap_on_nil;
2206
     		el = new_exp_list(1);
2354
		el = new_exp_list(1);
2207
     		el = add_exp_list(el, test, 1);
2355
		el = add_exp_list(el, test, 1);
2208
     		return me_complete_id(d,
-
 
2209
		   f_conditional(&lb, f_sequence(el, trp),
2356
		return me_complete_id(d, f_conditional(&lb, f_sequence(el, trp),
2210
				f_contents_with_mode(md, s, me_obtain(d))) );
2357
		    f_contents_with_mode(md, s, me_obtain(d))));
2211
 
-
 
2212
   	};
2358
	}
2213
#endif
2359
#endif
2214
  if (md & f_volatile)
2360
	if (md & f_volatile) {
2215
    return me_c2(s, arg1, contvol_tag);
2361
		return me_c2(s, arg1, contvol_tag);
2216
  else
2362
	} else {
2217
    return me_c2(s, arg1, cont_tag);
2363
		return me_c2(s, arg1, cont_tag);
-
 
2364
	}
2218
}
2365
}
-
 
2366
 
2219
 
2367
 
-
 
2368
exp
2220
exp f_current_env
2369
f_current_env(void)
-
 
2370
{
-
 
2371
	if (!in_proc_def) {
-
 
2372
		failer("current_env must be in proc definition");
-
 
2373
	}
2221
    PROTO_Z ()
2374
	uses_crt_env = 1;
-
 
2375
	uses_loc_address = 1;
-
 
2376
	return getexp(f_pointer(frame_alignment), nilexp, 0, nilexp, nilexp, 0,
-
 
2377
		      0, current_env_tag);
-
 
2378
}
-
 
2379
 
-
 
2380
 
-
 
2381
int
-
 
2382
eq_et(error_treatment a, error_treatment b)
2222
{
2383
{
2223
  if (!in_proc_def) failer("current_env must be in proc definition");
-
 
2224
  uses_crt_env = 1;
-
 
2225
  uses_loc_address = 1;
-
 
2226
  return getexp(f_pointer(frame_alignment), nilexp, 0,
2384
	return (a.err_code == b.err_code &&
2227
                  nilexp, nilexp, 0, 0, current_env_tag);
2385
		(a.err_code != 4 || a.jmp_dest == b.jmp_dest));
2228
 
-
 
2229
}
2386
}
2230
 
2387
 
2231
int eq_et
-
 
2232
    PROTO_N ( (a, b) )
-
 
2233
    PROTO_T ( error_treatment a X error_treatment b )
-
 
2234
{
-
 
2235
	return ( a.err_code == b.err_code
-
 
2236
		 && (a.err_code != 4 || a.jmp_dest == b.jmp_dest)
-
 
2237
		);
-
 
2238
}
-
 
2239
 
2388
 
2240
exp div_rem
2389
exp
2241
    PROTO_N ( (div0_err, ov_err, arg1, arg2, f) )
-
 
2242
    PROTO_T ( error_treatment div0_err X error_treatment ov_err X exp arg1 X
2390
div_rem(error_treatment div0_err, error_treatment ov_err, exp arg1, exp arg2,
2243
	      exp arg2 X exp (*f) PROTO_S ((error_treatment, exp, exp)) )
2391
	exp(*f)(error_treatment, exp, exp))
2244
{
2392
{
2245
	if (eq_et(div0_err, ov_err) || eq_et(ov_err, f_impossible)) {
2393
	if (eq_et(div0_err, ov_err) || eq_et(ov_err, f_impossible)) {
2246
		return f(div0_err, arg1, arg2);
2394
		return f(div0_err, arg1, arg2);
2247
	}
-
 
2248
	else
-
 
2249
	if (eq_et(div0_err, f_impossible)) {
2395
	} else if (eq_et(div0_err, f_impossible)) {
2250
		return f(ov_err, arg1, arg2);
2396
		return f(ov_err, arg1, arg2);
2251
	}
-
 
2252
	else {
2397
	} else {
2253
		exp da2 = me_startid(sh(arg1), arg2, 0);
2398
		exp da2 = me_startid(sh(arg1), arg2, 0);
2254
		exp hldr = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, 0);
2399
		exp hldr = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, 0);
2255
		exp lb = getexp(f_top, nilexp, 0, hldr, nilexp, 0, 0, labst_tag);
2400
		exp lb = getexp(f_top, nilexp, 0, hldr, nilexp, 0, 0,
-
 
2401
				labst_tag);
2256
		exp tst = f_integer_test(no_nat_option, f_equal, &lb,
2402
		exp tst = f_integer_test(no_nat_option, f_equal, &lb,
2257
				 me_obtain(da2), me_shint(sh(arg2), 0));
2403
					 me_obtain(da2), me_shint(sh(arg2), 0));
2258
		exp_list st;
2404
		exp_list st;
2259
		exp wrong;
2405
		exp wrong;
2260
		st = new_exp_list(1);
2406
		st = new_exp_list(1);
2261
		st = add_exp_list(st,tst,0);
2407
		st = add_exp_list(st, tst, 0);
2262
		if (div0_err.err_code == 4) {
2408
		if (div0_err.err_code == 4) {
2263
			wrong = f_goto(div0_err.jmp_dest);
2409
			wrong = f_goto(div0_err.jmp_dest);
2264
		}
-
 
2265
		else
-
 
2266
		if (div0_err.err_code > 4) {
2410
		} else if (div0_err.err_code > 4) {
2267
			wrong = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0,
2411
			wrong = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0,
2268
				f_overflow, trap_tag);
2412
				       f_overflow, trap_tag);
2269
		}
-
 
2270
		else {
2413
		} else {
2271
			wrong = me_shint(sh(arg1), 0);
2414
			wrong = me_shint(sh(arg1), 0);
2340
#if check_shape
3008
#if check_shape
-
 
3009
	{
-
 
3010
		exp temp = first;
-
 
3011
		while (1) {
2341
  if (!eq_shape(sh(arg1), sh(arg2)) || !is_integer(sh(arg1)))
3012
			if (!eq_shape(sh(temp), sh(first))) {
2342
    failer(CHSH_DIV1);
3013
				failer(CHSH_MAKENOF);
-
 
3014
			}
-
 
3015
			if (temp == arg1.end) {
-
 
3016
				break;
-
 
3017
			}
-
 
3018
			temp = bro(temp);
-
 
3019
		}
-
 
3020
	}
2343
#endif
3021
#endif
2344
 
3022
 
-
 
3023
	if (name(sh(first)) == bitfhd) {
-
 
3024
		/* make make_nof bitbields into make-compound */
-
 
3025
		int sf = shape_size(sh(first));
-
 
3026
		int snof = shape_size(sh(r));
-
 
3027
		exp *a = &arg1.start;
-
 
3028
		int scs = (((sf - 1) &sf) == 0) ? sf : snof;
-
 
3029
		shape cs = containedshape(scs, 1);
-
 
3030
		int i;
-
 
3031
		shape cpds = f_compound(hold_check(f_offset_pad(f_alignment(cs),
-
 
3032
		    f_shape_offset(sh(r)))));
-
 
3033
		exp soff = getexp(f_offset(f_alignment(cpds),
-
 
3034
					   f_alignment(sh(first))),
2345
  return div_rem(div0_err, ov_err, arg1, arg2, div1_aux);
3035
				  nilexp, 0, nilexp, nilexp, 0, 0, val_tag);
-
 
3036
		for (i = 0; i < arg1.number; i++) {
-
 
3037
			bro(soff) = *a;
-
 
3038
			*a = copyexp(soff);
-
 
3039
			a = &bro(bro(*a));
-
 
3040
			no(soff) += sf;
-
 
3041
		}
-
 
3042
		arg1.number *= 2;
-
 
3043
		return f_make_compound(hold_check(f_shape_offset(cpds)), arg1);
-
 
3044
	}
-
 
3045
 
-
 
3046
	setfather(r, arg1.end);
-
 
3047
	return r;
2346
}
3048
}
-
 
3049
 
2347
 
3050
 
-
 
3051
exp
-
 
3052
f_make_nof_int(variety v, string s)
-
 
3053
{
-
 
3054
	shape sha;
2348
exp div2_aux
3055
	exp res;
-
 
3056
	nat t;
-
 
3057
	int i;
-
 
3058
	shape elem_sh = f_integer(v);
-
 
3059
	int elem_sz = shape_size(elem_sh);
-
 
3060
 
-
 
3061
	if (PIC_code) {
-
 
3062
		proc_externs = 1;
-
 
3063
	}
-
 
3064
 
-
 
3065
	nat_issmall(t) = 1;
-
 
3066
	natint(t) = s.number;
-
 
3067
	sha = f_nof(t, elem_sh);
-
 
3068
	res = getexp(sha, nilexp, 0, nilexp, nilexp, (prop)elem_sz, 0,
-
 
3069
		     string_tag);
-
 
3070
 
-
 
3071
 
-
 
3072
	if (elem_sz == 64) {
-
 
3073
		int *ss = (int *)xcalloc(s.number, sizeof(int));
-
 
3074
		for (i = 0; i < s.number; ++i) {
-
 
3075
			flt64 x;
-
 
3076
			flpt f;
-
 
3077
			int ov;
-
 
3078
			int sg = is_signed(elem_sh);
-
 
3079
			x.big = 0;
-
 
3080
			switch (s.size) {
-
 
3081
			case 8:
-
 
3082
				x.small = (unsigned int)s.ints.chars[i];
-
 
3083
				break;
-
 
3084
			case 16:
-
 
3085
				x.small = (unsigned int)s.ints.shorts[i];
-
 
3086
				break;
-
 
3087
			case 32:
-
 
3088
				x.small = (unsigned int)s.ints.longs[i];
-
 
3089
				break;
-
 
3090
			default:
-
 
3091
				f = (flpt)s.ints.longs[i];
-
 
3092
				x = flt_to_f64(f, 0, &ov);
-
 
3093
				flpt_ret(f);
2349
    PROTO_N ( (ov_err, arg1, arg2) )
3094
				if (s.size < 64 && sg) {
-
 
3095
					x.big = (x.big << (64 - s.size)) >>
-
 
3096
					    (64 - s.size);
-
 
3097
				}
-
 
3098
			}
-
 
3099
			ss[i] = f64_to_flt(x, sg);
-
 
3100
		}
-
 
3101
		nostr(res) = (char *)(void *)ss;
-
 
3102
		return res;
-
 
3103
	}
-
 
3104
 
-
 
3105
	switch (s.size) {
-
 
3106
	case 8:
-
 
3107
		switch (elem_sz) {
-
 
3108
		case 8:
-
 
3109
			nostr(res) = (char *)s.ints.chars;
-
 
3110
			return res;
-
 
3111
		case 16: {
2350
    PROTO_T ( error_treatment ov_err X exp arg1 X exp arg2 )
3112
			short *ss = (short *)xcalloc(s.number, sizeof(short));
-
 
3113
			for (i = 0; i < s.number; ++i) {
-
 
3114
				ss[i] = (short)(unsigned char)s.ints.chars[i];
-
 
3115
			}
-
 
3116
			nostr(res) = (char *)(void *)ss;
-
 
3117
			return res;
-
 
3118
		}
-
 
3119
		case 32: {
-
 
3120
			int *ss = (int *)xcalloc(s.number, sizeof(int));
-
 
3121
			for (i = 0; i < s.number; ++i) {
-
 
3122
				ss[i] = (int)(unsigned char)s.ints.chars[i];
-
 
3123
			}
-
 
3124
			nostr(res) = (char *)(void *)ss;
-
 
3125
			return res;
-
 
3126
		}
-
 
3127
		}
-
 
3128
	case 16:
-
 
3129
		switch (elem_sz) {
-
 
3130
		case 8: {
-
 
3131
			char *ss = (char *)xcalloc(s.number, sizeof(char));
-
 
3132
			for (i = 0; i < s.number; ++i) {
-
 
3133
				ss[i] = (char)(unsigned short)s.ints.shorts[i];
-
 
3134
			}
-
 
3135
			nostr(res) = (char *)(void *)ss;
-
 
3136
			return res;
-
 
3137
		}
-
 
3138
		case 16:
-
 
3139
			nostr(res) = (char *)(void *)s.ints.shorts;
-
 
3140
			return res;
-
 
3141
		case 32: {
-
 
3142
			int *ss = (int *)xcalloc(s.number, sizeof(int));
-
 
3143
			for (i = 0; i < s.number; ++i) {
-
 
3144
				ss[i] = (int)(unsigned short)s.ints.shorts[i];
-
 
3145
			}
-
 
3146
			nostr(res) = (char *)(void *)ss;
-
 
3147
			return res;
-
 
3148
		}
-
 
3149
		}
-
 
3150
	case 32:
-
 
3151
		switch (elem_sz) {
-
 
3152
		case 8: {
-
 
3153
			char *ss = (char *)xcalloc(s.number, sizeof(char));
-
 
3154
			for (i = 0; i < s.number; ++i) {
-
 
3155
				ss[i] = (char)(unsigned long)s.ints.longs[i];
-
 
3156
			}
-
 
3157
			nostr(res) = (char *)(void *)ss;
-
 
3158
			return res;
-
 
3159
		}
-
 
3160
		case 16: {
-
 
3161
			short *ss = (short *)xcalloc(s.number, sizeof(short));
-
 
3162
			for (i = 0; i < s.number; ++i) {
-
 
3163
				ss[i] = (short)(unsigned long)s.ints.longs[i];
-
 
3164
			}
-
 
3165
			nostr(res) = (char *)(void *)ss;
-
 
3166
			return res;
-
 
3167
		}
-
 
3168
		case 32:
-
 
3169
			nostr(res) = (char *)(void *)s.ints.longs;
-
 
3170
			return res;
-
 
3171
		}
-
 
3172
	}
-
 
3173
	return res;
-
 
3174
}
-
 
3175
 
-
 
3176
 
-
 
3177
exp
-
 
3178
f_make_null_local_lv(void)
2351
{
3179
{
-
 
3180
	return me_null(f_local_label_value, lv_null, null_tag);
-
 
3181
}
-
 
3182
 
-
 
3183
 
-
 
3184
exp
2352
#if !has64bits
3185
f_make_null_proc(void)
-
 
3186
{
-
 
3187
	return me_null(f_proc, proc_null, null_tag);
-
 
3188
}
-
 
3189
 
-
 
3190
 
-
 
3191
exp
-
 
3192
f_make_null_ptr(alignment a)
-
 
3193
{
-
 
3194
	return me_null(f_pointer(a), ptr_null, null_tag);
-
 
3195
}
-
 
3196
 
-
 
3197
exp
-
 
3198
f_maximum(exp arg1, exp arg2)
-
 
3199
{
2353
	if (name(sh(arg1)) >= s64hd &&
3200
	if (name(sh(arg1)) == bothd) {
2354
		(name(arg1)!=val_tag || name(arg2) != val_tag
3201
		kill_exp(arg2, arg2);
-
 
3202
		return arg1;
-
 
3203
	}
2355
			|| ov_err.err_code > 2)) {
3204
	if (name(sh(arg2)) == bothd) {
2356
		return TDFcallop2(ov_err,arg1,arg2,div2_tag);
3205
		kill_exp(arg1, arg1);
-
 
3206
		return arg2;
2357
	}
3207
	}
2358
#endif
-
 
2359
  return me_b1(ov_err, arg1, arg2, div2_tag);
-
 
2360
}
-
 
2361
 
-
 
2362
exp f_div2
-
 
2363
    PROTO_N ( (div0_err, ov_err, arg1, arg2) )
-
 
2364
    PROTO_T ( error_treatment div0_err X error_treatment ov_err X exp arg1 X exp arg2 )
-
 
2365
{
-
 
2366
  if (name(sh(arg1)) == bothd)
-
 
2367
    { kill_exp(arg2,arg2); return arg1; }
-
 
2368
  if (name(sh(arg2)) == bothd)
-
 
2369
    { kill_exp(arg1,arg1); return arg2; }
-
 
2370
 
-
 
2371
 
3208
 
2372
#if check_shape
3209
#if check_shape
2373
  if (!eq_shape(sh(arg1), sh(arg2)) || !is_integer(sh(arg1)))
3210
	if (!eq_shape(sh(arg1), sh(arg2)) || !is_integer(sh(arg1))) {
2374
    failer(CHSH_DIV2);
3211
		failer(CHSH_MAX);
-
 
3212
	}
2375
#endif
3213
#endif
2376
  return div_rem(div0_err, ov_err, arg1, arg2, div2_aux);
-
 
2377
}
-
 
2378
 
-
 
2379
 
-
 
2380
 
-
 
2381
exp f_env_offset
3214
#if !has64bits
2382
    PROTO_N ( (fa, y, t) )
3215
	if (name(sh(arg1)) >= s64hd &&
2383
    PROTO_T ( alignment fa X alignment y X tag t )
3216
	    (name(arg1) != val_tag || name(arg2) != val_tag)) {
2384
{
-
 
2385
  exp e = get_tag(t);
-
 
2386
  shape s = f_offset(fa, y);
-
 
2387
  exp res;
-
 
2388
  if (e == nilexp) {
-
 
2389
	e = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0,
-
 
2390
                    0, ident_tag);
-
 
2391
	son(e) = e; /* used to indicate that tag is not yet defined!?*/
-
 
2392
	set_tag(t, e);
-
 
2393
  }
-
 
2394
  res = getexp(s, nilexp, 0, e, nilexp, 0, 0, env_offset_tag);
-
 
2395
  setvis(e);
-
 
2396
  setenvoff(e);
-
 
2397
  return res;
-
 
2398
}
-
 
2399
 
-
 
2400
 
-
 
2401
 
-
 
2402
exp f_fail_installer
-
 
2403
    PROTO_N ( (message) )
-
 
2404
    PROTO_T ( string message )
-
 
2405
{
-
 
2406
  char * m = (char *)xcalloc(message.number+1, sizeof(char));
-
 
2407
  int i;
-
 
2408
  for (i=0; i<message.number; ++i)
-
 
2409
    m[i] = message.ints.chars[i];
-
 
2410
  m[message.number] = 0;
-
 
2411
  failer(m);
-
 
2412
  exit(EXIT_FAILURE);
-
 
2413
  return(nilexp);
-
 
2414
}
-
 
2415
 
-
 
2416
 
-
 
2417
 
-
 
2418
exp f_goto
-
 
2419
    PROTO_N ( (dest) )
-
 
2420
    PROTO_T ( label dest )
-
 
2421
{
-
 
2422
  exp lab = get_lab(dest);
-
 
2423
  exp r = getexp(f_bottom, nilexp, 0, nilexp, lab,
-
 
2424
                  0, 0, goto_tag);
3217
		return TDFcallop3(arg1, arg2, max_tag);
2425
  ++no(son(lab));
-
 
2426
  return r;
-
 
2427
}
3218
	}
2428
 
-
 
2429
exp f_goto_local_lv
-
 
2430
    PROTO_N ( (arg1) )
-
 
2431
    PROTO_T ( exp arg1 )
-
 
2432
{
-
 
2433
  if (name(sh(arg1)) == bothd)
-
 
2434
    return arg1;
-
 
2435
 
-
 
2436
#if check_shape
-
 
2437
  if (name(sh(arg1)) != ptrhd)
-
 
2438
    failer(CHSH_GOLOCALLV);
-
 
2439
#endif
3219
#endif
2440
 
-
 
2441
  return me_u3(f_bottom, arg1, goto_lv_tag);
-
 
2442
}
-
 
2443
 
-
 
2444
exp f_identify
-
 
2445
    PROTO_N ( (acc, name_intro, definition, body) )
-
 
2446
    PROTO_T ( access_option acc X tag name_intro X exp definition X exp body )
-
 
2447
{
-
 
2448
  exp i = get_tag(name_intro);
-
 
2449
  exp d = son(i);
-
 
2450
  UNUSED(acc);
-
 
2451
  if (name(sh(definition)) == bothd)
-
 
2452
    { kill_exp(body,body); return definition; }
-
 
2453
  setsh(i, sh(body));
-
 
2454
  setbro(d, body);
-
 
2455
  clearlast(d);
-
 
2456
  setfather (i, body);
-
 
2457
  return i;
-
 
2458
}
-
 
2459
 
-
 
2460
void start_identify
-
 
2461
    PROTO_N ( (acc, name_intro, definition) )
-
 
2462
    PROTO_T ( access_option acc X tag name_intro X exp definition )
-
 
2463
{
-
 
2464
  exp i = get_tag(name_intro);
-
 
2465
  if (i == nilexp || son(i) != i) {
-
 
2466
	i = getexp(f_bottom, nilexp, 0, definition, nilexp, 0,
-
 
2467
                    0, ident_tag);
-
 
2468
  }
-
 
2469
  else {  /* could have been already used in env_offset */
-
 
2470
	son(i) = definition;
-
 
2471
  }
-
 
2472
  clearvar(i);
-
 
2473
  if ((acc & (f_visible | f_long_jump_access)) != 0)
-
 
2474
   {
-
 
2475
    setvis(i);
-
 
2476
   };
-
 
2477
  set_tag(name_intro, i);
-
 
2478
 
-
 
2479
  return;
-
 
2480
}
-
 
2481
 
-
 
2482
exp f_ignorable
-
 
2483
    PROTO_N ( (arg1) )
-
 
2484
    PROTO_T ( exp arg1 )
-
 
2485
{
-
 
2486
  if (name(sh(arg1)) == bothd)
-
 
2487
    return arg1;
-
 
2488
  return me_u2(arg1, ignorable_tag);
3220
	return me_b2(arg1, arg2, max_tag);
2489
}
3221
}
2490
 
3222
 
2491
 
3223
exp
2492
exp f_integer_test
-
 
2493
    PROTO_N ( (prob, nt, dest, arg1, arg2) )
3224
f_minimum(exp arg1, exp arg2)
2494
    PROTO_T ( nat_option prob X ntest nt X label dest X exp arg1 X exp arg2 )
-
 
2495
{
3225
{
2496
  if (name(sh(arg1)) == bothd)
3226
	if (name(sh(arg1)) == bothd) {
2497
    { kill_exp(arg2,arg2); return arg1; }
3227
		kill_exp(arg2, arg2);
-
 
3228
		return arg1;
-
 
3229
	}
2498
  if (name(sh(arg2)) == bothd)
3230
	if (name(sh(arg2)) == bothd) {
2499
    { kill_exp(arg1,arg1); return arg2; }
3231
		kill_exp(arg1, arg1);
-
 
3232
		return arg2;
2500
 
3233
	}
2501
#if check_shape
3234
#if check_shape
2502
  if (!is_integer(sh(arg1)) || !eq_shape(sh(arg1), sh(arg2)))
3235
	if (!eq_shape(sh(arg1), sh(arg2)) || !is_integer(sh(arg1))) {
2503
    failer(CHSH_INTTEST);
3236
		failer(CHSH_MIN);
-
 
3237
	}
2504
#endif
3238
#endif
2505
#if !has64bits
3239
#if !has64bits
2506
	if (name(sh(arg1)) >= s64hd &&
3240
	if (name(sh(arg1)) >= s64hd &&
2507
		(name(arg1)!=val_tag || name(arg2) != val_tag)) {
3241
	    (name(arg1) != val_tag || name(arg2) != val_tag)) {
2508
		error_treatment ov_err;
3242
		error_treatment ov_err;
2509
		ov_err = f_wrap;
3243
		ov_err = f_wrap;
2510
		arg1 = TDFcallop2(ov_err,arg1,arg2,test_tag);
3244
		return TDFcallop2(ov_err, arg1, arg2, min_tag);
2511
		arg2 = getexp(slongsh, nilexp, 0, nilexp, nilexp, 0,
-
 
2512
			0, val_tag);
-
 
2513
	}
3245
	}
2514
#endif
3246
#endif
2515
  if (nt == f_comparable || nt == f_not_comparable)
-
 
2516
    return replace_ntest(nt, dest, arg1, arg2);
-
 
2517
  else
-
 
2518
    return me_q1(prob, convert_ntest[nt], dest, arg1, arg2, test_tag);
-
 
2519
}
-
 
2520
 
-
 
2521
exp f_labelled
-
 
2522
    PROTO_N ( (placelabs_intro, starter, places) )
-
 
2523
    PROTO_T ( label_list placelabs_intro X exp starter X exp_list places )
-
 
2524
{
-
 
2525
  exp f = places.start;
-
 
2526
  exp b;
-
 
2527
  int i;
-
 
2528
  clear_exp_list(places);
-
 
2529
 
-
 
2530
  for (i=0; i<places.number; ++i)
-
 
2531
   {exp labst = get_lab(placelabs_intro.elems[i]);
-
 
2532
    b = bro(f);
-
 
2533
 
3247
 
2534
    setbro(son(labst), f);
-
 
2535
    setbro(f, labst);
-
 
2536
    setlast(f);
-
 
2537
    setsh(labst, sh(f));
-
 
2538
    if (name(starter) == case_tag ||
-
 
2539
	(name(starter) == seq_tag && name(son(son(starter))) == case_tag))
-
 
2540
      fno(labst) = (float)(1.0/places.number);
-
 
2541
    else
-
 
2542
      fno(labst) = (float)5.0;
-
 
2543
    f = b;
-
 
2544
   };
-
 
2545
  return(clean_labelled(starter, placelabs_intro));
3248
	return me_b2(arg1, arg2, min_tag);
2546
}
3249
}
2547
 
3250
 
-
 
3251
 
-
 
3252
static int in_initial_value;
-
 
3253
 
2548
void start_labelled
3254
static void
-
 
3255
push_proc_props(void)
-
 
3256
{
-
 
3257
	proc_props *temp = (proc_props *)xcalloc(1, sizeof(proc_props));
-
 
3258
	temp->proc_struct_result = proc_struct_result;
-
 
3259
	temp->has_alloca = has_alloca;
-
 
3260
	temp->proc_is_recursive = proc_is_recursive;
-
 
3261
	temp->uses_crt_env = uses_crt_env;
2549
    PROTO_N ( ( placelabs_intro) )
3262
	temp->has_setjmp = has_setjmp;
-
 
3263
	temp->uses_loc_address = uses_loc_address;
2550
    PROTO_T ( label_list placelabs_intro )
3264
	temp->proc_label_count = proc_label_count;
-
 
3265
	temp->proc_struct_res = proc_struct_res;
-
 
3266
	temp->default_freq = default_freq;
-
 
3267
	temp->proc_externs = proc_externs;
-
 
3268
	temp->in_proc_def = in_proc_def;
-
 
3269
	temp->pushed = old_proc_props;
-
 
3270
	temp->rep_make_proc = rep_make_proc;
-
 
3271
	temp->frame_alignment = frame_alignment;
-
 
3272
	temp->in_initial_value = in_initial_value;
-
 
3273
	old_proc_props = temp;
-
 
3274
	return;
-
 
3275
}
-
 
3276
 
-
 
3277
 
-
 
3278
static void
-
 
3279
pop_proc_props(void)
2551
{
3280
{
-
 
3281
	proc_props *temp = old_proc_props;
-
 
3282
	proc_struct_result = temp->proc_struct_result;
2552
  UNUSED(placelabs_intro);
3283
	has_alloca = temp->has_alloca;
-
 
3284
	proc_is_recursive =temp->proc_is_recursive;
2553
  if (crt_repeat != nilexp)
3285
	uses_crt_env = temp->uses_crt_env;
2554
	  ++no (crt_repeat);
3286
	has_setjmp = temp->has_setjmp;
-
 
3287
	uses_loc_address = temp->uses_loc_address;
-
 
3288
	proc_label_count = temp->proc_label_count;
-
 
3289
	proc_struct_res = temp->proc_struct_res;
-
 
3290
	default_freq = temp->default_freq;
2555
  repeat_list = getexp (f_top, crt_repeat, 0, nilexp,
3291
	proc_externs = temp->proc_externs;
-
 
3292
	in_proc_def = temp->in_proc_def;
2556
	    repeat_list, 0, 0, 0);
3293
	old_proc_props = temp->pushed;
-
 
3294
	rep_make_proc = temp->rep_make_proc;
2557
  crt_repeat = repeat_list;
3295
	frame_alignment = temp->frame_alignment;
-
 
3296
	in_initial_value = temp->in_initial_value;
-
 
3297
	if (temp != &initial_value_pp) {
-
 
3298
		xfree((void *)temp);
-
 
3299
	}
-
 
3300
	return;
-
 
3301
}
2558
 
3302
 
-
 
3303
 
-
 
3304
void
-
 
3305
start_make_proc(shape result_shape, tagshacc_list params_intro,
-
 
3306
		tagacc_option vartag)
-
 
3307
{
-
 
3308
	/* initialise global flags which are used at the end of the
-
 
3309
	   reading process in f_make_proc */
-
 
3310
	UNUSED(result_shape); UNUSED(params_intro);
-
 
3311
	push_proc_props();
-
 
3312
 
-
 
3313
	proc_struct_result = nilexp;
-
 
3314
	has_alloca = 0;
-
 
3315
	proc_is_recursive = 0;
-
 
3316
	uses_crt_env = 0;
-
 
3317
	has_setjmp = 0;
-
 
3318
	uses_loc_address = 0;
-
 
3319
	proc_label_count = 0;
-
 
3320
	proc_struct_res = 0;
-
 
3321
	default_freq = 1.0;
-
 
3322
	proc_externs = 0;
-
 
3323
	in_initial_value = 0;
-
 
3324
	frame_alignment = f_unite_alignments(f_locals_alignment,
-
 
3325
					     var_callers_alignment);
-
 
3326
 
-
 
3327
	if (vartag.present) {
-
 
3328
		shape sha = getshape(0, const_al1, const_al1, VAR_PARAM_ALIGN,
-
 
3329
				     0, cpdhd);
-
 
3330
		exp d = getexp(sha, nilexp, 0, nilexp, nilexp, 0, 0, clear_tag);
-
 
3331
		exp i = getexp(f_bottom, nilexp, 1, d, nilexp, 0, 0, ident_tag);
-
 
3332
		setvis(i);
-
 
3333
		setvar(i);
-
 
3334
		setparam(i);
-
 
3335
		set_tag(vartag.val.tg, i);
-
 
3336
	}
-
 
3337
 
-
 
3338
	/* set this flag to distinguish values created during procedure
-
 
3339
	   reading. */
-
 
3340
	in_proc_def = 1;
-
 
3341
 
2559
  return;
3342
	return;
2560
}
3343
}
2561
 
3344
 
-
 
3345
 
2562
exp f_last_local
3346
exp
2563
    PROTO_N ( (x) )
3347
f_make_proc(shape result_shape, tagshacc_list params_intro,
2564
    PROTO_T ( exp x )
3348
	    tagacc_option vartag, exp body)
2565
{
3349
{
2566
  UNUSED(x);
3350
	exp res;
2567
  return getexp(f_pointer(f_alloca_alignment), nilexp, 0, nilexp, nilexp,
-
 
2568
                  0, 0, last_local_tag);
-
 
2569
}
-
 
2570
 
-
 
2571
exp f_local_alloc
3351
	int varhack = 0;
2572
    PROTO_N ( (arg1) )
-
 
2573
    PROTO_T ( exp arg1 )
3352
#if ishppa
2574
{
-
 
2575
  alignment a;
3353
	exp t, id, ptr;
2576
  if (name(sh(arg1)) == bothd)
-
 
2577
    return arg1;
3354
#endif
2578
 
3355
 
2579
#if check_shape
3356
#if check_shape
2580
  if (name(sh(arg1)) != offsethd)
3357
	if (name(sh(body)) != bothd) {
2581
    failer(CHSH_LOCALLOC);
3358
		failer(CHSH_MAKE_PROC);
-
 
3359
	}
-
 
3360
#endif
-
 
3361
 
-
 
3362
	if (vartag.present) {
-
 
3363
		exp i = get_tag(vartag.val.tg);
-
 
3364
		if (params_intro.id == nilexp) {
-
 
3365
			params_intro.id = i;
-
 
3366
		} else {
-
 
3367
			bro(params_intro.last_def) = i;
-
 
3368
		}
-
 
3369
		bro(i) = params_intro.last_id;
-
 
3370
		params_intro.last_def = son(i);
-
 
3371
		params_intro.last_id = i;
-
 
3372
		setvis(i);
-
 
3373
		++params_intro.number;
-
 
3374
		varhack = 1;
-
 
3375
	}
-
 
3376
 
-
 
3377
	res = getexp(f_proc, nilexp, 0, params_intro.id, result_shape, 0, 0,
-
 
3378
		     proc_tag);
-
 
3379
 
-
 
3380
	if (params_intro.number == 0) {
-
 
3381
		son(res) = body;
-
 
3382
		setlast(body);
-
 
3383
		bro(body) = res;
-
 
3384
	} else {
-
 
3385
		bro(son(res)) = res;
-
 
3386
		bro(params_intro.last_def) = body;
-
 
3387
		setlast(body);
-
 
3388
		bro(body) = params_intro.last_id;
-
 
3389
#ifdef promote_pars
-
 
3390
		promote_formals(son(res));
-
 
3391
#endif
-
 
3392
	}
-
 
3393
 
-
 
3394
	/* set the properties of the procedure construction from the
-
 
3395
	   global values accumulated during reading.
-
 
3396
	   WE OUGHT TO POP THE OLD VALUES.
-
 
3397
	 */
-
 
3398
	if (has_alloca) {
-
 
3399
		set_proc_has_alloca(res);
-
 
3400
	}
-
 
3401
	if (proc_is_recursive) {
-
 
3402
		setrecursive(res);
-
 
3403
	}
-
 
3404
	if (has_lv) {
-
 
3405
		set_proc_has_lv(res);
-
 
3406
	}
-
 
3407
	if (uses_crt_env) {
-
 
3408
		set_proc_uses_crt_env(res);
-
 
3409
	}
-
 
3410
	if (has_setjmp) {
-
 
3411
		set_proc_has_setjmp(res);
-
 
3412
	}
-
 
3413
	if (uses_loc_address) {
-
 
3414
		set_loc_address(res);
-
 
3415
	}
-
 
3416
	if (proc_struct_res) {
-
 
3417
		set_struct_res(res);
-
 
3418
	}
-
 
3419
	if (proc_externs) {
-
 
3420
		set_proc_uses_external(res);
-
 
3421
	}
-
 
3422
 
-
 
3423
	/* apply check_id to the parameters */
-
 
3424
 
-
 
3425
	if (params_intro.number != 0) {
-
 
3426
		exp param;
-
 
3427
		for (param = params_intro.last_id; param != res;
-
 
3428
		     param = bro(param)) {
-
 
3429
			if (redo_structparams &&
-
 
3430
#if ishppa
-
 
3431
			    (varhack || ((shape_size(sh(son(param))) >64) &&
-
 
3432
					 (name(sh(son(param))) == cpdhd ||
-
 
3433
					  name(sh(son(param))) == nofhd ||
-
 
3434
					  name(sh(son(param))) == doublehd))))
-
 
3435
#else
-
 
3436
#if issparc
-
 
3437
			    (varhack || sparccpd(sh(son(param)))))
-
 
3438
 
-
 
3439
#else
-
 
3440
			    (varhack || name(sh(son(param))) == cpdhd ||
-
 
3441
			     name(sh(son(param))) == nofhd ||
-
 
3442
			     name(sh(son(param))) == doublehd))
-
 
3443
#endif
-
 
3444
#endif
-
 
3445
			{
-
 
3446
				/*
-
 
3447
				 * Param IS struct/union-by-value.  Incoming
-
 
3448
				 * acutal parameter will have been changed to
-
 
3449
				 * be ptr-to expected value (see
-
 
3450
				 * f_apply_proc()), so adjust usage in body.
-
 
3451
				 */
-
 
3452
				exp use;	/* use of ident in pt() chain */
-
 
3453
				exp prev;	/* previous use in pt() chain */
-
 
3454
				exp eo = nilexp;
-
 
3455
				shape ptr_s =
-
 
3456
				    f_pointer(f_alignment(sh(son(param))));
-
 
3457
 
-
 
3458
#if ishppa
-
 
3459
				/* modify parameter itself */
-
 
3460
				if (!varhack) {
-
 
3461
					exp obtain_param;
-
 
3462
					exp assign;
-
 
3463
					shape sha=sh(son(param));
-
 
3464
					t=me_obtain(param);
-
 
3465
					if (uses_crt_env) {
-
 
3466
						eo = f_env_offset(
-
 
3467
						     frame_alignment,
-
 
3468
						     f_parameter_alignment(
-
 
3469
						     ptr_s), brog(param));
-
 
3470
						obtain_param =
-
 
3471
						    f_add_to_ptr(
-
 
3472
						    f_current_env(), eo);
-
 
3473
					}
-
 
3474
					id = me_startid(f_top,
-
 
3475
							me_u3(sha, t, cont_tag),
-
 
3476
							1);
-
 
3477
					ptr = me_startid(f_top, me_obtain(id),
-
 
3478
							 0);
-
 
3479
					if (uses_crt_env) {
-
 
3480
						assign =
-
 
3481
						    f_assign(obtain_param,
-
 
3482
							     me_obtain(id));
-
 
3483
						body = f_sequence(add_exp_list(
-
 
3484
						       new_exp_list(1), assign,
-
 
3485
						       0), body);
-
 
3486
					}
-
 
3487
					clearlast(son(ptr));
-
 
3488
					bro(son(ptr)) = body;
-
 
3489
					setlast(body);
-
 
3490
					bro(body) = ptr;
-
 
3491
					sh(ptr) = sh(body);
-
 
3492
					body = id;
-
 
3493
					clearlast(son(id));
-
 
3494
					bro(son(id)) = ptr;
-
 
3495
					setlast(ptr);
-
 
3496
					bro(ptr) = id;
-
 
3497
					sh(id) = sh(ptr);
-
 
3498
					bro(params_intro.last_def) = body;
-
 
3499
					setlast(body);
-
 
3500
					bro(body) = param;
-
 
3501
				}
-
 
3502
#endif
-
 
3503
 
-
 
3504
				/* visit each use of the parameter modifying
-
 
3505
				   appropriately*/
-
 
3506
				for (prev = param, use = pt(prev);
-
 
3507
				     use != nilexp;
-
 
3508
				     prev = use, use = pt(prev)) {
-
 
3509
					if (!uses_crt_env ||
-
 
3510
					    (uses_crt_env && use != eo)) {
-
 
3511
						if (!isvar(param)) {
-
 
3512
							/* add cont */
-
 
3513
							exp new_use =
-
 
3514
							    getexp(ptr_s, use,
-
 
3515
								   (bool)1,
-
 
3516
								   son(use),
-
 
3517
								   pt(use),
-
 
3518
								   props(use),
-
 
3519
								   0, name_tag);
-
 
3520
							son(use) = new_use;
-
 
3521
							pt(prev) = new_use;
-
 
3522
							pt(use) = nilexp;
-
 
3523
							props(use) = (prop)0;
-
 
3524
							setname(use, cont_tag);
-
 
3525
							/* retain same no and
-
 
3526
							   sh */
-
 
3527
 
-
 
3528
							use = new_use;
-
 
3529
						}
-
 
3530
 
-
 
3531
						if (no(use) > 0) {
-
 
3532
							/* add reff */
-
 
3533
							exp new_use =
-
 
3534
							    getexp(ptr_s, use,
-
 
3535
								   (bool)1,
-
 
3536
								   son(use),
-
 
3537
								   pt(use),
-
 
3538
								   props(use),
-
 
3539
								   0, name_tag);
-
 
3540
							son(use) = new_use;
-
 
3541
							pt(prev) = new_use;
-
 
3542
							pt(use) = nilexp;
-
 
3543
							props(use) = (prop)0;
-
 
3544
							setname(use, reff_tag);
-
 
3545
							/* retain same no and
-
 
3546
							   sh */
-
 
3547
 
-
 
3548
							use = new_use;
-
 
3549
						}
-
 
3550
					}
-
 
3551
				} /* for */
-
 
3552
 
-
 
3553
#if ishppa
-
 
3554
				if (!varhack) {
-
 
3555
					/* Change all but ptr's references to
-
 
3556
					   param to references to ptr */
-
 
3557
					for (use = pt(param); use != nilexp;
-
 
3558
					     use = pt(use)) {
-
 
3559
						if ((son(use) ==param) &&
-
 
3560
						    (use != son(son(id))) &&
-
 
3561
						    (!uses_crt_env ||
-
 
3562
						     (uses_crt_env &&
-
 
3563
						      use != eo))) {
-
 
3564
							son(use) =ptr;
-
 
3565
						}
-
 
3566
					}
-
 
3567
					pt(ptr) =pt(param);
-
 
3568
				}
2582
#endif
3569
#endif
-
 
3570
 
-
 
3571
				/* modify parameter itself */
2583
  if (al2(sh(arg1)) <8 ) {
3572
				if (isenvoff(param)) {
2584
	arg1 = hold_check(f_offset_pad(f_alignment(ucharsh), arg1) );
3573
					props(param) = (prop)0;
-
 
3574
					setvis(param);
-
 
3575
				} else {
-
 
3576
					props(param) = (prop)0;
2585
  }
3577
				}
-
 
3578
				setparam(param);
2586
  a = long_to_al(al1(sh(arg1)));
3579
				setcaonly(param);
-
 
3580
				if (varhack) {
-
 
3581
					setvis(param);
-
 
3582
				}
-
 
3583
				setsh(son(param), ptr_s);
-
 
3584
			} /* if redo... */
2587
  has_alloca = 1;
3585
			varhack = 0;
-
 
3586
			/* apply check_id to the parameters */
2588
  return me_u3(f_pointer(a), arg1, alloca_tag);
3587
			IGNORE check_id(param, param);
-
 
3588
		} /* for */
2589
}
3589
	}
2590
 
3590
 
-
 
3591
	if (proc_struct_result != nilexp) {
-
 
3592
		bro(son(proc_struct_result)) = son(res);
-
 
3593
		setfather(proc_struct_result, son(res));
2591
exp f_local_alloc_check
3594
		son(res) = proc_struct_result;
-
 
3595
		setfather(res, proc_struct_result);
-
 
3596
	}
-
 
3597
 
-
 
3598
	/* clear this flag to distinguish values created during procedure
2592
    PROTO_N ( (arg1) )
3599
	   reading. */
2593
    PROTO_T ( exp arg1 )
3600
	in_proc_def = 0;
-
 
3601
 
-
 
3602
	pop_proc_props();
2594
{
3603
 
-
 
3604
	if (old_proc_props != (proc_props *)0 || rep_make_proc) {
-
 
3605
		dec *extra_dec = make_extra_dec(make_local_name(), 0, 0, res,
-
 
3606
						f_proc);
2595
	exp res = f_local_alloc(arg1);
3607
		exp e = extra_dec->dec_u.dec_val.dec_exp;
2596
	if (name(res)==alloca_tag) {
3608
		res = getexp(f_proc, nilexp, 0, e, nilexp, 0, 0, name_tag);
2597
		set_checkalloc(res);
3609
		pt(e) = res;
-
 
3610
		no(e) = 1;
2598
	}
3611
	}
2599
	return res;
-
 
2600
}
-
 
2601
 
3612
 
2602
exp f_local_free
-
 
2603
    PROTO_N ( (a, p) )
-
 
2604
    PROTO_T ( exp a X exp p )
-
 
2605
{
-
 
2606
  if (name(sh(a)) == bothd)
-
 
2607
    { kill_exp(p,p); return a; }
-
 
2608
  if (name(sh(p)) == bothd)
-
 
2609
    { kill_exp(a,a); return p; }
-
 
2610
 
-
 
2611
#if check_shape
-
 
2612
  if (name(sh(a)) != offsethd || name(sh(p)) != ptrhd)
-
 
2613
    failer(CHSH_LOCFREE);
-
 
2614
#endif
-
 
2615
  if (al2(sh(a)) <8 ) {
-
 
2616
	a = hold_check(f_offset_pad(f_alignment(ucharsh), a) );
-
 
2617
  }
-
 
2618
 
-
 
2619
  return me_b3(f_top, p, a, local_free_tag);
-
 
2620
}
-
 
2621
 
-
 
2622
exp f_local_free_all
-
 
2623
    PROTO_Z ()
-
 
2624
{
-
 
2625
  has_setjmp = 1; /* this really means dont inline
-
 
2626
                     and use a stack frame */
-
 
2627
  return getexp(f_top, nilexp, 0, nilexp, nilexp,
-
 
2628
                   0, 0, local_free_all_tag);
-
 
2629
}
-
 
2630
 
-
 
2631
 
-
 
2632
exp f_long_jump
-
 
2633
    PROTO_N ( (arg1, arg2) )
-
 
2634
    PROTO_T ( exp arg1 X exp arg2 )
-
 
2635
{
-
 
2636
  if (name(sh(arg1)) == bothd)
-
 
2637
    { kill_exp(arg2,arg2); return arg1; }
-
 
2638
  if (name(sh(arg2)) == bothd)
-
 
2639
    { kill_exp(arg1,arg1); return arg2; }
-
 
2640
 
-
 
2641
#if check_shape
-
 
2642
  if (name(sh(arg1)) != ptrhd || name(sh(arg2)) != ptrhd)
-
 
2643
    failer(CHSH_LONGJUMP);
-
 
2644
#endif
-
 
2645
 
-
 
2646
  has_setjmp = 1; /* this really means dont inline
-
 
2647
                     and use a stack frame */
-
 
2648
  return me_b3(f_bottom, arg1, arg2, long_jump_tag);
-
 
2649
}
-
 
2650
 
-
 
2651
static int comp_compare
-
 
2652
    PROTO_N ( (a, b) )
-
 
2653
    PROTO_T ( CONST void * a X CONST void * b )
-
 
2654
{
-
 
2655
  return no(*((exp*)a)) - no(*((exp*)b));
-
 
2656
}
-
 
2657
 
-
 
2658
 
-
 
2659
exp f_make_compound
-
 
2660
    PROTO_N ( (arg1, arg2) )
-
 
2661
    PROTO_T ( exp arg1 X exp_list arg2 )
-
 
2662
{
-
 
2663
  exp first = arg2.start;
-
 
2664
  exp r = getexp (f_compound(arg1), nilexp, 0, first,
-
 
2665
                  nilexp, 0, 0, compound_tag);
-
 
2666
  clear_exp_list(arg2);
-
 
2667
 
-
 
2668
  if (arg2.number == 0)
-
 
2669
    {
-
 
2670
      setname (r, clear_tag);
-
 
2671
      return r;
-
 
2672
    }
-
 
2673
 
-
 
2674
#if check_shape
-
 
2675
  {
-
 
2676
    exp t = first;
-
 
2677
    while (1)
-
 
2678
     {
-
 
2679
       if (t != arg2.end && name(sh(bro(t))) == bothd)
-
 
2680
	 return bro(t);
3613
	return res;
2681
       if (t == arg2.end ||
-
 
2682
            name(sh(t)) != offsethd ||
-
 
2683
            (!doing_aldefs && al2(sh(t)) < shape_align(sh(bro(t)))))
-
 
2684
           failer(CHSH_MAKECPD);
-
 
2685
       if (bro(t) == arg2.end)
-
 
2686
          break;
-
 
2687
       t = bro(bro(t));
-
 
2688
     };
-
 
2689
  };
-
 
2690
#endif
-
 
2691
 
-
 
2692
  setfather (r, arg2.end);
-
 
2693
 
-
 
2694
  if (!doing_aldefs && arg2.number > 2) {
-
 
2695
    exp * arr = (exp*)xcalloc(arg2.number, sizeof(exp));
-
 
2696
    int i;
-
 
2697
    exp t = son(r);
-
 
2698
 
-
 
2699
 
-
 
2700
    for (i = 0; i < arg2.number; ++i)  {
-
 
2701
      if (!(i & 1) && (no(t) + shape_size(sh(bro(t))) > shape_size(sh(r)) ))
-
 
2702
	failer ("make_compound size exceeded");
-
 
2703
      arr[i] = t;
-
 
2704
      t = bro(t);
-
 
2705
    };
-
 
2706
 
-
 
2707
#ifdef promote_pars
-
 
2708
    for (i = 0; i < arg2.number; i+=2)  {
-
 
2709
	alignment a = al2_of(sh(arr[i]));
-
 
2710
	if (a->al.sh_hd !=0) {
-
 
2711
		shape s = sh(arr[i+1]);
-
 
2712
		if (name(s)>=scharhd && name(s)<=uwordhd) {
-
 
2713
		    shape ns = (is_signed(s))? slongsh:ulongsh;
-
 
2714
		    exp w = hold_check(f_change_variety(f_wrap,ns, arr[i+1]));
-
 
2715
		    arr[i+1] = w;
-
 
2716
		}
-
 
2717
	}
3614
}
2718
    }
-
 
2719
 
-
 
2720
#endif
-
 
2721
 
-
 
2722
    qsort(arr, (size_t)(arg2.number/2), (size_t)(2*sizeof(exp)),
-
 
2723
			 comp_compare);
-
 
2724
 
3615
 
2725
    son(r) = arr[0];
-
 
2726
    for (i = 1; i < arg2.number; ++i)  {
-
 
2727
      bro(arr[i-1]) = arr[i];
-
 
2728
      clearlast(arr[i-1]);
-
 
2729
    };
-
 
2730
    bro(arr[arg2.number-1]) = r;
-
 
2731
    setlast(arr[arg2.number-1]);
-
 
2732
 
-
 
2733
    xfree((void*)arr);
-
 
2734
  };
-
 
2735
 
-
 
2736
  return r;
-
 
2737
}
-
 
2738
 
-
 
2739
 
-
 
2740
 
-
 
2741
exp f_make_int
-
 
2742
    PROTO_N ( (v, value) )
-
 
2743
    PROTO_T ( variety v X signed_nat value )
-
 
2744
{
-
 
2745
  int n;
-
 
2746
 
-
 
2747
  if (!snat_issmall(value) ||
-
 
2748
	(n = snatint(value), shape_size(v) > 32 &&
-
 
2749
	  (n & (int)0x80000000) != 0))
-
 
2750
    {
-
 
2751
      flpt b;
-
 
2752
      exp res;
-
 
2753
 
-
 
2754
      if (shape_size(v) <= 32) {
-
 
2755
	if (!extra_checks) {
-
 
2756
		flt64 temp;
-
 
2757
		int ov;
-
 
2758
		temp = flt_to_f64(value.signed_nat_val.big_s_nat, 0, &ov);
-
 
2759
		n = temp.small;
-
 
2760
		res = getexp(f_integer(v), nilexp, 0, nilexp, nilexp, 0,
-
 
2761
                			 n, val_tag);
-
 
2762
		return res;
-
 
2763
	}
-
 
2764
	else {
-
 
2765
        	failer(BIG_32);
-
 
2766
       		exit(EXIT_FAILURE);
-
 
2767
	}
-
 
2768
      };
-
 
2769
      if (snat_issmall(value)) {
-
 
2770
	flt64 temp;
-
 
2771
	temp.big = 0;
-
 
2772
	temp.small = (unsigned int)n;
-
 
2773
	b = f64_to_flt(temp, 0);
-
 
2774
      }
-
 
2775
      else { /* copy required since exp may be killed & value may be token res */
-
 
2776
	b = new_flpt();
-
 
2777
        flt_copy (flptnos[value.signed_nat_val.big_s_nat], &flptnos[b]);
-
 
2778
      };
-
 
2779
      if (snatneg(value))
-
 
2780
	  flptnos[b].sign = -1;
-
 
2781
 
-
 
2782
      if (flptnos[b].exp > 3) {
-
 
2783
        failer(BIG_32);
-
 
2784
        exit(EXIT_FAILURE);
-
 
2785
      };
-
 
2786
      res = getexp(f_integer(v), nilexp, 0, nilexp, nilexp, 0,
-
 
2787
                 b, val_tag);
-
 
2788
      setbigval(res);
-
 
2789
      return res;
-
 
2790
    }
-
 
2791
  else {
-
 
2792
    if (snatneg(value))
-
 
2793
      n = -n;
-
 
2794
 
-
 
2795
    return getexp(f_integer(v), nilexp, 0, nilexp, nilexp, 0,
-
 
2796
                 n, val_tag);
-
 
2797
  };
-
 
2798
}
-
 
2799
 
-
 
2800
exp f_make_local_lv
-
 
2801
    PROTO_N ( (lab) )
-
 
2802
    PROTO_T ( label lab )
-
 
2803
{
-
 
2804
  exp l = get_lab(lab);
-
 
2805
  exp res = getexp(f_local_label_value, nilexp, 0, nilexp, l,
-
 
2806
                  0, 0, make_lv_tag);
-
 
2807
  ++no(son(l));
-
 
2808
  set_loaded_lv(l);
-
 
2809
  has_lv = 1;
-
 
2810
  return res;
-
 
2811
}
-
 
2812
 
-
 
2813
exp f_make_nof
-
 
2814
    PROTO_N ( (arg1) )
-
 
2815
    PROTO_T ( exp_list arg1 )
-
 
2816
{
-
 
2817
  exp first = arg1.start;
-
 
2818
  nat t;
-
 
2819
  exp r;
-
 
2820
  clear_exp_list(arg1);
-
 
2821
  nat_issmall(t) = 1;
-
 
2822
  natint(t) = arg1.number;
-
 
2823
  if (arg1.number == 0)  {
-
 
2824
    return getexp(f_nof(t, f_top), nilexp, 0, nilexp, nilexp,
-
 
2825
			 0, 0, nof_tag);
-
 
2826
  };
-
 
2827
  r = getexp (f_nof(t, sh(first)), nilexp, 0, first,
-
 
2828
                  nilexp, 0, 0, nof_tag);
-
 
2829
 
-
 
2830
#if check_shape
-
 
2831
  {exp temp = first;
-
 
2832
   while (1)
-
 
2833
     {
-
 
2834
       if (!eq_shape(sh(temp), sh(first)))
-
 
2835
         failer(CHSH_MAKENOF);
-
 
2836
       if (temp == arg1.end)
-
 
2837
         break;
-
 
2838
       temp = bro(temp);
-
 
2839
     };
-
 
2840
  };
-
 
2841
#endif
-
 
2842
 
-
 
2843
  if (name(sh(first))==bitfhd) {
-
 
2844
	/* make make_nof bitbields into make-compound */
-
 
2845
	int sf = shape_size(sh(first));
-
 
2846
	int snof = shape_size(sh(r));
-
 
2847
	exp *a = &arg1.start;
-
 
2848
	int scs = (((sf-1)&sf)==0)?sf:snof;
-
 
2849
	shape cs = containedshape(scs, 1);
-
 
2850
	int i;
-
 
2851
	shape cpds = f_compound(hold_check(f_offset_pad(f_alignment(cs),
-
 
2852
					f_shape_offset(sh(r)))));
-
 
2853
	exp soff = getexp(f_offset(f_alignment(cpds), f_alignment(sh(first))),
-
 
2854
			  nilexp, 0, nilexp, nilexp, 0, 0, val_tag);
-
 
2855
	for(i=0; i< arg1.number; i++) {
-
 
2856
		bro(soff) = *a;
-
 
2857
		*a = copyexp(soff);
-
 
2858
		a = &bro(bro(*a));
-
 
2859
		no(soff)+= sf;
-
 
2860
	}
-
 
2861
	arg1.number *= 2;
-
 
2862
	return f_make_compound(hold_check(f_shape_offset(cpds)), arg1);
-
 
2863
  }
-
 
2864
 
-
 
2865
 
-
 
2866
  setfather (r, arg1.end);
-
 
2867
  return r;
-
 
2868
}
-
 
2869
 
3616
 
2870
exp f_make_nof_int
3617
procprops crt_procprops;
-
 
3618
 
-
 
3619
void
2871
    PROTO_N ( (v, s) )
3620
start_make_general_proc(shape result_shape, procprops prcprops,
2872
    PROTO_T ( variety v X string s )
3621
			tagshacc_list caller_intro, tagshacc_list callee_intro)
2873
{
3622
{
-
 
3623
	/* initialise global flags which are used at the end of the
-
 
3624
	   reading process in f_make_proc */
-
 
3625
 
-
 
3626
	push_proc_props();
-
 
3627
 
-
 
3628
	proc_struct_result = nilexp;
2874
   shape sha;
3629
	has_alloca = 0;
-
 
3630
	proc_is_recursive = 0;
2875
   exp res;
3631
	uses_crt_env = 0;
2876
   nat t;
3632
	has_setjmp = 0;
-
 
3633
	uses_loc_address = 0;
2877
   int i;
3634
	proc_label_count = 0;
-
 
3635
	proc_struct_res = 0;
-
 
3636
	default_freq = 1.0;
-
 
3637
	frame_alignment = f_unite_alignments(f_locals_alignment,
2878
   shape elem_sh = f_integer(v);
3638
					     f_callers_alignment((prcprops &
2879
   int elem_sz = shape_size(elem_sh);
3639
					     f_var_callers) != 0));
-
 
3640
	frame_alignment =  f_unite_alignments(frame_alignment,
-
 
3641
					      f_callees_alignment((prcprops &
-
 
3642
					      f_var_callees) != 0));
2880
 
3643
 
-
 
3644
	proc_externs = 0;
-
 
3645
	/* set this flag to distinguish values created during procedure
2881
   if (PIC_code)
3646
	   reading. */
2882
     proc_externs = 1;
3647
	in_proc_def = 1;
-
 
3648
	crt_procprops = prcprops;
-
 
3649
	return;
-
 
3650
}
2883
 
3651
 
2884
   nat_issmall(t) = 1;
-
 
2885
   natint(t) = s.number;
-
 
2886
   sha = f_nof(t, elem_sh);
-
 
2887
   res = getexp(sha, nilexp, 0, nilexp, nilexp, (prop)elem_sz,
-
 
2888
                 0, string_tag);
-
 
2889
 
3652
 
2890
 
-
 
2891
   if (elem_sz == 64) {
-
 
2892
     int * ss = (int*)xcalloc(s.number, sizeof(int));
-
 
2893
     for (i = 0; i < s.number; ++i) {
-
 
2894
	flt64 x;
-
 
2895
	flpt f;
-
 
2896
	int ov;
-
 
2897
	int sg = is_signed(elem_sh);
-
 
2898
	x.big = 0;
-
 
2899
	switch (s.size) {
-
 
2900
	  case 8:
-
 
2901
	    x.small = (unsigned int)s.ints.chars[i];
-
 
2902
	    break;
-
 
2903
	  case 16:
-
 
2904
	    x.small = (unsigned int)s.ints.shorts[i];
-
 
2905
	    break;
-
 
2906
	  case 32:
-
 
2907
	    x.small = (unsigned int)s.ints.longs[i];
-
 
2908
	    break;
-
 
2909
	  default: {
-
 
2910
	    f = (flpt)s.ints.longs[i];
-
 
2911
	    x = flt_to_f64(f, 0, &ov);
-
 
2912
	    flpt_ret(f);
-
 
2913
	    if (s.size < 64 && sg)
-
 
2914
	      x.big = (x.big << (64-s.size)) >> (64-s.size);
-
 
2915
	  };
-
 
2916
	};
-
 
2917
	ss[i] = f64_to_flt(x, sg);
-
 
2918
     };
-
 
2919
     nostr(res) = (char*) (void*)ss;
-
 
2920
     return res;
-
 
2921
   };
-
 
2922
 
-
 
2923
   switch (s.size)
-
 
2924
    {
-
 
2925
      case 8:
-
 
2926
	{
-
 
2927
	  switch (elem_sz)
-
 
2928
	   {
-
 
2929
		case 8: nostr(res) = (char*)s.ints.chars;
-
 
2930
		        return res;
-
 
2931
		case 16:{short * ss =
-
 
2932
			  (short*)xcalloc(s.number, sizeof(short));
-
 
2933
			 for (i = 0; i < s.number; ++i)
-
 
2934
			   ss[i] = (short)(unsigned char)s.ints.chars[i];
-
 
2935
			 nostr(res) = (char*) (void*)ss;
-
 
2936
			 return res;
-
 
2937
			};
-
 
2938
		case 32:{int * ss =
-
 
2939
			  (int*)xcalloc(s.number, sizeof(int));
-
 
2940
			 for (i = 0; i < s.number; ++i)
-
 
2941
			   ss[i] = (int)(unsigned char)s.ints.chars[i];
-
 
2942
			 nostr(res) = (char*) (void*)ss;
-
 
2943
			 return res;
-
 
2944
			};
-
 
2945
	   };
-
 
2946
	};
3653
exp
2947
      case 16:
-
 
2948
	{
-
 
2949
	  switch (elem_sz)
-
 
2950
	   {
-
 
2951
		case 8:{char * ss =
-
 
2952
			  (char*)xcalloc(s.number, sizeof(char));
-
 
2953
			 for (i = 0; i < s.number; ++i)
-
 
2954
			   ss[i] = (char)(unsigned short)s.ints.shorts[i];
-
 
2955
			 nostr(res) = (char*) (void*)ss;
-
 
2956
			 return res;
-
 
2957
			};
-
 
2958
		case 16: nostr(res) = (char*) (void*)s.ints.shorts;
3654
f_make_general_proc(shape result_shape, procprops prcprops,
2959
			 return res;
-
 
2960
		case 32:{int * ss =
-
 
2961
			  (int*)xcalloc(s.number, sizeof(int));
-
 
2962
			 for (i = 0; i < s.number; ++i)
-
 
2963
			   ss[i] = (int)(unsigned short)s.ints.shorts[i];
-
 
2964
			 nostr(res) = (char*) (void*)ss;
-
 
2965
			 return res;
-
 
2966
			};
-
 
2967
	   };
-
 
2968
	};
-
 
2969
      case 32:
-
 
2970
	{
-
 
2971
	  switch (elem_sz)
-
 
2972
	   {
-
 
2973
		case 8:{char * ss =
-
 
2974
			  (char*)xcalloc(s.number, sizeof(char));
-
 
2975
			 for (i = 0; i < s.number; ++i)
-
 
2976
			   ss[i] = (char)(unsigned long)s.ints.longs[i];
-
 
2977
			 nostr(res) = (char*) (void*)ss;
-
 
2978
			 return res;
-
 
2979
			};
-
 
2980
		case 16:{short * ss =
-
 
2981
			  (short*)xcalloc(s.number, sizeof(short));
-
 
2982
			 for (i = 0; i < s.number; ++i)
-
 
2983
			   ss[i] = (short)(unsigned long)s.ints.longs[i];
-
 
2984
			 nostr(res) = (char*) (void*)ss;
-
 
2985
			 return res;
-
 
2986
			};
-
 
2987
		case 32: nostr(res) = (char*)(void*)s.ints.longs;
-
 
2988
			 return res;
-
 
2989
	   };
-
 
2990
	};
-
 
2991
    };
-
 
2992
   return res;
-
 
2993
}
-
 
2994
 
-
 
2995
exp f_make_null_local_lv
-
 
2996
    PROTO_Z ()
-
 
2997
{
-
 
2998
  return me_null(f_local_label_value, lv_null, null_tag);
3655
		    tagshacc_list caller_intro, tagshacc_list callee_intro,
2999
}
-
 
3000
 
-
 
3001
exp f_make_null_proc
-
 
3002
    PROTO_Z ()
3656
		    exp body)
3003
{
-
 
3004
  return me_null(f_proc, proc_null, null_tag);
-
 
3005
}
-
 
3006
 
-
 
3007
exp f_make_null_ptr
-
 
3008
    PROTO_N ( (a) )
-
 
3009
    PROTO_T ( alignment a )
-
 
3010
{
3657
{
3011
  return me_null(f_pointer(a), ptr_null, null_tag);
-
 
3012
}
-
 
3013
 
-
 
3014
exp f_maximum
3658
	exp res;
3015
    PROTO_N ( (arg1, arg2) )
-
 
3016
    PROTO_T ( exp arg1 X exp arg2 )
-
 
3017
{
-
 
3018
  if (name(sh(arg1)) == bothd)
-
 
3019
    { kill_exp(arg2,arg2); return arg1; }
-
 
3020
  if (name(sh(arg2)) == bothd)
-
 
3021
    { kill_exp(arg1,arg1); return arg2; }
-
 
3022
 
-
 
3023
#if check_shape
3659
#if check_shape
3024
  if (!eq_shape(sh(arg1), sh(arg2)) || !is_integer(sh(arg1)))
-
 
3025
    failer(CHSH_MAX);
-
 
3026
#endif
-
 
3027
#if !has64bits
-
 
3028
	if (name(sh(arg1)) >= s64hd &&
3660
	if (name(sh(body)) != bothd) {
3029
		(name(arg1)!=val_tag || name(arg2) != val_tag)) {
-
 
3030
		return TDFcallop3(arg1,arg2,max_tag);
3661
		failer(CHSH_MAKE_PROC);
3031
	}
3662
	}
3032
#endif
3663
#endif
-
 
3664
	res = getexp(f_proc, nilexp, 0, caller_intro.id, result_shape, 0, 0,
3033
  return me_b2(arg1, arg2, max_tag);
3665
		     general_proc_tag);
3034
}
-
 
3035
 
3666
 
-
 
3667
	if (caller_intro.number == 0 && callee_intro.number == 0) {
-
 
3668
		son(res) = body;
3036
exp f_minimum
3669
		setlast(body);
3037
    PROTO_N ( (arg1, arg2) )
3670
		bro(body) = res;
3038
    PROTO_T ( exp arg1 X exp arg2 )
3671
	} else if (callee_intro.number == 0) {
3039
{
-
 
3040
  if (name(sh(arg1)) == bothd)
3672
		bro(son(res)) = res;
3041
    { kill_exp(arg2,arg2); return arg1; }
3673
		bro(caller_intro.last_def) = body;
3042
  if (name(sh(arg2)) == bothd)
3674
		setlast(body);
3043
    { kill_exp(arg1,arg1); return arg2; }
3675
		bro(body) = caller_intro.last_id;
3044
#if check_shape
3676
	} else {
-
 
3677
		int i;
-
 
3678
		exp z = callee_intro.id;
3045
  if (!eq_shape(sh(arg1), sh(arg2)) || !is_integer(sh(arg1)))
3679
		for (i = 0; i < callee_intro.number; i++) {
-
 
3680
			set_callee(z);
3046
    failer(CHSH_MIN);
3681
			z = bro(son(z));
3047
#endif
3682
		}
-
 
3683
		if (caller_intro.number != 0) {
-
 
3684
			bro(caller_intro.last_def) = callee_intro.id;
-
 
3685
			bro(callee_intro.id) = caller_intro.last_id;	/*???*/
3048
#if !has64bits
3686
		} else {
3049
	if (name(sh(arg1)) >= s64hd &&
3687
			son(res) = callee_intro.id;
-
 
3688
		}
3050
		(name(arg1)!=val_tag || name(arg2) != val_tag)) {
3689
		bro(son(res)) = res;
3051
		error_treatment ov_err;
3690
		bro(callee_intro.last_def) = body;
3052
		ov_err = f_wrap;
3691
		setlast(body);
3053
		return TDFcallop2(ov_err,arg1,arg2,min_tag);
3692
		bro(body) = callee_intro.last_id;
3054
	}
3693
	}
3055
#endif
-
 
3056
 
-
 
3057
  return me_b2(arg1, arg2, min_tag);
-
 
3058
}
-
 
3059
 
-
 
3060
static int in_initial_value;
-
 
3061
 
-
 
3062
static void push_proc_props
-
 
3063
    PROTO_Z ()
-
 
3064
{
-
 
3065
  proc_props * temp = (proc_props*)xcalloc(1, sizeof(proc_props));
-
 
3066
  temp->proc_struct_result = proc_struct_result;
-
 
3067
  temp->has_alloca = has_alloca;
-
 
3068
  temp->proc_is_recursive = proc_is_recursive;
-
 
3069
  temp->uses_crt_env = uses_crt_env;
-
 
3070
  temp->has_setjmp = has_setjmp;
-
 
3071
  temp->uses_loc_address = uses_loc_address;
-
 
3072
  temp->proc_label_count = proc_label_count;
-
 
3073
  temp->proc_struct_res = proc_struct_res;
-
 
3074
  temp->default_freq = default_freq;
-
 
3075
  temp->proc_externs = proc_externs;
-
 
3076
  temp->in_proc_def = in_proc_def;
-
 
3077
  temp->pushed = old_proc_props;
-
 
3078
  temp->rep_make_proc = rep_make_proc;
-
 
3079
  temp->frame_alignment = frame_alignment;
-
 
3080
  temp->in_initial_value = in_initial_value;
-
 
3081
  old_proc_props = temp;
-
 
3082
  return;
-
 
3083
}
-
 
3084
 
-
 
3085
static void pop_proc_props
-
 
3086
    PROTO_Z ()
-
 
3087
{
-
 
3088
  proc_props * temp = old_proc_props;
-
 
3089
  proc_struct_result = temp->proc_struct_result;
-
 
3090
  has_alloca = temp->has_alloca;
-
 
3091
  proc_is_recursive =temp-> proc_is_recursive;
-
 
3092
  uses_crt_env = temp->uses_crt_env;
-
 
3093
  has_setjmp = temp->has_setjmp;
-
 
3094
  uses_loc_address = temp->uses_loc_address;
-
 
3095
  proc_label_count = temp->proc_label_count;
-
 
3096
  proc_struct_res = temp->proc_struct_res;
-
 
3097
  default_freq = temp->default_freq;
-
 
3098
  proc_externs = temp->proc_externs;
-
 
3099
  in_proc_def = temp->in_proc_def;
-
 
3100
  old_proc_props = temp->pushed;
-
 
3101
  rep_make_proc = temp->rep_make_proc;
-
 
3102
  frame_alignment = temp->frame_alignment;
-
 
3103
  in_initial_value = temp->in_initial_value;
-
 
3104
  if (temp != &initial_value_pp) xfree((void*)temp);
-
 
3105
  return;
-
 
3106
}
-
 
3107
 
-
 
3108
void start_make_proc
-
 
3109
    PROTO_N ( (result_shape, params_intro, vartag) )
-
 
3110
    PROTO_T ( shape result_shape X tagshacc_list params_intro X tagacc_option vartag )
-
 
3111
{
-
 
3112
    /* initialise global flags which are used at the end of the
-
 
3113
       reading process in f_make_proc */
-
 
3114
  UNUSED(result_shape); UNUSED(params_intro);
-
 
3115
  push_proc_props();
-
 
3116
 
-
 
3117
  proc_struct_result = nilexp;
-
 
3118
  has_alloca = 0;
-
 
3119
  proc_is_recursive = 0;
-
 
3120
  uses_crt_env = 0;
-
 
3121
  has_setjmp = 0;
-
 
3122
  uses_loc_address = 0;
-
 
3123
  proc_label_count = 0;
-
 
3124
  proc_struct_res = 0;
-
 
3125
  default_freq = 1.0;
-
 
3126
  proc_externs = 0;
-
 
3127
  in_initial_value = 0;
-
 
3128
  frame_alignment = f_unite_alignments(f_locals_alignment, var_callers_alignment);
-
 
3129
 
-
 
3130
  if (vartag.present) {
-
 
3131
    shape sha = getshape(0, const_al1, const_al1,
-
 
3132
			 VAR_PARAM_ALIGN, 0, cpdhd);
-
 
3133
    exp d = getexp(sha, nilexp, 0, nilexp, nilexp, 0, 0, clear_tag);
-
 
3134
    exp i = getexp(f_bottom, nilexp, 1, d, nilexp, 0, 0, ident_tag);
-
 
3135
    setvis(i);
-
 
3136
    setvar(i);
-
 
3137
    setparam(i);
-
 
3138
    set_tag(vartag.val.tg, i);
-
 
3139
   };
-
 
3140
 
-
 
3141
    /* set this flag to distinguish values created during procedure
-
 
3142
       reading.
-
 
3143
    */
-
 
3144
  in_proc_def = 1;
-
 
3145
 
-
 
3146
  return;
-
 
3147
}
-
 
3148
 
-
 
3149
exp f_make_proc
-
 
3150
    PROTO_N ( (result_shape, params_intro, vartag, body) )
-
 
3151
    PROTO_T ( shape result_shape X tagshacc_list params_intro X tagacc_option vartag X exp body )
-
 
3152
{
-
 
3153
  exp res;
-
 
3154
  int varhack = 0;
-
 
3155
#if ishppa
-
 
3156
  exp t,id,ptr;
-
 
3157
#endif
-
 
3158
 
-
 
3159
#if check_shape
-
 
3160
  if (name(sh(body)) != bothd)
-
 
3161
    failer(CHSH_MAKE_PROC);
-
 
3162
#endif
-
 
3163
 
-
 
3164
  if (vartag.present)  {
-
 
3165
    exp i = get_tag(vartag.val.tg);
-
 
3166
    if (params_intro.id == nilexp)
-
 
3167
      params_intro.id = i;
-
 
3168
    else
-
 
3169
      bro(params_intro.last_def) = i;
-
 
3170
    bro(i) = params_intro.last_id;
-
 
3171
    params_intro.last_def = son(i);
-
 
3172
    params_intro.last_id = i;
-
 
3173
    setvis(i);
-
 
3174
    ++params_intro.number;
-
 
3175
    varhack = 1;
-
 
3176
  };
-
 
3177
 
-
 
3178
  res = getexp(f_proc, nilexp, 0, params_intro.id, result_shape,
-
 
3179
                     0, 0, proc_tag);
-
 
3180
 
3694
 
3181
  if (params_intro.number == 0)
-
 
3182
   {
-
 
3183
     son(res) = body;
-
 
3184
     setlast(body);
-
 
3185
     bro(body) = res;
-
 
3186
   }
-
 
3187
  else
-
 
3188
   {
-
 
3189
     bro(son(res)) = res;
-
 
3190
     bro(params_intro.last_def) = body;
-
 
3191
     setlast(body);
-
 
3192
     bro(body) = params_intro.last_id;
-
 
3193
#ifdef promote_pars
3695
#ifdef promote_pars
3194
  	promote_formals(son(res));
3696
	promote_formals(son(res));
3195
#endif
3697
#endif
3196
   };
-
 
3197
 
-
 
3198
     /* set the properties of the procedure construction from the
3698
	/* set the properties of the procedure construction from the
3199
        global values accumulated during reading.
3699
	   global values accumulated during reading.
3200
        WE OUGHT TO POP THE OLD VALUES.
3700
	   WE OUGHT TO POP THE OLD VALUES.
3201
     */
3701
	 */
3202
  if (has_alloca)
3702
	if (has_alloca) {
3203
    set_proc_has_alloca(res);
3703
		set_proc_has_alloca(res);
-
 
3704
	}
3204
  if (proc_is_recursive)
3705
	if (proc_is_recursive) {
3205
    setrecursive(res);
3706
		setrecursive(res);
-
 
3707
	}
3206
  if (has_lv)
3708
	if (has_lv) {
3207
    set_proc_has_lv(res);
3709
		set_proc_has_lv(res);
3208
  if (uses_crt_env)
-
 
3209
    set_proc_uses_crt_env(res);
-
 
3210
  if (has_setjmp)
-
 
3211
    set_proc_has_setjmp(res);
-
 
3212
  if (uses_loc_address)
-
 
3213
    set_loc_address(res);
-
 
3214
  if (proc_struct_res)
-
 
3215
    set_struct_res(res);
-
 
3216
  if (proc_externs)
-
 
3217
    set_proc_uses_external(res);
-
 
3218
 
-
 
3219
    /* apply check_id to the parameters */
-
 
3220
 
-
 
3221
  if (params_intro.number !=0)
-
 
3222
  {
-
 
3223
    exp param;
-
 
3224
    for (param = params_intro.last_id; param != res; param = bro(param))
-
 
3225
    {
-
 
3226
      if (redo_structparams  &&
-
 
3227
#if ishppa
-
 
3228
	 (varhack || ((shape_size(sh(son(param)))>64) &&
-
 
3229
                      (name(sh(son(param))) == cpdhd ||name(sh(son(param))) == nofhd ||
-
 
3230
		       name(sh(son(param))) == doublehd))))
-
 
3231
#else
-
 
3232
#if issparc
-
 
3233
	(varhack || sparccpd(sh(son(param))) ))
-
 
3234
 
-
 
3235
#else
-
 
3236
		(varhack || name(sh(son(param))) == cpdhd||name(sh(son(param))) == nofhd ||
-
 
3237
		 name(sh(son(param))) == doublehd))
-
 
3238
#endif
-
 
3239
#endif
-
 
3240
 
-
 
3241
      {
-
 
3242
        /*
-
 
3243
         * Param IS struct/union-by-value.  Incoming acutal parameter
-
 
3244
         * will have been changed to be ptr-to expected value (see
-
 
3245
         * f_apply_proc()), so adjust usage in body.
-
 
3246
         */
-
 
3247
        exp use;                /* use of ident in pt() chain */
-
 
3248
        exp prev;               /* previous use in pt() chain */
-
 
3249
	exp eo = nilexp;
-
 
3250
        shape ptr_s = f_pointer(f_alignment(sh(son(param))));
-
 
3251
 
-
 
3252
#if ishppa
-
 
3253
        /* modify parameter itself */
-
 
3254
        if (!varhack)
-
 
3255
	{
3710
	}
3256
	  exp obtain_param;
-
 
3257
	  exp assign;
-
 
3258
          shape sha=sh(son(param));
-
 
3259
          t=me_obtain(param);
-
 
3260
          if (uses_crt_env)
3711
	if (uses_crt_env) {
3261
	  {
-
 
3262
	    eo = f_env_offset(frame_alignment,f_parameter_alignment(ptr_s),brog(param));
-
 
3263
            obtain_param = f_add_to_ptr(f_current_env(), eo);
-
 
3264
	  }
-
 
3265
          id=me_startid(f_top,me_u3(sha,t,cont_tag),1);
-
 
3266
          ptr=me_startid(f_top,me_obtain(id),0);
-
 
3267
          if (uses_crt_env)
3712
		set_proc_uses_crt_env(res);
3268
	  {
-
 
3269
 	    assign = f_assign(obtain_param, me_obtain(id));
-
 
3270
	    body = f_sequence(add_exp_list(new_exp_list(1),assign, 0), body);
-
 
3271
	  }
-
 
3272
          clearlast(son(ptr));
-
 
3273
          bro(son(ptr))=body;
-
 
3274
          setlast(body);
-
 
3275
          bro(body)=ptr;
-
 
3276
          sh(ptr)=sh(body);
-
 
3277
          body=id;
-
 
3278
          clearlast(son(id));
-
 
3279
          bro(son(id)) = ptr;
-
 
3280
          setlast(ptr);
-
 
3281
          bro(ptr) = id;
-
 
3282
          sh(id) = sh(ptr);
-
 
3283
          bro(params_intro.last_def) = body;
-
 
3284
          setlast(body);
-
 
3285
          bro(body) = param;
-
 
3286
	}
3713
	}
3287
#endif
-
 
3288
 
-
 
3289
        /* visit each use of the parameter modifying appropriately*/
-
 
3290
        for (prev = param, use = pt(prev);
-
 
3291
             use != nilexp;
-
 
3292
             prev = use, use = pt(prev))
-
 
3293
	if (!uses_crt_env || (uses_crt_env && use != eo))
-
 
3294
        {
-
 
3295
          if (!isvar(param))    /* add cont */
-
 
3296
          {
-
 
3297
            exp new_use =
-
 
3298
                getexp(ptr_s,
-
 
3299
                       use, (bool)1, son(use), pt(use), props(use), 0, name_tag);
-
 
3300
            son(use) = new_use;
-
 
3301
            pt(prev) = new_use;
-
 
3302
            pt(use) = nilexp;
-
 
3303
            props(use) = (prop)0;
-
 
3304
            setname(use, cont_tag); /* retain same no and sh */
-
 
3305
 
-
 
3306
            use = new_use;
-
 
3307
          }
-
 
3308
 
-
 
3309
          if (no(use) > 0)      /* add reff */
-
 
3310
          {
-
 
3311
            exp new_use =
-
 
3312
                getexp(ptr_s,
-
 
3313
                       use, (bool)1, son(use), pt(use), props(use), 0, name_tag);
-
 
3314
            son(use) = new_use;
-
 
3315
            pt(prev) = new_use;
-
 
3316
            pt(use) = nilexp;
-
 
3317
            props(use) = (prop)0;
-
 
3318
            setname(use, reff_tag); /* retain same no and sh */
-
 
3319
 
-
 
3320
            use = new_use;
-
 
3321
          }
-
 
3322
        } /* for */
-
 
3323
 
-
 
3324
#if ishppa
-
 
3325
	if (!varhack)
3714
	if (has_setjmp) {
3326
	{
-
 
3327
          /* Change all but ptr's references to param to references to ptr */
-
 
3328
          for (use = pt(param); use != nilexp; use = pt(use))
-
 
3329
	  {
-
 
3330
            if ((son(use)==param) && (use!=son(son(id)))
-
 
3331
                && (!uses_crt_env || (uses_crt_env && use != eo )))
-
 
3332
               son(use)=ptr;
-
 
3333
          }
-
 
3334
          pt(ptr)=pt(param);
3715
		set_proc_has_setjmp(res);
3335
	}
3716
	}
-
 
3717
	if (uses_loc_address) {
3336
#endif
3718
		set_loc_address(res);
3337
 
3719
	}
3338
        /* modify parameter itself */
3720
	if (proc_struct_res) {
3339
	if (isenvoff(param)) {
3721
		set_struct_res(res);
-
 
3722
	}
3340
        	props(param) = (prop)0;
3723
	if (proc_externs) {
3341
		setvis(param);
3724
		set_proc_uses_external(res);
3342
	}
3725
	}
3612
 
3864
 
3613
 
3865
 
3614
exp find_caller_id
3866
exp
3615
    PROTO_N ( (n, p) )
-
 
3616
    PROTO_T ( int n X exp p )
3867
find_caller_id(int n, exp p)
3617
{
3868
{
3618
	while (name(p) == ident_tag) {
3869
	while (name(p) == ident_tag) {
3619
		if (name(son(p)) == caller_name_tag && no(son(p))==n) {
3870
		if (name(son(p)) == caller_name_tag && no(son(p)) ==n) {
3620
			return p;
3871
			return p;
3621
		}
3872
		}
3622
		p = bro(son(p));
3873
		p = bro(son(p));
3623
	}
3874
	}
3624
	return nilexp;
3875
	return nilexp;
3625
}
3876
}
-
 
3877
 
3626
 
3878
 
3627
void start_apply_general_proc
3879
void
3628
    PROTO_N ( (result_shape, prcprops, p, caller_params_intro, callee_params) )
-
 
3629
    PROTO_T ( shape result_shape X procprops_option prcprops X exp p X
3880
start_apply_general_proc(shape result_shape, procprops_option prcprops, exp p,
3630
	      otagexp_list caller_params_intro X callees callee_params )
3881
			 otagexp_list caller_params_intro,
-
 
3882
			 callees callee_params)
3631
{
3883
{
3632
  return;
3884
	return;
3633
}
3885
}
-
 
3886
 
3634
 
3887
 
3635
exp f_apply_general_proc
3888
exp
3636
    PROTO_N ( (result_shape, prcprops, p, caller_pars, callee_pars, postlude) )
-
 
3637
    PROTO_T ( shape result_shape X procprops prcprops X exp p X
3889
f_apply_general_proc(shape result_shape, procprops prcprops, exp p,
3638
	      otagexp_list caller_pars X callees callee_pars X exp postlude )
3890
		     otagexp_list caller_pars, callees callee_pars,
-
 
3891
		     exp postlude)
3639
{
3892
{
3640
	exp res = getexp(result_shape, nilexp, 0, p, nilexp,
3893
	exp res = getexp(result_shape, nilexp, 0, p, nilexp, 0, 0,
3641
                     0, 0, apply_general_tag);
3894
			 apply_general_tag);
3642
        exp r_p;
3895
	exp r_p;
3643
        exp redos = nilexp;
3896
	exp redos = nilexp;
3644
	exp last_redo;
3897
	exp last_redo;
3645
        has_alloca = 1;
3898
	has_alloca = 1;
3646
 
3899
 
3647
	if (name(callee_pars) == same_callees_tag) {
3900
	if (name(callee_pars) == same_callees_tag) {
3648
		/* it's a constant */
3901
		/* it's a constant */
3649
		callee_pars = copy(callee_pars);
3902
		callee_pars = copy(callee_pars);
3650
	}
3903
	}
3651
 
3904
 
3652
 
3905
 
3653
	if (redo_structparams){
3906
	if (redo_structparams) {
3654
	    int i;
3907
		int i;
3655
	    exp * plce = &caller_pars.start;
3908
		exp *plce = &caller_pars.start;
3656
	    for(i=0; i< caller_pars.number; i++) {
3909
		for (i = 0; i < caller_pars.number; i++) {
3657
	        exp ote = *plce;
3910
			exp ote = *plce;
3658
		exp param = (name(ote)==caller_tag)?son(ote):ote;
3911
			exp param = (name(ote) == caller_tag) ? son(ote) : ote;
-
 
3912
			if ((name(sh(param)) == cpdhd ||
3659
		if ((name(sh(param)) == cpdhd || name(sh(param)) == nofhd ||
3913
			     name(sh(param)) == nofhd ||
3660
			 name(sh(param)) == doublehd)
3914
			     name(sh(param)) == doublehd)
3661
#if issparc
3915
#if issparc
3662
		|| sparccpd(sh(param))
3916
			    || sparccpd(sh(param))
3663
 
-
 
3664
#endif
3917
#endif
3665
#if ishppa
3918
#if ishppa 
3666
		&& shape_size(sh(param))>64
3919
			    && shape_size(sh(param)) >64
3667
#endif
3920
#endif
-
 
3921
			    ) {
3668
		) { /* make copy of par and use ptr as par */
3922
				/* make copy of par and use ptr as par */
-
 
3923
				shape nshape =
3669
		    shape nshape = f_pointer(f_alignment(sh(param)));
3924
				    f_pointer(f_alignment(sh(param)));
3670
		    exp rd = me_startid(nshape, param, 1);
3925
				exp rd = me_startid(nshape, param, 1);
3671
		    exp npar = me_obtain(rd);
3926
				exp npar = me_obtain(rd);
3672
		    exp id;
3927
				exp id;
3673
		    if (name(ote)==caller_tag &&
3928
				if (name(ote) ==caller_tag &&
3674
			(id = find_caller_id(i, caller_pars.id)) != nilexp) {
3929
				    (id = find_caller_id(i, caller_pars.id)) !=
-
 
3930
				    nilexp) {
3675
			exp p = pt(id);
3931
					exp p = pt(id);
3676
			son(ote) = npar;
3932
					son(ote) = npar;
-
 
3933
					bro(npar) = ote;
3677
			bro(npar)= ote; setlast(npar);
3934
					setlast(npar);
3678
			sh(son(id)) = sh(npar);
3935
					sh(son(id)) = sh(npar);
-
 
3936
					while(p != nilexp) {
3679
			while(p != nilexp) { /* replaces uses in postlude */
3937
						/* replaces uses in postlude */
3680
			    exp bp = bro(p);
3938
						exp bp = bro(p);
3681
			    int l = last(p);
3939
						int l = last(p);
3682
			    exp np = pt(p);
3940
						exp np = pt(p);
3683
			    exp * pos = refto(father(p), p);
3941
						exp *pos = refto(father(p), p);
3684
			    exp c;
3942
						exp c;
3685
			    sh(p) = nshape;
3943
						sh(p) = nshape;
3686
			    c = f_contents(sh(ote), p);
3944
						c = f_contents(sh(ote), p);
-
 
3945
						if (l) {
-
 
3946
							setlast(c);
-
 
3947
						} else {
3687
			    if (l) { setlast(c); } else {clearlast(c); }
3948
							clearlast(c);
-
 
3949
						}
3688
			    bro(c) = bp;
3950
						bro(c) = bp;
3689
			    *pos = c;
3951
						*pos = c;
3690
			    p = np;
3952
						p = np;
3691
			}
3953
					}
3692
			sh(ote) = nshape;
3954
					sh(ote) = nshape;
3693
			plce = &bro(ote);
3955
					plce = &bro(ote);
3694
		     }
3956
				} else {
3695
		     else {
3957
					if (last(ote)) {
3696
		        if (last(ote)) { setlast(npar); }
3958
						setlast(npar);
-
 
3959
					}
3697
		     	bro(npar) = bro(ote);
3960
					bro(npar) = bro(ote);
3698
			if (ote == caller_pars.end) caller_pars.end = npar;
3961
					if (ote == caller_pars.end) {
-
 
3962
						caller_pars.end = npar;
-
 
3963
					}
3699
			*plce = npar;
3964
					*plce = npar;
3700
			plce = &bro(npar);
3965
					plce = &bro(npar);
3701
		     }
3966
				}
3702
		     bro(son(rd)) = redos; clearlast(son(rd));
3967
				bro(son(rd)) = redos;
-
 
3968
				clearlast(son(rd));
3703
		     if (redos != nilexp) {
3969
				if (redos != nilexp) {
3704
		     	bro(redos) = rd; setlast(redos);
3970
					bro(redos) = rd;
-
 
3971
					setlast(redos);
3705
		     }
3972
				} else {
3706
		     else last_redo = rd;
3973
					last_redo = rd;
-
 
3974
				}
3707
		     redos = rd;
3975
				redos = rd;
3708
		 }
3976
			} else {
3709
		 else {plce = &bro(ote);}
3977
				plce = &bro(ote);}
3710
	    }
3978
		}
3711
	}
3979
	}
3712
 
3980
 
3713
        if (caller_pars.id != nilexp) {
3981
	if (caller_pars.id != nilexp) {
3714
        	exp a = caller_pars.id;
3982
		exp a = caller_pars.id;
3715
        	while (bro(son(a)) != nilexp) { a = bro(son(a)); }
3983
		while (bro(son(a)) != nilexp) {
-
 
3984
			a = bro(son(a));
-
 
3985
		}
3716
        	bro(son(a)) = postlude;
3986
		bro(son(a)) = postlude;
3717
        	setfather(a,postlude);
3987
		setfather(a, postlude);
3718
        	postlude = caller_pars.id;
3988
		postlude = caller_pars.id;
3719
        }
3989
	}
3720
 
3990
 
3721
        setfather(res, postlude);
3991
	setfather(res, postlude);
3722
 
3992
 
3723
        bro(callee_pars) = postlude; clearlast(callee_pars);
3993
	bro(callee_pars) = postlude;
-
 
3994
	clearlast(callee_pars);
3724
        props(callee_pars) = prcprops;
3995
	props(callee_pars) = prcprops;
3725
 
3996
 
3726
        r_p = getexp(f_top, callee_pars, 0, caller_pars.start, nilexp, prcprops,
3997
	r_p = getexp(f_top, callee_pars, 0, caller_pars.start, nilexp, prcprops,
3727
        		caller_pars.number, 0);
3998
		     caller_pars.number, 0);
-
 
3999
	if (caller_pars.number != 0) {
3728
        if (caller_pars.number !=0) { setfather(r_p,caller_pars.end); }
4000
		setfather(r_p, caller_pars.end);
-
 
4001
	}
3729
 
4002
 
3730
        bro(p) = r_p; clearlast(p);
4003
	bro(p) = r_p; clearlast(p);
3731
#ifdef promote_pars
4004
#ifdef promote_pars
3732
    {	int i;
4005
	{	int i;
3733
	exp ote = caller_pars.start;
4006
		exp ote = caller_pars.start;
3734
	for (i = 0; i< caller_pars.number; i++) {
4007
		for (i = 0; i < caller_pars.number; i++) {
3735
	    shape s = sh(ote);
4008
			shape s = sh(ote);
3736
	    if (name(s)>=scharhd && name(s)<=uwordhd) {
4009
			if (name(s) >= scharhd && name(s) <= uwordhd) {
3737
	        shape ns = (is_signed(s))? slongsh:ulongsh;
4010
				shape ns = (is_signed(s)) ? slongsh : ulongsh;
3738
		exp par = (name(ote)==caller_tag)?son(ote):ote;
4011
				exp par = (name(ote) == caller_tag) ?
-
 
4012
				    son(ote) : ote;
3739
		exp next = bro(ote);
4013
				exp next = bro(ote);
3740
		exp id;
4014
				exp id;
3741
		int l = last(ote);
4015
				int l = last(ote);
3742
	        exp w = hold_check(f_change_variety(f_wrap,ns, copy(par)));
4016
				exp w = hold_check(f_change_variety(f_wrap, ns,
-
 
4017
								    copy(par)));
3743
		if (name(ote)==caller_tag) sh(ote)=ns;
4018
				if (name(ote) == caller_tag) {
-
 
4019
					sh(ote) = ns;
-
 
4020
				}
3744
	        replace(par, w, nilexp);
4021
				replace(par, w, nilexp);
3745
	        kill_exp(par, nilexp);
4022
				kill_exp(par, nilexp);
3746
	    	if (name(ote) == caller_tag &&
4023
				if (name(ote) == caller_tag &&
3747
			(id = find_caller_id(i, postlude)) != nilexp) {
4024
				    (id = find_caller_id(i, postlude)) !=
-
 
4025
				    nilexp) {
3748
		    exp p = pt(id);
4026
					exp p = pt(id);
3749
		    sh(son(id))=ns;
4027
					sh(son(id)) = ns;
-
 
4028
					while(p != nilexp) {
3750
		    while(p != nilexp) { /* replaces uses in postlude */
4029
						/* replaces uses in postlude */
3751
			exp nextp = pt(p);
4030
						exp nextp = pt(p);
3752
			sh(p) = ns;
4031
						sh(p) = ns;
3753
		    	w = f_change_variety(f_wrap, s, copy(p));
4032
						w = f_change_variety(f_wrap, s,
-
 
4033
								     copy(p));
3754
			replace(p, w, nilexp);
4034
						replace(p, w, nilexp);
3755
			kill_exp(p, nilexp);
4035
						kill_exp(p, nilexp);
3756
			p = nextp;
4036
						p = nextp;
3757
		    }
4037
					}
-
 
4038
				}
-
 
4039
				if (l) {
-
 
4040
					break;
-
 
4041
				}
-
 
4042
				ote = next;
-
 
4043
			} else ote = bro(ote);
3758
		}
4044
		}
3759
		if (l) break;
-
 
3760
		ote = next;
-
 
3761
	    }
-
 
3762
	    else ote = bro(ote);
-
 
3763
	}
4045
	}
3764
    }
-
 
3765
#endif
4046
#endif
3766
 
4047
 
3767
  if (redo_structfns && !reg_result(result_shape))
4048
	if (redo_structfns && !reg_result(result_shape))
3768
   {
4049
	{
3769
     /* replace f(x) by {var r; f(r, x); cont(r)} */
4050
		/* replace f(x) by {var r; f(r, x); cont(r)} */
3770
     exp init, vardec, cont, contname, seq, app, appname, tmp;
4051
		exp init, vardec, cont, contname, seq, app, appname, tmp;
3771
     exp_list list;
4052
		exp_list list;
3772
     shape ptr_res_shape = f_pointer(f_alignment(result_shape));
4053
		shape ptr_res_shape = f_pointer(f_alignment(result_shape));
3773
 
4054
 
3774
     init = getexp(result_shape, nilexp, 0, nilexp, nilexp,
4055
		init = getexp(result_shape, nilexp, 0, nilexp, nilexp, 0, 0,
3775
                                0, 0, clear_tag);
4056
			      clear_tag);
3776
     vardec = getexp(result_shape, nilexp, 0, init, nilexp,
4057
		vardec = getexp(result_shape, nilexp, 0, init, nilexp, 0, 1,
3777
                                0, 1, ident_tag);
4058
				ident_tag);
3778
     setvar(vardec);
4059
		setvar(vardec);
3779
     contname = getexp(ptr_res_shape, nilexp, 0,
4060
		contname = getexp(ptr_res_shape, nilexp, 0, vardec, nilexp, 0,
3780
                           vardec, nilexp, 0, 0, name_tag);
4061
				  0, name_tag);
3781
     pt(vardec) = contname;
4062
		pt(vardec) = contname;
3782
     cont = f_contents(result_shape, contname);
4063
		cont = f_contents(result_shape, contname);
3783
 
4064
 
3784
     appname = getexp(ptr_res_shape, son(r_p), 0,
4065
		appname = getexp(ptr_res_shape, son(r_p), 0, vardec, contname,
3785
                        vardec, contname, 0, 0, name_tag);
4066
				 0, 0, name_tag);
3786
     if(no(r_p)++ == 0) {
4067
		if (no(r_p)++ == 0) {
3787
     		setfather(r_p, appname);
4068
			setfather(r_p, appname);
3788
     }
4069
		}
3789
     ++no(vardec);
4070
		++no(vardec);
3790
     pt(vardec) = appname;
4071
		pt(vardec) = appname;
3791
     app = getexp(f_top, nilexp, 0, son(res), nilexp, 0, 32,
4072
		app = getexp(f_top, nilexp, 0, son(res), nilexp, 0, 32,
3792
                    apply_general_tag);
4073
			     apply_general_tag);
3793
     son(r_p) = appname;
4074
		son(r_p) = appname;
-
 
4075
 
-
 
4076
		tmp = postlude;
-
 
4077
		while (name(tmp) ==ident_tag &&
-
 
4078
		       name(son(tmp)) == caller_name_tag) {
-
 
4079
			no(son(tmp))++;
-
 
4080
			tmp = bro(son(tmp));
-
 
4081
		}
-
 
4082
 
-
 
4083
		bro(postlude) = app;
-
 
4084
		list.number = 1;
-
 
4085
		list.start = app;
-
 
4086
		list.end = app;
-
 
4087
		seq = f_sequence(list, cont);
-
 
4088
		bro(init) = seq;
-
 
4089
		setfather(vardec, seq);
-
 
4090
		retcell(res);
-
 
4091
		res = vardec;
-
 
4092
	}
3794
 
4093
 
3795
     tmp = postlude;
4094
	if (redos != nilexp) {
3796
     while(name(tmp)==ident_tag && name(son(tmp))==caller_name_tag) {
4095
		/* put in decs given by redo_structparams */
3797
		no(son(tmp))++;
4096
		bro(son(last_redo)) = res;
3798
		tmp = bro(son(tmp));
4097
		clearlast(son(last_redo));
-
 
4098
		bro(res) = last_redo;
-
 
4099
		setlast(res);
-
 
4100
		res = redos;
3799
     }
4101
	}
-
 
4102
 
-
 
4103
	return res;
-
 
4104
}
3800
 
4105
 
3801
     bro(postlude) = app;
-
 
3802
     list.number = 1;
-
 
3803
     list.start = app;
-
 
3804
     list.end = app;
-
 
3805
     seq = f_sequence(list, cont);
-
 
3806
     bro(init) = seq;
-
 
3807
     setfather(vardec, seq);
-
 
3808
     retcell(res);
-
 
3809
     res = vardec;
-
 
3810
   };
-
 
3811
 
4106
 
3812
   if (redos != nilexp) { /* put in decs given by redo_structparams */
-
 
3813
   	bro(son(last_redo)) = res; clearlast(son(last_redo));
-
 
3814
	bro(res) = last_redo; setlast(res);
-
 
3815
	res = redos;
-
 
3816
   }
4107
exp
3817
 
-
 
3818
   return res;
-
 
3819
}
-
 
3820
 
-
 
3821
 
-
 
3822
exp f_tail_call
-
 
3823
    PROTO_N ( (prcprops,p,callee_params) )
-
 
3824
    PROTO_T ( procprops prcprops X exp p X callees callee_params )
4108
f_tail_call(procprops prcprops, exp p, callees callee_params)
3825
{
4109
{
3826
	exp res = getexp(f_bottom,nilexp, 0, p, nilexp, 0,0,
4110
	exp res = getexp(f_bottom, nilexp, 0, p, nilexp, 0, 0, tail_call_tag);
3827
			tail_call_tag);
-
 
3828
	exp e_p;
4111
	exp e_p;
3829
	if (name(callee_params) == same_callees_tag) {
4112
	if (name(callee_params) == same_callees_tag) {
3830
		/* it's a constant */
4113
		/* it's a constant */
3831
		callee_params = copy(callee_params);
4114
		callee_params = copy(callee_params);
3832
	}
4115
	}
3833
	e_p = getexp(f_top, res, 1, callee_params, nilexp, prcprops,
4116
	e_p = getexp(f_top, res, 1, callee_params, nilexp, prcprops, 0, 0);
3834
				0, 0);
-
 
3835
	has_setjmp = 1; /* stop inlining ! */
4117
	has_setjmp = 1; /* stop inlining! */
3836
	has_alloca = 1; /* make sure has fp */
4118
	has_alloca = 1; /* make sure has fp */
3837
	props(callee_params) = prcprops;
4119
	props(callee_params) = prcprops;
3838
	bro(p) = callee_params; 	clearlast(p);
4120
	bro(p) = callee_params;
-
 
4121
	clearlast(p);
3839
	setfather(res, callee_params);
4122
	setfather(res, callee_params);
3840
	return res;
4123
	return res;
3841
}
4124
}
3842
 
4125
 
3843
 
4126
 
3844
 
4127
exp
3845
exp f_untidy_return
4128
f_untidy_return(exp arg)
3846
    PROTO_N ( (arg) )
-
 
3847
    PROTO_T ( exp arg )
-
 
3848
{
4129
{
3849
   	exp res = getexp(f_bottom, nilexp, 0, arg, nilexp, 0, 0,
4130
	exp res = getexp(f_bottom, nilexp, 0, arg, nilexp, 0, 0,
3850
   				untidy_return_tag);
4131
			 untidy_return_tag);
3851
   	setfather(res,arg);
4132
	setfather(res, arg);
3852
	has_setjmp = 1;
4133
	has_setjmp = 1;
3853
   	return res;
4134
	return res;
3854
 }
4135
}
-
 
4136
 
3855
 
4137
 
3856
alignment f_parameter_align
4138
alignment
3857
    PROTO_N ( (a) )
-
 
3858
    PROTO_T ( alignment a )
4139
f_parameter_align(alignment a)
3859
{
4140
{
3860
	return( f_var_param_alignment);
4141
	return (f_var_param_alignment);
3861
 
-
 
3862
}
-
 
3863
 
4142
 
3864
exp f_set_stack_limit
-
 
3865
    PROTO_N ( (flim) )
-
 
3866
    PROTO_T ( exp flim )
-
 
3867
{
-
 
3868
   	return me_u3(f_top, flim, set_stack_limit_tag);
-
 
3869
}
4143
}
3870
 
4144
 
-
 
4145
exp
3871
exp f_give_stack_limit
4146
f_set_stack_limit(exp flim)
-
 
4147
{
3872
    PROTO_N ( (frame_al) )
4148
   	return me_u3(f_top, flim, set_stack_limit_tag);
-
 
4149
}
-
 
4150
 
-
 
4151
exp
3873
    PROTO_T ( alignment frame_al )
4152
f_give_stack_limit(alignment frame_al)
3874
{
4153
{
3875
   	exp res = getexp(f_pointer(frame_al), nilexp, 0, nilexp, nilexp, 0, 0,
4154
   	exp res = getexp(f_pointer(frame_al), nilexp, 0, nilexp, nilexp, 0, 0,
3876
   				give_stack_limit_tag);
4155
			 give_stack_limit_tag);
3877
   	return res;
4156
   	return res;
3878
}
4157
}
3879
 
4158
 
3880
exp f_make_stack_limit
4159
exp
3881
    PROTO_N ( (stack_base, frame_size, alloca_size) )
-
 
3882
    PROTO_T ( exp stack_base X exp frame_size X exp alloca_size )
4160
f_make_stack_limit(exp stack_base, exp frame_size, exp alloca_size)
3883
{
4161
{
3884
 
4162
 
3885
	exp sz;
4163
	exp sz;
3886
	frame_size = hold_check(f_offset_pad(al1_of(sh(alloca_size)), frame_size) );
4164
	frame_size = hold_check(f_offset_pad(al1_of(sh(alloca_size)),
-
 
4165
					     frame_size));
3887
	alloca_size = hold_check(f_offset_pad(f_alignment(ucharsh), alloca_size) );
4166
	alloca_size = hold_check(f_offset_pad(f_alignment(ucharsh),
-
 
4167
					      alloca_size));
3888
	sz = hold_check(f_offset_add(frame_size, alloca_size));
4168
	sz = hold_check(f_offset_add(frame_size, alloca_size));
3889
	return me_b2(stack_base, sz, make_stack_limit_tag);
4169
	return me_b2(stack_base, sz, make_stack_limit_tag);
3890
}
4170
}
-
 
4171
 
-
 
4172
 
3891
exp f_env_size
4173
exp
3892
    PROTO_N ( (proctag) )
-
 
3893
    PROTO_T ( tag proctag )
4174
f_env_size(tag proctag)
3894
{
4175
{
3895
  	exp res = getexp(f_offset(f_locals_alignment,f_locals_alignment ), nilexp, 0,
4176
  	exp res = getexp(f_offset(f_locals_alignment, f_locals_alignment),
3896
  			 f_obtain_tag(proctag), nilexp, 0, 0, env_size_tag);
4177
			 nilexp, 0, f_obtain_tag(proctag), nilexp, 0, 0,
-
 
4178
			 env_size_tag);
3897
  	bro(son(res))=res; setlast(son(res));
4179
  	bro(son(res)) = res;
-
 
4180
	setlast(son(res));
3898
  	return res;
4181
  	return res;
3899
}
4182
}
3900
 
4183
 
3901
 
4184
 
3902
 
4185
 
3903
nat f_error_val
4186
nat
3904
    PROTO_N ( (ec) )
-
 
3905
    PROTO_T ( error_code ec )
4187
f_error_val(error_code ec)
3906
{
4188
{
3907
	nat res;
4189
	nat res;
3908
	nat_issmall(res) =1;
4190
	nat_issmall(res) =1;
3909
	natint(res) = ec;
4191
	natint(res) = ec;
3910
	return res;
4192
	return res;
3911
}
4193
}
3912
 
4194
 
3913
exp f_make_top
-
 
3914
    PROTO_Z ()
-
 
3915
{
-
 
3916
  return getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, top_tag);
-
 
3917
}
4195
exp
3918
 
-
 
3919
exp f_make_value
4196
f_make_top(void)
3920
    PROTO_N ( (s) )
-
 
3921
    PROTO_T ( shape s )
-
 
3922
{
-
 
3923
  return me_l1(s, clear_tag);
-
 
3924
}
-
 
3925
 
-
 
3926
exp f_minus
-
 
3927
    PROTO_N ( (ov_err, arg1, arg2) )
-
 
3928
    PROTO_T ( error_treatment ov_err X exp arg1 X exp arg2 )
-
 
3929
{
4197
{
3930
  if (name(sh(arg1)) == bothd)
-
 
3931
    { kill_exp(arg2,arg2); return arg1; }
-
 
3932
  if (name(sh(arg2)) == bothd)
-
 
3933
    { kill_exp(arg1,arg1); return arg2; }
4198
	return getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, top_tag);
-
 
4199
}
3934
 
4200
 
3935
#if check_shape
-
 
3936
  if (!eq_shape(sh(arg1), sh(arg2)) || !is_integer(sh(arg1)))
-
 
3937
    failer(CHSH_MINUS);
-
 
3938
#endif
-
 
3939
#if !has64bits
-
 
3940
	if (name(sh(arg1)) >= s64hd &&
-
 
3941
		(name(arg1)!=val_tag || name(arg2) != val_tag|| ov_err.err_code > 2)) {
-
 
3942
		return TDFcallop2(ov_err,arg1,arg2,minus_tag);
-
 
3943
	}
4201
exp
3944
#endif
-
 
3945
  return me_b1(ov_err, arg1, arg2, minus_tag);
-
 
3946
}
-
 
3947
 
-
 
3948
exp f_move_some
4202
f_make_value(shape s)
3949
    PROTO_N ( (md, arg1, arg2, arg3) )
-
 
3950
    PROTO_T ( transfer_mode md X exp arg1 X exp arg2 X exp arg3 )
-
 
3951
{
4203
{
3952
  exp r = getexp(f_top, nilexp, 0, arg1, nilexp, 0, 0,
-
 
3953
                  movecont_tag);
-
 
3954
  if (name(sh(arg1)) == bothd)
-
 
3955
    { kill_exp(arg2,arg2); kill_exp(arg3,arg3); return arg1; }
-
 
3956
  if (name(sh(arg2)) == bothd)
-
 
3957
    { kill_exp(arg1,arg1); kill_exp(arg3,arg3); return arg2; }
-
 
3958
  if (name(sh(arg3)) == bothd)
-
 
3959
    { kill_exp(arg1,arg1); kill_exp(arg2,arg2); return arg3; }
-
 
3960
 
-
 
3961
#if check_shape
-
 
3962
  if (name(sh(arg1)) != ptrhd || name(sh(arg2)) != ptrhd ||
-
 
3963
       name(sh(arg3)) != offsethd ||
-
 
3964
       al1(sh(arg1)) < al1(sh(arg3)) || al1(sh(arg2)) < al1(sh(arg3)))
-
 
3965
    failer(CHSH_MOVESOME);
-
 
3966
#endif
-
 
3967
#ifdef no_trap_on_nil_contents
-
 
3968
	if ((md & f_trap_on_nil) != 0) {
-
 
3969
		exp d2 = me_startid(f_top, arg2, 0);
-
 
3970
                exp d1 = me_startid(f_top, arg1,0);
-
 
3971
                exp hldr = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, 0);
-
 
3972
     		exp lb = getexp(f_top, nilexp, 0, hldr, nilexp, 0, 0, labst_tag);
-
 
3973
		exp_list el;
-
 
3974
		exp test2 = me_q1(no_nat_option, f_not_equal, &lb, me_obtain(d2),
-
 
3975
				f_make_null_ptr(al1_of(sh(arg2))), test_tag);
-
 
3976
                exp test1 = me_q1(no_nat_option, f_not_equal, &lb, me_obtain(d1),
-
 
3977
                                  f_make_null_ptr(al1_of(sh(arg1))), test_tag);
-
 
3978
		exp trp = getexp(f_bottom, nilexp, 0, nilexp, nilexp,
-
 
3979
				    0 , f_nil_access, trap_tag);
-
 
3980
		md &= ~f_trap_on_nil;
-
 
3981
     		el = new_exp_list(2);
-
 
3982
     		el = add_exp_list(el, test1, 1);
-
 
3983
                el = add_exp_list(el, test2, 2);
-
 
3984
 
-
 
3985
     		return me_complete_id(d2,me_complete_id(d1,
-
 
3986
		   f_conditional(&lb, f_sequence(el,f_move_some(md, me_obtain(d1), me_obtain(d2), arg3) ),trp
-
 
3987
				) ));
-
 
3988
 
-
 
3989
   	};
-
 
3990
#endif
-
 
3991
  if (!(md & f_overlap) && name(arg3) == val_tag && al2(sh(arg3)) > 1) {
-
 
3992
    exp c = f_contents(f_compound(arg3), arg1);
-
 
3993
    return f_assign(arg2, c);
4204
	return me_l1(s, clear_tag);
3994
  };
-
 
3995
 
-
 
3996
  if (al2(sh(arg3)) < 8) {
-
 
3997
	arg3 = hold_check(f_offset_pad(f_alignment(ucharsh), arg3));
-
 
3998
  }
-
 
3999
 
-
 
4000
  if (!(md & f_overlap))
-
 
4001
    setnooverlap(r);
-
 
4002
  clearlast(arg1);
-
 
4003
  setbro(arg1, arg2);
-
 
4004
  clearlast(arg2);
-
 
4005
  setbro(arg2, arg3);
-
 
4006
  setfather(r, arg3);
-
 
4007
  return r;
-
 
4008
}
4205
}
4009
 
4206
 
4010
exp f_mult
4207
exp
4011
    PROTO_N ( (ov_err, arg1, arg2) )
-
 
4012
    PROTO_T ( error_treatment ov_err X exp arg1 X exp arg2 )
4208
f_minus(error_treatment ov_err, exp arg1, exp arg2)
4013
{
4209
{
4014
  if (name(sh(arg1)) == bothd)
4210
	if (name(sh(arg1)) == bothd) {
4015
    { kill_exp(arg2,arg2); return arg1; }
4211
		kill_exp(arg2, arg2);
-
 
4212
		return arg1;
-
 
4213
	}
4016
  if (name(sh(arg2)) == bothd)
4214
	if (name(sh(arg2)) == bothd) {
4017
    { kill_exp(arg1,arg1); return arg2; }
4215
		kill_exp(arg1, arg1);
-
 
4216
		return arg2;
-
 
4217
	}
4018
 
4218
 
4019
#if check_shape
4219
#if check_shape
4020
  if (!eq_shape(sh(arg1), sh(arg2)) || !is_integer(sh(arg1)))
4220
	if (!eq_shape(sh(arg1), sh(arg2)) || !is_integer(sh(arg1))) {
4021
    failer(CHSH_MULT);
4221
		failer(CHSH_MINUS);
-
 
4222
	}
4022
#endif
4223
#endif
4023
#if !has64bits
4224
#if !has64bits
4024
	if (name(sh(arg1)) >= s64hd &&
4225
	if (name(sh(arg1)) >= s64hd &&
4025
		(name(arg1)!=val_tag || name(arg2) != val_tag|| ov_err.err_code > 2)) {
4226
	    (name(arg1) != val_tag || name(arg2) != val_tag ||
-
 
4227
	     ov_err.err_code > 2)) {
4026
		return TDFcallop2(ov_err,arg1,arg2,mult_tag);
4228
		return TDFcallop2(ov_err, arg1, arg2, minus_tag);
4027
	}
4229
	}
4028
#endif
4230
#endif
-
 
4231
	return me_b1(ov_err, arg1, arg2, minus_tag);
-
 
4232
}
-
 
4233
 
-
 
4234
exp
-
 
4235
f_move_some(transfer_mode md, exp arg1, exp arg2, exp arg3)
-
 
4236
{
-
 
4237
	exp r = getexp(f_top, nilexp, 0, arg1, nilexp, 0, 0, movecont_tag);
-
 
4238
	if (name(sh(arg1)) == bothd) {
-
 
4239
		kill_exp(arg2, arg2);
-
 
4240
		kill_exp(arg3, arg3);
-
 
4241
		return arg1;
-
 
4242
	}
-
 
4243
	if (name(sh(arg2)) == bothd) {
-
 
4244
		kill_exp(arg1, arg1);
-
 
4245
		kill_exp(arg3, arg3);
-
 
4246
		return arg2;
-
 
4247
	}
-
 
4248
	if (name(sh(arg3)) == bothd) {
-
 
4249
		kill_exp(arg1, arg1);
-
 
4250
		kill_exp(arg2, arg2);
-
 
4251
		return arg3;
-
 
4252
	}
4029
 
4253
 
-
 
4254
#if check_shape
-
 
4255
	if (name(sh(arg1)) != ptrhd || name(sh(arg2)) != ptrhd ||
-
 
4256
	    name(sh(arg3)) != offsethd || al1(sh(arg1)) < al1(sh(arg3)) ||
-
 
4257
	    al1(sh(arg2)) < al1(sh(arg3))) {
-
 
4258
		failer(CHSH_MOVESOME);
-
 
4259
	}
-
 
4260
#endif
-
 
4261
#ifdef no_trap_on_nil_contents
-
 
4262
	if ((md & f_trap_on_nil) != 0) {
-
 
4263
		exp d2 = me_startid(f_top, arg2, 0);
-
 
4264
		exp d1 = me_startid(f_top, arg1, 0);
-
 
4265
		exp hldr = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, 0);
-
 
4266
		exp lb = getexp(f_top, nilexp, 0, hldr, nilexp, 0, 0,
-
 
4267
				labst_tag);
-
 
4268
		exp_list el;
-
 
4269
		exp test2 = me_q1(no_nat_option, f_not_equal, &lb,
-
 
4270
				  me_obtain(d2),
4030
  return me_b1(ov_err, arg1, arg2, mult_tag);
4271
				  f_make_null_ptr(al1_of(sh(arg2))), test_tag);
-
 
4272
		exp test1 = me_q1(no_nat_option, f_not_equal, &lb,
-
 
4273
				  me_obtain(d1), f_make_null_ptr(al1_of(
-
 
4274
				  sh(arg1))), test_tag);
-
 
4275
		exp trp = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0,
-
 
4276
				 f_nil_access, trap_tag);
-
 
4277
		md &= ~f_trap_on_nil;
-
 
4278
		el = new_exp_list(2);
-
 
4279
		el = add_exp_list(el, test1, 1);
-
 
4280
		el = add_exp_list(el, test2, 2);
-
 
4281
 
-
 
4282
		return me_complete_id(d2, me_complete_id(d1, f_conditional(&lb,
-
 
4283
		    f_sequence(el, f_move_some(md, me_obtain(d1), me_obtain(d2),
-
 
4284
					       arg3)), trp)));
-
 
4285
	}
-
 
4286
#endif
-
 
4287
	if (!(md & f_overlap) && name(arg3) == val_tag && al2(sh(arg3)) > 1) {
-
 
4288
		exp c = f_contents(f_compound(arg3), arg1);
-
 
4289
		return f_assign(arg2, c);
-
 
4290
	}
-
 
4291
 
-
 
4292
	if (al2(sh(arg3)) < 8) {
-
 
4293
		arg3 = hold_check(f_offset_pad(f_alignment(ucharsh), arg3));
-
 
4294
	}
-
 
4295
 
-
 
4296
	if (!(md & f_overlap)) {
-
 
4297
		setnooverlap(r);
-
 
4298
	}
-
 
4299
	clearlast(arg1);
-
 
4300
	setbro(arg1, arg2);
-
 
4301
	clearlast(arg2);
-
 
4302
	setbro(arg2, arg3);
-
 
4303
	setfather(r, arg3);
-
 
4304
	return r;
4031
}
4305
}
-
 
4306
 
4032
 
4307
 
-
 
4308
exp
-
 
4309
f_mult(error_treatment ov_err, exp arg1, exp arg2)
-
 
4310
{
-
 
4311
	if (name(sh(arg1)) == bothd) {
-
 
4312
		kill_exp(arg2, arg2);
-
 
4313
		return arg1;
-
 
4314
	}
-
 
4315
	if (name(sh(arg2)) == bothd) {
-
 
4316
		kill_exp(arg1, arg1);
-
 
4317
		return arg2;
-
 
4318
	}
-
 
4319
 
-
 
4320
#if check_shape
-
 
4321
	if (!eq_shape(sh(arg1), sh(arg2)) || !is_integer(sh(arg1))) {
-
 
4322
		failer(CHSH_MULT);
-
 
4323
	}
-
 
4324
#endif
4033
exp f_n_copies
4325
#if !has64bits
-
 
4326
	if (name(sh(arg1)) >= s64hd &&
-
 
4327
	    (name(arg1) != val_tag || name(arg2) != val_tag ||
4034
    PROTO_N ( (n, arg1) )
4328
	     ov_err.err_code > 2)) {
-
 
4329
		return TDFcallop2(ov_err, arg1, arg2, mult_tag);
-
 
4330
	}
-
 
4331
#endif
-
 
4332
 
-
 
4333
	return me_b1(ov_err, arg1, arg2, mult_tag);
-
 
4334
}
-
 
4335
 
-
 
4336
 
-
 
4337
exp
4035
    PROTO_T ( nat n X exp arg1 )
4338
f_n_copies(nat n, exp arg1)
4036
{
4339
{
4037
  exp r;
4340
	exp r;
4038
  if (name(sh(arg1)) == bothd)
4341
	if (name(sh(arg1)) == bothd) {
4039
    return arg1;
4342
		return arg1;
-
 
4343
	}
4040
 
4344
 
4041
#if !has64bits
4345
#if !has64bits
4042
  if (!nat_issmall(n))
4346
	if (!nat_issmall(n)) {
4043
    failer(TOO_BIG_A_VECTOR);
4347
		failer(TOO_BIG_A_VECTOR);
-
 
4348
	}
4044
#endif
4349
#endif
4045
 
4350
 
4046
  r = getexp(f_nof(n, sh(arg1)), nilexp, 0, arg1, nilexp,
4351
	r = getexp(f_nof(n, sh(arg1)), nilexp, 0, arg1, nilexp, 0, natint(n),
4047
             0, natint(n), ncopies_tag);
4352
		   ncopies_tag);
4048
  if (name(sh(arg1))==bitfhd) {
4353
	if (name(sh(arg1)) == bitfhd) {
4049
	/* make ncopies bitfields into (ncopies) make-compound */
4354
		/* make ncopies bitfields into (ncopies) make-compound */
4050
	int sf = shape_size(sh(arg1));
4355
		int sf = shape_size(sh(arg1));
4051
	int snof = shape_size(sh(r));
4356
		int snof = shape_size(sh(r));
4052
	int scs = (((sf-1)&sf)==0)?sf:snof;
4357
		int scs = (((sf - 1) &sf) ==0) ? sf : snof;
4053
	shape cs = containedshape( scs, 1);
4358
		shape cs = containedshape(scs, 1);
4054
	exp_list a;
4359
		exp_list a;
4055
	shape cpds = f_compound(hold_check(f_offset_pad(f_alignment(cs),
4360
		shape cpds = f_compound(hold_check(f_offset_pad(f_alignment(cs),
4056
					f_shape_offset(sh(r)))));
4361
		    f_shape_offset(sh(r)))));
4057
	exp soff = getexp(f_offset(f_alignment(cpds), f_alignment(sh(arg1))),
4362
		exp soff = getexp(f_offset(f_alignment(cpds),
-
 
4363
					   f_alignment(sh(arg1))), nilexp, 0,
4058
			  nilexp, 0, nilexp, nilexp, 0, 0, val_tag);
4364
				  nilexp, nilexp, 0, 0, val_tag);
4059
	exp cexp;
4365
		exp cexp;
4060
	a.start = copyexp(soff);
4366
		a.start = copyexp(soff);
4061
	a.end = a.start;
4367
		a.end = a.start;
4062
	a.number = 2;
4368
		a.number = 2;
4063
	bro(a.end) = copyexp(arg1);
-
 
4064
        a.end = bro(a.end);
-
 
4065
	for(no(soff)=sf; no(soff) <= shape_size(cs)-sf; no(soff)+=sf ) {
-
 
4066
		bro(a.end) = copyexp(soff); clearlast(a.end);
-
 
4067
		a.end = bro(a.end);
-
 
4068
		bro(a.end) = copyexp(arg1);
4369
		bro(a.end) = copyexp(arg1);
4069
		a.end = bro(a.end);
4370
		a.end = bro(a.end);
-
 
4371
		for (no(soff) = sf; no(soff) <= shape_size(cs) -sf;
-
 
4372
		     no(soff) +=sf) {
-
 
4373
			bro(a.end) = copyexp(soff);
-
 
4374
			clearlast(a.end);
-
 
4375
			a.end = bro(a.end);
-
 
4376
			bro(a.end) = copyexp(arg1);
-
 
4377
			a.end = bro(a.end);
4070
		a.number +=2;
4378
			a.number += 2;
4071
	}
4379
		}
4072
 
4380
 
4073
	setlast(a.end);
4381
		setlast(a.end);
4074
	bro(a.end) = nilexp;
4382
		bro(a.end) = nilexp;
4075
	cexp = f_make_compound(hold_check(f_shape_offset(cs)), a);
4383
		cexp = f_make_compound(hold_check(f_shape_offset(cs)), a);
4076
	if (shape_size(cs) >=shape_size(cpds)) {
4384
		if (shape_size(cs) >= shape_size(cpds)) {
4077
		return cexp;
4385
			return cexp;
4078
	}
-
 
4079
	else {
4386
		} else {
4080
		natint(n) = shape_size(cpds)/shape_size(cs);
4387
			natint(n) = shape_size(cpds) / shape_size(cs);
4081
		return f_n_copies(n, cexp);
4388
			return f_n_copies(n, cexp);
4082
	}
4389
		}
4083
  }
4390
	}
4084
 
4391
 
4085
  setfather(r, arg1);
4392
	setfather(r, arg1);
4086
  return r;
4393
	return r;
-
 
4394
}
-
 
4395
 
-
 
4396
 
-
 
4397
exp
-
 
4398
f_negate(error_treatment ov_err, exp arg1)
-
 
4399
{
-
 
4400
	if (name(sh(arg1)) == bothd) {
-
 
4401
		return arg1;
-
 
4402
	}
-
 
4403
 
-
 
4404
#if check_shape
-
 
4405
	if (!is_integer(sh(arg1))) {
-
 
4406
		failer(CHSH_NEGATE);
-
 
4407
	}
-
 
4408
#endif
-
 
4409
	if (!is_signed(sh(arg1)) && ov_err.err_code > 2) {
-
 
4410
		return f_minus(ov_err, me_shint(sh(arg1), 0), arg1);
-
 
4411
	}
-
 
4412
#if !has64bits
-
 
4413
	if (name(sh(arg1)) >= s64hd &&
-
 
4414
	    (name(arg1) != val_tag|| ov_err.err_code > 2)) {
-
 
4415
		return TDFcallop1(ov_err, arg1, neg_tag);
-
 
4416
	}
-
 
4417
#endif
-
 
4418
 
-
 
4419
	return me_u1(ov_err, arg1, neg_tag);
4087
}
4420
}
4088
 
4421
 
-
 
4422
 
4089
exp f_negate
4423
exp
4090
    PROTO_N ( (ov_err, arg1) )
4424
f_not(exp arg1)
4091
    PROTO_T ( error_treatment ov_err X exp arg1 )
-
 
4092
{
4425
{
4093
  if (name(sh(arg1)) == bothd)
4426
	if (name(sh(arg1)) == bothd) {
4094
    return arg1;
4427
		return arg1;
-
 
4428
	}
4095
 
4429
 
4096
#if check_shape
4430
#if check_shape
4097
  if (!is_integer(sh(arg1)))
4431
	if (!is_integer(sh(arg1))) {
4098
    failer(CHSH_NEGATE);
4432
		failer(CHSH_NOT);
-
 
4433
	}
4099
#endif
4434
#endif
4100
  if (!is_signed(sh(arg1)) && ov_err.err_code >2) {
-
 
4101
	return f_minus(ov_err, me_shint(sh(arg1),0), arg1);
-
 
4102
  }
-
 
4103
#if !has64bits
4435
#if !has64bits
4104
	if (name(sh(arg1)) >= s64hd &&
4436
	if (name(sh(arg1)) >= s64hd &&
4105
		(name(arg1)!=val_tag|| ov_err.err_code > 2 )) {
4437
	    name(arg1) != val_tag) {
4106
		return TDFcallop1(ov_err,arg1,neg_tag);
4438
		return TDFcallop4(arg1, not_tag);
4107
	}
4439
	}
4108
#endif
-
 
4109
 
-
 
4110
  return me_u1(ov_err, arg1, neg_tag);
-
 
4111
}
-
 
4112
 
-
 
4113
exp f_not
-
 
4114
    PROTO_N ( (arg1) )
-
 
4115
    PROTO_T ( exp arg1 )
-
 
4116
{
-
 
4117
  if (name(sh(arg1)) == bothd)
-
 
4118
    return arg1;
-
 
4119
 
-
 
4120
#if check_shape
-
 
4121
  if (!is_integer(sh(arg1)))
-
 
4122
    failer(CHSH_NOT);
-
 
4123
#endif
4440
#endif
4124
#if !has64bits
-
 
4125
	if (name(sh(arg1)) >= s64hd &&
-
 
4126
		name(arg1)!=val_tag ){
-
 
4127
		return TDFcallop4(arg1,not_tag);
4441
	return me_u2(arg1, not_tag);
4128
	}
4442
}
4129
#endif
-
 
4130
  return me_u2(arg1, not_tag);
-
 
4131
}
4443
 
4132
 
4444
 
4133
exp f_obtain_tag
4445
exp
4134
    PROTO_N ( (t) )
-
 
4135
    PROTO_T ( tag t )
4446
f_obtain_tag(tag t)
4136
{
4447
{
4137
   shape s;
4448
	shape s;
4138
   exp r;
4449
	exp r;
4139
   exp tg = get_tag(t);
4450
	exp tg = get_tag(t);
4140
 
4451
 
4141
   if (tg == nilexp)
4452
	if (tg == nilexp) {
4142
     failer(UNDEF_TAG);
4453
		failer(UNDEF_TAG);
-
 
4454
	}
4143
 
4455
 
4144
   if (isglob(tg))
4456
	if (isglob(tg)) {
4145
     {
-
 
4146
        s = sh(t -> dec_u.dec_val.dec_exp);
4457
		s = sh(t->dec_u.dec_val.dec_exp);
4147
#ifdef NEWDIAGS
4458
#ifdef NEWDIAGS
4148
	if (!within_diags)
4459
		if (!within_diags) {
4149
          proc_externs = 1;
4460
			proc_externs = 1;
-
 
4461
		}
4150
#else
4462
#else
4151
        proc_externs = 1;
4463
		proc_externs = 1;
4152
#endif
4464
#endif
4153
     }
-
 
4154
   else
4465
	} else {
4155
     s = sh(son(tg));
4466
		s = sh(son(tg));
-
 
4467
	}
4156
 
4468
 
4157
   if (isvar(tg)) {
4469
	if (isvar(tg)) {
4158
     if (isparam(tg)) {
4470
		if (isparam(tg)) {
4159
	s = f_pointer(f_parameter_alignment(s));
4471
			s = f_pointer(f_parameter_alignment(s));
4160
     }
-
 
4161
     else {
4472
		} else {
4162
      	s = f_pointer(f_alignment(s));
4473
			s = f_pointer(f_alignment(s));
4163
     }
4474
		}
4164
   }
4475
	}
4165
 
4476
 
4166
   r = getexp (s, nilexp, 0, tg, pt (tg), 0, 0, name_tag);
4477
	r = getexp(s, nilexp, 0, tg, pt(tg), 0, 0, name_tag);
4167
   pt(tg) = r;
4478
	pt(tg) = r;
4168
   no(tg) = no(tg)+1;
4479
	no(tg) = no(tg) +1;
4169
   return(r);
4480
	return (r);
4170
}
-
 
4171
 
-
 
4172
exp f_offset_add
-
 
4173
    PROTO_N ( (arg1, arg2) )
-
 
4174
    PROTO_T ( exp arg1 X exp arg2 )
-
 
4175
{
-
 
4176
  shape sres;
-
 
4177
  if (name(sh(arg1)) == bothd)
-
 
4178
    { kill_exp(arg2,arg2); return arg1; }
-
 
4179
  if (name(sh(arg2)) == bothd)
-
 
4180
    { kill_exp(arg1,arg1); return arg2; }
-
 
4181
 
-
 
4182
 
-
 
4183
#if check_shape
-
 
4184
  if (!doing_aldefs &&
-
 
4185
	((name(sh(arg1)) != offsethd || name(sh(arg2)) != offsethd ||
-
 
4186
       (al1(sh(arg2)) > al2(sh(arg1))
-
 
4187
#if issparc
-
 
4188
		&& al1_of(sh(arg2)) != REAL_ALIGN
-
 
4189
#endif
-
 
4190
	) )))
-
 
4191
    failer(CHSH_OFFSETADD);
-
 
4192
#endif
-
 
4193
  sres = f_offset(al1_of(sh(arg1)), al2_of(sh(arg2)));
-
 
4194
#if 0
-
 
4195
	  if ((al1_of(sh(arg1))->al.al_val.al_frame & 4) != 0 &&
-
 
4196
		al2_of(sh(arg2))->al.sh_hd != 0) {
-
 
4197
		exp ne;
-
 
4198
		if (al2_of(sh(arg2))->al.sh_hd > nofhd) {
-
 
4199
		        shape ps = f_pointer(f_alignment(sh(arg1)));
-
 
4200
			ne = hold_check(
-
 
4201
                                f_offset_pad(f_alignment(ps), f_shape_offset(ps))
-
 
4202
			     );
-
 
4203
		}
-
 
4204
		else {
-
 
4205
			ne = arg2;
-
 
4206
		}
-
 
4207
		arg2 = hold_check(me_u2(ne, offset_negate_tag));
-
 
4208
	  }
-
 
4209
#endif
-
 
4210
  return me_b3(sres,arg1, arg2, offset_add_tag);
-
 
4211
}
4481
}
4212
 
-
 
4213
exp f_offset_div
-
 
4214
    PROTO_N ( (v, arg1, arg2) )
-
 
4215
    PROTO_T ( variety v X exp arg1 X exp arg2 )
-
 
4216
{
-
 
4217
  if (name(sh(arg1)) == bothd)
-
 
4218
    { kill_exp(arg2,arg2); return arg1; }
-
 
4219
  if (name(sh(arg2)) == bothd)
-
 
4220
    { kill_exp(arg1,arg1); return arg2; }
-
 
4221
#if check_shape
-
 
4222
  if (name(sh(arg1)) != offsethd || name(sh(arg2)) != offsethd)
-
 
4223
    failer(CHSH_OFFSETDIV);
-
 
4224
#endif
-
 
4225
 
-
 
4226
  return me_b3(f_integer(v), arg1, arg2, offset_div_tag);
-
 
4227
}
-
 
4228
 
-
 
4229
exp f_offset_div_by_int
-
 
4230
    PROTO_N ( (arg1, arg2) )
-
 
4231
    PROTO_T ( exp arg1 X exp arg2 )
-
 
4232
{
-
 
4233
   if (name(sh(arg1)) == bothd)
-
 
4234
    { kill_exp(arg2,arg2); return arg1; }
-
 
4235
  if (name(sh(arg2)) == bothd)
-
 
4236
    { kill_exp(arg1,arg1); return arg2; }
-
 
4237
 
-
 
4238
#if check_shape
-
 
4239
  if (!doing_aldefs &&
-
 
4240
	(name(sh(arg1)) != offsethd || !is_integer(sh(arg2)) ||
-
 
4241
       (al1(sh(arg1)) != al2(sh(arg1)) && al2(sh(arg1))!=1)) )
-
 
4242
    failer(CHSH_OFFSETDIVINT);
-
 
4243
#endif
-
 
4244
 
-
 
4245
  return me_b3(sh(arg1), arg1, arg2, offset_div_by_int_tag);
-
 
4246
}
-
 
4247
 
-
 
4248
exp f_offset_max
-
 
4249
    PROTO_N ( (arg1, arg2) )
-
 
4250
    PROTO_T ( exp arg1 X exp arg2 )
-
 
4251
{
-
 
4252
  alignment a1 = al1_of(sh(arg1));
-
 
4253
  alignment a2 = al1_of(sh(arg2));
-
 
4254
  alignment a3 = al2_of(sh(arg1));
-
 
4255
  shape sha;
-
 
4256
  if (name(sh(arg1)) == bothd)
-
 
4257
    { kill_exp(arg2,arg2); return arg1; }
-
 
4258
  if (name(sh(arg2)) == bothd)
-
 
4259
    { kill_exp(arg1,arg1); return arg2; }
-
 
4260
 
4482
 
4261
#if check_shape
-
 
4262
  if (!doing_aldefs &&
-
 
4263
	(name(sh(arg1)) != offsethd || name(sh(arg2)) != offsethd))
-
 
4264
    failer(CHSH_OFFSETMAX);
-
 
4265
#endif
-
 
4266
 
4483
 
4267
  if (a1->al.al_n != 1 || a2->al.al_n != 1) {
-
 
4268
    alignment ares = (alignment)calloc(1, sizeof(aldef));
-
 
4269
    if (!doing_aldefs)
-
 
4270
       failer(CHSH_OFFSETMAX);
-
 
4271
    ares->al.al_n = 2;
-
 
4272
    ares->al.al_val.al_join.a = a1;
-
 
4273
    ares->al.al_val.al_join.b = a2;
-
 
4274
    ares->next_aldef = top_aldef;
-
 
4275
    top_aldef = ares;
-
 
4276
    sha = f_offset(ares, a3);
-
 
4277
  }
4484
exp
4278
  else
-
 
4279
   sha = f_offset(long_to_al(max(a1->al.al_val.al,
-
 
4280
				 a2->al.al_val.al)),
-
 
4281
			 a3);
-
 
4282
 
-
 
4283
  return me_b3(sha, arg1, arg2, offset_max_tag);
-
 
4284
}
-
 
4285
exp f_offset_mult
-
 
4286
    PROTO_N ( (arg1, arg2) )
-
 
4287
    PROTO_T ( exp arg1 X exp arg2 )
4485
f_offset_add(exp arg1, exp arg2)
4288
{
-
 
4289
  if (name(sh(arg1)) == bothd)
-
 
4290
    { kill_exp(arg2,arg2); return arg1; }
-
 
4291
  if (name(sh(arg2)) == bothd)
-
 
4292
    { kill_exp(arg1,arg1); return arg2; }
-
 
4293
 
-
 
4294
#if check_shape
-
 
4295
  if (!doing_aldefs &&
-
 
4296
	(name(sh(arg1)) != offsethd || !is_integer(sh(arg2))))
-
 
4297
    failer(CHSH_OFFSETMULT);
-
 
4298
#endif
-
 
4299
 
-
 
4300
  if (shape_size(sh(arg2)) != PTR_SZ) {
-
 
4301
    if (PTR_SZ == 32)
-
 
4302
      arg2 = hold_check(f_change_variety(f_impossible, slongsh, arg2));
-
 
4303
    else
-
 
4304
      arg2 = hold_check(f_change_variety(f_impossible, s64sh, arg2));
-
 
4305
  };
-
 
4306
 
-
 
4307
  return me_b3(sh(arg1), arg2, arg1, offset_mult_tag);
-
 
4308
    /* the order of arguments is being interchanged */
-
 
4309
}
-
 
4310
 
-
 
4311
exp f_offset_negate
-
 
4312
    PROTO_N ( (arg1) )
-
 
4313
    PROTO_T ( exp arg1 )
-
 
4314
{
4486
{
-
 
4487
	shape sres;
4315
  if (name(sh(arg1)) == bothd)
4488
	if (name(sh(arg1)) == bothd) {
-
 
4489
		kill_exp(arg2, arg2);
4316
    return arg1;
4490
		return arg1;
-
 
4491
	}
-
 
4492
	if (name(sh(arg2)) == bothd) {
-
 
4493
		kill_exp(arg1, arg1);
-
 
4494
		return arg2;
-
 
4495
	}
-
 
4496
 
4317
 
4497
 
4318
#if check_shape
4498
#if check_shape
4319
  if (!doing_aldefs &&
4499
	if (!doing_aldefs &&
4320
	(name(sh(arg1)) != offsethd ||
4500
	    ((name(sh(arg1)) != offsethd || name(sh(arg2)) != offsethd ||
4321
       (al1(sh(arg1)) != al2(sh(arg1)) && al2(sh(arg1)) != 1
4501
	      (al1(sh(arg2)) > al2(sh(arg1))
4322
#if issparc
4502
#if issparc
4323
		&& al1_of(sh(arg1)) != REAL_ALIGN
4503
	       && al1_of(sh(arg2)) != REAL_ALIGN
-
 
4504
#endif
-
 
4505
	       )))) {
-
 
4506
		failer(CHSH_OFFSETADD);
-
 
4507
	}
4324
#endif
4508
#endif
4538
#endif
4891
#endif
4539
  return div_rem(div0_err, ov_err, arg1, arg2, rem1_aux);
4892
	return me_b1(ov_err, arg1, arg2, mod_tag);
4540
}
4893
}
-
 
4894
 
4541
 
4895
 
4542
exp rem0_aux
4896
exp
4543
    PROTO_N ( (ov_err, arg1, arg2) )
-
 
4544
    PROTO_T ( error_treatment ov_err X exp arg1 X exp arg2 )
4897
f_rem1(error_treatment div0_err, error_treatment ov_err, exp arg1, exp arg2)
4545
{
4898
{
4546
#if !has64bits
-
 
4547
	if (name(sh(arg1)) >= s64hd &&
4899
	if (name(sh(arg1)) == bothd) {
4548
		(name(arg1)!=val_tag || name(arg2) != val_tag|| ov_err.err_code > 2)) {
4900
		kill_exp(arg2, arg2);
4549
		return TDFcallop2(ov_err,arg1,arg2,rem0_tag);
4901
		return arg1;
4550
	}
4902
	}
4551
#endif
4903
	if (name(sh(arg2)) == bothd) {
4552
#if div0_implemented
4904
		kill_exp(arg1, arg1);
4553
  return me_b1(ov_err, arg1, arg2, rem0_tag);
4905
		return arg2;
4554
#else
4906
	}
-
 
4907
 
-
 
4908
#if check_shape
4555
  if (name(arg2) == val_tag && !isbigval(arg2)) {
4909
	if (!eq_shape(sh(arg1), sh(arg2)) || !is_integer(sh(arg1))) {
4556
    int n = no(arg2);
4910
		failer(CHSH_REM1);
4557
    if ((n & (n-1)) == 0)
-
 
4558
      return me_b1(ov_err, arg1, arg2, mod_tag);
-
 
4559
  };
4911
	}
4560
  return me_b1(ov_err, arg1, arg2, rem2_tag);
-
 
4561
#endif
4912
#endif
-
 
4913
	return div_rem(div0_err, ov_err, arg1, arg2, rem1_aux);
4562
}
4914
}
4563
exp f_rem0
-
 
4564
    PROTO_N ( (div0_err, ov_err, arg1, arg2) )
-
 
4565
    PROTO_T ( error_treatment div0_err X error_treatment ov_err X exp arg1 X exp arg2 )
-
 
4566
{
-
 
4567
  if (name(sh(arg1)) == bothd)
-
 
4568
    { kill_exp(arg2,arg2); return arg1; }
-
 
4569
  if (name(sh(arg2)) == bothd)
-
 
4570
    { kill_exp(arg1,arg1); return arg2; }
-
 
4571
 
-
 
4572
 
4915
 
4573
#if check_shape
-
 
4574
  if (!eq_shape(sh(arg1), sh(arg2)) || !is_integer(sh(arg1)))
-
 
4575
    failer(CHSH_REM0);
-
 
4576
#endif
-
 
4577
 
-
 
4578
  return div_rem(div0_err, ov_err, arg1, arg2, rem0_aux);
-
 
4579
 
4916
 
4580
}
4917
exp
4581
 
-
 
4582
exp rem2_aux
-
 
4583
    PROTO_N ( (ov_err, arg1, arg2) )
-
 
4584
    PROTO_T ( error_treatment ov_err X exp arg1 X exp arg2 )
4918
rem0_aux(error_treatment ov_err, exp arg1, exp arg2)
4585
{
4919
{
4586
#if !has64bits
4920
#if !has64bits
4587
	if (name(sh(arg1)) >= s64hd &&
4921
	if (name(sh(arg1)) >= s64hd &&
4588
		(name(arg1)!=val_tag || name(arg2) != val_tag|| ov_err.err_code > 2)) {
4922
	    (name(arg1) != val_tag || name(arg2) != val_tag ||
-
 
4923
	     ov_err.err_code > 2)) {
4589
		return TDFcallop2(ov_err,arg1,arg2,rem2_tag);
4924
		return TDFcallop2(ov_err, arg1, arg2, rem0_tag);
4590
	}
4925
	}
4591
#endif
4926
#endif
4778
#endif
4993
#endif
4779
 
4994
 
-
 
4995
	return div_rem(div0_err, ov_err, arg1, arg2, rem2_aux);
-
 
4996
}
-
 
4997
 
-
 
4998
 
-
 
4999
static int silly_count = 0; /* for pathological numbers of repeats*/
-
 
5000
exp
-
 
5001
f_repeat(label repeat_label_intro, exp start, exp body)
-
 
5002
{
-
 
5003
	exp r = getexp(sh(body), nilexp, 0, start, crt_repeat, 0, 0, rep_tag);
-
 
5004
	exp labst = get_lab(repeat_label_intro);
-
 
5005
 
-
 
5006
	bro(start) = labst;
-
 
5007
	clearlast(start);
-
 
5008
	setbro(son(labst), body);
-
 
5009
	clearlast(son(labst));
-
 
5010
	setbro(body, labst);
-
 
5011
	setlast(body);
-
 
5012
	setsh(labst, sh(body));
-
 
5013
	son(crt_repeat) = r;
-
 
5014
	crt_repeat = bro(crt_repeat);
-
 
5015
	setfather(r, labst);
-
 
5016
	if (silly_count == 0) {
-
 
5017
		default_freq = (float)(default_freq / 20.0);
-
 
5018
	} else {
-
 
5019
		silly_count--;
-
 
5020
	}
-
 
5021
	
-
 
5022
	return r;
-
 
5023
}
-
 
5024
 
-
 
5025
 
-
 
5026
void
-
 
5027
start_repeat(label repeat_label_intro)
-
 
5028
{
-
 
5029
	exp labst;
-
 
5030
	exp def;
-
 
5031
	def = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, clear_tag);
-
 
5032
 
-
 
5033
	/* enter this repeat on crt_repeat and repeat_list - see
-
 
5034
	   documentation */
-
 
5035
	if (crt_repeat != nilexp) {
-
 
5036
		++no(crt_repeat);
-
 
5037
	}
-
 
5038
	repeat_list = getexp(f_top, crt_repeat, 0, nilexp, repeat_list, 1, 0,
-
 
5039
			     0);
-
 
5040
	crt_repeat = repeat_list;
-
 
5041
	labst = getexp(f_bottom, nilexp, 0, def, nilexp, 0, 0, labst_tag);
-
 
5042
	if (default_freq < (float)10e10) {
-
 
5043
		default_freq = (float)(20.0 * default_freq);
-
 
5044
	} else {
-
 
5045
		silly_count++;
-
 
5046
	}
-
 
5047
	fno(labst) = default_freq;
-
 
5048
	++proc_label_count;
-
 
5049
	set_lab(repeat_label_intro, labst);
-
 
5050
	return;
-
 
5051
}
-
 
5052
 
-
 
5053
 
-
 
5054
exp
-
 
5055
f_return(exp arg1)
-
 
5056
{
-
 
5057
	if (name(sh(arg1)) == bothd) {
-
 
5058
		return arg1;
-
 
5059
	}
-
 
5060
	if (!reg_result(sh(arg1))) {
-
 
5061
		proc_struct_res = 1;
-
 
5062
	}
-
 
5063
 
-
 
5064
	/* transformation if we are giving procedures which deliver a struct
-
 
5065
	   result an extra pointer parameter */
-
 
5066
	if (redo_structfns && !reg_result(sh(arg1))) {
-
 
5067
		exp ret, obt;
-
 
5068
		exp assname, ass;
-
 
5069
		shape ptr_res_shape;
-
 
5070
		exp_list list;
-
 
5071
 
-
 
5072
		if (proc_struct_result == nilexp) {
-
 
5073
			exp init = getexp(f_pointer(f_alignment(sh(arg1))),
-
 
5074
					  nilexp, 0, nilexp, nilexp, 0, 0,
-
 
5075
					  clear_tag);
-
 
5076
			exp iddec = getexp(sh(arg1), nilexp, 0, init, nilexp,
-
 
5077
					   0, 0, ident_tag);
-
 
5078
			setparam(iddec);
-
 
5079
			proc_struct_result = iddec;
-
 
5080
		}
-
 
5081
		ptr_res_shape = f_pointer(f_alignment(sh(arg1)));
-
 
5082
		obt = getexp(ptr_res_shape, nilexp, 0, proc_struct_result,
-
 
5083
			     pt(proc_struct_result), 0, 0, name_tag);
-
 
5084
		++no(proc_struct_result);
-
 
5085
		pt(proc_struct_result) = obt;
-
 
5086
 
-
 
5087
		ret = me_u3(f_bottom, obt, res_tag);
-
 
5088
 
-
 
5089
		assname = getexp(ptr_res_shape, nilexp, 0, proc_struct_result,
-
 
5090
				 pt(proc_struct_result), 0, 0, name_tag);
-
 
5091
		++no(proc_struct_result);
-
 
5092
		pt(proc_struct_result) = assname;
-
 
5093
		ass = hold_check(f_assign(assname, arg1));
-
 
5094
		list.number = 1;
-
 
5095
		list.start = ass;
-
 
5096
		list.end = ass;
-
 
5097
		return f_sequence(list, ret);
-
 
5098
	}
4780
  return me_b2(arg1, arg2, rotr_tag);
5099
	return me_u3(f_bottom, arg1, res_tag);
4781
}
5100
}
4782
 
5101
 
4783
 
5102
 
4784
 
-
 
4785
exp f_sequence
-
 
4786
    PROTO_N ( (statements, result) )
-
 
4787
    PROTO_T ( exp_list statements X exp result )
-
 
4788
{
-
 
4789
  exp r;
-
 
4790
  exp h = getexp(f_bottom, result, 0, statements.start,
-
 
4791
                  nilexp, 0, statements.number, 0);
-
 
4792
  exp l = statements.end;
-
 
4793
  clear_exp_list(statements);
-
 
4794
 
-
 
4795
    /* re-organise so that sequence lists do not get too long.
-
 
4796
       limit to MAX_ST_LENGTH */
-
 
4797
  if (statements.number == 0)
-
 
4798
    return result;
-
 
4799
  if (statements.number <= MAX_ST_LENGTH) {
-
 
4800
    setlast(l);
-
 
4801
    setbro(l, h);
-
 
4802
    r = getexp(sh(result), nilexp, 0, h, nilexp, 0, 0, seq_tag);
-
 
4803
    setfather (r, result);
-
 
4804
    return r;
-
 
4805
  }
5103
exp
4806
  else {
-
 
4807
    int num_bits = statements.number / MAX_ST_LENGTH;
-
 
4808
    int rest = statements.number - (num_bits*MAX_ST_LENGTH);
-
 
4809
    exp_list work;
-
 
4810
    exp_list res;
-
 
4811
    exp t = statements.start;
-
 
4812
    int i, j;
-
 
4813
    res = new_exp_list(num_bits+1);
-
 
4814
    if (rest == 0)
-
 
4815
      {
-
 
4816
        --num_bits;
-
 
4817
        rest = MAX_ST_LENGTH;
-
 
4818
      };
-
 
4819
 
-
 
4820
    for (i = 0; i < num_bits; ++i)
-
 
4821
      {
-
 
4822
        work.start = t;
-
 
4823
        work.number = MAX_ST_LENGTH;
-
 
4824
        for (j = 0; j < (MAX_ST_LENGTH-1); ++j)
-
 
4825
          t = bro(t);
-
 
4826
        work.end = t;
-
 
4827
        t = bro(t);
-
 
4828
        res = add_exp_list(res,
-
 
4829
                           hold_check(f_sequence(work, f_make_top())),
-
 
4830
			   i);
-
 
4831
      };
-
 
4832
 
-
 
4833
    work.start = t;
-
 
4834
    work.end = l;
-
 
4835
    work.number = rest;
-
 
4836
    res = add_exp_list(res,
-
 
4837
		       hold_check(f_sequence(work, f_make_top())),
-
 
4838
		       num_bits);
-
 
4839
    return f_sequence(res, result);
5104
f_rotate_left(exp arg1, exp arg2)
4840
  };
-
 
4841
}
-
 
4842
 
-
 
4843
exp f_shape_offset
-
 
4844
    PROTO_N ( (s) )
-
 
4845
    PROTO_T ( shape s )
-
 
4846
{
5105
{
4847
 
-
 
4848
  return getexp(f_offset(f_alignment(s), long_to_al(1)),
5106
	if (name(sh(arg1)) == bothd) {
4849
		  nilexp, 0,
5107
		kill_exp(arg2, arg2);
4850
                  nilexp, nilexp,
5108
		return arg1;
4851
                  0, shape_size(s), val_tag);
-
 
4852
}
5109
	}
4853
 
-
 
4854
exp f_shift_left
-
 
4855
    PROTO_N ( (ov_err, arg1, arg2) )
-
 
4856
    PROTO_T ( error_treatment ov_err X exp arg1 X exp arg2 )
-
 
4857
{
-
 
4858
  if (name(sh(arg1)) == bothd)
5110
	if (name(sh(arg2)) == bothd) {
4859
    { kill_exp(arg2,arg2); return arg1; }
5111
		kill_exp(arg1, arg1);
4860
  if (name(sh(arg2)) == bothd)
-
 
4861
    { kill_exp(arg1,arg1); return arg2; }
5112
		return arg2;
-
 
5113
	}
4862
 
5114
 
4863
#if check_shape
5115
#if check_shape
4864
  if (!is_integer(sh(arg1)) || !is_integer(sh(arg2)))
5116
	if (!is_integer(sh(arg1)) || !is_integer(sh(arg2))) {
4865
    failer(CHSH_SHL);
5117
		failer(CHSH_ROTL);
4866
#endif
-
 
4867
#if !has64bits
-
 
4868
	if (name(sh(arg1)) >= s64hd &&
-
 
4869
		(name(arg1)!=val_tag || name(arg2) != val_tag|| ov_err.err_code > 2)) {
-
 
4870
	    arg2 = hold_check(f_change_variety(ov_err, ulongsh, arg2));
-
 
4871
	    return TDFcallop2(ov_err,arg1,arg2,shl_tag);
-
 
4872
	}
5118
	}
4873
#endif
5119
#endif
4939
	}
5330
	}
4940
#endif
5331
#endif
-
 
5332
#if !has64bits
-
 
5333
	if (name(sh(arg1)) >= s64hd &&
-
 
5334
	    (name(arg1) != val_tag || name(arg2) != val_tag)) {
-
 
5335
		error_treatment ov_err;
-
 
5336
		ov_err = f_wrap;
-
 
5337
		arg2 = hold_check(f_change_variety(ov_err, ulongsh, arg2));
-
 
5338
		return TDFcallop2(ov_err, arg1, arg2, shr_tag);
-
 
5339
	}
-
 
5340
#endif
4941
  return me_b2(arg1, arg2, shr_tag);
5341
	return me_b2(arg1, arg2, shr_tag);
-
 
5342
}
-
 
5343
 
-
 
5344
 
-
 
5345
exp
-
 
5346
f_subtract_ptrs(exp arg1, exp arg2)
-
 
5347
{
-
 
5348
	if (name(sh(arg1)) == bothd) {
-
 
5349
		kill_exp(arg2, arg2);
-
 
5350
		return arg1;
-
 
5351
	}
-
 
5352
	if (name(sh(arg2)) == bothd) {
-
 
5353
		kill_exp(arg1, arg1);
-
 
5354
		return arg2;
-
 
5355
	}
-
 
5356
	return me_b3(f_offset(al1_of(sh(arg2)), al1_of(sh(arg1))), arg1, arg2,
-
 
5357
		     minptr_tag);
4942
}
5358
}
-
 
5359
 
4943
 
5360
 
4944
exp f_subtract_ptrs
5361
exp
4945
    PROTO_N ( (arg1, arg2) )
-
 
4946
    PROTO_T ( exp arg1 X exp arg2 )
5362
f_variable(access_option acc, tag name_intro, exp init, exp body)
4947
{
5363
{
4948
  if (name(sh(arg1)) == bothd)
5364
	exp i = get_tag(name_intro);
4949
    { kill_exp(arg2,arg2); return arg1; }
5365
	exp d = son(i);
-
 
5366
	UNUSED(acc);
-
 
5367
	UNUSED(init);
4950
  if (name(sh(arg2)) == bothd)
5368
	setsh(i, sh(body));
-
 
5369
	setbro(d, body);
-
 
5370
	clearlast(d);
4951
    { kill_exp(arg1,arg1); return arg2; }
5371
	setfather(i, body);
-
 
5372
#ifdef NEWDIAGS
4952
  return me_b3(f_offset(al1_of(sh(arg2)),
5373
	if (doing_mark_scope) {
4953
                        al1_of(sh(arg1))),
5374
		/* must be reading old diags */
4954
                arg1, arg2, minptr_tag);
5375
		correct_mark_scope(i);
-
 
5376
	}
-
 
5377
#endif
-
 
5378
	return i;
4955
}
5379
}
-
 
5380
 
4956
 
5381
 
4957
exp f_variable
5382
void
4958
    PROTO_N ( (acc, name_intro, init, body) )
-
 
4959
    PROTO_T ( access_option acc X tag name_intro X exp init X exp body )
5383
start_variable(access_option acc, tag name_intro, exp init)
4960
{
5384
{
4961
  exp i = get_tag(name_intro);
5385
	exp i = get_tag(name_intro);
4962
  exp d = son(i);
5386
	if (i == nilexp || son(i) != i) {
4963
  UNUSED(acc); UNUSED(init);
5387
		i = getexp(f_bottom, nilexp, 0, init, nilexp, 0, 0, ident_tag);
4964
  setsh(i, sh(body));
5388
	} else {
-
 
5389
		/* could have been already used in env_offset */
4965
  setbro(d, body);
5390
		son(i) = init;
-
 
5391
	}
-
 
5392
 
4966
  clearlast(d);
5393
	setvar(i);
-
 
5394
	if (acc & (f_visible | f_long_jump_access)) {
4967
  setfather (i, body);
5395
		setvis(i);
4968
#ifdef NEWDIAGS
5396
		setenvoff(i);
4969
  if (doing_mark_scope)		/* must be reading old diags */
5397
	} else if ((acc & f_no_other_read) && (acc & f_no_other_write)) {
4970
    correct_mark_scope (i);
5398
		setcaonly(i);
4971
#endif
5399
	}
-
 
5400
	set_tag(name_intro, i);
-
 
5401
 
4972
  return i;
5402
	return;
4973
}
5403
}
-
 
5404
 
4974
 
5405
 
4975
void start_variable
5406
exp
4976
    PROTO_N ( (acc, name_intro, init) )
5407
f_xor(exp arg1, exp arg2)
4977
    PROTO_T ( access_option acc X tag name_intro X exp init )
-
 
4978
{
5408
{
4979
  exp i = get_tag(name_intro);
-
 
4980
  if (i == nilexp || son(i) != i) {
5409
	if (name(sh(arg1)) == bothd) {
4981
	i = getexp(f_bottom, nilexp, 0, init, nilexp, 0,
-
 
4982
                    0, ident_tag);
5410
		kill_exp(arg2, arg2);
4983
  }
-
 
4984
  else {  /* could have been already used in env_offset */
-
 
4985
	son(i) = init;
5411
		return arg1;
4986
  }
5412
	}
4987
  setvar(i);
-
 
4988
  if (acc & (f_visible | f_long_jump_access))
5413
	if (name(sh(arg2)) == bothd) {
4989
   {
-
 
4990
    setvis(i);
-
 
4991
    setenvoff(i);
-
 
4992
   }
-
 
4993
  else
-
 
4994
  if ((acc & f_no_other_read) && (acc & f_no_other_write))
-
 
4995
    setcaonly(i);
-
 
4996
  set_tag(name_intro, i);
5414
		kill_exp(arg1, arg1);
4997
 
-
 
4998
  return;
5415
		return arg2;
4999
}
5416
	}
5000
 
-
 
5001
exp f_xor
-
 
5002
    PROTO_N ( (arg1, arg2) )
-
 
5003
    PROTO_T ( exp arg1 X exp arg2 )
-
 
5004
{
-
 
5005
  if (name(sh(arg1)) == bothd)
-
 
5006
    { kill_exp(arg2,arg2); return arg1; }
-
 
5007
  if (name(sh(arg2)) == bothd)
-
 
5008
    { kill_exp(arg1,arg1); return arg2; }
-
 
5009
 
5417
 
5010
#if check_shape
5418
#if check_shape
5011
  if (!eq_shape(sh(arg1), sh(arg2)) || !is_integer(sh(arg1)))
5419
	if (!eq_shape(sh(arg1), sh(arg2)) || !is_integer(sh(arg1))) {
5012
    failer(CHSH_XOR);
5420
		failer(CHSH_XOR);
-
 
5421
	}
5013
#endif
5422
#endif
5014
#if !has64bits
5423
#if !has64bits
5015
	if (name(sh(arg1)) >= s64hd &&
5424
	if (name(sh(arg1)) >= s64hd &&
5016
		(name(arg1)!=val_tag || name(arg2) != val_tag)){
5425
	    (name(arg1) != val_tag || name(arg2) != val_tag)) {
5017
		return TDFcallop3(arg1,arg2,xor_tag);
5426
		return TDFcallop3(arg1, arg2, xor_tag);
5018
	}
5427
	}
5019
#endif
5428
#endif
5020
  return me_b2( arg1, arg2, xor_tag);
5429
	return me_b2(arg1, arg2, xor_tag);
5021
}
5430
}
-
 
5431
 
5022
 
5432
 
5023
void init_exp
5433
void
5024
    PROTO_Z ()
5434
init_exp(void)
5025
{
5435
{
5026
  freelist = nilexp;
5436
	freelist = nilexp;
5027
  exps_left = 0;
5437
	exps_left = 0;
5028
  crt_labno = 0;
5438
	crt_labno = 0;
5029
  global_case = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0, 0, 0);
5439
	global_case = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0, 0, 0);
5030
  in_initial_value = 0;
5440
	in_initial_value = 0;
5031
  	initial_value_pp.proc_struct_result = nilexp;
5441
	initial_value_pp.proc_struct_result = nilexp;
5032
  	initial_value_pp.has_alloca = 0;
5442
	initial_value_pp.has_alloca = 0;
5033
  	initial_value_pp.proc_is_recursive = 0;
5443
	initial_value_pp.proc_is_recursive = 0;
5034
  	initial_value_pp.uses_crt_env = 0;
5444
	initial_value_pp.uses_crt_env = 0;
5035
  	initial_value_pp.has_setjmp = 0;
5445
	initial_value_pp.has_setjmp = 0;
5036
  	initial_value_pp.uses_loc_address = 0;
5446
	initial_value_pp.uses_loc_address = 0;
5037
  	initial_value_pp.proc_label_count = 0;
5447
	initial_value_pp.proc_label_count = 0;
5038
  	initial_value_pp.proc_struct_res = 0;
5448
	initial_value_pp.proc_struct_res = 0;
5039
  	initial_value_pp.default_freq = default_freq;
5449
	initial_value_pp.default_freq = default_freq;
5040
  	initial_value_pp.proc_externs = 0;
5450
	initial_value_pp.proc_externs = 0;
5041
  	initial_value_pp.in_proc_def = 0;
5451
	initial_value_pp.in_proc_def = 0;
5042
  	initial_value_pp.pushed = (proc_props*)0;
5452
	initial_value_pp.pushed = (proc_props*)0;
5043
  	initial_value_pp.rep_make_proc = 0;
5453
	initial_value_pp.rep_make_proc = 0;
5044
  return;
5454
	return;
5045
}
5455
}
-
 
5456
 
5046
 
5457
 
5047
exp f_dummy_exp;
5458
exp f_dummy_exp;
5048
 
5459
 
5049
exp f_return_to_label
5460
exp
5050
    PROTO_N ( (e) )
-
 
5051
    PROTO_T ( exp e )
5461
f_return_to_label(exp e)
5052
{
5462
{
5053
	has_lv = 1;
5463
	has_lv = 1;
5054
	return me_u3(f_bottom, e, return_to_label_tag);
5464
	return me_u3(f_bottom, e, return_to_label_tag);
5055
}
5465
}
5056
 
5466
 
5057
 
5467
 
5058
 
5468
nat
5059
nat f_computed_nat
5469
f_computed_nat(exp arg)
5060
    PROTO_N ( (arg) )
-
 
5061
    PROTO_T ( exp arg )
-
 
5062
{
5470
{
5063
  nat res;
5471
	nat res;
5064
  if (name(arg) == val_tag)
5472
	if (name(arg) == val_tag) {
5065
   {
-
 
5066
     if (extra_checks && constovf(arg))
5473
		if (extra_checks && constovf(arg)) {
5067
       failer(ILLNAT);
5474
			failer(ILLNAT);
-
 
5475
		}
5068
 
5476
 
5069
     if (!isbigval(arg))  {
5477
		if (!isbigval(arg)) {
5070
       nat_issmall(res) = 1;
5478
			nat_issmall(res) = 1;
5071
       natint(res) = no(arg);
5479
			natint(res) = no(arg);
5072
       return res;
5480
			return res;
5073
     }
-
 
5074
     else  {
5481
		} else {
5075
       nat_issmall(res) = 0;
5482
			nat_issmall(res) = 0;
5076
       natbig(res) = no(arg);
5483
			natbig(res) = no(arg);
5077
       return res;
5484
			return res;
5078
     };
5485
		}
5079
   };
5486
	}
5080
 
5487
 
5081
  if (name(arg) == name_tag && !isvar(son(arg))) {
5488
	if (name(arg) == name_tag && !isvar(son(arg))) {
5082
    res = f_computed_nat(son(son(arg)));
5489
		res = f_computed_nat(son(son(arg)));
5083
    kill_exp(arg, arg);
5490
		kill_exp(arg, arg);
5084
    return res;
5491
		return res;
5085
  };
5492
	}
5086
 
5493
 
5087
  failer(ILLCOMPNAT);
5494
	failer(ILLCOMPNAT);
5088
  nat_issmall(res) = 1;
5495
	nat_issmall(res) = 1;
5089
  natint(res) = 1;
5496
	natint(res) = 1;
5090
  return res;
5497
	return res;
5091
}
5498
}
-
 
5499
 
5092
 
5500
 
5093
nat f_make_nat
5501
nat
5094
    PROTO_N ( (n) )
-
 
5095
    PROTO_T ( tdfint n )
5502
f_make_nat(tdfint n)
5096
{
5503
{
5097
  return n;
5504
	return n;
5098
}
5505
}
-
 
5506
 
5099
 
5507
 
5100
void init_nat
5508
void
5101
    PROTO_Z ()
5509
init_nat(void)
5102
{
5510
{
5103
  return;
5511
	return;
5104
}
5512
}
-
 
5513
 
5105
 
5514
 
5106
nat f_dummy_nat;
5515
nat f_dummy_nat;
5107
 
5516
 
5108
void init_ntest
5517
void
5109
    PROTO_Z ()
5518
init_ntest(void)
5110
{
5519
{
5111
  return;
5520
	return;
5112
}
5521
}
5113
 
5522
 
-
 
5523
 
5114
void init_otagexp
5524
void
5115
    PROTO_Z ()
5525
init_otagexp(void)
5116
{
5526
{
5117
	return;
5527
	return;
5118
}
5528
}
5119
 
5529
 
-
 
5530
 
-
 
5531
void
5120
void init_procprops
5532
init_procprops(void)
-
 
5533
{
-
 
5534
	return;
-
 
5535
}
-
 
5536
 
-
 
5537
 
5121
    PROTO_Z ()
5538
ntest f_dummy_ntest;
-
 
5539
 
-
 
5540
void
-
 
5541
init_rounding_mode(void)
5122
{
5542
{
5123
	return;
5543
	return;
5124
}
5544
}
5125
 
5545
 
5126
 
-
 
5127
 
-
 
5128
ntest f_dummy_ntest;
-
 
5129
 
-
 
5130
void init_rounding_mode
-
 
5131
    PROTO_Z ()
-
 
5132
{
-
 
5133
  return;
-
 
5134
}
-
 
5135
 
5546
 
5136
rounding_mode f_dummy_rounding_mode;
5547
rounding_mode f_dummy_rounding_mode;
5137
 
5548
 
5138
shape f_bitfield
5549
shape
5139
    PROTO_N ( (bf_var) )
-
 
5140
    PROTO_T ( bitfield_variety bf_var )
5550
f_bitfield(bitfield_variety bf_var)
5141
{
-
 
5142
  return getshape(bf_var.has_sign, const_al1, const_al1,
-
 
5143
                   BF_ALIGN, bf_var.bits, bitfhd);
-
 
5144
 
-
 
5145
}
-
 
5146
 
-
 
5147
shape f_compound
-
 
5148
    PROTO_N ( (off) )
-
 
5149
    PROTO_T ( exp off )
-
 
5150
{
-
 
5151
  int sz;
-
 
5152
  if (name(off)==val_tag)
-
 
5153
    sz = no(off);
-
 
5154
  else
-
 
5155
    {failer(ILLCPDOFFSET);
-
 
5156
     sz = 0;
-
 
5157
    };
-
 
5158
  return getshape(0, const_al1, const_al1,
-
 
5159
		   al1_of(sh(off)),
-
 
5160
		   sz, cpdhd);
-
 
5161
}
-
 
5162
 
-
 
5163
shape f_floating
-
 
5164
    PROTO_N ( (fv) )
-
 
5165
    PROTO_T ( floating_variety fv )
-
 
5166
{
-
 
5167
  switch (fv)
-
 
5168
   {
-
 
5169
     case shrealfv:
-
 
5170
          return shrealsh;
-
 
5171
     case realfv:
-
 
5172
	  return realsh;
-
 
5173
     case doublefv:
-
 
5174
          return doublesh;
-
 
5175
     case shcomplexfv:
-
 
5176
	  return shcomplexsh;
-
 
5177
     case complexfv:
-
 
5178
	  return complexsh;
-
 
5179
     case complexdoublefv:
-
 
5180
	  return complexdoublesh;
-
 
5181
   };
-
 
5182
   return realsh;
-
 
5183
}
-
 
5184
 
-
 
5185
shape f_integer
-
 
5186
    PROTO_N ( (var) )
-
 
5187
    PROTO_T ( variety var )
-
 
5188
{
-
 
5189
  return var;
-
 
5190
}
-
 
5191
 
-
 
5192
shape f_nof
-
 
5193
    PROTO_N ( (n, s) )
-
 
5194
    PROTO_T ( nat n X shape s )
-
 
5195
{
-
 
5196
  if (doing_aldefs)
-
 
5197
    return s;
-
 
5198
  else  {
-
 
5199
    int al = shape_align(s);
-
 
5200
    int sz = rounder (shape_size(s), al);
-
 
5201
    int nm = (int)name(s);
-
 
5202
    int nofsz = natint(n)*sz;
-
 
5203
    shape res;
-
 
5204
    if (name(s) == nofhd)
-
 
5205
      nm = ptno(s);
-
 
5206
#if !has64bits
-
 
5207
    if (!nat_issmall(n))
-
 
5208
      failer(TOO_BIG_A_VECTOR);
-
 
5209
#endif
-
 
5210
    if (name(s) == tophd) {
-
 
5211
	/* pathological - make it nof(0, char) */
-
 
5212
	res = getshape(0, const_al1, const_al1,align_of(ucharsh), 0, nofhd);
-
 
5213
    }
-
 
5214
    else
-
 
5215
    if (al == 1) {
-
 
5216
        if ( (sz &(sz-1)) != 0 && nofsz > BF_STORE_UNIT) {
-
 
5217
		IGNORE fprintf(stderr, "Warning: Bitfields of nof cannot all be variety enclosed \n");
-
 
5218
	}
-
 
5219
	if ((sz &(sz-1)) == 0 || nofsz > BF_STORE_UNIT) {
-
 
5220
		shape news = containedshape(sz,1);
-
 
5221
		int nsz = shape_align(news);
-
 
5222
		int newn = rounder(nofsz, nsz);
-
 
5223
		res = getshape(0, const_al1, const_al1, align_of(news),
-
 
5224
				newn, nofhd);
-
 
5225
	}
-
 
5226
	else {
-
 
5227
		shape news = containedshape(nofsz,1);
-
 
5228
		res = getshape(0, const_al1, const_al1, align_of(news),
-
 
5229
				shape_size(news), cpdhd);
-
 
5230
 
-
 
5231
	}
-
 
5232
 
-
 
5233
    }
-
 
5234
    else {
-
 
5235
    	res = getshape(0, const_al1, const_al1, align_of(s), nofsz, nofhd);
-
 
5236
    }
-
 
5237
 
-
 
5238
    ptno(res) = nm;	/* set the pt field of the shape to the
-
 
5239
			   shapemacs.h hd identifier of the shape */
-
 
5240
    return res;
-
 
5241
  };
-
 
5242
}
-
 
5243
 
-
 
5244
shape f_offset
-
 
5245
    PROTO_N ( (arg1, arg2) )
-
 
5246
    PROTO_T ( alignment arg1 X alignment arg2 )
-
 
5247
{
-
 
5248
    /* use values pre-computed by init since we never alter shapes */
-
 
5249
  if (arg1->al.al_n != 1 || arg2->al.al_n != 1 ||
-
 
5250
       arg1->al.sh_hd != 0 || arg2->al.sh_hd != 0
-
 
5251
     || arg1->al.al_val.al_frame !=0 || arg2->al.al_val.al_frame != 0)
-
 
5252
    return getshape(0, arg1, arg2, OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5253
 
-
 
5254
 /* use values pre-computed by init since we never alter shapes */
-
 
5255
  switch (arg1->al.al_val.al)
-
 
5256
   {
-
 
5257
     case 512:
-
 
5258
       switch (arg2->al.al_val.al)
-
 
5259
        {
-
 
5260
          case 512: return f_off512_512;
-
 
5261
          case 64: return f_off512_64;
-
 
5262
          case 32: return f_off512_32;
-
 
5263
          case 16: return f_off512_16;
-
 
5264
          case 8: return f_off512_8;
-
 
5265
          case 1: return f_off512_1;
-
 
5266
          default: failer(ILLOFF2); return f_off64_8;
-
 
5267
        };
-
 
5268
     case 64:
-
 
5269
       switch (arg2->al.al_val.al)
-
 
5270
        {
-
 
5271
          case 64: return f_off64_64;
-
 
5272
          case 32: return f_off64_32;
-
 
5273
          case 16: return f_off64_16;
-
 
5274
          case 8: return f_off64_8;
-
 
5275
          case 1: return f_off64_1;
-
 
5276
          default: failer(ILLOFF2); return f_off64_8;
-
 
5277
        };
-
 
5278
     case 32:
-
 
5279
       switch (arg2->al.al_val.al)
-
 
5280
        {
-
 
5281
          case 32: return f_off32_32;
-
 
5282
          case 16: return f_off32_16;
-
 
5283
          case 8: return f_off32_8;
-
 
5284
          case 1: return f_off32_1;
-
 
5285
          default: failer(ILLOFF2); return f_off32_8;
-
 
5286
        };
-
 
5287
     case 16:
-
 
5288
       switch (arg2->al.al_val.al)
-
 
5289
        {
-
 
5290
          case 16: return f_off16_16;
-
 
5291
          case 8: return f_off16_8;
-
 
5292
          case 1: return f_off16_1;
-
 
5293
          default: failer(ILLOFF2); return f_off16_8;
-
 
5294
        };
-
 
5295
     case 8:
-
 
5296
       switch (arg2->al.al_val.al)
-
 
5297
        {
-
 
5298
          case 8: return f_off8_8;
-
 
5299
          case 1: return f_off8_1;
-
 
5300
          default: failer(ILLOFF2); return f_off8_8;
-
 
5301
        };
-
 
5302
     case 1:
-
 
5303
       switch (arg2->al.al_val.al)
-
 
5304
        {
-
 
5305
          case 1: return f_off1_1;
-
 
5306
          default: failer(ILLOFF2); return f_off1_1;
-
 
5307
        };
-
 
5308
     default: failer(ILLOFF1); return f_off8_8;
-
 
5309
   };
-
 
5310
}
-
 
5311
 
-
 
5312
static shape frame_ptrs[32];
-
 
5313
 
-
 
5314
static struct SAL{alignment al; shape ptr_sh; struct SAL * rest;} * cache_pashs;
-
 
5315
 
-
 
5316
shape f_pointer
-
 
5317
    PROTO_N ( (arg) )
-
 
5318
    PROTO_T ( alignment arg )
-
 
5319
{
-
 
5320
    /* use values pre-computed by init since we never alter shapes */
-
 
5321
  int af = arg->al.al_val.al_frame;
-
 
5322
  if (arg->al.al_n != 1 && af == 0)
-
 
5323
    return getshape(0, arg, const_al1, PTR_ALIGN, PTR_SZ, ptrhd);
-
 
5324
  if (af != 0) {
-
 
5325
	if (frame_ptrs[af] == (shape)0) {
-
 
5326
		frame_ptrs[af] =
-
 
5327
			getshape(0, arg, const_al1, PTR_ALIGN, PTR_SZ, ptrhd);
-
 
5328
	}
-
 
5329
	return frame_ptrs[af];
-
 
5330
  }
-
 
5331
  if (arg->al.sh_hd !=0) {
-
 
5332
	struct SAL * c = cache_pashs;
-
 
5333
	shape res;
-
 
5334
	while (c != (struct SAL*)0) {
-
 
5335
		if (arg == c->al) return c->ptr_sh;
-
 
5336
		c = c->rest;
-
 
5337
	}
-
 
5338
	res = getshape(0, arg, const_al1, PTR_ALIGN, PTR_SZ, ptrhd);
-
 
5339
	c = (struct SAL*)xmalloc(sizeof(struct SAL));
-
 
5340
	c->al = arg; c->ptr_sh = res; c->rest = cache_pashs;
-
 
5341
	cache_pashs = c;
-
 
5342
	return res;
-
 
5343
  }
-
 
5344
 
-
 
5345
  switch (arg->al.al_val.al)
-
 
5346
   {
-
 
5347
     case 1: return f_ptr1;
-
 
5348
     case 8: return f_ptr8;
-
 
5349
     case 16: return f_ptr16;
-
 
5350
     case 32: return f_ptr32;
-
 
5351
     case 64: return f_ptr64;
-
 
5352
     default: failer(ILLALIGN); return f_ptr8;
-
 
5353
   };
-
 
5354
}
-
 
5355
 
-
 
5356
shape f_proc;
-
 
5357
 
-
 
5358
void init_shape
-
 
5359
    PROTO_Z ()
-
 
5360
{
5551
{
5361
   /* pre-compute values for use in f_pointer and f_offset */
5552
	return getshape(bf_var.has_sign, const_al1, const_al1, BF_ALIGN,
-
 
5553
			bf_var.bits, bitfhd);
-
 
5554
}
-
 
5555
 
5362
 
5556
 
-
 
5557
shape
-
 
5558
f_compound(exp off)
-
 
5559
{
5363
  int i;
5560
	int sz;
-
 
5561
	if (name(off) ==val_tag) {
-
 
5562
		sz = no(off);
-
 
5563
	} else {
-
 
5564
		failer(ILLCPDOFFSET);
-
 
5565
		sz = 0;
-
 
5566
	}
-
 
5567
	return getshape(0, const_al1, const_al1, al1_of(sh(off)), sz, cpdhd);
-
 
5568
}
-
 
5569
 
-
 
5570
 
-
 
5571
shape
-
 
5572
f_floating(floating_variety fv)
-
 
5573
{
-
 
5574
	switch (fv)
-
 
5575
	{
-
 
5576
	case shrealfv:
-
 
5577
		return shrealsh;
-
 
5578
	case realfv:
-
 
5579
		return realsh;
-
 
5580
	case doublefv:
-
 
5581
		return doublesh;
-
 
5582
	case shcomplexfv:
-
 
5583
		return shcomplexsh;
-
 
5584
	case complexfv:
-
 
5585
		return complexsh;
-
 
5586
	case complexdoublefv:
-
 
5587
		return complexdoublesh;
-
 
5588
	}
-
 
5589
	return realsh;
-
 
5590
}
-
 
5591
 
-
 
5592
 
-
 
5593
shape
-
 
5594
f_integer(variety var)
-
 
5595
{
-
 
5596
	return var;
-
 
5597
}
-
 
5598
 
-
 
5599
 
-
 
5600
shape
-
 
5601
f_nof(nat n, shape s)
-
 
5602
{
-
 
5603
	if (doing_aldefs) {
-
 
5604
		return s;
-
 
5605
	} else {
-
 
5606
		int al = shape_align(s);
5364
  for(i=0; i<32; i++) frame_ptrs[i] = (shape)0;
5607
		int sz = rounder(shape_size(s), al);
-
 
5608
		int nm = (int)name(s);
5365
  cache_pashs = (struct SAL*)0;
5609
		int nofsz = natint(n)*sz;
-
 
5610
		shape res;
-
 
5611
		if (name(s) == nofhd) {
-
 
5612
			nm = ptno(s);
-
 
5613
		}
-
 
5614
#if !has64bits
-
 
5615
		if (!nat_issmall(n)) {
-
 
5616
			failer(TOO_BIG_A_VECTOR);
-
 
5617
		}
-
 
5618
#endif
-
 
5619
		if (name(s) == tophd) {
-
 
5620
			/* pathological - make it nof(0, char) */
-
 
5621
			res = getshape(0, const_al1, const_al1,
-
 
5622
				       align_of(ucharsh), 0, nofhd);
-
 
5623
		} else if (al == 1) {
-
 
5624
			if ((sz & (sz - 1)) != 0 && nofsz > BF_STORE_UNIT) {
-
 
5625
				IGNORE fprintf(stderr, "Warning: Bitfields of nof cannot all be variety enclosed \n");
-
 
5626
			}
-
 
5627
			if ((sz & (sz - 1)) == 0 || nofsz > BF_STORE_UNIT) {
-
 
5628
				shape news = containedshape(sz, 1);
-
 
5629
				int nsz = shape_align(news);
-
 
5630
				int newn = rounder(nofsz, nsz);
-
 
5631
				res = getshape(0, const_al1, const_al1,
-
 
5632
					       align_of(news), newn, nofhd);
-
 
5633
			} else {
-
 
5634
				shape news = containedshape(nofsz, 1);
-
 
5635
				res = getshape(0, const_al1, const_al1,
-
 
5636
					       align_of(news), shape_size(news),
-
 
5637
					       cpdhd);
-
 
5638
			}
-
 
5639
		} else {
-
 
5640
			res = getshape(0, const_al1, const_al1, align_of(s),
-
 
5641
				       nofsz, nofhd);
-
 
5642
		}
-
 
5643
 
-
 
5644
		ptno(res) = nm;	/* set the pt field of the shape to the
-
 
5645
				   shapemacs.h hd identifier of the shape */
-
 
5646
		return res;
-
 
5647
	}
-
 
5648
}
5366
 
5649
 
5367
  f_bottom = getshape(0, const_al1, const_al1, const_al1, 0, bothd);
-
 
5368
 
-
 
5369
  f_top = getshape(0, const_al1, const_al1, TOP_ALIGN, TOP_SZ, tophd);
-
 
5370
 
-
 
5371
  f_proc = getshape(0, const_al1, const_al1, PROC_ALIGN, PROC_SZ, prokhd);
-
 
5372
 
-
 
5373
  f_ptr1 = getshape(0, const_al1, const_al1, PTR_ALIGN, PTRBIT_SZ, ptrhd);
-
 
5374
 
-
 
5375
  f_ptr8 = getshape(0, const_al8, const_al1, PTR_ALIGN, PTR_SZ, ptrhd);
-
 
5376
  f_local_label_value = f_ptr8;
-
 
5377
 
-
 
5378
  f_ptr16 = getshape(0, const_al16, const_al1, PTR_ALIGN, PTR_SZ, ptrhd);
-
 
5379
 
5650
 
-
 
5651
shape
-
 
5652
f_offset(alignment arg1, alignment arg2)
-
 
5653
{
-
 
5654
	/* use values pre-computed by init since we never alter shapes */
-
 
5655
	if (arg1->al.al_n != 1 || arg2->al.al_n != 1 || arg1->al.sh_hd != 0 ||
-
 
5656
	    arg2->al.sh_hd != 0 || arg1->al.al_val.al_frame != 0 ||
-
 
5657
	    arg2->al.al_val.al_frame != 0) {
5380
  f_ptr32 = getshape(0, const_al32, const_al1, PTR_ALIGN, PTR_SZ, ptrhd);
5658
		return getshape(0, arg1, arg2, OFFSET_ALIGN, OFFSET_SZ,
-
 
5659
				offsethd);
-
 
5660
	}
-
 
5661
 
-
 
5662
	/* use values pre-computed by init since we never alter shapes */
-
 
5663
	switch (arg1->al.al_val.al) {
-
 
5664
	case 512:
-
 
5665
		switch (arg2->al.al_val.al) {
-
 
5666
		case 512:
-
 
5667
			return f_off512_512;
-
 
5668
		case 64:
-
 
5669
			return f_off512_64;
-
 
5670
		case 32:
-
 
5671
			return f_off512_32;
-
 
5672
		case 16:
-
 
5673
			return f_off512_16;
-
 
5674
		case 8:
-
 
5675
			return f_off512_8;
-
 
5676
		case 1:
-
 
5677
			return f_off512_1;
-
 
5678
		default:
-
 
5679
			failer(ILLOFF2);
-
 
5680
			return f_off64_8;
-
 
5681
		}
-
 
5682
	case 64:
-
 
5683
		switch (arg2->al.al_val.al) {
-
 
5684
		case 64:
-
 
5685
			return f_off64_64;
-
 
5686
		case 32:
-
 
5687
			return f_off64_32;
-
 
5688
		case 16:
-
 
5689
			return f_off64_16;
-
 
5690
		case 8:
-
 
5691
			return f_off64_8;
-
 
5692
		case 1:
-
 
5693
			return f_off64_1;
-
 
5694
		default:
-
 
5695
			failer(ILLOFF2);
-
 
5696
			return f_off64_8;
-
 
5697
		}
-
 
5698
	case 32:
-
 
5699
		switch (arg2->al.al_val.al) {
-
 
5700
		case 32:
-
 
5701
			return f_off32_32;
-
 
5702
		case 16:
-
 
5703
			return f_off32_16;
-
 
5704
		case 8:
-
 
5705
			return f_off32_8;
-
 
5706
		case 1:
-
 
5707
			return f_off32_1;
-
 
5708
		default:
-
 
5709
			failer(ILLOFF2);
-
 
5710
			return f_off32_8;
-
 
5711
		}
-
 
5712
	case 16:
-
 
5713
		switch (arg2->al.al_val.al) {
-
 
5714
		case 16:
-
 
5715
			return f_off16_16;
-
 
5716
		case 8:
-
 
5717
			return f_off16_8;
-
 
5718
		case 1:
-
 
5719
			return f_off16_1;
-
 
5720
		default:
-
 
5721
			failer(ILLOFF2);
-
 
5722
			return f_off16_8;
-
 
5723
		}
-
 
5724
	case 8:
-
 
5725
		switch (arg2->al.al_val.al) {
-
 
5726
		case 8:
-
 
5727
			return f_off8_8;
-
 
5728
		case 1:
-
 
5729
			return f_off8_1;
-
 
5730
		default:
-
 
5731
			failer(ILLOFF2);
-
 
5732
			return f_off8_8;
-
 
5733
		}
-
 
5734
	case 1:
-
 
5735
		switch (arg2->al.al_val.al) {
-
 
5736
		case 1:
-
 
5737
			return f_off1_1;
-
 
5738
		default:
-
 
5739
			failer(ILLOFF2);
-
 
5740
			return f_off1_1;
-
 
5741
		}
-
 
5742
	default:
-
 
5743
		failer(ILLOFF1);
-
 
5744
		return f_off8_8;
-
 
5745
	}
-
 
5746
}
-
 
5747
 
5381
 
5748
 
5382
  f_ptr64 = getshape(0, const_al64, const_al1, PTR_ALIGN, PTR_SZ, ptrhd);
5749
static shape frame_ptrs[32];
5383
 
5750
 
5384
  f_off1_1 = getshape(1, const_al1, const_al1,
5751
static struct SAL {
-
 
5752
	alignment al;
-
 
5753
	shape ptr_sh;
5385
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
5754
	struct SAL *rest;
-
 
5755
} *cache_pashs;
5386
 
5756
 
-
 
5757
shape
-
 
5758
f_pointer(alignment arg)
-
 
5759
{
-
 
5760
	/* use values pre-computed by init since we never alter shapes */
5387
  f_off0_0 = getshape(1, const_al1, const_al1,
5761
	int af = arg->al.al_val.al_frame;
-
 
5762
	if (arg->al.al_n != 1 && af == 0) {
5388
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
5763
		return getshape(0, arg, const_al1, PTR_ALIGN, PTR_SZ, ptrhd);
5389
 
5764
	}
-
 
5765
	if (af != 0) {
-
 
5766
		if (frame_ptrs[af] == (shape)0) {
5390
  f_off8_8 = getshape(1, const_al8, const_al8,
5767
			frame_ptrs[af] = getshape(0, arg, const_al1, PTR_ALIGN,
5391
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
5768
						  PTR_SZ, ptrhd);
-
 
5769
		}
-
 
5770
		return frame_ptrs[af];
5392
 
5771
	}
-
 
5772
	if (arg->al.sh_hd != 0) {
-
 
5773
		struct SAL *c = cache_pashs;
-
 
5774
		shape res;
5393
  f_off8_1 = getshape(1, const_al8, const_al1,
5775
		while (c != (struct SAL*)0) {
5394
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
5776
			if (arg == c->al) return c->ptr_sh;
-
 
5777
			c = c->rest;
5395
 
5778
		}
5396
  f_off16_16 = getshape(1, const_al16, const_al16,
5779
		res = getshape(0, arg, const_al1, PTR_ALIGN, PTR_SZ, ptrhd);
-
 
5780
		c = (struct SAL*)xmalloc(sizeof(struct SAL));
5397
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
5781
		c->al = arg; c->ptr_sh = res; c->rest = cache_pashs;
-
 
5782
		cache_pashs = c;
-
 
5783
		return res;
-
 
5784
	}
5398
 
5785
 
5399
  f_off16_8 = getshape(1, const_al16, const_al8,
5786
	switch (arg->al.al_val.al)
5400
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5401
 
5787
	{
-
 
5788
	case 1: return f_ptr1;
-
 
5789
	case 8: return f_ptr8;
5402
  f_off16_1 = getshape(1, const_al16, const_al1,
5790
	case 16: return f_ptr16;
-
 
5791
	case 32: return f_ptr32;
-
 
5792
	case 64: return f_ptr64;
5403
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
5793
	default: failer(ILLALIGN); return f_ptr8;
-
 
5794
	};
-
 
5795
}
5404
 
5796
 
5405
  f_off32_32 = getshape(1, const_al32, const_al32,
-
 
5406
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5407
 
5797
 
5408
  f_off32_16 = getshape(1, const_al32, const_al16,
-
 
5409
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5410
 
-
 
5411
  f_off32_8 = getshape(1, const_al32, const_al8,
5798
shape f_proc;
5412
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5413
 
5799
 
5414
  f_off32_1 = getshape(1, const_al32, const_al1,
-
 
5415
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5416
 
-
 
5417
  f_off64_64 = getshape(1, const_al64, const_al64,
-
 
5418
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5419
 
-
 
5420
  f_off64_32 = getshape(1, const_al64, const_al32,
-
 
5421
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5422
 
-
 
5423
  f_off64_16 = getshape(1, const_al64, const_al16,
-
 
5424
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5425
 
-
 
5426
  f_off64_8 = getshape(1, const_al64, const_al8,
-
 
5427
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5428
 
-
 
5429
  f_off64_1 = getshape(1, const_al64, const_al1,
-
 
5430
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5431
 
-
 
5432
  f_off512_512 = getshape(1, const_al512, const_al512,
-
 
5433
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5434
 
-
 
5435
  f_off512_64 = getshape(1, const_al512, const_al64,
-
 
5436
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5437
 
-
 
5438
  f_off512_32 = getshape(1, const_al512, const_al32,
-
 
5439
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5440
 
-
 
5441
  f_off512_16 = getshape(1, const_al512, const_al16,
-
 
5442
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5443
 
-
 
5444
  f_off512_8 = getshape(1, const_al512, const_al8,
-
 
5445
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5446
 
-
 
5447
  f_off512_1 = getshape(1, const_al512, const_al1,
-
 
5448
                        OFFSET_ALIGN, OFFSET_SZ, offsethd);
-
 
5449
 
-
 
5450
  return;
-
 
5451
}
5800
void
5452
 
-
 
5453
shape f_dummy_shape;
-
 
5454
 
-
 
5455
 
-
 
5456
signed_nat f_computed_signed_nat
5801
init_shape(void)
5457
    PROTO_N ( (arg) )
-
 
5458
    PROTO_T ( exp arg )
-
 
5459
{
5802
{
5460
  signed_nat res;
-
 
5461
  if (name(arg) == val_tag)
-
 
5462
   {
-
 
5463
     if (extra_checks && constovf(arg))
-
 
5464
       failer(ILLNAT);
-
 
5465
 
-
 
5466
     if (!isbigval(arg)) {
-
 
5467
       snat_issmall(res) = 1;
-
 
5468
       if (!is_signed(sh(arg)))
-
 
5469
        {
-
 
5470
         snatneg(res) = 0;
-
 
5471
         snatint(res) = no(arg);
-
 
5472
        }
-
 
5473
       else
-
 
5474
        {if (no(arg) < 0)
-
 
5475
          {
-
 
5476
            snatneg(res) = 1;
-
 
5477
            snatint(res) = -no(arg);
-
 
5478
          }
-
 
5479
         else
-
 
5480
          {
-
 
5481
            snatneg(res) = 0;
-
 
5482
            snatint(res) = no(arg);
-
 
5483
          }
-
 
5484
        };
-
 
5485
       return res;
-
 
5486
     }
-
 
5487
     else  {
-
 
5488
       snat_issmall(res) = 0;
-
 
5489
       snatneg(res) = (bool)(flptnos[no(arg)].sign == -1);
5803
	/* pre-compute values for use in f_pointer and f_offset */
5490
       flptnos[no(arg)].sign = 1;
-
 
5491
       snatint(res) = no(arg);
-
 
5492
       return res;
-
 
5493
     };
-
 
5494
  };
-
 
5495
 
5804
 
-
 
5805
	int i;
-
 
5806
	for (i = 0; i < 32; i++) {
-
 
5807
		frame_ptrs[i] = (shape)0;
-
 
5808
	}
-
 
5809
	cache_pashs = (struct SAL *)0;
-
 
5810
 
5496
  if (name(arg) == name_tag && !isvar(son(arg))) {
5811
	f_bottom = getshape(0, const_al1, const_al1, const_al1, 0, bothd);
-
 
5812
 
-
 
5813
	f_top = getshape(0, const_al1, const_al1, TOP_ALIGN, TOP_SZ, tophd);
-
 
5814
 
-
 
5815
	f_proc = getshape(0, const_al1, const_al1, PROC_ALIGN, PROC_SZ, prokhd);
-
 
5816
 
-
 
5817
	f_ptr1 = getshape(0, const_al1, const_al1, PTR_ALIGN, PTRBIT_SZ, ptrhd);
-
 
5818
 
-
 
5819
	f_ptr8 = getshape(0, const_al8, const_al1, PTR_ALIGN, PTR_SZ, ptrhd);
5497
    res = f_computed_signed_nat(son(son(arg)));
5820
	f_local_label_value = f_ptr8;
-
 
5821
 
-
 
5822
	f_ptr16 = getshape(0, const_al16, const_al1, PTR_ALIGN, PTR_SZ, ptrhd);
-
 
5823
 
-
 
5824
	f_ptr32 = getshape(0, const_al32, const_al1, PTR_ALIGN, PTR_SZ, ptrhd);
-
 
5825
 
-
 
5826
	f_ptr64 = getshape(0, const_al64, const_al1, PTR_ALIGN, PTR_SZ, ptrhd);
-
 
5827
 
-
 
5828
	f_off1_1 = getshape(1, const_al1, const_al1, OFFSET_ALIGN, OFFSET_SZ,
-
 
5829
			    offsethd);
-
 
5830
 
-
 
5831
	f_off0_0 = getshape(1, const_al1, const_al1, OFFSET_ALIGN, OFFSET_SZ,
-
 
5832
			    offsethd);
-
 
5833
 
-
 
5834
	f_off8_8 = getshape(1, const_al8, const_al8, OFFSET_ALIGN, OFFSET_SZ,
-
 
5835
			    offsethd);
-
 
5836
 
-
 
5837
	f_off8_1 = getshape(1, const_al8, const_al1, OFFSET_ALIGN, OFFSET_SZ,
-
 
5838
			    offsethd);
-
 
5839
 
-
 
5840
	f_off16_16 = getshape(1, const_al16, const_al16, OFFSET_ALIGN,
-
 
5841
			      OFFSET_SZ, offsethd);
-
 
5842
 
-
 
5843
	f_off16_8 = getshape(1, const_al16, const_al8, OFFSET_ALIGN, OFFSET_SZ,
-
 
5844
			     offsethd);
-
 
5845
 
-
 
5846
	f_off16_1 = getshape(1, const_al16, const_al1, OFFSET_ALIGN, OFFSET_SZ,
-
 
5847
			     offsethd);
-
 
5848
 
-
 
5849
	f_off32_32 = getshape(1, const_al32, const_al32, OFFSET_ALIGN,
-
 
5850
			      OFFSET_SZ, offsethd);
-
 
5851
 
-
 
5852
	f_off32_16 = getshape(1, const_al32, const_al16, OFFSET_ALIGN,
-
 
5853
			      OFFSET_SZ, offsethd);
-
 
5854
 
-
 
5855
	f_off32_8 = getshape(1, const_al32, const_al8, OFFSET_ALIGN, OFFSET_SZ,
-
 
5856
			     offsethd);
-
 
5857
 
-
 
5858
	f_off32_1 = getshape(1, const_al32, const_al1, OFFSET_ALIGN, OFFSET_SZ,
-
 
5859
			     offsethd);
-
 
5860
 
-
 
5861
	f_off64_64 = getshape(1, const_al64, const_al64, OFFSET_ALIGN,
-
 
5862
			      OFFSET_SZ, offsethd);
-
 
5863
 
-
 
5864
	f_off64_32 = getshape(1, const_al64, const_al32, OFFSET_ALIGN,
-
 
5865
			      OFFSET_SZ, offsethd);
-
 
5866
 
-
 
5867
	f_off64_16 = getshape(1, const_al64, const_al16, OFFSET_ALIGN,
5498
    kill_exp(arg, arg);
5868
			      OFFSET_SZ, offsethd);
-
 
5869
 
-
 
5870
	f_off64_8 = getshape(1, const_al64, const_al8, OFFSET_ALIGN, OFFSET_SZ,
-
 
5871
			     offsethd);
-
 
5872
 
-
 
5873
	f_off64_1 = getshape(1, const_al64, const_al1, OFFSET_ALIGN, OFFSET_SZ,
5499
    return res;
5874
			     offsethd);
-
 
5875
 
-
 
5876
	f_off512_512 = getshape(1, const_al512, const_al512, OFFSET_ALIGN,
-
 
5877
				OFFSET_SZ, offsethd);
-
 
5878
 
-
 
5879
	f_off512_64 = getshape(1, const_al512, const_al64, OFFSET_ALIGN,
-
 
5880
			       OFFSET_SZ, offsethd);
-
 
5881
 
-
 
5882
	f_off512_32 = getshape(1, const_al512, const_al32, OFFSET_ALIGN,
-
 
5883
			       OFFSET_SZ, offsethd);
-
 
5884
 
-
 
5885
	f_off512_16 = getshape(1, const_al512, const_al16, OFFSET_ALIGN,
-
 
5886
			       OFFSET_SZ, offsethd);
-
 
5887
 
-
 
5888
	f_off512_8 = getshape(1, const_al512, const_al8, OFFSET_ALIGN,
-
 
5889
			      OFFSET_SZ, offsethd);
5500
  };
5890
 
-
 
5891
	f_off512_1 = getshape(1, const_al512, const_al1, OFFSET_ALIGN,
-
 
5892
			      OFFSET_SZ, offsethd);
5501
 
5893
 
-
 
5894
	return;
-
 
5895
}
-
 
5896
 
-
 
5897
 
-
 
5898
shape f_dummy_shape;
-
 
5899
 
-
 
5900
signed_nat
-
 
5901
f_computed_signed_nat(exp arg)
-
 
5902
{
-
 
5903
	signed_nat res;
-
 
5904
	if (name(arg) == val_tag) {
-
 
5905
		if (extra_checks && constovf(arg)) {
-
 
5906
			failer(ILLNAT);
-
 
5907
		}
-
 
5908
 
-
 
5909
		if (!isbigval(arg)) {
-
 
5910
			snat_issmall(res) = 1;
-
 
5911
			if (!is_signed(sh(arg))) {
-
 
5912
				snatneg(res) = 0;
-
 
5913
				snatint(res) = no(arg);
-
 
5914
			} else {
-
 
5915
				if (no(arg) < 0) {
-
 
5916
					snatneg(res) = 1;
-
 
5917
					snatint(res) = -no(arg);
-
 
5918
				} else {
-
 
5919
					snatneg(res) = 0;
-
 
5920
					snatint(res) = no(arg);
-
 
5921
				}
-
 
5922
			}
-
 
5923
			return res;
-
 
5924
		} else {
-
 
5925
			snat_issmall(res) = 0;
-
 
5926
			snatneg(res) = (bool)(flptnos[no(arg)].sign == -1);
-
 
5927
			flptnos[no(arg)].sign = 1;
-
 
5928
			snatint(res) = no(arg);
-
 
5929
			return res;
-
 
5930
		}
-
 
5931
	}
-
 
5932
 
-
 
5933
	if (name(arg) == name_tag && !isvar(son(arg))) {
-
 
5934
		res = f_computed_signed_nat(son(son(arg)));
-
 
5935
		kill_exp(arg, arg);
-
 
5936
		return res;
-
 
5937
	}
-
 
5938
 
5502
  failer(ILLCOMPSNAT);
5939
	failer(ILLCOMPSNAT);
5503
  snat_issmall(res) = 1;
5940
	snat_issmall(res) = 1;
5504
  snatneg(res) = 0;
5941
	snatneg(res) = 0;
5505
  snatint(res) = 1;
5942
	snatint(res) = 1;
-
 
5943
	return res;
-
 
5944
}
-
 
5945
 
-
 
5946
 
-
 
5947
signed_nat
-
 
5948
f_snat_from_nat(bool neg, nat n)
-
 
5949
{
-
 
5950
	signed_nat res;
-
 
5951
 
-
 
5952
	if (snat_issmall(n)) {
-
 
5953
		snatneg(res) = (bool)((natint(n) == 0) ? 0 : neg);
-
 
5954
		snat_issmall(res) = 1;
-
 
5955
		snatint(res) = natint(n);
5506
  return res;
5956
		return res;
-
 
5957
	}
-
 
5958
 
-
 
5959
	snat_issmall(res) = 0;
-
 
5960
	snatbig(res) = natbig(n);
-
 
5961
	snatneg(res) = neg;
-
 
5962
	return res;
-
 
5963
}
-
 
5964
 
-
 
5965
 
-
 
5966
signed_nat
-
 
5967
f_make_signed_nat(tdfbool neg, tdfint n)
-
 
5968
{
-
 
5969
	return f_snat_from_nat(neg, n);
-
 
5970
}
-
 
5971
 
-
 
5972
 
-
 
5973
void
-
 
5974
init_signed_nat(void)
-
 
5975
{
-
 
5976
	return;
5507
}
5977
}
5508
 
5978
 
5509
signed_nat f_snat_from_nat
-
 
5510
    PROTO_N ( (neg, n) )
-
 
5511
    PROTO_T ( bool neg X nat n )
-
 
5512
{
-
 
5513
  signed_nat res;
-
 
5514
 
-
 
5515
  if (snat_issmall(n))  {
-
 
5516
    snatneg(res) = (bool)((natint(n) == 0) ? 0 : neg);
-
 
5517
    snat_issmall(res) = 1;
-
 
5518
    snatint(res) = natint(n);
-
 
5519
    return res;
-
 
5520
  }
-
 
5521
 
-
 
5522
  snat_issmall(res) = 0;
-
 
5523
  snatbig(res) = natbig(n);
-
 
5524
  snatneg(res) = neg;
-
 
5525
  return res;
-
 
5526
}
-
 
5527
 
-
 
5528
signed_nat f_make_signed_nat
-
 
5529
    PROTO_N ( (neg, n) )
-
 
5530
    PROTO_T ( tdfbool neg X tdfint n )
-
 
5531
{
-
 
5532
  return f_snat_from_nat(neg, n);
-
 
5533
}
-
 
5534
 
-
 
5535
void init_signed_nat
-
 
5536
    PROTO_Z ()
-
 
5537
{
-
 
5538
   return;
-
 
5539
}
-
 
5540
 
5979
 
5541
signed_nat f_dummy_signed_nat;
5980
signed_nat f_dummy_signed_nat;
5542
 
5981
 
5543
string f_dummy_string;
5982
string f_dummy_string;
5544
 
5983
 
5545
void init_string
5984
void
5546
    PROTO_Z ()
5985
init_string(void)
5547
{
5986
{
5548
	return;
5987
	return;
5549
}
5988
}
5550
 
5989
 
-
 
5990
 
5551
string f_concat_string
5991
string
5552
    PROTO_N ( (a1, a2) )
-
 
5553
    PROTO_T ( string a1 X string a2 )
5992
f_concat_string(string a1, string a2)
5554
{
5993
{
5555
	int i;
5994
	int i;
5556
 	string res;
5995
	string res;
5557
	if (a1.size != a2.size) {
5996
	if (a1.size != a2.size) {
5558
		failer("Concatenated strings have different unit size");
5997
		failer("Concatenated strings have different unit size");
5559
	}
5998
	}
5560
	res.number = a1.number + a2.number;
5999
	res.number = a1.number + a2.number;
5561
	res.size = a1.size;
6000
	res.size = a1.size;
5562
	if (res.size<=8) {
6001
	if (res.size <= 8) {
5563
		res.ints.chars = (char*)xcalloc(res.number+1, sizeof(char));
6002
		res.ints.chars = (char *)xcalloc(res.number + 1, sizeof(char));
5564
		for (i=0; i<a1.number; i++)
6003
		for (i = 0; i < a1.number; i++) {
5565
			res.ints.chars[i] = a1.ints.chars[i];
6004
			res.ints.chars[i] = a1.ints.chars[i];
-
 
6005
		}
5566
		for (i=0; i<a2.number; i++)
6006
		for (i = 0; i < a2.number; i++) {
5567
			res.ints.chars[i+a1.number] = a2.ints.chars[i];
6007
			res.ints.chars[i + a1.number] = a2.ints.chars[i];
5568
		res.ints.chars[res.number]=0;
-
 
5569
	}
6008
		}
5570
	else
6009
		res.ints.chars[res.number] = 0;
5571
	if (res.size<=16) {
6010
	} else if (res.size <= 16) {
5572
		res.ints.shorts = (short*)xcalloc(res.number+1, sizeof(short));
6011
		res.ints.shorts = (short *)xcalloc(res.number + 1,
-
 
6012
						   sizeof(short));
5573
		for (i=0; i<a1.number; i++)
6013
		for (i = 0; i < a1.number; i++) {
5574
			res.ints.shorts[i] = a1.ints.shorts[i];
6014
			res.ints.shorts[i] = a1.ints.shorts[i];
-
 
6015
		}
5575
		for (i=0; i<a2.number; i++)
6016
		for (i = 0; i < a2.number; i++) {
5576
			res.ints.shorts[i+a1.number] = a2.ints.shorts[i];
6017
			res.ints.shorts[i + a1.number] = a2.ints.shorts[i];
-
 
6018
		}
5577
		res.ints.shorts[res.number]=0;
6019
		res.ints.shorts[res.number] =0;
5578
	}
-
 
5579
	else {
6020
	} else {
5580
		res.ints.longs = (int*)xcalloc(res.number+1, sizeof(int));
6021
		res.ints.longs = (int *)xcalloc(res.number + 1, sizeof(int));
5581
		for (i=0; i<a1.number; i++)
6022
		for (i = 0; i < a1.number; i++) {
5582
			res.ints.longs[i] = a1.ints.longs[i];
6023
			res.ints.longs[i] = a1.ints.longs[i];
-
 
6024
		}
5583
		for (i=0; i<a2.number; i++)
6025
		for (i = 0; i < a2.number; i++) {
5584
			res.ints.longs[i+a1.number] = a2.ints.longs[i];
6026
			res.ints.longs[i + a1.number] = a2.ints.longs[i];
-
 
6027
		}
5585
		res.ints.longs[res.number]=0;
6028
		res.ints.longs[res.number] =0;
5586
	}
6029
	}
5587
	return res;
6030
	return res;
5588
}
6031
}
-
 
6032
 
5589
 
6033
 
5590
string f_make_string
6034
string
5591
    PROTO_N ( (s) )
-
 
5592
    PROTO_T ( tdfstring s )
6035
f_make_string(tdfstring s)
5593
{
6036
{
5594
	return s;
6037
	return s;
5595
}
6038
}
-
 
6039
 
5596
 
6040
 
5597
tagshacc f_make_tagshacc
6041
tagshacc
5598
    PROTO_N ( (sha, visible, tg_intro) )
-
 
5599
    PROTO_T ( shape sha X access_option visible X tag tg_intro )
6042
f_make_tagshacc(shape sha, access_option visible, tag tg_intro)
5600
{
6043
{
5601
  tagshacc res;
6044
	tagshacc res;
5602
  res.sha = sha;
6045
	res.sha = sha;
5603
  res.visible = visible;
6046
	res.visible = visible;
5604
  res.tg = tg_intro;
6047
	res.tg = tg_intro;
5605
  return res;
6048
	return res;
5606
}
6049
}
-
 
6050
 
5607
 
6051
 
5608
void init_tagshacc
6052
void
5609
    PROTO_Z ()
6053
init_tagshacc(void)
5610
{
6054
{
5611
  return;
6055
	return;
5612
}
6056
}
-
 
6057
 
5613
 
6058
 
5614
transfer_mode f_dummy_transfer_mode;
6059
transfer_mode f_dummy_transfer_mode;
5615
 
6060
 
5616
transfer_mode f_add_modes
6061
transfer_mode
5617
    PROTO_N ( (md1, md2) )
-
 
5618
    PROTO_T ( transfer_mode md1 X transfer_mode md2 )
6062
f_add_modes(transfer_mode md1, transfer_mode md2)
5619
{
6063
{
5620
  return md1 | md2;
6064
	return md1 | md2;
5621
}
6065
}
5622
 
6066
 
5623
 
6067
 
-
 
6068
version
-
 
6069
f_user_info(tdfident t)
-
 
6070
{
5624
version f_user_info
6071
	version res;
-
 
6072
	UNUSED(t);
-
 
6073
	res.major_version = MAJOR_VERSION;
-
 
6074
	res.minor_version = MINOR_VERSION;
-
 
6075
	return res;
-
 
6076
}
-
 
6077
 
-
 
6078
 
-
 
6079
variety
-
 
6080
f_var_limits(signed_nat lower_bound, signed_nat upper_bound)
-
 
6081
{
-
 
6082
	unsigned int h;
-
 
6083
	unsigned int l;
-
 
6084
 
-
 
6085
	if (!snat_issmall(lower_bound) || !snat_issmall(upper_bound)) {
-
 
6086
		if (snatneg(lower_bound)) {
-
 
6087
			return s64sh;
-
 
6088
		} else {
-
 
6089
			return u64sh;
-
 
6090
		}
-
 
6091
	}
-
 
6092
 
-
 
6093
	/* normalise the varieties to use only the six standard ones */
-
 
6094
	l = (unsigned int)(snatint(lower_bound));
-
 
6095
	/* these assume the length of unsigned int equals int */
-
 
6096
	h = (unsigned int)(snatint(upper_bound));
-
 
6097
 
-
 
6098
	if (!snatneg(lower_bound)) {
5625
    PROTO_N ( (t) )
6099
		if (h <= 255) {
-
 
6100
			return ucharsh;
-
 
6101
		}
-
 
6102
		if (h <= 65535) {
-
 
6103
			return uwordsh;
-
 
6104
		}
-
 
6105
		return ulongsh;
-
 
6106
	}
-
 
6107
 
-
 
6108
	if (l <= 128 && h <= 127) {
-
 
6109
		return scharsh;
-
 
6110
	}
-
 
6111
	if (l<= 32768 && h <= 32767) {
-
 
6112
		return swordsh;
-
 
6113
	}
-
 
6114
 
-
 
6115
	return slongsh;
-
 
6116
}
-
 
6117
 
-
 
6118
 
-
 
6119
variety
5626
    PROTO_T ( tdfident t )
6120
f_var_width(bool sig, nat bits)
5627
{
6121
{
-
 
6122
	int w = natint(bits);
-
 
6123
	if (sig) {
-
 
6124
		if (w <= 8) {
-
 
6125
			return scharsh;
-
 
6126
		}
-
 
6127
		if (w <= 16) {
5628
  version res;
6128
			return swordsh;
-
 
6129
		}
5629
  UNUSED(t);
6130
		if (w <= 32) {
5630
  res.major_version = MAJOR_VERSION;
6131
			return slongsh;
-
 
6132
		}
-
 
6133
		if (w <= 64) {
-
 
6134
			return s64sh;
-
 
6135
		}
5631
  res.minor_version = MINOR_VERSION;
6136
		failer(WIDTH_ERROR);
5632
  return res;
6137
		return slongsh;
5633
}
6138
	}
5634
 
6139
 
5635
 
-
 
5636
variety f_var_limits
6140
	if (w <= 8) {
5637
    PROTO_N ( (lower_bound, upper_bound) )
6141
		return ucharsh;
5638
    PROTO_T ( signed_nat lower_bound X signed_nat upper_bound )
-
 
5639
{
6142
	}
5640
  unsigned int h;
6143
	if (w <= 16) {
5641
  unsigned int l;
6144
		return uwordsh;
5642
 
6145
	}
5643
  if (!snat_issmall(lower_bound) || !snat_issmall(upper_bound)) {
-
 
5644
    if (snatneg(lower_bound))
6146
	if (w <= 32) {
5645
      return s64sh;
6147
		return ulongsh;
-
 
6148
	}
5646
    else
6149
	if (w <= 64) {
5647
      return u64sh;
6150
		return u64sh;
5648
  };
6151
	}
-
 
6152
	failer(WIDTH_ERROR);
-
 
6153
	return ulongsh;
5649
 
6154
}
5650
    /* normalise the varieties to use only the six standard ones */
-
 
5651
  l = (unsigned int)(snatint(lower_bound));
-
 
5652
		/* these assume the length of unsigned int equals int */
-
 
5653
  h = (unsigned int)(snatint(upper_bound));
-
 
5654
 
6155
 
5655
 
-
 
5656
  if (!snatneg(lower_bound))
-
 
5657
   {
-
 
5658
     if (h <= 255)
-
 
5659
       return ucharsh;
-
 
5660
     if (h <= 65535)
-
 
5661
       return uwordsh;
-
 
5662
     return ulongsh;
-
 
5663
   };
-
 
5664
 
-
 
5665
 
-
 
5666
  if (l <= 128 && h <= 127)
-
 
5667
   {
-
 
5668
     return scharsh;
-
 
5669
   };
-
 
5670
  if (l<= 32768 && h <= 32767)
-
 
5671
   {
-
 
5672
     return swordsh;
-
 
5673
   };
-
 
5674
  return slongsh;
-
 
5675
}
-
 
5676
 
-
 
5677
variety f_var_width
-
 
5678
    PROTO_N ( (sig, bits) )
-
 
5679
    PROTO_T ( bool sig X nat bits )
-
 
5680
{
-
 
5681
  int w = natint(bits);
-
 
5682
  if (sig) {
-
 
5683
    if (w <= 8)
-
 
5684
      return scharsh;
-
 
5685
    if (w <= 16)
-
 
5686
      return swordsh;
-
 
5687
    if (w <= 32)
-
 
5688
      return slongsh;
-
 
5689
    if (w <= 64)
-
 
5690
      return s64sh;
-
 
5691
    failer(WIDTH_ERROR);
-
 
5692
    return slongsh;
-
 
5693
  }
-
 
5694
 
-
 
5695
  if (w <= 8)
-
 
5696
    return ucharsh;
-
 
5697
  if (w <= 16)
-
 
5698
    return uwordsh;
-
 
5699
  if (w <= 32)
-
 
5700
    return ulongsh;
-
 
5701
  if (w <= 64)
-
 
5702
    return u64sh;
-
 
5703
  failer(WIDTH_ERROR);
-
 
5704
  return ulongsh;
-
 
5705
}
-
 
5706
 
6156
 
5707
void init_variety
6157
void init_variety
5708
    PROTO_Z ()
6158
(void)
5709
{
6159
{
5710
  ucharsh = getshape(0, const_al1, const_al1, UCHAR_ALIGN, UCHAR_SZ, ucharhd);
6160
	ucharsh = getshape(0, const_al1, const_al1, UCHAR_ALIGN, UCHAR_SZ,
-
 
6161
			   ucharhd);
5711
  scharsh = getshape(1, const_al1, const_al1, SCHAR_ALIGN, SCHAR_SZ, scharhd);
6162
	scharsh = getshape(1, const_al1, const_al1, SCHAR_ALIGN, SCHAR_SZ,
-
 
6163
			   scharhd);
5712
  uwordsh = getshape(0, const_al1, const_al1, UWORD_ALIGN, UWORD_SZ, uwordhd);
6164
	uwordsh = getshape(0, const_al1, const_al1, UWORD_ALIGN, UWORD_SZ,
-
 
6165
			   uwordhd);
5713
  swordsh = getshape(1, const_al1, const_al1, SWORD_ALIGN, SWORD_SZ, swordhd);
6166
	swordsh = getshape(1, const_al1, const_al1, SWORD_ALIGN, SWORD_SZ,
-
 
6167
			   swordhd);
5714
  ulongsh = getshape(0, const_al1, const_al1, ULONG_ALIGN, ULONG_SZ, ulonghd);
6168
	ulongsh = getshape(0, const_al1, const_al1, ULONG_ALIGN, ULONG_SZ,
-
 
6169
			   ulonghd);
5715
  slongsh = getshape(1, const_al1, const_al1, SLONG_ALIGN, SLONG_SZ, slonghd);
6170
	slongsh = getshape(1, const_al1, const_al1, SLONG_ALIGN, SLONG_SZ,
-
 
6171
			   slonghd);
5716
  u64sh = getshape(0, const_al1, const_al1, U64_ALIGN, U64_SZ, u64hd);
6172
	u64sh = getshape(0, const_al1, const_al1, U64_ALIGN, U64_SZ, u64hd);
5717
  s64sh = getshape(1, const_al1, const_al1, S64_ALIGN, S64_SZ, s64hd);
6173
	s64sh = getshape(1, const_al1, const_al1, S64_ALIGN, S64_SZ, s64hd);
5718
  return;
6174
	return;
5719
}
-
 
5720
 
-
 
5721
variety f_dummy_variety;
-
 
5722
 
-
 
5723
version f_make_version
-
 
5724
    PROTO_N ( (major_version, minor_version) )
-
 
5725
    PROTO_T ( tdfint major_version X tdfint minor_version )
-
 
5726
{
-
 
5727
  version res;
-
 
5728
  res.major_version = natint(major_version);
-
 
5729
  res.minor_version = natint(minor_version);
-
 
5730
  if (res.major_version >= 3)
-
 
5731
    newcode = 1;
-
 
5732
  else
-
 
5733
    newcode = 0;
-
 
5734
  return res;
-
 
5735
}
-
 
5736
 
-
 
5737
version_props f_make_versions
-
 
5738
    PROTO_N ( (version_info) )
-
 
5739
    PROTO_T ( version_props version_info )
-
 
5740
{
-
 
5741
  UNUSED(version_info);
-
 
5742
  return 0;
-
 
5743
}
6175
}
5744
 
6176
 
5745
 
6177
 
5746
exp_list new_exp_list
6178
variety f_dummy_variety;
-
 
6179
 
-
 
6180
version
-
 
6181
f_make_version(tdfint major_version, tdfint minor_version)
-
 
6182
{
-
 
6183
	version res;
-
 
6184
	res.major_version = natint(major_version);
-
 
6185
	res.minor_version = natint(minor_version);
-
 
6186
	if (res.major_version >= 3) {
-
 
6187
		newcode = 1;
-
 
6188
	} else {
-
 
6189
		newcode = 0;
-
 
6190
	}
-
 
6191
	return res;
-
 
6192
}
-
 
6193
 
-
 
6194
 
-
 
6195
version_props
-
 
6196
f_make_versions(version_props version_info)
-
 
6197
{
5747
    PROTO_N ( (n) )
6198
	UNUSED(version_info);
-
 
6199
	return 0;
-
 
6200
}
-
 
6201
 
-
 
6202
 
-
 
6203
exp_list
5748
    PROTO_T ( int n )
6204
new_exp_list(int n)
5749
{
6205
{
5750
  exp_list res;
6206
	exp_list res;
5751
  UNUSED(n);
6207
	UNUSED(n);
5752
  res.number = 0;;
6208
	res.number = 0;;
5753
  res.start = nilexp;
6209
	res.start = nilexp;
5754
  res.end = nilexp;
6210
	res.end = nilexp;
5755
 
6211
 
5756
  return res;
6212
	return res;
5757
}
6213
}
-
 
6214
 
5758
 
6215
 
5759
exp_list add_exp_list
6216
exp_list
5760
    PROTO_N ( (list, elem, index) )
-
 
5761
    PROTO_T ( exp_list list X exp elem X int index )
6217
add_exp_list(exp_list list, exp elem, int index)
5762
{
6218
{
5763
  UNUSED(index);
6219
	UNUSED(index);
5764
  ++list.number;
6220
	++list.number;
5765
  parked(elem) = 1;
6221
	parked(elem) = 1;
5766
  if (list.start == nilexp)
6222
	if (list.start == nilexp) {
5767
   {
-
 
5768
     list.start = elem;
6223
		list.start = elem;
5769
     list.end = elem;
6224
		list.end = elem;
5770
     setlast(elem);
6225
		setlast(elem);
5771
     bro(elem) = nilexp;
6226
		bro(elem) = nilexp;
5772
     return list;
6227
		return list;
5773
   };
6228
	}
5774
  clearlast(list.end);
6229
	clearlast(list.end);
5775
  bro(list.end) = elem;
6230
	bro(list.end) = elem;
5776
  list.end = elem;
6231
	list.end = elem;
5777
  setlast(elem);
6232
	setlast(elem);
5778
  bro(elem) = nilexp;
6233
	bro(elem) = nilexp;
5779
  return list;
6234
	return list;
5780
}
6235
}
-
 
6236
 
5781
 
6237
 
5782
caselim_list new_caselim_list
6238
caselim_list
5783
    PROTO_N ( (n) )
-
 
5784
    PROTO_T ( int n )
6239
new_caselim_list(int n)
5785
{
6240
{
5786
  UNUSED(n);
6241
	UNUSED(n);
5787
/*  bro(global_case) = nilexp;
6242
	/*  bro(global_case) = nilexp;
5788
  return 0;
6243
	    return 0;
5789
*/
6244
	 */
5790
  return nilexp;
6245
	return nilexp;
5791
}
6246
}
-
 
6247
 
5792
 
6248
 
5793
caselim_list add_caselim_list
6249
caselim_list
5794
    PROTO_N ( (list, elem, index) )
-
 
5795
    PROTO_T ( caselim_list list X caselim elem X int index )
6250
add_caselim_list(caselim_list list, caselim elem, int index)
5796
{
6251
{
5797
       /* see the documentation for the representation of cases */
6252
	/* see the documentation for the representation of cases */
5798
     exp ht;
6253
	exp ht;
5799
     int  low;
6254
	int  low;
5800
     int  high;
6255
	int  high;
5801
     exp lowval = getexp (slongsh, nilexp, 0, nilexp, nilexp, 0, 0, 0);
6256
	exp lowval = getexp(slongsh, nilexp, 0, nilexp, nilexp, 0, 0, 0);
5802
/*     UNUSED(list);
6257
	/* UNUSED(list); */
5803
*/
-
 
5804
     UNUSED(index);
6258
	UNUSED(index);
5805
     pt(lowval) = get_lab(elem.lab);	/* label for this branch */
6259
	pt(lowval) = get_lab(elem.lab);	/* label for this branch */
-
 
6260
 
-
 
6261
	if (snat_issmall(elem.low)) {
-
 
6262
		low = snatint(elem.low);
-
 
6263
		if (snatneg(elem.low)) {
-
 
6264
			low = - low;
-
 
6265
		}
-
 
6266
	} else {
-
 
6267
#if !has64bits
-
 
6268
		SET(low);
-
 
6269
		failer(TOO_BIG_A_CASE_ELEMENT);
-
 
6270
#else
-
 
6271
		low = snatbig(elem.low);
-
 
6272
		if (snatneg(elem.low)) {
-
 
6273
			flpt z = new_flpt();
-
 
6274
			flt_copy(flptnos[low], &flptnos[z]);
-
 
6275
			low = z;
-
 
6276
			flptnos[low].sign = - flptnos[low].sign;
-
 
6277
		}
-
 
6278
		setbigval(lowval);
-
 
6279
#endif
-
 
6280
	}
-
 
6281
	no(lowval) = low;
5806
 
6282
 
5807
     if (snat_issmall(elem.low)){
6283
	if (snat_issmall(elem.high)) {
5808
       low = snatint(elem.low);
6284
		high = snatint(elem.high);
5809
       if (snatneg(elem.low))
6285
		if (snatneg(elem.high)) {
-
 
6286
			high = - high;
-
 
6287
		}
-
 
6288
		if (!isbigval(lowval) && high == low) {
-
 
6289
			ht = nilexp;
-
 
6290
		} else {
-
 
6291
			ht = getexp(slongsh, nilexp, 1, nilexp, nilexp, 0,
5810
         low = - low;
6292
				    high, 0);
5811
     }
6293
		}
5812
     else {
6294
	} else {
5813
#if !has64bits
6295
#if !has64bits
5814
       SET(low);
6296
		SET(ht);
5815
       failer(TOO_BIG_A_CASE_ELEMENT);
6297
		failer(TOO_BIG_A_CASE_ELEMENT);
5816
#else
6298
#else
-
 
6299
		int lh_eq;
5817
       low = snatbig(elem.low);
6300
		high = snatbig(elem.high);
5818
       if (snatneg(elem.low)) {
6301
		if (snatneg(elem.high)) {
5819
	 flpt z = new_flpt();
6302
			flpt z = new_flpt();
5820
	 flt_copy(flptnos[low], &flptnos[z]);
6303
			flt_copy(flptnos[high], &flptnos[z]);
5821
	 low = z;
6304
			high = z;
5822
	 flptnos[low].sign = - flptnos[low].sign;
6305
			flptnos[high].sign = - flptnos[high].sign;
5823
       }
6306
		}
5824
       setbigval(lowval);
6307
		if (isbigval(lowval)) {
-
 
6308
			lh_eq = flt_cmp(flptnos[low], flptnos[high]);
5825
#endif
6309
		} else {
5826
     };
6310
			lh_eq = 0;
5827
     no(lowval) = low;
6311
		}
5828
 
6312
 
5829
     if (snat_issmall(elem.high)) {
-
 
5830
       high = snatint(elem.high);
-
 
5831
       if (snatneg(elem.high))
-
 
5832
         high = - high;
-
 
5833
       if (!isbigval(lowval) && high == low)
-
 
5834
	   ht = nilexp;
-
 
5835
       else
-
 
5836
	   ht = getexp (slongsh, nilexp, 1, nilexp, nilexp, 0, high, 0);
-
 
5837
     }
-
 
5838
     else {
-
 
5839
#if !has64bits
-
 
5840
       SET(ht);
-
 
5841
       failer(TOO_BIG_A_CASE_ELEMENT);
-
 
5842
#else
-
 
5843
       int lh_eq;
-
 
5844
       high = snatbig(elem.high);
-
 
5845
       if (snatneg(elem.high)) {
-
 
5846
	 flpt z = new_flpt();
-
 
5847
	 flt_copy(flptnos[high], &flptnos[z]);
-
 
5848
	 high = z;
-
 
5849
	 flptnos[high].sign = - flptnos[high].sign;
-
 
5850
       }
-
 
5851
       if (isbigval(lowval)) {
-
 
5852
         lh_eq = flt_cmp(flptnos[low], flptnos[high]);
-
 
5853
       }
-
 
5854
       else
-
 
5855
	 lh_eq = 0;
-
 
5856
 
-
 
5857
       if (!lh_eq) {
6313
		if (!lh_eq) {
5858
	   ht = getexp (slongsh, nilexp, 1, nilexp, nilexp, 0,
6314
			ht = getexp(slongsh, nilexp, 1, nilexp, nilexp, 0,
5859
			 high, 0);
6315
				    high, 0);
5860
	   setbigval(ht);
6316
			setbigval(ht);
5861
       }
-
 
5862
       else
6317
		} else {
5863
	   ht = nilexp;
6318
			ht = nilexp;
-
 
6319
		}
5864
#endif
6320
#endif
5865
     };
6321
	}
5866
 
6322
 
5867
/*     if (ht != nilexp && docmp_f((int)f_less_than, ht, lowval)){
6323
	/*     if (ht != nilexp && docmp_f((int)f_less_than, ht, lowval)){
5868
	 retcell(lowval);
6324
	       retcell(lowval);
5869
	 retcell(ht);
6325
	       retcell(ht);
5870
	 return 0;
6326
	       return 0;
5871
     }
6327
	       }
5872
*/
6328
	 */
5873
     ++no (son (pt(lowval)));	/* record label use */
6329
	++no(son(pt(lowval)));	/* record label use */
5874
     son(lowval) = ht;
6330
	son(lowval) = ht;
5875
 /*    case_item (lowval);
6331
	/*    case_item (lowval);
5876
*/
6332
	 */
5877
     bro(lowval) = list;
6333
	bro(lowval) = list;
5878
     return lowval;
6334
	return lowval;
5879
}
6335
}
-
 
6336
 
5880
 
6337
 
5881
label_list new_label_list
6338
label_list
5882
    PROTO_N ( (n) )
-
 
5883
    PROTO_T ( int n )
6339
new_label_list(int n)
5884
{
6340
{
5885
  label_list res;
6341
	label_list res;
5886
  res.elems = (label *)xcalloc(n, sizeof(label));
6342
	res.elems = (label *)xcalloc(n, sizeof(label));
5887
  res.number = n;
6343
	res.number = n;
5888
  return res;
6344
	return res;
5889
}
6345
}
-
 
6346
 
5890
 
6347
 
5891
label_list add_label_list
6348
label_list
5892
    PROTO_N ( (list, elem, index) )
-
 
5893
    PROTO_T ( label_list list X label elem X int index )
6349
add_label_list(label_list list, label elem, int index)
5894
{
6350
{
5895
    exp def;
6351
	exp def;
5896
    exp labst;
6352
	exp labst;
5897
    def = getexp (f_top, nilexp, 0, nilexp, nilexp, 0, 0,
6353
	def = getexp(f_top, nilexp, 0, nilexp, nilexp, 0, 0, clear_tag);
5898
                    clear_tag);
-
 
5899
    labst = getexp (f_bottom, nilexp, 0, def, nilexp, 0, 0,
6354
	labst = getexp(f_bottom, nilexp, 0, def, nilexp, 0, 0, labst_tag);
5900
                        labst_tag);
-
 
5901
    fno(labst) = default_freq;
6355
	fno(labst) = default_freq;
5902
    ++proc_label_count;
6356
	++proc_label_count;
5903
    set_lab(elem, labst);
6357
	set_lab(elem, labst);
5904
    list.elems[index] = elem;
6358
	list.elems[index] = elem;
5905
    return list;
6359
	return list;
5906
}
6360
}
-
 
6361
 
5907
 
6362
 
5908
tagshacc_list new_tagshacc_list
6363
tagshacc_list
5909
    PROTO_N ( (n) )
-
 
5910
    PROTO_T ( int n )
6364
new_tagshacc_list(int n)
5911
{
6365
{
5912
  tagshacc_list res;
6366
	tagshacc_list res;
5913
  res.size = 0;
6367
	res.size = 0;
5914
  res.id = nilexp;
6368
	res.id = nilexp;
5915
  res.last_id = nilexp;
6369
	res.last_id = nilexp;
5916
  res.last_def = nilexp;
6370
	res.last_def = nilexp;
5917
  res.number = n;
6371
	res.number = n;
5918
  return res;
6372
	return res;
5919
}
6373
}
-
 
6374
 
5920
 
6375
 
5921
tagshacc_list add_tagshacc_list
6376
tagshacc_list
5922
    PROTO_N ( (list, elem, index) )
-
 
5923
    PROTO_T ( tagshacc_list list X tagshacc elem X int index )
6377
add_tagshacc_list(tagshacc_list list, tagshacc elem, int index)
5924
{
6378
{
5925
  exp d = getexp(elem.sha, nilexp, 0, nilexp, nilexp, 0, 0, clear_tag);
6379
	exp d = getexp(elem.sha, nilexp, 0, nilexp, nilexp, 0, 0, clear_tag);
5926
  exp i = getexp(f_bottom, list.last_id, 1, d, nilexp, 0, 0, ident_tag);
6380
	exp i = getexp(f_bottom, list.last_id, 1, d, nilexp, 0, 0, ident_tag);
5927
  UNUSED(index);
6381
	UNUSED(index);
5928
  set_tag(elem.tg, i);
6382
	set_tag(elem.tg, i);
5929
  if (list.id == nilexp)
6383
	if (list.id == nilexp) {
5930
    list.id = i;
6384
		list.id = i;
5931
  else
6385
	} else {
5932
    bro(list.last_def) = i;
6386
		bro(list.last_def) = i;
-
 
6387
	}
5933
  list.last_def = d;
6388
	list.last_def = d;
5934
  list.last_id = i;
6389
	list.last_id = i;
5935
  if (elem.visible & (f_visible | f_long_jump_access))
6390
	if (elem.visible & (f_visible | f_long_jump_access)) {
5936
    setvis(i);
6391
		setvis(i);
-
 
6392
	}
5937
  if (elem.visible & f_out_par)
6393
	if (elem.visible & f_out_par) {
5938
	setoutpar(i);
6394
		setoutpar(i);
-
 
6395
	}
5939
  setvar(i);
6396
	setvar(i);
5940
  setparam(i);
6397
	setparam(i);
5941
  return list;
6398
	return list;
5942
}
6399
}
-
 
6400
 
5943
 
6401
 
5944
version_list new_version_list
6402
version_list
5945
    PROTO_N ( (n) )
-
 
5946
    PROTO_T ( int n )
6403
new_version_list(int n)
5947
{
6404
{
5948
  UNUSED(n);
6405
	UNUSED(n);
5949
  return 0;
6406
	return 0;
5950
}
6407
}
-
 
6408
 
5951
 
6409
 
5952
static int version_printed = 0;
6410
static int version_printed = 0;
5953
 
6411
 
5954
version_list add_version_list
6412
version_list
5955
    PROTO_N ( (list, elem, index) )
-
 
5956
    PROTO_T ( version_list list X version elem X int index )
6413
add_version_list(version_list list, version elem, int index)
5957
{
6414
{
-
 
6415
	UNUSED(list);
5958
  UNUSED(list); UNUSED(index);
6416
	UNUSED(index);
5959
  if (global_version.major_version == 0)
6417
	if (global_version.major_version == 0) {
5960
    global_version = elem;
6418
		global_version = elem;
-
 
6419
	}
5961
 
6420
 
5962
  if (elem.major_version != global_version.major_version)  {
6421
	if (elem.major_version != global_version.major_version) {
5963
    failer(WRONG_VERSION);
6422
		failer(WRONG_VERSION);
5964
    IGNORE fprintf(stderr, "This TDF has mixed versions\n");
6423
		IGNORE fprintf(stderr, "This TDF has mixed versions\n");
5965
  };
6424
	}
5966
 
6425
 
5967
  if (report_versions) {
6426
	if (report_versions) {
5968
    if (!version_printed) {
6427
		if (!version_printed) {
5969
      version_printed = 1;
6428
			version_printed = 1;
5970
      IGNORE fprintf(stderr, "This TDF is composed from Capsules of the following versions:-\n");
6429
			IGNORE fprintf(stderr, "This TDF is composed from Capsules of the following versions:-\n");
5971
    };
6430
		}
5972
    IGNORE fprintf(stderr, "TDF Version %d.%d\n",
6431
		IGNORE fprintf(stderr, "TDF Version %d.%d\n",
5973
		 elem.major_version, elem.minor_version);
6432
			       elem.major_version, elem.minor_version);
5974
  };
6433
	}
5975
 
6434
 
5976
  return 0;
6435
	return 0;
5977
}
6436
}
-
 
6437
 
5978
 
6438
 
5979
version f_dummy_version;
6439
version f_dummy_version;
5980
 
6440
 
5981
access_option no_access_option = 0;
6441
access_option no_access_option = 0;
5982
 
6442
 
5983
access_option yes_access_option
6443
access_option
5984
    PROTO_N ( (acc) )
-
 
5985
    PROTO_T ( access acc )
6444
yes_access_option(access acc)
5986
{
6445
{
5987
  return acc;
6446
	return acc;
5988
}
6447
}
-
 
6448
 
5989
 
6449
 
5990
string_option no_string_option;
6450
string_option no_string_option;
5991
string_option yes_string_option
6451
string_option
5992
    PROTO_N ( (s) )
-
 
5993
    PROTO_T ( string s )
6452
yes_string_option(string s)
5994
{
6453
{
5995
 	string_option res;
6454
	string_option res;
5996
	res.val = s;
6455
	res.val = s;
5997
	res.present = 1;
6456
	res.present = 1;
5998
  	return res;
6457
	return res;
5999
}
6458
}
6000
 
6459
 
-
 
6460
 
-
 
6461
void
6001
void init_string_option
6462
init_string_option(void)
6002
    PROTO_Z ()
-
 
6003
{
6463
{
6004
	no_string_option.present = 0;
6464
	no_string_option.present = 0;
6005
}
6465
}
6006
 
6466
 
6007
 
6467
 
6008
tagacc_option no_tagacc_option;
6468
tagacc_option no_tagacc_option;
6009
tagacc_option yes_tagacc_option
6469
tagacc_option
6010
    PROTO_N ( (elem) )
-
 
6011
    PROTO_T ( tagacc elem )
6470
yes_tagacc_option(tagacc elem)
6012
{
6471
{
6013
  tagacc_option res;
6472
	tagacc_option res;
6014
  res.val = elem;
6473
	res.val = elem;
6015
  res.present = 1;
6474
	res.present = 1;
6016
  return res;
6475
	return res;
6017
}
6476
}
-
 
6477
 
6018
 
6478
 
-
 
6479
void
6019
void init_tagacc_option
6480
init_tagacc_option(void)
6020
    PROTO_Z ()
-
 
6021
{
6481
{
6022
  no_tagacc_option.present = 0;
6482
	no_tagacc_option.present = 0;
6023
  return;
6483
	return;
6024
}
6484
}
-
 
6485
 
6025
 
6486
 
6026
nat_option no_nat_option;
6487
nat_option no_nat_option;
6027
nat_option yes_nat_option
6488
nat_option
6028
    PROTO_N ( (n) )
-
 
6029
    PROTO_T ( nat n )
6489
yes_nat_option(nat n)
6030
{
6490
{
6031
  nat_option res;
6491
	nat_option res;
6032
  res.val = n;
6492
	res.val = n;
6033
  res.present = 1;
6493
	res.present = 1;
6034
  return res;
6494
	return res;
6035
}
6495
}
-
 
6496
 
6036
 
6497
 
-
 
6498
void
6037
void init_nat_option
6499
init_nat_option(void)
6038
    PROTO_Z ()
-
 
6039
{
6500
{
6040
  no_nat_option.present = 0;
6501
	no_nat_option.present = 0;
6041
  return;
6502
	return;
6042
}
6503
}
-
 
6504
 
6043
 
6505
 
6044
void init_tagacc
6506
void
6045
    PROTO_Z ()
6507
init_tagacc(void)
6046
{
6508
{
6047
  return;
6509
	return;
6048
}
6510
}
-
 
6511
 
6049
 
6512
 
6050
tagacc f_make_tagacc
6513
tagacc
6051
    PROTO_N ( (tg, acc) )
-
 
6052
    PROTO_T ( tag tg X access_option acc )
6514
f_make_tagacc(tag tg, access_option acc)
6053
{
6515
{
6054
  tagacc res;
6516
	tagacc res;
6055
  res.tg = tg;
6517
	res.tg = tg;
6056
  res.visible = acc;
6518
	res.visible = acc;
6057
  return res;
6519
	return res;
6058
}
6520
}
-
 
6521
 
6059
 
6522
 
-
 
6523
void
6060
void init_transfer_mode
6524
init_transfer_mode(void)
6061
    PROTO_Z ()
-
 
6062
{
6525
{
6063
  return;
6526
	return;
6064
}
6527
}
-
 
6528
 
6065
 
6529
 
-
 
6530
void
6066
void init_version_props
6531
init_version_props(void)
6067
    PROTO_Z ()
-
 
6068
{
6532
{
6069
  global_version.major_version = 0;
6533
	global_version.major_version = 0;
6070
  global_version.minor_version = 0;
6534
	global_version.minor_version = 0;
6071
  return;
6535
	return;
6072
}
6536
}
-
 
6537
 
6073
 
6538
 
6074
void init_version
6539
void
6075
    PROTO_Z ()
6540
init_version(void)
6076
{
6541
{
6077
  return;
6542
	return;
6078
}
6543
}
6079
 
6544
 
6080
 
6545
 
-
 
6546
void
6081
void init_access_option
6547
init_access_option(void)
6082
    PROTO_Z ()
-
 
6083
{
6548
{
6084
  return;
6549
	return;
6085
}
6550
}
6086
 
-
 
6087
 
6551
 
6088
 
6552
 
6089
static int seq_n = 0;
6553
static int seq_n = 0;
6090
 
6554
 
6091
char * init_NAME
6555
char *
6092
    PROTO_N ( (good_name) )
-
 
6093
    PROTO_T ( char * good_name )
6556
init_NAME(char *good_name)
6094
{
6557
{
6095
   char * prefix  = "__I.TDF";
6558
	char *prefix  = "__I.TDF";
6096
   time_t t;
6559
	time_t t;
6097
   int i,j;
6560
	int i, j;
6098
   char * c;
6561
	char *c;
6099
   char * res;
6562
	char *res;
-
 
6563
	int sc;
-
 
6564
	int sp;
6100
   int sc; int sp; int sg;
6565
	int sg;
6101
   t = time(NULL) + (time_t)(seq_n++);
6566
	t = time(NULL) + (time_t)(seq_n++);
6102
   c = asctime(localtime(&t));
6567
	c = asctime(localtime(&t));
-
 
6568
	sc = (int)strlen(c);
-
 
6569
	sp = (int)strlen(prefix);
6103
   sc = (int)strlen(c); sp = (int)strlen(prefix); sg = (int)strlen(good_name);
6570
	sg = (int)strlen(good_name);
6104
   res = (char*)xcalloc(sc+sp+sg, sizeof(char));
6571
	res = (char*)xcalloc(sc + sp + sg, sizeof(char));
-
 
6572
	for (i = 0; i < sp; i++) {
6105
   for(i=0; i<sp; i++) res[i] = prefix[i];
6573
		res[i] = prefix[i];
-
 
6574
	}
6106
   for(j=0; j<sg; i++, j++) res[i] = good_name[j];
6575
	for (j = 0; j < sg; i++, j++) {
-
 
6576
		res[i] = good_name[j];
-
 
6577
	}
6107
   for(j=0; j<sc; j++) {
6578
	for (j = 0; j < sc; j++) {
6108
	if(isalpha(c[j])|| isdigit(c[j]) ){ res[i] = c[j]; i++;}
6579
		if (isalpha(c[j]) || isdigit(c[j])) {
-
 
6580
			res[i] = c[j]; i++;
6109
   }
6581
		}
-
 
6582
	}
6110
   res[i] = 0;
6583
	res[i] = 0;
6111
   dynamic_init_proc = res;
6584
	dynamic_init_proc = res;
6112
   return(res);
6585
	return (res);
6113
}
6586
}
-
 
6587
 
6114
 
6588
 
-
 
6589
void
6115
void start_initial_value
6590
start_initial_value(void)
6116
    PROTO_Z ()
-
 
6117
{
6591
{
6118
   if (in_initial_value++ == 0) {
6592
	if (in_initial_value++ == 0) {
6119
	proc_props * real_pp = (proc_props*)0;
6593
		proc_props *real_pp = (proc_props *)0;
6120
	if (old_proc_props != (proc_props*)0) {
6594
		if (old_proc_props != (proc_props *)0) {
6121
		/* initial value in proc */
6595
			/* initial value in proc */
6122
		push_proc_props();
6596
			push_proc_props();
6123
		real_pp = old_proc_props;
6597
			real_pp = old_proc_props;
6124
	}
6598
		}
6125
	old_proc_props = &initial_value_pp;
6599
		old_proc_props = &initial_value_pp;
6126
	pop_proc_props();
6600
		pop_proc_props();
6127
	old_proc_props = real_pp;
6601
		old_proc_props = real_pp;
6128
   }
6602
	}
6129
 
6603
}
6130
}
6604
 
6131
 
6605
 
6132
exp f_initial_value
6606
exp
6133
    PROTO_N ( (e) )
-
 
6134
    PROTO_T ( exp e )
6607
f_initial_value(exp e)
6135
{
6608
{
6136
   	if (--in_initial_value > 0) return e;
6609
	if (--in_initial_value > 0) {
-
 
6610
		return e;
-
 
6611
	}
6137
 
6612
 
6138
  	initial_value_pp.proc_struct_result = proc_struct_result;
6613
	initial_value_pp.proc_struct_result = proc_struct_result;
6139
  	initial_value_pp.has_alloca = has_alloca;
6614
	initial_value_pp.has_alloca = has_alloca;
6140
  	initial_value_pp.proc_is_recursive = proc_is_recursive;
6615
	initial_value_pp.proc_is_recursive = proc_is_recursive;
6141
  	initial_value_pp.uses_crt_env = uses_crt_env;
6616
	initial_value_pp.uses_crt_env = uses_crt_env;
6142
  	initial_value_pp.has_setjmp = has_setjmp;
6617
	initial_value_pp.has_setjmp = has_setjmp;
6143
  	initial_value_pp.uses_loc_address = uses_loc_address;
6618
	initial_value_pp.uses_loc_address = uses_loc_address;
6144
  	initial_value_pp.proc_label_count = proc_label_count;
6619
	initial_value_pp.proc_label_count = proc_label_count;
6145
  	initial_value_pp.proc_struct_res = proc_struct_res;
6620
	initial_value_pp.proc_struct_res = proc_struct_res;
6146
  	initial_value_pp.default_freq = default_freq;
6621
	initial_value_pp.default_freq = default_freq;
6147
  	initial_value_pp.proc_externs = proc_externs;
6622
	initial_value_pp.proc_externs = proc_externs;
6148
  	initial_value_pp.in_proc_def = in_proc_def;
6623
	initial_value_pp.in_proc_def = in_proc_def;
6149
  	initial_value_pp.pushed = old_proc_props;
6624
	initial_value_pp.pushed = old_proc_props;
6150
  	initial_value_pp.rep_make_proc = rep_make_proc;
6625
	initial_value_pp.rep_make_proc = rep_make_proc;
6151
	if (old_proc_props != (proc_props*)0) {
6626
	if (old_proc_props != (proc_props *)0) {
6152
		/* init was in a proc - must make new variable */
6627
		/* init was in a proc - must make new variable */
6153
		dec * my_def = make_extra_dec(make_local_name(), 1, 0,
6628
		dec *my_def = make_extra_dec(make_local_name(), 1, 0, me_u2(e,
6154
						me_u2(e, initial_value_tag), sh(e) );
6629
					     initial_value_tag), sh(e));
6155
		exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
6630
		exp crt_exp = my_def->dec_u.dec_val.dec_exp;
6156
		pop_proc_props();
6631
		pop_proc_props();
6157
		return f_contents(sh(e), me_obtain(crt_exp));
6632
		return f_contents(sh(e), me_obtain(crt_exp));
6158
	}
6633
	}
6159
	return me_u2(e, initial_value_tag);
6634
	return me_u2(e, initial_value_tag);
6160
}
6635
}
6161
 
6636
 
-
 
6637
 
-
 
6638
void
6162
void tidy_initial_values
6639
tidy_initial_values(void)
6163
    PROTO_Z ()
-
 
6164
{
6640
{
6165
   dec * my_def = top_def;
6641
	dec *my_def = top_def;
6166
   exp_list initial_as;
6642
	exp_list initial_as;
6167
   exp_list prom_as;
6643
	exp_list prom_as;
6168
   char * good_name = (char*)0;
6644
	char *good_name = (char *)0;
6169
   initial_as = new_exp_list(0);
6645
	initial_as = new_exp_list(0);
6170
   prom_as = new_exp_list(0);
6646
	prom_as = new_exp_list(0);
6171
   dynamic_init_proc = (char*) 0;
6647
	dynamic_init_proc = (char *)0;
6172
   while (my_def != (dec*)0){
6648
	while (my_def != (dec *)0) {
6173
	exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
6649
		exp crt_exp = my_def->dec_u.dec_val.dec_exp;
6174
	if (son(crt_exp) != nilexp && my_def -> dec_u.dec_val.extnamed) {
6650
		if (son(crt_exp) != nilexp && my_def->dec_u.dec_val.extnamed) {
6175
		good_name = my_def -> dec_u.dec_val.dec_id;
-
 
6176
	}
-
 
6177
	if (son(crt_exp) != nilexp && name(son(crt_exp)) == initial_value_tag) {
-
 
6178
		/* accumulate assignments of initial values in one explist */
-
 
6179
		if (!(my_def -> dec_u.dec_val.dec_var)) { /* make sure its a variable */
-
 
6180
		    exp p = pt(crt_exp);
-
 
6181
		    setvar(crt_exp);
-
 
6182
		    my_def -> dec_u.dec_val.dec_var = 1;
-
 
6183
		    while(p != nilexp){
-
 
6184
			    exp np = pt(p);
-
 
6185
			    exp c =
-
 
6186
				hold_check(f_contents(sh(p), me_obtain(crt_exp)));
-
 
6187
			    replace(p, c ,nilexp);
-
 
6188
			    p = np;
-
 
6189
		    }
-
 
6190
		}
-
 
6191
	       {exp init = son(son(crt_exp));
-
 
6192
		exp new_init = f_make_value(sh(init));
-
 
6193
	        if (good_name == (char*)0) {
-
 
6194
			good_name = my_def -> dec_u.dec_val.dec_id;
6651
			good_name = my_def->dec_u.dec_val.dec_id;
6195
		}
6652
		}
-
 
6653
		if (son(crt_exp) != nilexp &&
-
 
6654
		    name(son(crt_exp)) == initial_value_tag) {
-
 
6655
			/* accumulate assignments of initial values in one
-
 
6656
			   explist */
-
 
6657
			if (!(my_def->dec_u.dec_val.dec_var)) {
-
 
6658
				/* make sure its a variable */
-
 
6659
				exp p = pt(crt_exp);
-
 
6660
				setvar(crt_exp);
-
 
6661
				my_def->dec_u.dec_val.dec_var = 1;
-
 
6662
				while (p != nilexp) {
-
 
6663
					exp np = pt(p);
-
 
6664
					exp c = hold_check(f_contents(sh(p),
-
 
6665
							   me_obtain(crt_exp)));
-
 
6666
					replace(p, c, nilexp);
-
 
6667
					p = np;
-
 
6668
				}
-
 
6669
			}
-
 
6670
			{
-
 
6671
				exp init = son(son(crt_exp));
-
 
6672
				exp new_init = f_make_value(sh(init));
-
 
6673
				if (good_name == (char *)0) {
-
 
6674
					good_name =
-
 
6675
					    my_def->dec_u.dec_val.dec_id;
-
 
6676
				}
6196
		retcell(son(crt_exp));
6677
				retcell(son(crt_exp));
6197
		son(crt_exp) = new_init;
6678
				son(crt_exp) = new_init;
6198
		bro(new_init) = crt_exp; setlast(new_init);
6679
				bro(new_init) = crt_exp; setlast(new_init);
6199
		initial_as = add_exp_list(initial_as,
6680
				initial_as = add_exp_list(initial_as,
6200
			hold_check(f_assign(me_obtain(crt_exp), init)), 0);
6681
				    hold_check(f_assign(me_obtain(crt_exp),
-
 
6682
							init)), 0);
-
 
6683
			}
-
 
6684
		}
-
 
6685
		if (do_prom && son(crt_exp) != nilexp &&
-
 
6686
		    my_def->dec_u.dec_val.dec_var && !is_comm(son(crt_exp))) {
-
 
6687
			/* accumulate assignments of non-zero initialisations
-
 
6688
			   in one explist */
-
 
6689
			exp init = son(crt_exp);
-
 
6690
			exp new_init = f_make_value(sh(init));
-
 
6691
			if (good_name == (char *)0) {
-
 
6692
				good_name = my_def->dec_u.dec_val.dec_id;
-
 
6693
			}
-
 
6694
			if (name(init) == compound_tag ||
-
 
6695
			    name(init) == nof_tag ||
-
 
6696
			    name(init) == concatnof_tag ||
-
 
6697
			    name(init) == ncopies_tag ||
-
 
6698
			    name(init) == string_tag) {
-
 
6699
				dec *id_dec = make_extra_dec(make_local_name(),
-
 
6700
							     0, 0, init,
-
 
6701
							     sh(init));
-
 
6702
				init = me_obtain(id_dec->dec_u.dec_val.dec_exp);
-
 
6703
			}
-
 
6704
			son(crt_exp) = new_init;
-
 
6705
			no(new_init) = -1; /* we may need to distinguish for
-
 
6706
					      diags */
-
 
6707
			bro(new_init) = crt_exp;
-
 
6708
			setlast(new_init);
-
 
6709
			prom_as = add_exp_list(prom_as,
-
 
6710
					       hold_check(f_assign(me_obtain(
-
 
6711
							  crt_exp), init)), 0);
6201
		}
6712
		}
-
 
6713
		my_def = my_def->def_next;
6202
	}
6714
	}
-
 
6715
	if (initial_as.number != 0) {
-
 
6716
		/* ie there are some dynamic initialisations */
-
 
6717
		exp prc;
-
 
6718
		dec *extra_dec;
-
 
6719
		tagshacc_list tsl;
-
 
6720
 
-
 
6721
		exp ret = f_return(f_make_top());
-
 
6722
		exp seq = f_sequence(initial_as, ret);
-
 
6723
		tsl = new_tagshacc_list(0);
-
 
6724
 
6203
	if (do_prom && son(crt_exp) != nilexp && my_def -> dec_u.dec_val.dec_var
6725
		old_proc_props = &initial_value_pp;  pop_proc_props();
6204
				&& !is_comm (son(crt_exp))) {
6726
		old_proc_props = (proc_props *)0;
-
 
6727
		rep_make_proc = 0;
-
 
6728
		push_proc_props();
-
 
6729
		prc = f_make_proc(f_top, tsl, no_tagacc_option, seq);
6205
		/* accumulate assignments of non-zero initialisations in one explist */
6730
		/* prc has one visible param - hence looks like varargs */
-
 
6731
		if (do_prom) {
6206
		exp init = son(crt_exp);
6732
			/* struct (proc, ptr) */
-
 
6733
			exp off_proc = hold_check(f_offset_zero(PROC_ALIGN));
-
 
6734
			exp off_ptr = hold_check(f_offset_pad(PTR_ALIGN,
-
 
6735
						 hold_check(f_offset_add(copy(
-
 
6736
						 off_proc), hold_check(
-
 
6737
						 f_shape_offset(f_proc))))));
-
 
6738
			shape str_sh = f_compound(hold_check(f_offset_add(copy(
-
 
6739
						  off_ptr), hold_check(
-
 
6740
						  f_shape_offset(f_pointer(
-
 
6741
						  PROC_ALIGN))))));
-
 
6742
			dec *str_dec = make_extra_dec(make_local_name(), 1, 0,
6207
		exp new_init = f_make_value(sh(init));
6743
						      f_make_value(str_sh),
-
 
6744
						      str_sh);
-
 
6745
			dec *prc_dec = make_extra_dec(make_local_name(), 0, 0,
6208
	        if (good_name == (char*)0) {
6746
						      prc, f_proc);
-
 
6747
			exp prc_exp = prc_dec->dec_u.dec_val.dec_exp;
6209
			good_name = my_def -> dec_u.dec_val.dec_id;
6748
			exp str_exp = str_dec->dec_u.dec_val.dec_exp;
-
 
6749
			exp list_exp = find_named_tg("__PROM_init_list",
-
 
6750
						     f_pointer(f_alignment(
-
 
6751
						     str_sh)));
-
 
6752
			brog(list_exp)->dec_u.dec_val.dec_var = 1;
-
 
6753
			setvar(list_exp);
-
 
6754
			prom_as = add_exp_list(prom_as, hold_check(f_assign(
-
 
6755
					       f_add_to_ptr(me_obtain(str_exp),
-
 
6756
							    copy(off_proc)),
-
 
6757
					       me_obtain(prc_exp))), 0);
-
 
6758
			prom_as = add_exp_list(prom_as, hold_check(f_assign(
-
 
6759
					       f_add_to_ptr(me_obtain(str_exp),
-
 
6760
							    copy(off_ptr)),
-
 
6761
					       f_contents(sh(list_exp),
-
 
6762
					       me_obtain(list_exp)))), 0);
-
 
6763
			prom_as = add_exp_list(prom_as, hold_check(f_assign(
-
 
6764
					       me_obtain(list_exp),
-
 
6765
					       me_obtain(str_exp))), 0);
-
 
6766
		} else {
-
 
6767
			extra_dec = make_extra_dec(add_prefix(init_NAME(
-
 
6768
						   good_name)), 0, 1, prc,
-
 
6769
						   f_proc);
6210
		}
6770
		}
6211
		if (name(init) == compound_tag || name(init) == nof_tag ||
-
 
6212
			name(init) == concatnof_tag || name(init) == ncopies_tag ||
-
 
6213
			name(init) == string_tag) {
-
 
6214
		  dec * id_dec = make_extra_dec (make_local_name(), 0, 0, init, sh(init));
-
 
6215
		  init = me_obtain(id_dec -> dec_u.dec_val.dec_exp);
-
 
6216
		}
-
 
6217
		son(crt_exp) = new_init;
-
 
6218
		no(new_init) = -1;	/* we may need to distinguish for diags */
-
 
6219
		bro(new_init) = crt_exp; setlast(new_init);
-
 
6220
		prom_as = add_exp_list(prom_as,
-
 
6221
			hold_check(f_assign(me_obtain(crt_exp), init)), 0);
-
 
6222
	}
6771
	}
6223
	my_def = my_def->def_next;
6772
	if (do_prom && prom_as.number != 0) {
6224
   }
-
 
6225
   if (initial_as.number != 0) { /* ie there are some dynamic initialisations */
6773
		/* ie there are some prom initialisations */
6226
	exp prc;
6774
		exp prc;
6227
	dec * extra_dec;
6775
		dec *extra_dec;
6228
	tagshacc_list tsl;
6776
		tagshacc_list tsl;
6229
 
-
 
6230
	exp ret = f_return(f_make_top());
-
 
6231
	exp seq = f_sequence(initial_as, ret);
-
 
6232
	tsl = new_tagshacc_list(0);
-
 
6233
 
6777
 
6234
	old_proc_props = &initial_value_pp;  pop_proc_props();
6778
		exp ret = f_return(f_make_top());
6235
	old_proc_props = (proc_props*)0; rep_make_proc = 0; push_proc_props();
6779
		exp seq = f_sequence(prom_as, ret);
6236
	prc = f_make_proc(f_top, tsl, no_tagacc_option, seq);
6780
		tsl = new_tagshacc_list(0);
6237
		/* prc has one visible param - hence looks like varargs */
-
 
6238
	if (do_prom) {
6781
 
6239
		/* struct (proc, ptr) */
6782
		rep_make_proc = 0;
6240
	  exp off_proc = hold_check (f_offset_zero (PROC_ALIGN));
-
 
6241
	  exp off_ptr = hold_check (f_offset_pad (PTR_ALIGN,
-
 
6242
			hold_check (f_offset_add (copy (off_proc),
6783
		start_make_proc(f_top, tsl, no_tagacc_option);
6243
				hold_check (f_shape_offset (f_proc))))));
6784
		prc = f_make_proc(f_top, tsl, no_tagacc_option, seq);
6244
	  shape str_sh = f_compound (hold_check (f_offset_add (copy (off_ptr),
-
 
6245
				hold_check (f_shape_offset (f_pointer (PROC_ALIGN))))));
-
 
6246
	  dec * str_dec = make_extra_dec (make_local_name(), 1, 0,
6785
		extra_dec = make_extra_dec(add_prefix(init_NAME(good_name)), 0,
6247
				f_make_value (str_sh), str_sh);
-
 
6248
	  dec * prc_dec = make_extra_dec(make_local_name(), 0, 0, prc, f_proc);
-
 
6249
	  exp prc_exp = prc_dec -> dec_u.dec_val.dec_exp;
-
 
6250
	  exp str_exp = str_dec -> dec_u.dec_val.dec_exp;
-
 
6251
	  exp list_exp = find_named_tg ("__PROM_init_list", f_pointer (f_alignment (str_sh)));
-
 
6252
	  brog(list_exp) -> dec_u.dec_val.dec_var = 1;
-
 
6253
          setvar(list_exp);
-
 
6254
	  prom_as = add_exp_list (prom_as,
-
 
6255
		hold_check (f_assign (f_add_to_ptr (me_obtain(str_exp), copy (off_proc)),
-
 
6256
				me_obtain(prc_exp))), 0);
6786
					   1, prc, f_proc);
6257
	  prom_as = add_exp_list (prom_as,
-
 
6258
		hold_check (f_assign (f_add_to_ptr (me_obtain(str_exp), copy (off_ptr)),
-
 
6259
	  			f_contents (sh(list_exp), me_obtain(list_exp)))), 0);
-
 
6260
	  prom_as = add_exp_list (prom_as,
-
 
6261
		hold_check (f_assign (me_obtain(list_exp), me_obtain(str_exp))), 0);
-
 
6262
	}
6787
	}
6263
	else
-
 
6264
	  extra_dec = make_extra_dec(add_prefix(init_NAME(good_name)), 0, 1, prc, f_proc);
-
 
6265
    }
-
 
6266
   if (do_prom && prom_as.number != 0) { /* ie there are some prom initialisations */
-
 
6267
	exp prc;
-
 
6268
	dec * extra_dec;
-
 
6269
	tagshacc_list tsl;
-
 
6270
 
-
 
6271
	exp ret = f_return(f_make_top());
-
 
6272
	exp seq = f_sequence(prom_as, ret);
-
 
6273
	tsl = new_tagshacc_list(0);
-
 
6274
 
-
 
6275
	rep_make_proc = 0;
-
 
6276
	start_make_proc(f_top, tsl, no_tagacc_option);
-
 
6277
	prc = f_make_proc(f_top, tsl, no_tagacc_option, seq);
-
 
6278
	extra_dec = make_extra_dec(add_prefix(init_NAME(good_name)), 0, 1, prc, f_proc);
-
 
6279
    }
-
 
6280
}
6788
}