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/producers/common/output/dump.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
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
29
 
59
 
30
 
60
 
31
#include "config.h"
61
#include "config.h"
32
#include <limits.h>
62
#include <limits.h>
33
#include "system.h"
63
#include "system.h"
34
#include "version.h"
64
#include "version.h"
35
#include "c_types.h"
65
#include "c_types.h"
Line 70... Line 100...
70
 
100
 
71
/*
101
/*
72
    DUMP FILE OPTIONS
102
    DUMP FILE OPTIONS
73
 
103
 
74
    These variables give the various dump file options.
104
    These variables give the various dump file options.
75
*/
105
*/
76
 
106
 
77
int do_dump = 0 ;
107
int do_dump = 0;
78
int do_error = 0 ;
108
int do_error = 0;
79
int do_header = 0 ;
109
int do_header = 0;
80
int do_keyword = 0 ;
110
int do_keyword = 0;
81
int do_local = 0 ;
111
int do_local = 0;
82
int do_macro = 0 ;
112
int do_macro = 0;
83
int do_scope = 0 ;
113
int do_scope = 0;
84
int do_string = 0 ;
114
int do_string = 0;
85
int do_usage = 0 ;
115
int do_usage = 0;
86
 
116
 
87
 
117
 
88
/*
118
/*
89
    DUMP FILE VARIABLES
119
    DUMP FILE VARIABLES
90
 
120
 
91
    These variables give the dump file and the associated dump buffer.
121
    These variables give the dump file and the associated dump buffer.
92
*/
122
*/
93
 
123
 
94
static FILE *dump_file = NULL ;
124
static FILE *dump_file = NULL;
95
static BUFFER dump_buff_rep = NULL_buff ;
125
static BUFFER dump_buff_rep = NULL_buff;
96
static BUFFER *dump_buff = &dump_buff_rep ;
126
static BUFFER *dump_buff = &dump_buff_rep;
97
 
127
 
98
 
128
 
99
/*
129
/*
100
    DUMP BUFFER TO FILE
130
    DUMP BUFFER TO FILE
101
 
131
 
102
    This routine adds the contents of the dump buffer to the dump file.
132
    This routine adds the contents of the dump buffer to the dump file.
103
*/
133
*/
104
 
134
 
105
static void dump_string
135
static void
106
    PROTO_Z ()
136
dump_string(void)
107
{
137
{
108
    FILE *f = dump_file ;
138
	FILE *f = dump_file;
109
    BUFFER *bf = dump_buff ;
139
	BUFFER *bf = dump_buff;
110
    string s = bf->start ;
140
	string s = bf->start;
111
    size_t n = ( size_t ) ( bf->posn - s ) ;
141
	size_t n = (size_t)(bf->posn - s);
112
    fprintf_v ( f, "&%lu<", ( unsigned long ) n ) ;
142
	fprintf_v(f, "&%lu<",(unsigned long)n);
113
    if ( n ) {
143
	if (n) {
114
	IGNORE fwrite ( ( gen_ptr ) s, sizeof ( character ), n, f ) ;
144
		IGNORE fwrite((gen_ptr)s, sizeof(character), n, f);
115
	bf->posn = s ;
145
		bf->posn = s;
116
    }
146
	}
117
    fputc_v ( '>', f ) ;
147
	fputc_v('>', f);
118
    return ;
148
	return;
119
}
149
}
120
 
150
 
121
 
151
 
122
/*
152
/*
123
    FORWARD DECLARATIONS
153
    FORWARD DECLARATIONS
124
 
154
 
125
    The dump routines defined in this module are defined recursively
155
    The dump routines defined in this module are defined recursively
126
    so a couple of forward declarations are required.
156
    so a couple of forward declarations are required.
127
*/
157
*/
128
 
158
 
129
static void dump_id PROTO_S ( ( IDENTIFIER ) ) ;
159
static void dump_id(IDENTIFIER);
130
static void dump_type PROTO_S ( ( TYPE ) ) ;
160
static void dump_type(TYPE);
131
static void dump_tok_appl PROTO_S ( ( IDENTIFIER, LIST ( TOKEN ) ) ) ;
161
static void dump_tok_appl(IDENTIFIER, LIST(TOKEN));
132
static void dump_nat PROTO_S ( ( NAT, int ) ) ;
162
static void dump_nat(NAT, int);
133
 
163
 
134
 
164
 
135
/*
165
/*
136
    DUMP FLAGS
166
    DUMP FLAGS
137
 
167
 
138
    The flag dump_implicit can be set to true to indicate that the
168
    The flag dump_implicit can be set to true to indicate that the
139
    following declaration or definition is actually implicit.  The flag
169
    following declaration or definition is actually implicit.  The flag
140
    dump_anon_class can be set to inhibit type definitions which name
170
    dump_anon_class can be set to inhibit type definitions which name
141
    anonymous classes being output twice.
171
    anonymous classes being output twice.
142
*/
172
*/
143
 
173
 
144
int dump_implicit = 0 ;
174
int dump_implicit = 0;
145
int dump_template = 0 ;
175
int dump_template = 0;
146
int dump_anon_class = 0 ;
176
int dump_anon_class = 0;
147
 
177
 
148
 
178
 
149
/*
179
/*
150
    FIND AN IDENTIFIER KEY
180
    FIND AN IDENTIFIER KEY
151
 
181
 
152
    This routine finds the key corresponding to the identifier id.
182
    This routine finds the key corresponding to the identifier id.
153
    This is a sequence of characters giving the type of identifier.
183
    This is a sequence of characters giving the type of identifier.
278
		}
361
		}
279
		break ;
-
 
280
	    }
-
 
281
	    case id_stat_mem_func_tag : {
-
 
282
		/* Static member functions */
-
 
283
		key = "CS" ;
-
 
284
		break ;
-
 
285
	    }
-
 
286
	    case id_stat_member_tag : {
-
 
287
		/* Static data members */
-
 
288
		key = "CD" ;
-
 
289
		break ;
-
 
290
	    }
-
 
291
	    case id_member_tag : {
-
 
292
		/* Data members */
-
 
293
		key = "CM" ;
-
 
294
		break ;
-
 
295
	    }
-
 
296
	    case id_enumerator_tag : {
-
 
297
		/* Enumerators */
-
 
298
		key = "E" ;
-
 
299
		break ;
-
 
300
	    }
-
 
301
	    case id_label_tag : {
-
 
302
		/* Labels */
-
 
303
		key = "L" ;
-
 
304
		break ;
-
 
305
	    }
-
 
306
	    case id_token_tag : {
-
 
307
		/* Tokens */
-
 
308
		DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
-
 
309
		if ( ds & dspec_auto ) {
-
 
310
		    if ( ds & dspec_template ) {
-
 
311
			key = "XT" ;
-
 
312
		    } else {
-
 
313
			key = "XP" ;
-
 
314
		    }
-
 
315
		} else {
-
 
316
		    TOKEN tok = DEREF_tok ( id_token_sort ( id ) ) ;
-
 
317
		    if ( !IS_NULL_tok ( tok ) && IS_tok_proc ( tok ) ) {
-
 
318
			key = "XF" ;
-
 
319
		    } else {
-
 
320
			key = "XO" ;
-
 
321
		    }
-
 
322
		}
362
		}
323
		break ;
-
 
324
	    }
-
 
325
	}
363
	}
326
    }
-
 
327
    return ( key ) ;
364
	return (key);
328
}
365
}
329
 
366
 
330
 
367
 
331
/*
368
/*
332
    DUMP A LEXICAL TOKEN
369
    DUMP A LEXICAL TOKEN
333
 
370
 
334
    This routine adds the lexical token t to the dump file.
371
    This routine adds the lexical token t to the dump file.
335
*/
372
*/
336
 
373
 
337
static void dump_lex
374
static void
338
    PROTO_N ( ( t ) )
-
 
339
    PROTO_T ( int t )
375
dump_lex(int t)
340
{
376
{
341
    FILE *f = dump_file ;
377
	FILE *f = dump_file;
342
    string s = token_name ( t ) ;
378
	string s = token_name(t);
343
    if ( s ) {
379
	if (s) {
344
	unsigned n = ( unsigned ) ustrlen ( s ) ;
380
		unsigned n = (unsigned)ustrlen(s);
345
	if ( n > 100 || ustrchr ( s, '>' ) ) fprintf_v ( f, "&%u", n ) ;
381
		if (n > 100 || ustrchr(s, '>')) {
-
 
382
			fprintf_v(f, "&%u", n);
-
 
383
		}
346
	fprintf_v ( f, "<%s>", strlit ( s ) ) ;
384
		fprintf_v(f, "<%s>", strlit(s));
347
    } else {
385
	} else {
348
	fputs_v ( "<>", f ) ;
386
		fputs_v("<>", f);
349
    }
387
	}
350
    return ;
388
	return;
351
}
389
}
352
 
390
 
353
 
391
 
354
/*
392
/*
355
    DUMP A HASH TABLE ENTRY
393
    DUMP A HASH TABLE ENTRY
356
 
394
 
357
    This routine adds the hash table entry nm to the dump file.
395
    This routine adds the hash table entry nm to the dump file.
358
*/
396
*/
359
 
397
 
360
static void dump_hashid
398
static void
361
    PROTO_N ( ( nm ) )
-
 
362
    PROTO_T ( HASHID nm )
399
dump_hashid(HASHID nm)
363
{
400
{
364
    FILE *f = dump_file ;
401
	FILE *f = dump_file;
365
    if ( IS_NULL_hashid ( nm ) ) {
402
	if (IS_NULL_hashid(nm)) {
366
	fputs_v ( "<>", f ) ;
403
		fputs_v("<>", f);
367
	return ;
404
		return;
368
    }
405
	}
369
    switch ( TAG_hashid ( nm ) ) {
406
	switch (TAG_hashid(nm)) {
370
	case hashid_name_tag :
407
	case hashid_name_tag:
371
	case hashid_ename_tag : {
408
	case hashid_ename_tag: {
372
	    /* Simple identifiers */
409
		/* Simple identifiers */
373
	    string s = DEREF_string ( hashid_name_etc_text ( nm ) ) ;
410
		string s = DEREF_string(hashid_name_etc_text(nm));
374
	    unsigned n = ( unsigned ) ustrlen ( s ) ;
411
		unsigned n = (unsigned)ustrlen(s);
375
	    if ( n > 100 || ustrchr ( s, '>' ) ) fprintf_v ( f, "&%u", n ) ;
412
		if (n > 100 || ustrchr(s, '>')) {
-
 
413
			fprintf_v(f, "&%u", n);
-
 
414
		}
376
	    fprintf_v ( f, "<%s>", strlit ( s ) ) ;
415
		fprintf_v(f, "<%s>", strlit(s));
377
	    break ;
416
		break;
378
	}
417
	}
379
	case hashid_constr_tag : {
418
	case hashid_constr_tag: {
380
	    /* Constructor names */
419
		/* Constructor names */
381
	    TYPE t = DEREF_type ( hashid_constr_type ( nm ) ) ;
420
		TYPE t = DEREF_type(hashid_constr_type(nm));
382
	    fputc_v ( 'C', f ) ;
421
		fputc_v('C', f);
383
	    dump_type ( t ) ;
422
		dump_type(t);
384
	    break ;
423
		break;
385
	}
424
	}
386
	case hashid_destr_tag : {
425
	case hashid_destr_tag: {
387
	    /* Destructor names */
426
		/* Destructor names */
388
	    TYPE t = DEREF_type ( hashid_destr_type ( nm ) ) ;
427
		TYPE t = DEREF_type(hashid_destr_type(nm));
389
	    fputc_v ( 'D', f ) ;
428
		fputc_v('D', f);
390
	    dump_type ( t ) ;
429
		dump_type(t);
391
	    break ;
430
		break;
392
	}
431
	}
393
	case hashid_conv_tag : {
432
	case hashid_conv_tag: {
394
	    /* Conversion function names */
433
		/* Conversion function names */
395
	    TYPE t = DEREF_type ( hashid_conv_type ( nm ) ) ;
434
		TYPE t = DEREF_type(hashid_conv_type(nm));
396
	    fputc_v ( 'T', f ) ;
435
		fputc_v('T', f);
397
	    dump_type ( t ) ;
436
		dump_type(t);
398
	    break ;
437
		break;
399
	}
438
	}
400
	case hashid_op_tag : {
439
	case hashid_op_tag: {
401
	    /* Overloaded operator names */
440
		/* Overloaded operator names */
402
	    int t = DEREF_int ( hashid_op_lex ( nm ) ) ;
441
		int t = DEREF_int(hashid_op_lex(nm));
403
	    fputc_v ( 'O', f ) ;
442
		fputc_v('O', f);
404
	    dump_lex ( t ) ;
443
		dump_lex(t);
405
	    break ;
444
		break;
406
	}
445
	}
407
	default : {
446
	default : {
408
	    /* Other names */
447
		/* Other names */
409
	    fputs_v ( "<>", f ) ;
448
		fputs_v("<>", f);
410
	    break ;
449
		break;
411
	}
450
	}
412
    }
451
	}
413
    return ;
452
	return;
414
}
453
}
415
 
454
 
416
 
455
 
417
/*
456
/*
418
    DUMP A NAMESPACE
457
    DUMP A NAMESPACE
419
 
458
 
420
    This routine adds the namespace ns to the dump file.  The current
459
    This routine adds the namespace ns to the dump file.  The current
421
    declaration block is taken into account in blk is true.
460
    declaration block is taken into account in blk is true.
422
*/
461
*/
423
 
462
 
424
static void dump_nspace
463
static void
425
    PROTO_N ( ( ns, blk ) )
-
 
426
    PROTO_T ( NAMESPACE ns X int blk )
464
dump_nspace(NAMESPACE ns, int blk)
427
{
465
{
428
    if ( !IS_NULL_nspace ( ns ) ) {
466
	if (!IS_NULL_nspace(ns)) {
429
	if ( blk ) {
467
		if (blk) {
430
	    LIST ( IDENTIFIER ) s ;
468
			LIST(IDENTIFIER)s;
431
	    s = LIST_stack ( DEREF_stack ( nspace_set ( ns ) ) ) ;
469
			s = LIST_stack(DEREF_stack(nspace_set(ns)));
432
	    if ( !IS_NULL_list ( s ) ) {
470
			if (!IS_NULL_list(s)) {
433
		/* Allow for declaration blocks */
471
				/* Allow for declaration blocks */
434
		IDENTIFIER id = DEREF_id ( HEAD_list ( s ) ) ;
472
				IDENTIFIER id = DEREF_id(HEAD_list(s));
435
		dump_id ( id ) ;
473
				dump_id(id);
436
		return ;
474
				return;
437
	    }
475
			}
438
	}
476
		}
439
	if ( !IS_nspace_global ( ns ) ) {
477
		if (!IS_nspace_global(ns)) {
440
	    ulong n = DEREF_ulong ( nspace_dump ( ns ) ) ;
478
			ulong n = DEREF_ulong(nspace_dump(ns));
441
	    if ( n == LINK_NONE ) {
479
			if (n == LINK_NONE) {
442
		IDENTIFIER id = DEREF_id ( nspace_name ( ns ) ) ;
480
				IDENTIFIER id = DEREF_id(nspace_name(ns));
443
		if ( !IS_NULL_id ( id ) ) {
481
				if (!IS_NULL_id(id)) {
444
		    /* Use namespace name */
482
					/* Use namespace name */
445
		    dump_id ( id ) ;
483
					dump_id(id);
446
		    n = DEREF_ulong ( id_dump ( id ) ) ;
484
					n = DEREF_ulong(id_dump(id));
447
		    COPY_ulong ( nspace_dump ( ns ), n ) ;
485
					COPY_ulong(nspace_dump(ns), n);
448
		    return ;
486
					return;
449
		}
487
				}
450
	    } else {
488
			} else {
451
		/* Already assigned value */
489
				/* Already assigned value */
452
		fprintf_v ( dump_file, "%lu", n ) ;
490
				fprintf_v(dump_file, "%lu", n);
453
		return ;
491
				return;
454
	    }
492
			}
-
 
493
		}
455
	}
494
	}
456
    }
-
 
457
    fputs_v ( "*", dump_file ) ;
495
	fputs_v("*", dump_file);
458
    return ;
496
	return;
459
}
497
}
460
 
498
 
461
 
499
 
462
/*
500
/*
463
    DUMP AN ACCESS SPECIFIER
501
    DUMP AN ACCESS SPECIFIER
464
 
502
 
465
    This routine adds the access specifier acc to the dump file.
503
    This routine adds the access specifier acc to the dump file.
466
*/
504
*/
467
 
505
 
468
static void dump_access
506
static void
469
    PROTO_N ( ( acc ) )
-
 
470
    PROTO_T ( DECL_SPEC acc )
507
dump_access(DECL_SPEC acc)
471
{
508
{
472
    DECL_SPEC ds = ( acc & dspec_access ) ;
509
	DECL_SPEC ds = (acc & dspec_access);
473
    if ( ds == dspec_private ) {
510
	if (ds == dspec_private) {
474
	fputc_v ( 'P', dump_file ) ;
511
		fputc_v('P', dump_file);
475
    } else if ( ds == dspec_protected ) {
512
	} else if (ds == dspec_protected) {
476
	fputc_v ( 'B', dump_file ) ;
513
		fputc_v('B', dump_file);
477
    }
514
	}
478
    return ;
515
	return;
479
}
516
}
480
 
517
 
481
 
518
 
482
/*
519
/*
483
    IDENTIFIER DUMP NUMBER
520
    IDENTIFIER DUMP NUMBER
484
 
521
 
485
    Each identifier dumped is assigned a number in a sequence given
522
    Each identifier dumped is assigned a number in a sequence given
486
    by this variable.  The zero value stands for the null identifier.
523
    by this variable.  The zero value stands for the null identifier.
487
*/
524
*/
488
 
525
 
489
ulong dump_id_next = 1 ;
526
ulong dump_id_next = 1;
490
 
527
 
491
 
528
 
492
/*
529
/*
493
    DUMP AN IDENTIFIER
530
    DUMP AN IDENTIFIER
494
 
531
 
495
    This routine adds the identifier id to the dump file.
532
    This routine adds the identifier id to the dump file.
496
*/
533
*/
497
 
534
 
498
static void dump_id
535
static void
499
    PROTO_N ( ( id ) )
-
 
500
    PROTO_T ( IDENTIFIER id )
536
dump_id(IDENTIFIER id)
501
{
537
{
502
    if ( IS_NULL_id ( id ) ) {
538
	if (IS_NULL_id(id)) {
503
	fputs_v ( "0", dump_file ) ;
539
		fputs_v("0", dump_file);
504
    } else {
-
 
505
	ulong n = DEREF_ulong ( id_dump ( id ) ) ;
-
 
506
	if ( n == LINK_NONE || ( n & LINK_EXTERN ) ) {
-
 
507
	    FILE *f = dump_file ;
-
 
508
	    HASHID nm = DEREF_hashid ( id_name ( id ) ) ;
-
 
509
	    NAMESPACE ns = DEREF_nspace ( id_parent ( id ) ) ;
-
 
510
	    DECL_SPEC acc = DEREF_dspec ( id_storage ( id ) ) ;
-
 
511
	    if ( n == LINK_NONE ) {
-
 
512
		/* Allocate new number */
-
 
513
		n = dump_id_next++ ;
-
 
514
	    } else {
-
 
515
		/* Use number from spec file */
-
 
516
		n &= ~LINK_EXTERN ;
-
 
517
	    }
-
 
518
	    COPY_ulong ( id_dump ( id ), n ) ;
-
 
519
	    fprintf_v ( f, "%lu = ", n ) ;
-
 
520
	    dump_hashid ( nm ) ;
-
 
521
	    fputc_v ( '\t', f ) ;
-
 
522
	    dump_access ( acc ) ;
-
 
523
	    dump_nspace ( ns, 1 ) ;
-
 
524
	} else {
540
	} else {
-
 
541
		ulong n = DEREF_ulong(id_dump(id));
-
 
542
		if (n == LINK_NONE || (n & LINK_EXTERN)) {
-
 
543
			FILE *f = dump_file;
-
 
544
			HASHID nm = DEREF_hashid(id_name(id));
-
 
545
			NAMESPACE ns = DEREF_nspace(id_parent(id));
-
 
546
			DECL_SPEC acc = DEREF_dspec(id_storage(id));
-
 
547
			if (n == LINK_NONE) {
-
 
548
				/* Allocate new number */
-
 
549
				n = dump_id_next++;
-
 
550
			} else {
-
 
551
				/* Use number from spec file */
-
 
552
				n &= ~LINK_EXTERN;
-
 
553
			}
-
 
554
			COPY_ulong(id_dump(id), n);
-
 
555
			fprintf_v(f, "%lu = ", n);
-
 
556
			dump_hashid(nm);
-
 
557
			fputc_v('\t', f);
-
 
558
			dump_access(acc);
-
 
559
			dump_nspace(ns, 1);
-
 
560
		} else {
525
	    fprintf_v ( dump_file, "%lu", n ) ;
561
			fprintf_v(dump_file, "%lu", n);
-
 
562
		}
526
	}
563
	}
527
    }
-
 
528
    return ;
564
	return;
529
}
565
}
530
 
566
 
531
 
567
 
532
/*
568
/*
533
    LAST DUMP LOCATION
569
    LAST DUMP LOCATION
534
 
570
 
535
    When dumping locations the previous location is stored in these
571
    When dumping locations the previous location is stored in these
536
    variables and only items which have changed are output.
572
    variables and only items which have changed are output.
537
*/
573
*/
538
 
574
 
539
static unsigned long last_ln = 0 ;
575
static unsigned long last_ln = 0;
540
static unsigned long last_cn = 0 ;
576
static unsigned long last_cn = 0;
541
static string last_file = NULL ;
577
static string last_file = NULL;
542
static string last_input = NULL ;
578
static string last_input = NULL;
543
static PTR ( POSITION ) last_posn = NULL_ptr ( POSITION ) ;
579
static PTR(POSITION)last_posn = NULL_ptr(POSITION);
544
 
580
 
545
 
581
 
546
/*
582
/*
547
    DUMP A LOCATION
583
    DUMP A LOCATION
548
 
584
 
549
    This routine adds the location loc to the dump file.
585
    This routine adds the location loc to the dump file.
550
*/
586
*/
551
 
587
 
552
static void dump_loc
588
static void
553
    PROTO_N ( ( loc ) )
-
 
554
    PROTO_T ( LOCATION *loc )
589
dump_loc(LOCATION *loc)
555
{
590
{
556
    FILE *f = dump_file ;
591
	FILE *f = dump_file;
557
    unsigned long ln = loc->line ;
592
	unsigned long ln = loc->line;
558
    unsigned long cn = loc->column ;
593
	unsigned long cn = loc->column;
559
    PTR ( POSITION ) posn = loc->posn ;
594
	PTR(POSITION)posn = loc->posn;
560
    if ( EQ_ptr ( posn, last_posn ) ) {
595
	if (EQ_ptr(posn, last_posn)) {
561
	/* Same file information as previously */
596
		/* Same file information as previously */
562
	if ( ln == last_ln ) {
597
		if (ln == last_ln) {
563
	    if ( cn == last_cn ) {
598
			if (cn == last_cn) {
564
		fputs_v ( "*", f ) ;
599
				fputs_v("*", f);
565
	    } else {
600
			} else {
566
		fprintf_v ( f, "%lu\t*", cn ) ;
601
				fprintf_v(f, "%lu\t*", cn);
-
 
602
				last_cn = cn;
-
 
603
			}
-
 
604
		} else {
-
 
605
			fprintf_v(f, "%lu\t%lu\t*", cn, ln );
567
		last_cn = cn ;
606
			last_cn = cn;
-
 
607
			last_ln = ln;
568
	    }
608
		}
569
	} else {
609
	} else {
-
 
610
		/* Different file information */
-
 
611
		string file = DEREF_string(posn_file(posn));
-
 
612
		string input = DEREF_string(posn_input(posn));
-
 
613
		unsigned long off = DEREF_ulong(posn_offset(posn));
570
	    fprintf_v ( f, "%lu\t%lu\t*", cn, ln ) ;
614
		fprintf_v(f, "%lu\t%lu\t%lu\t", cn, ln, ln - off );
-
 
615
		if (ustreq(file, last_file) && ustreq(input, last_input)) {
-
 
616
			/* File names unchanged */
-
 
617
			fputc_v('*', f);
-
 
618
		} else {
-
 
619
			unsigned n = (unsigned)ustrlen(file);
-
 
620
			fprintf_v(f, "&%u<%s>\t", n, strlit(file));
-
 
621
			if (ustreq(file, input)) {
-
 
622
				/* Current and actual files match */
-
 
623
				fputc_v('*', f);
-
 
624
			} else {
-
 
625
				/* Different current and actual files */
-
 
626
				n = (unsigned)ustrlen(input);
-
 
627
				fprintf_v(f, "&%u<%s>", n, strlit(input));
-
 
628
			}
-
 
629
			last_input = input;
-
 
630
			last_file = file;
-
 
631
		}
-
 
632
		last_posn = posn;
571
	    last_cn = cn ;
633
		last_cn = cn;
572
	    last_ln = ln ;
634
		last_ln = ln;
573
	}
635
	}
574
    } else {
-
 
575
	/* Different file information */
-
 
576
	string file = DEREF_string ( posn_file ( posn ) ) ;
-
 
577
	string input = DEREF_string ( posn_input ( posn ) ) ;
-
 
578
	unsigned long off = DEREF_ulong ( posn_offset ( posn ) ) ;
-
 
579
	fprintf_v ( f, "%lu\t%lu\t%lu\t", cn, ln, ln - off ) ;
-
 
580
	if ( ustreq ( file, last_file ) && ustreq ( input, last_input ) ) {
-
 
581
	    /* File names unchanged */
-
 
582
	    fputc_v ( '*', f ) ;
-
 
583
	} else {
-
 
584
	    unsigned n = ( unsigned ) ustrlen ( file ) ;
-
 
585
	    fprintf_v ( f, "&%u<%s>\t", n, strlit ( file ) ) ;
-
 
586
	    if ( ustreq ( file, input ) ) {
-
 
587
		/* Current and actual files match */
-
 
588
		fputc_v ( '*', f ) ;
-
 
589
	    } else {
-
 
590
		/* Different current and actual files */
-
 
591
		n = ( unsigned ) ustrlen ( input ) ;
-
 
592
		fprintf_v ( f, "&%u<%s>", n, strlit ( input ) ) ;
-
 
593
	    }
-
 
594
	    last_input = input ;
-
 
595
	    last_file = file ;
-
 
596
	}
-
 
597
	last_posn = posn ;
-
 
598
	last_cn = cn ;
-
 
599
	last_ln = ln ;
-
 
600
    }
-
 
601
    return ;
636
	return;
602
}
637
}
603
 
638
 
604
 
639
 
605
/*
640
/*
606
    DUMP AN EXPRESSION
641
    DUMP AN EXPRESSION
607
 
642
 
608
    This routine adds the expression e to the dump file.
643
    This routine adds the expression e to the dump file.
609
*/
644
*/
610
 
645
 
611
static void dump_exp
646
static void
612
    PROTO_N ( ( e ) )
-
 
613
    PROTO_T ( EXP e )
647
dump_exp(EXP e)
614
{
648
{
615
    if ( !IS_NULL_exp ( e ) ) {
649
	if (!IS_NULL_exp(e)) {
616
	switch ( TAG_exp ( e ) ) {
650
		switch (TAG_exp(e)) {
617
	    case exp_int_lit_tag : {
651
		case exp_int_lit_tag: {
618
		/* Integer literals */
652
			/* Integer literals */
619
		NAT n = DEREF_nat ( exp_int_lit_nat ( e ) ) ;
653
			NAT n = DEREF_nat(exp_int_lit_nat(e));
620
		dump_nat ( n, 0 ) ;
654
			dump_nat(n, 0);
621
		return ;
655
			return;
622
	    }
656
		}
623
	    case exp_token_tag : {
657
		case exp_token_tag: {
624
		/* Tokenised expressions */
658
			/* Tokenised expressions */
625
		IDENTIFIER id = DEREF_id ( exp_token_tok ( e ) ) ;
659
			IDENTIFIER id = DEREF_id(exp_token_tok(e));
626
		LIST ( TOKEN ) args = DEREF_list ( exp_token_args ( e ) ) ;
660
			LIST(TOKEN)args = DEREF_list(exp_token_args(e));
627
		dump_tok_appl ( id, args ) ;
661
			dump_tok_appl(id, args);
628
		return ;
662
			return;
-
 
663
		}
629
	    }
664
		}
630
	}
665
	}
631
    }
-
 
632
    IGNORE print_exp ( e, 0, dump_buff, 0 ) ;
666
	IGNORE print_exp(e, 0, dump_buff, 0);
633
    dump_string () ;
667
	dump_string();
634
    return ;
668
	return;
635
}
669
}
636
 
670
 
637
 
671
 
638
/*
672
/*
639
    DUMP AN OFFSET
673
    DUMP AN OFFSET
640
 
674
 
641
    This routine adds the offset off to the dump file.
675
    This routine adds the offset off to the dump file.
642
*/
676
*/
643
 
677
 
644
static void dump_off
678
static void
645
    PROTO_N ( ( off ) )
-
 
646
    PROTO_T ( OFFSET off )
679
dump_off(OFFSET off)
647
{
680
{
648
    IGNORE print_offset ( off, dump_buff, 0 ) ;
681
	IGNORE print_offset(off, dump_buff, 0);
649
    dump_string () ;
682
	dump_string();
650
    return ;
683
	return;
651
}
684
}
652
 
685
 
653
 
686
 
654
/*
687
/*
655
    DUMP AN INTEGER CONSTANT
688
    DUMP AN INTEGER CONSTANT
656
 
689
 
657
    This routine adds the integer constant n to the dump file.
690
    This routine adds the integer constant n to the dump file.
658
*/
691
*/
659
 
692
 
660
static void dump_nat
693
static void
661
    PROTO_N ( ( n, neg ) )
-
 
662
    PROTO_T ( NAT n X int neg )
694
dump_nat(NAT n, int neg)
663
{
695
{
664
    if ( !IS_NULL_nat ( n ) ) {
696
	if (!IS_NULL_nat(n)) {
665
	FILE *f = dump_file ;
697
		FILE *f = dump_file;
666
	ASSERT ( ORDER_nat == 5 ) ;
698
		ASSERT(ORDER_nat == 5);
667
	switch ( TAG_nat ( n ) ) {
699
		switch (TAG_nat(n)) {
668
	    case nat_small_tag : {
700
		case nat_small_tag: {
669
		/* Small literals */
701
			/* Small literals */
670
		unsigned v = DEREF_unsigned ( nat_small_value ( n ) ) ;
702
			unsigned v = DEREF_unsigned(nat_small_value(n));
671
		int s = ( neg ? '-' : '+' ) ;
703
			int s = (neg ? '-' : '+');
672
		fputc_v ( s, f ) ;
704
			fputc_v(s, f);
673
		fprintf_v ( f, "%u", v ) ;
705
			fprintf_v(f, "%u", v);
674
		break ;
706
			break;
675
	    }
707
		}
676
	    case nat_large_tag : {
708
		case nat_large_tag: {
677
		/* Large literals */
709
			/* Large literals */
678
		unsigned long v = get_nat_value ( n ) ;
710
			unsigned long v = get_nat_value(n);
679
		int s = ( neg ? '-' : '+' ) ;
711
			int s = (neg ? '-' : '+');
680
		fputc_v ( s, f ) ;
712
			fputc_v(s, f);
681
		fprintf_v ( f, "%lu", v ) ;
713
			fprintf_v(f, "%lu", v);
682
		break ;
714
			break;
683
	    }
715
		}
684
	    case nat_neg_tag : {
716
		case nat_neg_tag: {
685
		/* Negated literals */
717
			/* Negated literals */
686
		NAT m = DEREF_nat ( nat_neg_arg ( n ) ) ;
718
			NAT m = DEREF_nat(nat_neg_arg(n));
687
		dump_nat ( m, !neg ) ;
719
			dump_nat(m, !neg);
688
		break ;
720
			break;
689
	    }
721
		}
690
	    case nat_calc_tag : {
722
		case nat_calc_tag: {
691
		/* Calculated literals */
723
			/* Calculated literals */
692
		EXP e = DEREF_exp ( nat_calc_value ( n ) ) ;
724
			EXP e = DEREF_exp(nat_calc_value(n));
693
		dump_exp ( e ) ;
725
			dump_exp(e);
694
		break ;
726
			break;
695
	    }
727
		}
696
	    case nat_token_tag : {
728
		case nat_token_tag: {
697
		/* Tokenised literals */
729
			/* Tokenised literals */
698
		IDENTIFIER id = DEREF_id ( nat_token_tok ( n ) ) ;
730
			IDENTIFIER id = DEREF_id(nat_token_tok(n));
699
		LIST ( TOKEN ) args = DEREF_list ( nat_token_args ( n ) ) ;
731
			LIST(TOKEN)args = DEREF_list(nat_token_args(n));
700
		dump_tok_appl ( id, args ) ;
732
			dump_tok_appl(id, args);
701
		break ;
733
			break;
-
 
734
		}
702
	    }
735
		}
703
	}
736
	}
704
    }
-
 
705
    return ;
737
	return;
706
}
738
}
707
 
739
 
708
 
740
 
709
/*
741
/*
710
    DUMP A LIST OF TOKEN PARAMETERS
742
    DUMP A LIST OF TOKEN PARAMETERS
711
 
743
 
712
    This routine adds the list of token parameters pids to the dump file.
744
    This routine adds the list of token parameters pids to the dump file.
713
*/
745
*/
714
 
746
 
715
static void dump_params
747
static void
716
    PROTO_N ( ( pids ) )
-
 
717
    PROTO_T ( LIST ( IDENTIFIER ) pids )
748
dump_params(LIST(IDENTIFIER)pids)
718
{
749
{
719
    int started = 0 ;
750
	int started = 0;
720
    FILE *f = dump_file ;
751
	FILE *f = dump_file;
721
    while ( !IS_NULL_list ( pids ) ) {
752
	while (!IS_NULL_list(pids)) {
722
	IDENTIFIER pid = DEREF_id ( HEAD_list ( pids ) ) ;
753
		IDENTIFIER pid = DEREF_id(HEAD_list(pids));
723
	if ( !IS_NULL_id ( pid ) ) {
754
		if (!IS_NULL_id(pid)) {
724
	    if ( IS_id_token ( pid ) ) {
755
			if (IS_id_token(pid)) {
725
		pid = DEREF_id ( id_token_alt ( pid ) ) ;
756
				pid = DEREF_id(id_token_alt(pid));
726
	    }
757
			}
-
 
758
			if (started) {
727
	    if ( started ) fputc_v ( MANGLE_comma, f ) ;
759
				fputc_v(MANGLE_comma, f);
-
 
760
			}
728
	    dump_id ( pid ) ;
761
			dump_id(pid);
729
	    started = 1 ;
762
			started = 1;
-
 
763
		}
-
 
764
		pids = TAIL_list(pids);
730
	}
765
	}
731
	pids = TAIL_list ( pids ) ;
-
 
732
    }
-
 
733
    return ;
766
	return;
734
}
767
}
735
 
768
 
736
 
769
 
737
/*
770
/*
738
    DUMP A TOKEN SORT
771
    DUMP A TOKEN SORT
739
 
772
 
740
    This routine adds the token sort tok to the dump file.
773
    This routine adds the token sort tok to the dump file.
864
    DUMP AN INTEGRAL TYPE
896
    DUMP AN INTEGRAL TYPE
865
 
897
 
866
    This routine adds the integral type it to the dump file.  Note that
898
    This routine adds the integral type it to the dump file.  Note that
867
    for this and the other type dumping routines the representation
899
    for this and the other type dumping routines the representation
868
    chosen bears a marked resemblance to the C++ name mangling scheme,
900
    chosen bears a marked resemblance to the C++ name mangling scheme,
869
    and uses the same MANGLE_* macros.  This is primarily to avoid having
901
    and uses the same MANGLE_* macros.  This is primarily to avoid having
870
    to think up two different forms.
902
    to think up two different forms.
871
*/
903
*/
872
 
904
 
873
static void dump_itype
905
static void
874
    PROTO_N ( ( it ) )
-
 
875
    PROTO_T ( INT_TYPE it )
906
dump_itype(INT_TYPE it)
876
{
907
{
877
    FILE *f = dump_file ;
908
	FILE *f = dump_file;
878
    ASSERT ( ORDER_itype == 6 ) ;
909
	ASSERT(ORDER_itype == 6);
879
    switch ( TAG_itype ( it ) ) {
910
	switch (TAG_itype(it)) {
880
	case itype_basic_tag : {
911
	case itype_basic_tag: {
881
	    /* Basic integral types */
912
		/* Basic integral types */
882
	    BUILTIN_TYPE n = DEREF_ntype ( itype_basic_no ( it ) ) ;
913
		BUILTIN_TYPE n = DEREF_ntype(itype_basic_no(it));
883
	    fputs_v ( mangle_ntype [n], f ) ;
914
		fputs_v(mangle_ntype[n], f);
884
	    break ;
915
		break;
885
	}
916
	}
886
	case itype_bitfield_tag : {
917
	case itype_bitfield_tag: {
887
	    /* Bitfield types */
918
		/* Bitfield types */
888
	    NAT n = DEREF_nat ( itype_bitfield_size ( it ) ) ;
919
		NAT n = DEREF_nat(itype_bitfield_size(it));
889
	    TYPE s = DEREF_type ( itype_bitfield_sub ( it ) ) ;
920
		TYPE s = DEREF_type(itype_bitfield_sub(it));
890
	    fputc_v ( MANGLE_bitfield, f ) ;
921
		fputc_v(MANGLE_bitfield, f);
891
	    dump_nat ( n, 0 ) ;
922
		dump_nat(n, 0);
892
	    fputc_v ( MANGLE_colon, f ) ;
923
		fputc_v(MANGLE_colon, f);
893
	    dump_type ( s ) ;
924
		dump_type(s);
894
	    break ;
925
		break;
895
	}
926
	}
896
	case itype_promote_tag : {
927
	case itype_promote_tag: {
897
	    /* Promotion types */
928
		/* Promotion types */
898
	    INT_TYPE is = DEREF_itype ( itype_promote_arg ( it ) ) ;
929
		INT_TYPE is = DEREF_itype(itype_promote_arg(it));
899
	    fputc_v ( MANGLE_promote, f ) ;
930
		fputc_v(MANGLE_promote, f);
-
 
931
		dump_itype(is);
-
 
932
		break;
-
 
933
	}
-
 
934
	case itype_arith_tag: {
-
 
935
		/* Arithmetic types */
-
 
936
		INT_TYPE is = DEREF_itype(itype_arith_arg1(it));
-
 
937
		INT_TYPE ir = DEREF_itype(itype_arith_arg2(it));
-
 
938
		fputc_v(MANGLE_arith, f);
900
	    dump_itype ( is ) ;
939
		dump_itype(is);
-
 
940
		fputc_v(MANGLE_colon, f);
-
 
941
		dump_itype(ir);
-
 
942
		break;
-
 
943
	}
-
 
944
	case itype_literal_tag: {
-
 
945
		/* Literal types */
-
 
946
		NAT n = DEREF_nat(itype_literal_nat(it));
-
 
947
		string s = mangle_literal(it);
-
 
948
		fputs_v(strlit(s), f);
-
 
949
		dump_nat(n, 0);
901
	    break ;
950
		break;
902
	}
951
	}
903
	case itype_arith_tag : {
952
	case itype_token_tag: {
904
	    /* Arithmetic types */
953
		/* Tokenised types */
905
	    INT_TYPE is = DEREF_itype ( itype_arith_arg1 ( it ) ) ;
954
		BUILTIN_TYPE n = DEREF_ntype(itype_unprom(it));
-
 
955
		if (n == ntype_none || n == ntype_ellipsis) {
-
 
956
			IDENTIFIER id;
-
 
957
			LIST(TOKEN)args;
906
	    INT_TYPE ir = DEREF_itype ( itype_arith_arg2 ( it ) ) ;
958
			id = DEREF_id(itype_token_tok(it));
907
	    fputc_v ( MANGLE_arith, f ) ;
959
			args = DEREF_list(itype_token_args(it));
908
	    dump_itype ( is ) ;
960
			dump_tok_appl(id, args);
-
 
961
		} else {
909
	    fputc_v ( MANGLE_colon, f ) ;
962
			fputc_v(MANGLE_promote, f);
910
	    dump_itype ( ir ) ;
963
			fputs_v(mangle_ntype[n], f);
-
 
964
		}
911
	    break ;
965
		break;
912
	}
966
	}
913
	case itype_literal_tag : {
-
 
914
	    /* Literal types */
-
 
915
	    NAT n = DEREF_nat ( itype_literal_nat ( it ) ) ;
-
 
916
	    string s = mangle_literal ( it ) ;
-
 
917
	    fputs_v ( strlit ( s ), f ) ;
-
 
918
	    dump_nat ( n, 0 ) ;
-
 
919
	    break ;
-
 
920
	}
967
	}
921
	case itype_token_tag : {
-
 
922
	    /* Tokenised types */
-
 
923
	    BUILTIN_TYPE n = DEREF_ntype ( itype_unprom ( it ) ) ;
-
 
924
	    if ( n == ntype_none || n == ntype_ellipsis ) {
-
 
925
		IDENTIFIER id ;
-
 
926
		LIST ( TOKEN ) args ;
-
 
927
		id = DEREF_id ( itype_token_tok ( it ) ) ;
-
 
928
		args = DEREF_list ( itype_token_args ( it ) ) ;
-
 
929
		dump_tok_appl ( id, args ) ;
-
 
930
	    } else {
-
 
931
		fputc_v ( MANGLE_promote, f ) ;
-
 
932
		fputs_v ( mangle_ntype [n], f ) ;
-
 
933
	    }
-
 
934
	    break ;
-
 
935
	}
-
 
936
    }
-
 
937
    return ;
968
	return;
938
}
969
}
939
 
970
 
940
 
971
 
941
/*
972
/*
942
    DUMP A FLOATING POINT TYPE
973
    DUMP A FLOATING POINT TYPE
943
 
974
 
944
    This routine adds the floating point type ft to the dump file.
975
    This routine adds the floating point type ft to the dump file.
945
*/
976
*/
946
 
977
 
947
static void dump_ftype
978
static void
948
    PROTO_N ( ( ft ) )
-
 
949
    PROTO_T ( FLOAT_TYPE ft )
979
dump_ftype(FLOAT_TYPE ft)
950
{
980
{
951
    FILE *f = dump_file ;
981
	FILE *f = dump_file;
952
    ASSERT ( ORDER_ftype == 4 ) ;
982
	ASSERT(ORDER_ftype == 4);
953
    switch ( TAG_ftype ( ft ) ) {
983
	switch (TAG_ftype(ft)) {
954
	case ftype_basic_tag : {
984
	case ftype_basic_tag: {
955
	    /* Basic floating types */
985
		/* Basic floating types */
956
	    BUILTIN_TYPE n = DEREF_ntype ( ftype_basic_no ( ft ) ) ;
986
		BUILTIN_TYPE n = DEREF_ntype(ftype_basic_no(ft));
957
	    fputs_v ( mangle_ntype [n], f ) ;
987
		fputs_v(mangle_ntype[n], f);
958
	    break ;
-
 
959
	}
-
 
960
	case ftype_arg_promote_tag : {
-
 
961
	    /* Promotion types */
-
 
962
	    FLOAT_TYPE fs = DEREF_ftype ( ftype_arg_promote_arg ( ft ) ) ;
-
 
963
	    fputc_v ( MANGLE_promote, f ) ;
-
 
964
	    dump_ftype ( fs ) ;
-
 
965
	    break ;
988
		break;
966
	}
989
	}
967
	case ftype_arith_tag : {
990
	case ftype_arg_promote_tag: {
968
	    /* Arithmetic types */
991
		/* Promotion types */
969
	    FLOAT_TYPE fs = DEREF_ftype ( ftype_arith_arg1 ( ft ) ) ;
992
		FLOAT_TYPE fs = DEREF_ftype(ftype_arg_promote_arg(ft));
970
	    FLOAT_TYPE fr = DEREF_ftype ( ftype_arith_arg2 ( ft ) ) ;
-
 
971
	    fputc_v ( MANGLE_arith, f ) ;
993
		fputc_v(MANGLE_promote, f);
972
	    dump_ftype ( fs ) ;
994
		dump_ftype(fs);
973
	    fputc_v ( MANGLE_colon, f ) ;
-
 
974
	    dump_ftype ( fr ) ;
-
 
975
	    break ;
995
		break;
976
	}
996
	}
-
 
997
	case ftype_arith_tag: {
-
 
998
		/* Arithmetic types */
-
 
999
		FLOAT_TYPE fs = DEREF_ftype(ftype_arith_arg1(ft));
-
 
1000
		FLOAT_TYPE fr = DEREF_ftype(ftype_arith_arg2(ft));
-
 
1001
		fputc_v(MANGLE_arith, f);
-
 
1002
		dump_ftype(fs);
-
 
1003
		fputc_v(MANGLE_colon, f);
-
 
1004
		dump_ftype(fr);
-
 
1005
		break;
-
 
1006
	}
977
	case ftype_token_tag : {
1007
	case ftype_token_tag: {
978
	    /* Tokenised types */
1008
		/* Tokenised types */
979
	    IDENTIFIER id = DEREF_id ( ftype_token_tok ( ft ) ) ;
1009
		IDENTIFIER id = DEREF_id(ftype_token_tok(ft));
980
	    LIST ( TOKEN ) args = DEREF_list ( ftype_token_args ( ft ) ) ;
1010
		LIST(TOKEN)args = DEREF_list(ftype_token_args(ft));
981
	    dump_tok_appl ( id, args ) ;
1011
		dump_tok_appl(id, args);
982
	    break ;
1012
		break;
983
	}
1013
	}
984
    }
1014
	}
985
    return ;
1015
	return;
986
}
1016
}
987
 
1017
 
988
 
1018
 
989
/*
1019
/*
990
    DUMP A CLASS TYPE
1020
    DUMP A CLASS TYPE
991
 
1021
 
992
    This routine adds the class type ct to the dump file.
1022
    This routine adds the class type ct to the dump file.
993
*/
1023
*/
994
 
1024
 
995
static void dump_ctype
1025
static void
996
    PROTO_N ( ( ct ) )
-
 
997
    PROTO_T ( CLASS_TYPE ct )
1026
dump_ctype(CLASS_TYPE ct)
998
{
1027
{
999
    IDENTIFIER cid = DEREF_id ( ctype_name ( ct ) ) ;
1028
	IDENTIFIER cid = DEREF_id(ctype_name(ct));
1000
    dump_id ( cid ) ;
1029
	dump_id(cid);
1001
    return ;
1030
	return;
1002
}
1031
}
1003
 
1032
 
1004
 
1033
 
1005
/*
1034
/*
1006
    DUMP AN ENUMERATION TYPE
1035
    DUMP AN ENUMERATION TYPE
1007
 
1036
 
1008
    This routine adds the enumeration type et to the dump file.
1037
    This routine adds the enumeration type et to the dump file.
1009
*/
1038
*/
1010
 
1039
 
1011
static void dump_etype
1040
static void
1012
    PROTO_N ( ( et ) )
-
 
1013
    PROTO_T ( ENUM_TYPE et )
1041
dump_etype(ENUM_TYPE et)
1014
{
1042
{
1015
    IDENTIFIER eid = DEREF_id ( etype_name ( et ) ) ;
1043
	IDENTIFIER eid = DEREF_id(etype_name(et));
1016
    dump_id ( eid ) ;
1044
	dump_id(eid);
1017
    return ;
1045
	return;
1018
}
1046
}
1019
 
1047
 
1020
 
1048
 
1021
/*
1049
/*
1022
    DUMP A CONST-VOLATILE QUALIFIER
1050
    DUMP A CONST-VOLATILE QUALIFIER
1023
 
1051
 
1024
    This routine adds the const-volatile qualifier cv to the dump file.
1052
    This routine adds the const-volatile qualifier cv to the dump file.
1025
*/
1053
*/
1026
 
1054
 
1027
static void dump_cv
1055
static void
1028
    PROTO_N ( ( cv ) )
-
 
1029
    PROTO_T ( CV_SPEC cv )
1056
dump_cv(CV_SPEC cv)
1030
{
1057
{
-
 
1058
	if (cv & cv_const) {
1031
    if ( cv & cv_const ) fputc_v ( MANGLE_const, dump_file ) ;
1059
		fputc_v(MANGLE_const, dump_file);
-
 
1060
	}
-
 
1061
	if (cv & cv_volatile) {
1032
    if ( cv & cv_volatile ) fputc_v ( MANGLE_volatile, dump_file ) ;
1062
		fputc_v(MANGLE_volatile, dump_file);
-
 
1063
	}
1033
    return ;
1064
	return;
1034
}
1065
}
1035
 
1066
 
1036
 
1067
 
1037
/*
1068
/*
1038
    DUMP A LIST OF TYPES
1069
    DUMP A LIST OF TYPES
1039
 
1070
 
1040
    This routine adds the list of types p to the dump file.
1071
    This routine adds the list of types p to the dump file.
1041
*/
1072
*/
1042
 
1073
 
1043
static void dump_type_list
1074
static void
1044
    PROTO_N ( ( p, ell, started ) )
-
 
1045
    PROTO_T ( LIST ( TYPE ) p X int ell X int started )
1075
dump_type_list(LIST(TYPE)p, int ell, int started)
1046
{
1076
{
1047
    while ( !IS_NULL_list ( p ) ) {
1077
	while (!IS_NULL_list(p)) {
1048
	TYPE t = DEREF_type ( HEAD_list ( p ) ) ;
1078
		TYPE t = DEREF_type(HEAD_list(p));
1049
	if ( !IS_NULL_type ( t ) ) {
1079
		if (!IS_NULL_type(t)) {
-
 
1080
			if (started) {
1050
	    if ( started ) fputc_v ( MANGLE_comma, dump_file ) ;
1081
				fputc_v(MANGLE_comma, dump_file);
-
 
1082
			}
1051
	    if ( ell & FUNC_PARAMS ) t = unpromote_type ( t ) ;
1083
			if (ell & FUNC_PARAMS) {
-
 
1084
				t = unpromote_type(t);
-
 
1085
			}
1052
	    dump_type ( t ) ;
1086
			dump_type(t);
1053
	    started = 1 ;
1087
			started = 1;
-
 
1088
		}
-
 
1089
		p = TAIL_list(p);
1054
	}
1090
	}
1055
	p = TAIL_list ( p ) ;
-
 
1056
    }
-
 
1057
    return ;
1091
	return;
1058
}
1092
}
1059
 
1093
 
1060
 
1094
 
1061
/*
1095
/*
1062
    DUMP A TYPE
1096
    DUMP A TYPE
1063
 
1097
 
1064
    This routine adds the type t to the dump file.
1098
    This routine adds the type t to the dump file.
1065
*/
1099
*/
1066
 
1100
 
1067
static void dump_type
1101
static void
1068
    PROTO_N ( ( t ) )
-
 
1069
    PROTO_T ( TYPE t )
1102
dump_type(TYPE t)
1070
{
1103
{
1071
    CV_SPEC qual = DEREF_cv ( type_qual ( t ) ) ;
1104
	CV_SPEC qual = DEREF_cv(type_qual(t));
1072
    IDENTIFIER tid = DEREF_id ( type_name ( t ) ) ;
1105
	IDENTIFIER tid = DEREF_id(type_name(t));
1073
    dump_cv ( qual ) ;
1106
	dump_cv(qual);
1074
    if ( !IS_NULL_id ( tid ) ) {
1107
	if (!IS_NULL_id(tid)) {
1075
	switch ( TAG_id ( tid ) ) {
1108
		switch (TAG_id(tid)) {
1076
	    case id_class_alias_tag :
1109
		case id_class_alias_tag:
1077
	    case id_enum_alias_tag :
1110
		case id_enum_alias_tag:
1078
	    case id_type_alias_tag : {
1111
		case id_type_alias_tag: {
1079
		dump_id ( tid ) ;
1112
			dump_id(tid);
1080
		return ;
1113
			return;
1081
	    }
1114
		}
1082
	}
1115
		}
1083
    }
1116
	}
1084
    ASSERT ( ORDER_type == 18 ) ;
1117
	ASSERT(ORDER_type == 18);
1085
    switch ( TAG_type ( t ) ) {
1118
	switch (TAG_type(t)) {
1086
 
1119
 
1087
	case type_pre_tag : {
1120
	case type_pre_tag: {
1088
	    /* Pre-types */
1121
		/* Pre-types */
1089
	    if ( !IS_NULL_id ( tid ) ) {
1122
		if (!IS_NULL_id(tid)) {
1090
		dump_id ( tid ) ;
1123
			dump_id(tid);
1091
	    } else {
1124
		} else {
1092
		BASE_TYPE bt = DEREF_btype ( type_pre_rep ( t ) ) ;
1125
			BASE_TYPE bt = DEREF_btype(type_pre_rep(t));
1093
		if ( bt == btype_ellipsis ) {
1126
			if (bt == btype_ellipsis) {
1094
		    fputs_v ( "Q<...>", dump_file ) ;
1127
				fputs_v("Q<...>", dump_file);
1095
		} else {
1128
			} else {
1096
		    fputc_v ( MANGLE_error, dump_file ) ;
1129
				fputc_v(MANGLE_error, dump_file);
1097
		}
1130
			}
1098
	    }
1131
		}
1099
	    break ;
1132
		break;
1100
	}
1133
	}
1101
 
1134
 
1102
	case type_integer_tag : {
1135
	case type_integer_tag: {
1103
	    /* Integral types */
1136
		/* Integral types */
1104
	    INT_TYPE it = DEREF_itype ( type_integer_rep ( t ) ) ;
1137
		INT_TYPE it = DEREF_itype(type_integer_rep(t));
1105
	    dump_itype ( it ) ;
1138
		dump_itype(it);
-
 
1139
		break;
-
 
1140
	}
-
 
1141
 
-
 
1142
	case type_floating_tag: {
-
 
1143
		/* Floating point types */
-
 
1144
		FLOAT_TYPE ft = DEREF_ftype(type_floating_rep(t));
-
 
1145
		dump_ftype(ft);
-
 
1146
		break;
-
 
1147
	}
-
 
1148
 
-
 
1149
	case type_top_tag: {
-
 
1150
		/* Top type */
-
 
1151
		fputc_v(MANGLE_void, dump_file);
-
 
1152
		break;
-
 
1153
	}
-
 
1154
 
-
 
1155
	case type_bottom_tag: {
-
 
1156
		/* Bottom type */
-
 
1157
		fputc_v(MANGLE_bottom, dump_file);
-
 
1158
		break;
-
 
1159
	}
-
 
1160
 
-
 
1161
	case type_ptr_tag: {
-
 
1162
		/* Pointer types */
-
 
1163
		TYPE s = DEREF_type(type_ptr_sub(t));
-
 
1164
		fputc_v(MANGLE_ptr, dump_file);
-
 
1165
		dump_type(s);
-
 
1166
		break;
-
 
1167
	}
-
 
1168
 
-
 
1169
	case type_ref_tag: {
-
 
1170
		/* Reference types */
-
 
1171
		TYPE s = DEREF_type(type_ref_sub(t));
-
 
1172
		fputc_v(MANGLE_ref, dump_file);
-
 
1173
		dump_type(s);
1106
	    break ;
1174
		break;
1107
	}
1175
	}
1108
 
1176
 
1109
	case type_floating_tag : {
1177
	case type_ptr_mem_tag: {
1110
	    /* Floating point types */
1178
		/* Pointer to member types */
1111
	    FLOAT_TYPE ft = DEREF_ftype ( type_floating_rep ( t ) ) ;
1179
		CLASS_TYPE ct = DEREF_ctype(type_ptr_mem_of(t));
1112
	    dump_ftype ( ft ) ;
1180
		TYPE s = DEREF_type(type_ptr_mem_sub(t));
1113
	    break ;
-
 
1114
	}
-
 
1115
 
-
 
1116
	case type_top_tag : {
1181
		fputc_v(MANGLE_ptr_mem, dump_file);
1117
	    /* Top type */
1182
		dump_ctype(ct);
1118
	    fputc_v ( MANGLE_void, dump_file ) ;
1183
		fputc_v(MANGLE_colon, dump_file);
1119
	    break ;
1184
		dump_type(s);
1120
	}
-
 
1121
 
-
 
1122
	case type_bottom_tag : {
-
 
1123
	    /* Bottom type */
-
 
1124
	    fputc_v ( MANGLE_bottom, dump_file ) ;
-
 
1125
	    break ;
1185
		break;
1126
	}
1186
	}
1127
 
1187
 
1128
	case type_ptr_tag : {
-
 
1129
	    /* Pointer types */
-
 
1130
	    TYPE s = DEREF_type ( type_ptr_sub ( t ) ) ;
-
 
1131
	    fputc_v ( MANGLE_ptr, dump_file ) ;
-
 
1132
	    dump_type ( s ) ;
-
 
1133
	    break ;
-
 
1134
	}
-
 
1135
 
-
 
1136
	case type_ref_tag : {
-
 
1137
	    /* Reference types */
-
 
1138
	    TYPE s = DEREF_type ( type_ref_sub ( t ) ) ;
-
 
1139
	    fputc_v ( MANGLE_ref, dump_file ) ;
-
 
1140
	    dump_type ( s ) ;
-
 
1141
	    break ;
-
 
1142
	}
-
 
1143
 
-
 
1144
	case type_ptr_mem_tag : {
-
 
1145
	    /* Pointer to member types */
-
 
1146
	    CLASS_TYPE ct = DEREF_ctype ( type_ptr_mem_of ( t ) ) ;
-
 
1147
	    TYPE s = DEREF_type ( type_ptr_mem_sub ( t ) ) ;
-
 
1148
	    fputc_v ( MANGLE_ptr_mem, dump_file ) ;
-
 
1149
	    dump_ctype ( ct ) ;
-
 
1150
	    fputc_v ( MANGLE_colon, dump_file ) ;
-
 
1151
	    dump_type ( s ) ;
-
 
1152
	    break ;
-
 
1153
	}
-
 
1154
 
-
 
1155
	case type_func_tag : {
1188
	case type_func_tag: {
1156
	    /* Function types */
1189
		/* Function types */
1157
	    FILE *f = dump_file ;
1190
		FILE *f = dump_file;
1158
	    TYPE r = DEREF_type ( type_func_ret ( t ) ) ;
1191
		TYPE r = DEREF_type(type_func_ret(t));
1159
	    LIST ( TYPE ) p = DEREF_list ( type_func_ptypes ( t ) ) ;
1192
		LIST(TYPE)p = DEREF_list(type_func_ptypes(t));
1160
	    LIST ( TYPE ) e = DEREF_list ( type_func_except ( t ) ) ;
1193
		LIST(TYPE)e = DEREF_list(type_func_except(t));
1161
	    int ell = DEREF_int ( type_func_ellipsis ( t ) ) ;
1194
		int ell = DEREF_int(type_func_ellipsis(t));
1162
	    CV_SPEC mqual = DEREF_cv ( type_func_mqual ( t ) ) ;
1195
		CV_SPEC mqual = DEREF_cv(type_func_mqual(t));
1163
	    if ( ell & FUNC_WEAK ) {
1196
		if (ell & FUNC_WEAK) {
1164
		fputc_v ( MANGLE_weak, f ) ;
1197
			fputc_v(MANGLE_weak, f);
1165
	    } else {
1198
		} else {
1166
		fputc_v ( MANGLE_func, f ) ;
1199
			fputc_v(MANGLE_func, f);
1167
	    }
1200
		}
1168
	    dump_type ( r ) ;
1201
		dump_type(r);
1169
	    dump_type_list ( p, ell, 1 ) ;
1202
		dump_type_list(p, ell, 1);
1170
	    if ( ell & FUNC_VAR_PARAMS ) {
1203
		if (ell & FUNC_VAR_PARAMS) {
1171
		fputc_v ( MANGLE_dot, f ) ;
1204
			fputc_v(MANGLE_dot, f);
1172
	    } else {
1205
		} else {
1173
		fputc_v ( MANGLE_colon, f ) ;
1206
			fputc_v(MANGLE_colon, f);
1174
	    }
1207
		}
1175
	    if ( !EQ_list ( e, univ_type_set ) ) {
1208
		if (!EQ_list(e, univ_type_set)) {
1176
		/* Output exception specifiers */
1209
			/* Output exception specifiers */
1177
		fputc_v ( '(', f ) ;
1210
			fputc_v('(', f);
1178
		dump_type_list ( e, FUNC_NONE, 0 ) ;
1211
			dump_type_list(e, FUNC_NONE, 0);
1179
		fputc_v ( ')', f ) ;
1212
			fputc_v(')', f);
1180
	    }
1213
		}
1181
	    dump_cv ( mqual ) ;
1214
		dump_cv(mqual);
1182
	    if ( ell & FUNC_NO_PARAMS ) {
1215
		if (ell & FUNC_NO_PARAMS) {
1183
		fputc_v ( MANGLE_dot, f ) ;
1216
			fputc_v(MANGLE_dot, f);
1184
	    } else {
1217
		} else {
1185
		fputc_v ( MANGLE_colon, f ) ;
1218
			fputc_v(MANGLE_colon, f);
1186
	    }
1219
		}
1187
	    break ;
1220
		break;
1188
	}
1221
	}
1189
 
1222
 
1190
	case type_array_tag : {
1223
	case type_array_tag: {
1191
	    /* Array types */
1224
		/* Array types */
1192
	    TYPE s = DEREF_type ( type_array_sub ( t ) ) ;
1225
		TYPE s = DEREF_type(type_array_sub(t));
1193
	    NAT n = DEREF_nat ( type_array_size ( t ) ) ;
1226
		NAT n = DEREF_nat(type_array_size(t));
1194
	    fputc_v ( MANGLE_array, dump_file ) ;
1227
		fputc_v(MANGLE_array, dump_file);
1195
	    if ( !IS_NULL_nat ( n ) ) dump_nat ( n, 0 ) ;
1228
		if (!IS_NULL_nat(n)) {
-
 
1229
			dump_nat(n, 0);
-
 
1230
		}
1196
	    fputc_v ( MANGLE_colon, dump_file ) ;
1231
		fputc_v(MANGLE_colon, dump_file);
1197
	    dump_type ( s ) ;
1232
		dump_type(s);
1198
	    break ;
1233
		break;
1199
	}
1234
	}
1200
 
1235
 
1201
	case type_bitfield_tag : {
1236
	case type_bitfield_tag: {
1202
	    /* Bitfield types */
1237
		/* Bitfield types */
1203
	    INT_TYPE it = DEREF_itype ( type_bitfield_defn ( t ) ) ;
1238
		INT_TYPE it = DEREF_itype(type_bitfield_defn(t));
1204
	    dump_itype ( it ) ;
1239
		dump_itype(it);
1205
	    break ;
1240
		break;
1206
	}
1241
	}
1207
 
1242
 
1208
	case type_compound_tag : {
1243
	case type_compound_tag: {
1209
	    /* Class types */
1244
		/* Class types */
1210
	    CLASS_TYPE ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
1245
		CLASS_TYPE ct = DEREF_ctype(type_compound_defn(t));
1211
	    dump_ctype ( ct ) ;
1246
		dump_ctype(ct);
1212
	    break ;
1247
		break;
1213
	}
1248
	}
1214
 
1249
 
1215
	case type_enumerate_tag : {
1250
	case type_enumerate_tag: {
1216
	    /* Enumeration types */
1251
		/* Enumeration types */
1217
	    ENUM_TYPE et = DEREF_etype ( type_enumerate_defn ( t ) ) ;
1252
		ENUM_TYPE et = DEREF_etype(type_enumerate_defn(t));
1218
	    dump_etype ( et ) ;
1253
		dump_etype(et);
-
 
1254
		break;
-
 
1255
	}
-
 
1256
 
-
 
1257
	case type_token_tag: {
-
 
1258
		/* Tokenised types */
-
 
1259
		IDENTIFIER id = DEREF_id(type_token_tok(t));
-
 
1260
		LIST(TOKEN)args = DEREF_list(type_token_args(t));
-
 
1261
		dump_tok_appl(id, args);
-
 
1262
		break;
-
 
1263
	}
-
 
1264
 
-
 
1265
	case type_templ_tag: {
-
 
1266
		/* Template types */
-
 
1267
		TYPE s = DEREF_type(type_templ_defn(t));
-
 
1268
		TOKEN sort = DEREF_tok(type_templ_sort(t));
-
 
1269
		dump_sort(sort);
-
 
1270
		dump_type(s);
1219
	    break ;
1271
		break;
1220
	}
1272
	}
1221
 
1273
 
1222
	case type_token_tag : {
-
 
1223
	    /* Tokenised types */
-
 
1224
	    IDENTIFIER id = DEREF_id ( type_token_tok ( t ) ) ;
-
 
1225
	    LIST ( TOKEN ) args = DEREF_list ( type_token_args ( t ) ) ;
-
 
1226
	    dump_tok_appl ( id, args ) ;
-
 
1227
	    break ;
-
 
1228
	}
-
 
1229
 
-
 
1230
	case type_templ_tag : {
-
 
1231
	    /* Template types */
-
 
1232
	    TYPE s = DEREF_type ( type_templ_defn ( t ) ) ;
-
 
1233
	    TOKEN sort = DEREF_tok ( type_templ_sort ( t ) ) ;
-
 
1234
	    dump_sort ( sort ) ;
-
 
1235
	    dump_type ( s ) ;
-
 
1236
	    break ;
-
 
1237
	}
-
 
1238
 
-
 
1239
	case type_instance_tag : {
1274
	case type_instance_tag: {
1240
	    /* Template instance types */
1275
		/* Template instance types */
1241
	    IDENTIFIER id = DEREF_id ( type_name ( t ) ) ;
1276
		IDENTIFIER id = DEREF_id(type_name(t));
1242
	    dump_id ( id ) ;
1277
		dump_id(id);
1243
	    break ;
1278
		break;
1244
	}
1279
	}
1245
 
1280
 
1246
	default : {
1281
	default : {
1247
	    /* Other types */
1282
		/* Other types */
1248
	    fputc_v ( MANGLE_error, dump_file ) ;
1283
		fputc_v(MANGLE_error, dump_file);
1249
	    break ;
1284
		break;
1250
	}
1285
	}
1251
    }
1286
	}
1252
    return ;
1287
	return;
1253
}
1288
}
1254
 
1289
 
1255
 
1290
 
1256
/*
1291
/*
1257
    DUMP A GRAPH
1292
    DUMP A GRAPH
1258
 
1293
 
1259
    This routine adds the graph gr and all its subgraphs to the dump file.
1294
    This routine adds the graph gr and all its subgraphs to the dump file.
1260
*/
1295
*/
1261
 
1296
 
1262
static void dump_graph
1297
static void
1263
    PROTO_N ( ( gr ) )
-
 
1264
    PROTO_T ( GRAPH gr )
1298
dump_graph(GRAPH gr)
1265
{
1299
{
1266
    FILE *f = dump_file ;
1300
	FILE *f = dump_file;
1267
    unsigned n = DEREF_unsigned ( graph_no ( gr ) ) ;
1301
	unsigned n = DEREF_unsigned(graph_no(gr));
1268
    DECL_SPEC ds = DEREF_dspec ( graph_access ( gr ) ) ;
1302
	DECL_SPEC ds = DEREF_dspec(graph_access(gr));
1269
    if ( ds & dspec_main ) {
1303
	if (ds & dspec_main) {
1270
	/* First instance of base */
1304
		/* First instance of base */
1271
	DECL_SPEC acc = ( ds & dspec_access ) ;
1305
		DECL_SPEC acc = (ds & dspec_access);
1272
	CLASS_TYPE ct = DEREF_ctype ( graph_head ( gr ) ) ;
1306
		CLASS_TYPE ct = DEREF_ctype(graph_head(gr));
1273
	LIST ( GRAPH ) br = DEREF_list ( graph_tails ( gr ) ) ;
1307
		LIST(GRAPH)br = DEREF_list(graph_tails(gr));
1274
	fprintf_v ( f, "%u=", n ) ;
1308
		fprintf_v(f, "%u=", n);
1275
 
1309
 
1276
	/* Dump access */
1310
		/* Dump access */
1277
	if ( ds & dspec_virtual ) fputc_v ( 'V', f ) ;
1311
		if (ds & dspec_virtual) {
-
 
1312
			fputc_v('V', f);
-
 
1313
		}
1278
	if ( acc != dspec_public ) {
1314
		if (acc != dspec_public) {
1279
	    gr = DEREF_graph ( graph_equal ( gr ) ) ;
1315
			gr = DEREF_graph(graph_equal(gr));
1280
	    while ( !IS_NULL_graph ( gr ) ) {
1316
			while (!IS_NULL_graph(gr)) {
1281
		ds = DEREF_dspec ( graph_access ( gr ) ) ;
1317
				ds = DEREF_dspec(graph_access(gr));
1282
		ds &= dspec_access ;
1318
				ds &= dspec_access;
1283
		if ( ds < acc ) acc = ds ;
1319
				if (ds < acc) {
-
 
1320
					acc = ds;
-
 
1321
				}
1284
		if ( acc == dspec_public ) break ;
1322
				if (acc == dspec_public) {
-
 
1323
					break;
-
 
1324
				}
1285
		gr = DEREF_graph ( graph_equal ( gr ) ) ;
1325
				gr = DEREF_graph(graph_equal(gr));
1286
	    }
1326
			}
1287
	}
1327
		}
1288
	dump_access ( acc ) ;
1328
		dump_access(acc);
-
 
1329
 
-
 
1330
		/* Dump base classes */
-
 
1331
		dump_ctype(ct);
-
 
1332
		if (!IS_NULL_list(br)) {
-
 
1333
			fputs_v(" ( ", f);
-
 
1334
			while (!IS_NULL_list(br)) {
-
 
1335
				GRAPH gs = DEREF_graph(HEAD_list(br));
-
 
1336
				dump_graph(gs);
-
 
1337
				fputc_v(' ', f);
-
 
1338
				br = TAIL_list(br);
-
 
1339
			}
-
 
1340
			fputc_v(')', f);
-
 
1341
		}
1289
 
1342
 
1290
	/* Dump base classes */
1343
	} else {
1291
	dump_ctype ( ct ) ;
-
 
1292
	if ( !IS_NULL_list ( br ) ) {
-
 
1293
	    fputs_v ( " ( ", f ) ;
-
 
1294
	    while ( !IS_NULL_list ( br ) ) {
1344
		/* Subsequent instances of base */
1295
		GRAPH gs = DEREF_graph ( HEAD_list ( br ) ) ;
-
 
1296
		dump_graph ( gs ) ;
-
 
1297
		fputc_v ( ' ', f ) ;
1345
		fprintf_v(f, "%u:", n);
1298
		br = TAIL_list ( br ) ;
-
 
1299
	    }
-
 
1300
	    fputc_v ( ')', f ) ;
-
 
1301
	}
1346
	}
1302
 
-
 
1303
    } else {
-
 
1304
	/* Subsequent instances of base */
-
 
1305
	fprintf_v ( f, "%u:", n ) ;
-
 
1306
    }
-
 
1307
    return ;
1347
	return;
1308
}
1348
}
1309
 
1349
 
1310
/*
1350
/*
1311
    DUMP A TOKEN APPLICATION
1351
    DUMP A TOKEN APPLICATION
1312
 
1352
 
1313
    This routine adds the token application id ( args ) to the dump file.
1353
    This routine adds the token application id ( args ) to the dump file.
1314
*/
1354
*/
1315
 
1355
 
1316
static void dump_tok_appl
1356
static void
1317
    PROTO_N ( ( id, args ) )
-
 
1318
    PROTO_T ( IDENTIFIER id X LIST ( TOKEN ) args )
1357
dump_tok_appl(IDENTIFIER id, LIST(TOKEN)args)
1319
{
1358
{
1320
    if ( IS_id_token ( id ) ) {
1359
	if (IS_id_token(id)) {
1321
	IDENTIFIER alt = DEREF_id ( id_token_alt ( id ) ) ;
1360
		IDENTIFIER alt = DEREF_id(id_token_alt(id));
1322
	if ( !IS_NULL_id ( alt ) ) id = alt ;
1361
		if (!IS_NULL_id(alt)) {
-
 
1362
			id = alt;
1323
    }
1363
		}
-
 
1364
	}
1324
    if ( IS_NULL_list ( args ) ) {
1365
	if (IS_NULL_list(args)) {
1325
	dump_id ( id ) ;
1366
		dump_id(id);
1326
    } else {
1367
	} else {
1327
	FILE *f = dump_file ;
1368
		FILE *f = dump_file;
1328
	fputc_v ( 'T', f ) ;
1369
		fputc_v('T', f);
1329
	dump_id ( id ) ;
1370
		dump_id(id);
1330
	while ( !IS_NULL_list ( args ) ) {
1371
		while (!IS_NULL_list(args)) {
1331
	    TOKEN arg = DEREF_tok ( HEAD_list ( args ) ) ;
1372
			TOKEN arg = DEREF_tok(HEAD_list(args));
1332
	    fputc_v ( MANGLE_comma, f ) ;
1373
			fputc_v(MANGLE_comma, f);
1333
	    if ( !IS_NULL_tok ( arg ) ) {
1374
			if (!IS_NULL_tok(arg)) {
1334
		ASSERT ( ORDER_tok == 10 ) ;
1375
				ASSERT(ORDER_tok == 10);
1335
		switch ( TAG_tok ( arg ) ) {
1376
				switch (TAG_tok(arg)) {
1336
		    case tok_exp_tag : {
1377
				case tok_exp_tag: {
1337
			EXP e = DEREF_exp ( tok_exp_value ( arg ) ) ;
1378
					EXP e = DEREF_exp(tok_exp_value(arg));
1338
			fputc_v ( 'E', f ) ;
1379
					fputc_v('E', f);
1339
			if ( !IS_NULL_exp ( e ) ) dump_exp ( e ) ;
1380
					if (!IS_NULL_exp(e)) {
-
 
1381
						dump_exp(e);
-
 
1382
					}
1340
			break ;
1383
					break;
1341
		    }
1384
				}
1342
		    case tok_stmt_tag : {
1385
				case tok_stmt_tag: {
1343
			EXP e = DEREF_exp ( tok_stmt_value ( arg ) ) ;
1386
					EXP e = DEREF_exp(tok_stmt_value(arg));
1344
			fputc_v ( 'S', f ) ;
1387
					fputc_v('S', f);
1345
			if ( !IS_NULL_exp ( e ) ) dump_exp ( e ) ;
1388
					if (!IS_NULL_exp(e)) {
-
 
1389
						dump_exp(e);
-
 
1390
					}
1346
			break ;
1391
					break;
1347
		    }
1392
				}
1348
		    case tok_nat_tag : {
1393
				case tok_nat_tag: {
1349
			NAT n = DEREF_nat ( tok_nat_value ( arg ) ) ;
1394
					NAT n = DEREF_nat(tok_nat_value(arg));
1350
			fputc_v ( 'N', f ) ;
1395
					fputc_v('N', f);
1351
			if ( !IS_NULL_nat ( n ) ) dump_nat ( n, 0 ) ;
1396
					if (!IS_NULL_nat(n)) {
-
 
1397
						dump_nat(n, 0);
-
 
1398
					}
1352
			break ;
1399
					break;
1353
		    }
1400
				}
1354
		    case tok_snat_tag : {
1401
				case tok_snat_tag: {
1355
			NAT n = DEREF_nat ( tok_snat_value ( arg ) ) ;
1402
					NAT n = DEREF_nat(tok_snat_value(arg));
1356
			fputc_v ( 'I', f ) ;
1403
					fputc_v('I', f);
1357
			if ( !IS_NULL_nat ( n ) ) dump_nat ( n, 0 ) ;
1404
					if (!IS_NULL_nat(n)) {
-
 
1405
						dump_nat(n, 0);
-
 
1406
					}
1358
			break ;
1407
					break;
1359
		    }
1408
				}
1360
		    case tok_type_tag : {
1409
				case tok_type_tag: {
-
 
1410
					TYPE t =
1361
			TYPE t = DEREF_type ( tok_type_value ( arg ) ) ;
1411
					    DEREF_type(tok_type_value(arg));
1362
			fputc_v ( 'T', f ) ;
1412
					fputc_v('T', f);
1363
			if ( !IS_NULL_type ( t ) ) dump_type ( t ) ;
1413
					if (!IS_NULL_type(t)) {
-
 
1414
						dump_type(t);
-
 
1415
					}
1364
			break ;
1416
					break;
1365
		    }
1417
				}
1366
		    case tok_func_tag : {
1418
				case tok_func_tag: {
-
 
1419
					IDENTIFIER fid =
1367
			IDENTIFIER fid = DEREF_id ( tok_func_defn ( arg ) ) ;
1420
					    DEREF_id(tok_func_defn(arg));
1368
			fputc_v ( 'F', f ) ;
1421
					fputc_v('F', f);
1369
			if ( !IS_NULL_id ( fid ) ) dump_id ( fid ) ;
1422
					if (!IS_NULL_id(fid)) {
-
 
1423
						dump_id(fid);
-
 
1424
					}
1370
			break ;
1425
					break;
1371
		    }
1426
				}
1372
		    case tok_member_tag : {
1427
				case tok_member_tag: {
-
 
1428
					OFFSET off =
1373
			OFFSET off = DEREF_off ( tok_member_value ( arg ) ) ;
1429
					    DEREF_off(tok_member_value(arg));
1374
			fputc_v ( 'M', f ) ;
1430
					fputc_v('M', f);
1375
			if ( !IS_NULL_off ( off ) ) dump_off ( off ) ;
1431
					if (!IS_NULL_off(off)) {
-
 
1432
						dump_off(off);
-
 
1433
					}
1376
			break ;
1434
					break;
1377
		    }
1435
				}
1378
		    case tok_class_tag : {
1436
				case tok_class_tag: {
-
 
1437
					IDENTIFIER tid =
1379
			IDENTIFIER tid = DEREF_id ( tok_class_value ( arg ) ) ;
1438
					    DEREF_id(tok_class_value(arg));
1380
			fputc_v ( 'C', f ) ;
1439
					fputc_v('C', f);
1381
			if ( !IS_NULL_id ( tid ) ) dump_id ( tid ) ;
1440
					if (!IS_NULL_id(tid)) {
-
 
1441
						dump_id(tid);
-
 
1442
					}
1382
			break ;
1443
					break;
-
 
1444
				}
1383
		    }
1445
				}
-
 
1446
			}
-
 
1447
			args = TAIL_list(args);
1384
		}
1448
		}
1385
	    }
-
 
1386
	    args = TAIL_list ( args ) ;
1449
		fputc_v(MANGLE_colon, f);
1387
	}
1450
	}
1388
	fputc_v ( MANGLE_colon, f ) ;
-
 
1389
    }
-
 
1390
    return ;
1451
	return;
1391
}
1452
}
1392
 
1453
 
1393
 
1454
 
1394
/*
1455
/*
1395
    DUMP A BASE CLASS GRAPH
1456
    DUMP A BASE CLASS GRAPH
1396
 
1457
 
1397
    This routine adds the base class graph associated with the class type
1458
    This routine adds the base class graph associated with the class type
1398
    ct to the dump file.
1459
    ct to the dump file.
1399
*/
1460
*/
1400
 
1461
 
1401
void dump_base
1462
void
1402
    PROTO_N ( ( ct ) )
-
 
1403
    PROTO_T ( CLASS_TYPE ct )
1463
dump_base(CLASS_TYPE ct)
1404
{
1464
{
1405
    unsigned n = DEREF_unsigned ( ctype_no_bases ( ct ) ) ;
1465
	unsigned n = DEREF_unsigned(ctype_no_bases(ct));
1406
    if ( n > 1 ) {
1466
	if (n > 1) {
1407
	FILE *f = dump_file ;
1467
		FILE *f = dump_file;
1408
	if ( f ) {
1468
		if (f) {
1409
	    CONST char *key ;
1469
			CONST char *key;
1410
	    GRAPH gr = DEREF_graph ( ctype_base ( ct ) ) ;
1470
			GRAPH gr = DEREF_graph(ctype_base(ct));
1411
	    CLASS_INFO ci = DEREF_cinfo ( ctype_info ( ct ) ) ;
1471
			CLASS_INFO ci = DEREF_cinfo(ctype_info(ct));
1412
	    if ( ci & cinfo_union ) {
1472
			if (ci & cinfo_union) {
1413
		key = "TU" ;
1473
				key = "TU";
1414
	    } else if ( ci & cinfo_struct ) {
1474
			} else if (ci & cinfo_struct) {
1415
		key = "TS" ;
1475
				key = "TS";
1416
	    } else {
1476
			} else {
1417
		key = "TC" ;
1477
				key = "TC";
1418
	    }
1478
			}
1419
	    fprintf_v ( f, "B%s\t%u\t", key, n ) ;
1479
			fprintf_v(f, "B%s\t%u\t", key, n);
1420
	    dump_graph ( gr ) ;
1480
			dump_graph(gr);
1421
	    fputc_v ( '\n', f ) ;
1481
			fputc_v('\n', f);
-
 
1482
		}
1422
	}
1483
	}
1423
    }
-
 
1424
    return ;
1484
	return;
1425
}
1485
}
1426
 
1486
 
1427
 
1487
 
1428
/*
1488
/*
1429
    DUMP AN OVERRIDING VIRTUAL FUNCTION
1489
    DUMP AN OVERRIDING VIRTUAL FUNCTION
1430
 
1490
 
1431
    This routine dumps the fact that the virtual function id overrides
1491
    This routine dumps the fact that the virtual function id overrides
1432
    the virtual function fid.
1492
    the virtual function fid.
1433
*/
1493
*/
1434
 
1494
 
1435
void dump_override
1495
void
1436
    PROTO_N ( ( id, fid ) )
-
 
1437
    PROTO_T ( IDENTIFIER id X IDENTIFIER fid )
1496
dump_override(IDENTIFIER id, IDENTIFIER fid)
1438
{
1497
{
1439
    FILE *f = dump_file ;
1498
	FILE *f = dump_file;
1440
    if ( f ) {
1499
	if (f) {
1441
	fputs_v ( "O\t", f ) ;
1500
		fputs_v("O\t", f);
1442
	dump_id ( id ) ;
1501
		dump_id(id);
1443
	fputc_v ( '\t', f ) ;
1502
		fputc_v('\t', f);
1444
	dump_id ( fid ) ;
1503
		dump_id(fid);
1445
	fputc_v ( '\n', f ) ;
1504
		fputc_v('\n', f);
1446
    }
1505
	}
1447
    return ;
1506
	return;
1448
}
1507
}
1449
 
1508
 
1450
 
1509
 
1451
/*
1510
/*
1452
    DUMP A USING DECLARATION
1511
    DUMP A USING DECLARATION
1453
 
1512
 
1454
    This routine dumps the fact that a using declaration has been used to
1513
    This routine dumps the fact that a using declaration has been used to
1455
    set up the alias id for cid.
1514
    set up the alias id for cid.
1456
*/
1515
*/
1457
 
1516
 
1458
void dump_alias
1517
void
1459
    PROTO_N ( ( id, cid, loc ) )
-
 
1460
    PROTO_T ( IDENTIFIER id X IDENTIFIER cid X LOCATION *loc )
1518
dump_alias(IDENTIFIER id, IDENTIFIER cid, LOCATION *loc)
1461
{
1519
{
1462
    ulong n = DEREF_ulong ( id_dump ( cid ) ) ;
1520
	ulong n = DEREF_ulong(id_dump(cid));
1463
    COPY_ulong ( id_dump ( id ), n ) ;
1521
	COPY_ulong(id_dump(id), n);
1464
    /* NOT YET IMPLEMENTED */
1522
	/* NOT YET IMPLEMENTED */
1465
    UNUSED ( loc ) ;
1523
	UNUSED(loc);
1466
    return ;
1524
	return;
1467
}
1525
}
1468
 
1526
 
1469
 
1527
 
1470
/*
1528
/*
1471
    DUMP A USING DIRECTIVE
1529
    DUMP A USING DIRECTIVE
1472
 
1530
 
1473
    This routine dumps the fact that the namespace ns has been the subject
1531
    This routine dumps the fact that the namespace ns has been the subject
1474
    of a using directive in the namespace cns.
1532
    of a using directive in the namespace cns.
1475
*/
1533
*/
1476
 
-
 
1477
void dump_using
-
 
1478
    PROTO_N ( ( ns, cns, loc ) )
-
 
1479
    PROTO_T ( NAMESPACE ns X NAMESPACE cns X LOCATION *loc )
-
 
1480
{
-
 
1481
    /* NOT YET IMPLEMENTED */
-
 
1482
    UNUSED ( ns ) ;
-
 
1483
    UNUSED ( cns ) ;
-
 
1484
    UNUSED ( loc ) ;
-
 
1485
    return ;
-
 
1486
}
-
 
1487
 
1534
 
1488
 
-
 
1489
/*
1535
void
1490
    TABLE OF ERROR NUMBERS
1536
dump_using(NAMESPACE ns, NAMESPACE cns, LOCATION *loc)
1491
 
1537
{
1492
    This array contains a table of flags indicating whether each error
-
 
1493
    has been output or not.
1538
	/* NOT YET IMPLEMENTED */
-
 
1539
	UNUSED(ns);
-
 
1540
	UNUSED(cns);
-
 
1541
	UNUSED(loc);
1494
*/
1542
	return;
1495
 
1543
}
1496
static char *err_output = NULL ;
-
 
1497
 
1544
 
1498
 
1545
 
1499
/*
1546
/*
-
 
1547
    TABLE OF ERROR NUMBERS
-
 
1548
 
-
 
1549
    This array contains a table of flags indicating whether each error
-
 
1550
    has been output or not.
-
 
1551
*/
-
 
1552
 
-
 
1553
static char *err_output = NULL;
-
 
1554
 
-
 
1555
 
-
 
1556
/*
1500
    DUMP AN ERROR
1557
    DUMP AN ERROR
1501
 
1558
 
1502
    This routine adds the error e of severity sev to the dump file.  It
1559
    This routine adds the error e of severity sev to the dump file.  It
1503
    returns false if the dump has already been closed or e is an internal
1560
    returns false if the dump has already been closed or e is an internal
1504
    compiler error.
1561
    compiler error.
1505
*/
1562
*/
1506
 
1563
 
1507
int dump_error
1564
int
1508
    PROTO_N ( ( e, loc, sev, cnt ) )
-
 
1509
    PROTO_T ( ERROR e X LOCATION *loc X int sev X int cnt )
1565
dump_error(ERROR e, LOCATION *loc, int sev, int cnt)
1510
{
1566
{
1511
    if ( IS_err_simple ( e ) ) {
1567
	if (IS_err_simple(e)) {
1512
	/* Simple error message */
1568
		/* Simple error message */
1513
	FILE *f = dump_file ;
1569
		FILE *f = dump_file;
1514
	int n = DEREF_int ( err_simple_number ( e ) ) ;
1570
		int n = DEREF_int(err_simple_number(e));
1515
	ERR_DATA *msg = ERR_CATALOG + n ;
1571
		ERR_DATA *msg = ERR_CATALOG + n;
1516
	CONST char *sig = msg->signature ;
1572
		CONST char *sig = msg->signature;
1517
	ERR_PROPS props = msg->props ;
1573
		ERR_PROPS props = msg->props;
-
 
1574
 
-
 
1575
		/* Dump start of error */
-
 
1576
		if (f == NULL) {
-
 
1577
			return (0);
-
 
1578
		}
-
 
1579
		if (props & ERR_PROP_compiler) {
-
 
1580
			return (0);
-
 
1581
		}
-
 
1582
		if (loc) {
-
 
1583
			/* First error component */
-
 
1584
			CONST char *err;
-
 
1585
			switch (sev) {
-
 
1586
			case ERROR_FATAL:
-
 
1587
				err = "EF";
-
 
1588
				break;
-
 
1589
			case ERROR_INTERNAL:
-
 
1590
				err = "EI";
-
 
1591
				break;
-
 
1592
			case ERROR_WARNING:
-
 
1593
				err = "EW";
-
 
1594
				break;
-
 
1595
			default:
-
 
1596
				err = "ES";
-
 
1597
				break;
-
 
1598
			}
-
 
1599
			fprintf_v(f, "%s\t", err);
-
 
1600
			dump_loc(loc);
-
 
1601
			fputc_v('\t', f);
-
 
1602
		} else {
-
 
1603
			/* Subsequent error component */
-
 
1604
			fputs_v("EC\t", f);
-
 
1605
		}
-
 
1606
 
-
 
1607
		/* Dump error number */
-
 
1608
		if (err_output[n]) {
-
 
1609
			fprintf_v(f, "%d", n);
-
 
1610
		} else {
-
 
1611
			CONST char *name = msg->name;
-
 
1612
			fprintf_v(f, "%d = <%s.%s>", n, ERR_NAME, name);
-
 
1613
			err_output[n] = 1;
-
 
1614
		}
-
 
1615
 
-
 
1616
		/* Dump error arguments */
-
 
1617
		if (sig == NULL) {
-
 
1618
			fprintf_v(f, "\t0\t%d\n", cnt );
-
 
1619
		} else {
-
 
1620
			unsigned a;
-
 
1621
			unsigned na = (unsigned)strlen(sig);
-
 
1622
			fprintf_v(f, "\t%u\t%d\n", na, cnt );
-
 
1623
			for (a = 0; a < na; a++) {
-
 
1624
				switch (sig[a]) {
-
 
1625
				case ERR_KEY_ACCESS: {
-
 
1626
					ACCESS acc;
-
 
1627
					acc =
-
 
1628
					    DEREF_dspec(err_arg(e, a, ACCESS));
-
 
1629
					IGNORE print_access(acc, dump_buff, 0);
-
 
1630
					fputs_v("EAS\t", f);
-
 
1631
					dump_string();
-
 
1632
					break;
-
 
1633
				}
-
 
1634
				case ERR_KEY_BASE_TYPE: {
-
 
1635
					BASE_TYPE bt;
-
 
1636
					bt = DEREF_btype(err_arg(e, a, BASE_TYPE));
-
 
1637
					IGNORE print_btype(bt, dump_buff, 0);
-
 
1638
					fputs_v("EAS\t", f);
-
 
1639
					dump_string();
-
 
1640
					break;
-
 
1641
				}
-
 
1642
				case ERR_KEY_CLASS_TYPE: {
-
 
1643
					CLASS_TYPE ct;
-
 
1644
					ct = DEREF_ctype(err_arg(e, a, CLASS_TYPE));
-
 
1645
					fputs_v("EAT\t", f);
-
 
1646
					dump_ctype(ct);
-
 
1647
					break;
-
 
1648
				}
-
 
1649
				case ERR_KEY_CV_SPEC: {
-
 
1650
					CV_SPEC cv =
-
 
1651
					    DEREF_cv(err_arg(e, a, CV_SPEC));
-
 
1652
					IGNORE print_cv(cv, dump_buff, 0);
-
 
1653
					fputs_v("EAS\t", f);
-
 
1654
					dump_string();
-
 
1655
					break;
-
 
1656
				}
-
 
1657
				case ERR_KEY_DECL_SPEC: {
-
 
1658
					DECL_SPEC ds;
-
 
1659
					ds = DEREF_dspec(err_arg(e, a, DECL_SPEC));
-
 
1660
					IGNORE print_dspec(ds, dump_buff, 0);
-
 
1661
					fputs_v("EAS\t", f);
-
 
1662
					dump_string();
-
 
1663
					break;
-
 
1664
				}
-
 
1665
				case ERR_KEY_FLOAT: {
-
 
1666
					FLOAT flt =
-
 
1667
					    DEREF_flt(err_arg(e, a, FLOAT));
-
 
1668
					IGNORE print_flt(flt, dump_buff, 0);
-
 
1669
					fputs_v("EAS\t", f);
-
 
1670
					dump_string();
-
 
1671
					break;
-
 
1672
				}
-
 
1673
				case ERR_KEY_HASHID: {
-
 
1674
					HASHID nm;
-
 
1675
					nm = DEREF_hashid(err_arg(e, a, HASHID));
-
 
1676
					fputs_v("EAH\t", f);
-
 
1677
					dump_hashid(nm);
-
 
1678
					break;
-
 
1679
				}
-
 
1680
				case ERR_KEY_IDENTIFIER:
-
 
1681
				case ERR_KEY_LONG_ID: {
-
 
1682
					IDENTIFIER id;
-
 
1683
					id = DEREF_id(err_arg(e, a, IDENTIFIER));
-
 
1684
					fputs_v("EAI\t", f);
-
 
1685
					dump_id(id);
-
 
1686
					break;
-
 
1687
				}
-
 
1688
				case ERR_KEY_LEX: {
-
 
1689
					LEX t = DEREF_int(err_arg(e, a, LEX));
-
 
1690
					fputs_v("EAS\t", f);
-
 
1691
					dump_lex(t);
-
 
1692
					break;
-
 
1693
				}
-
 
1694
				case ERR_KEY_NAMESPACE: {
-
 
1695
					NAMESPACE ns;
-
 
1696
					ns = DEREF_nspace(err_arg(e, a, NAMESPACE));
-
 
1697
					fputs_v("EAC\t", f);
-
 
1698
					dump_nspace(ns, 0);
-
 
1699
					break;
-
 
1700
				}
-
 
1701
				case ERR_KEY_NAT: {
-
 
1702
					NAT nat = DEREF_nat(err_arg(e, a, NAT));
-
 
1703
					fputs_v("EAN\t", f);
-
 
1704
					dump_nat(nat, 0);
-
 
1705
					break;
-
 
1706
				}
-
 
1707
				case ERR_KEY_PPTOKEN_P: {
-
 
1708
					PPTOKEN_P tok;
-
 
1709
					tok = DEREF_pptok(err_arg(e, a, PPTOKEN_P));
-
 
1710
					IGNORE print_pptok(tok, dump_buff, 0);
-
 
1711
					fputs_v("EAS\t", f);
-
 
1712
					dump_string();
-
 
1713
					break;
-
 
1714
				}
-
 
1715
				case ERR_KEY_PTR_LOC: {
-
 
1716
					PTR_LOC ploc;
-
 
1717
					LOCATION aloc;
-
 
1718
					ploc =
-
 
1719
					    DEREF_ptr(err_arg(e, a, PTR_LOC));
-
 
1720
					DEREF_loc(ploc, aloc);
-
 
1721
					fputs_v("EAL\t", f);
-
 
1722
					dump_loc(&aloc);
-
 
1723
					break;
-
 
1724
				}
-
 
1725
				case ERR_KEY_QUALIFIER: {
-
 
1726
					CONST char *s;
-
 
1727
					QUALIFIER qual;
-
 
1728
					qual = DEREF_qual(err_arg(e, a, QUALIFIER));
-
 
1729
					if (qual == qual_full ||
-
 
1730
					    qual == qual_top) {
-
 
1731
						s = "::";
-
 
1732
					} else {
-
 
1733
						s = "";
-
 
1734
					}
-
 
1735
					fprintf_v(f, "EAS\t<%s>", s);
-
 
1736
					break;
-
 
1737
				}
-
 
1738
				case ERR_KEY_STRING: {
-
 
1739
					STRING str =
-
 
1740
					    DEREF_str(err_arg(e, a, STRING));
-
 
1741
					IGNORE print_str(str, dump_buff, 0);
-
 
1742
					fputs_v("EAS\t", f);
-
 
1743
					dump_string();
-
 
1744
					break;
-
 
1745
				}
-
 
1746
				case ERR_KEY_TYPE: {
-
 
1747
					TYPE t =
-
 
1748
					    DEREF_type(err_arg(e, a, TYPE));
-
 
1749
					fputs_v("EAT\t", f);
-
 
1750
					dump_type(t);
-
 
1751
					break;
-
 
1752
				}
-
 
1753
				case ERR_KEY_cint: {
-
 
1754
					cint i = DEREF_int(err_arg(e, a, cint));
-
 
1755
					fprintf_v(f, "EAV\t%d", i);
-
 
1756
					break;
-
 
1757
				}
-
 
1758
				case ERR_KEY_plural: {
-
 
1759
					plural i;
-
 
1760
					i = DEREF_unsigned(err_arg(e, a, plural));
-
 
1761
					if (i == 1) {
-
 
1762
						fputs_v("EAS\t<>", f);
-
 
1763
					} else {
-
 
1764
						fputs_v("EAS\t<s>", f);
-
 
1765
					}
-
 
1766
					break;
-
 
1767
				}
-
 
1768
				case ERR_KEY_cstring:
-
 
1769
				case ERR_KEY_string: {
-
 
1770
					string s;
-
 
1771
					s = DEREF_string(err_arg(e, a, string));
-
 
1772
					if (s) {
-
 
1773
						unsigned d =
-
 
1774
						    (unsigned)ustrlen(s);
-
 
1775
						fprintf_v(f, "EAS\t&%u<%s>", d,
-
 
1776
							  strlit(s));
-
 
1777
					} else {
-
 
1778
						fputs_v("EAS\t<>", f);
-
 
1779
					}
-
 
1780
					break;
-
 
1781
				}
-
 
1782
				case ERR_KEY_ulong:
-
 
1783
				case ERR_KEY_ucint: {
-
 
1784
					ulong u =
-
 
1785
					    DEREF_ulong(err_arg(e, a, ulong));
-
 
1786
					fprintf_v(f, "EAV\t%lu", u);
-
 
1787
					break;
-
 
1788
				}
-
 
1789
				case ERR_KEY_unsigned: {
-
 
1790
					unsigned u;
-
 
1791
					u = DEREF_unsigned(err_arg(e, a,
-
 
1792
								   unsigned));
-
 
1793
					fprintf_v(f, "EAV\t%u", u);
-
 
1794
					break;
-
 
1795
				}
-
 
1796
				default: {
-
 
1797
					fputs_v("EAS\t<>", f);
-
 
1798
					break;
-
 
1799
				}
-
 
1800
				}
-
 
1801
				fputc_v('\n', f);
-
 
1802
			}
-
 
1803
		}
1518
 
1804
 
1519
	/* Dump start of error */
-
 
1520
	if ( f == NULL ) return ( 0 ) ;
-
 
1521
	if ( props & ERR_PROP_compiler ) return ( 0 ) ;
-
 
1522
	if ( loc ) {
-
 
1523
	    /* First error component */
-
 
1524
	    CONST char *err ;
-
 
1525
	    switch ( sev ) {
-
 
1526
		case ERROR_FATAL : err = "EF" ; break ;
-
 
1527
		case ERROR_INTERNAL : err = "EI" ; break ;
-
 
1528
		case ERROR_WARNING : err = "EW" ; break ;
-
 
1529
		default : err = "ES" ; break ;
-
 
1530
	    }
-
 
1531
	    fprintf_v ( f, "%s\t", err ) ;
-
 
1532
	    dump_loc ( loc ) ;
-
 
1533
	    fputc_v ( '\t', f ) ;
-
 
1534
	} else {
1805
	} else {
1535
	    /* Subsequent error component */
-
 
1536
	    fputs_v ( "EC\t", f ) ;
-
 
1537
	}
-
 
1538
 
-
 
1539
	/* Dump error number */
1806
		/* Composite error message */
1540
	if ( err_output [n] ) {
-
 
1541
	    fprintf_v ( f, "%d", n ) ;
-
 
1542
	} else {
-
 
1543
	    CONST char *name = msg->name ;
-
 
1544
	    fprintf_v ( f, "%d = <%s.%s>", n, ERR_NAME, name ) ;
-
 
1545
	    err_output [n] = 1 ;
-
 
1546
	}
-
 
1547
 
-
 
1548
	/* Dump error arguments */
-
 
1549
	if ( sig == NULL ) {
-
 
1550
	    fprintf_v ( f, "\t0\t%d\n", cnt ) ;
-
 
1551
	} else {
-
 
1552
	    unsigned a ;
-
 
1553
	    unsigned na = ( unsigned ) strlen ( sig ) ;
-
 
1554
	    fprintf_v ( f, "\t%u\t%d\n", na, cnt ) ;
-
 
1555
	    for ( a = 0 ; a < na ; a++ ) {
-
 
1556
		switch ( sig [a] ) {
-
 
1557
		    case ERR_KEY_ACCESS : {
-
 
1558
			ACCESS acc ;
-
 
1559
			acc = DEREF_dspec ( err_arg ( e, a, ACCESS ) ) ;
-
 
1560
			IGNORE print_access ( acc, dump_buff, 0 ) ;
-
 
1561
			fputs_v ( "EAS\t", f ) ;
-
 
1562
			dump_string () ;
-
 
1563
			break ;
-
 
1564
		    }
-
 
1565
		    case ERR_KEY_BASE_TYPE : {
-
 
1566
			BASE_TYPE bt ;
-
 
1567
			bt = DEREF_btype ( err_arg ( e, a, BASE_TYPE ) ) ;
-
 
1568
			IGNORE print_btype ( bt, dump_buff, 0 ) ;
-
 
1569
			fputs_v ( "EAS\t", f ) ;
-
 
1570
			dump_string () ;
-
 
1571
			break ;
-
 
1572
		    }
-
 
1573
		    case ERR_KEY_CLASS_TYPE : {
-
 
1574
			CLASS_TYPE ct ;
-
 
1575
			ct = DEREF_ctype ( err_arg ( e, a, CLASS_TYPE ) ) ;
-
 
1576
			fputs_v ( "EAT\t", f ) ;
-
 
1577
			dump_ctype ( ct ) ;
-
 
1578
			break ;
-
 
1579
		    }
-
 
1580
		    case ERR_KEY_CV_SPEC : {
-
 
1581
			CV_SPEC cv = DEREF_cv ( err_arg ( e, a, CV_SPEC ) ) ;
-
 
1582
			IGNORE print_cv ( cv, dump_buff, 0 ) ;
-
 
1583
			fputs_v ( "EAS\t", f ) ;
-
 
1584
			dump_string () ;
-
 
1585
			break ;
-
 
1586
		    }
-
 
1587
		    case ERR_KEY_DECL_SPEC : {
-
 
1588
			DECL_SPEC ds ;
-
 
1589
			ds = DEREF_dspec ( err_arg ( e, a, DECL_SPEC ) ) ;
-
 
1590
			IGNORE print_dspec ( ds, dump_buff, 0 ) ;
-
 
1591
			fputs_v ( "EAS\t", f ) ;
-
 
1592
			dump_string () ;
-
 
1593
			break ;
-
 
1594
		    }
-
 
1595
		    case ERR_KEY_FLOAT : {
-
 
1596
			FLOAT flt = DEREF_flt ( err_arg ( e, a, FLOAT ) ) ;
1807
		ERROR e1 = DEREF_err(err_compound_head(e));
1597
			IGNORE print_flt ( flt, dump_buff, 0 ) ;
-
 
1598
			fputs_v ( "EAS\t", f ) ;
-
 
1599
			dump_string () ;
-
 
1600
			break ;
-
 
1601
		    }
-
 
1602
		    case ERR_KEY_HASHID : {
-
 
1603
			HASHID nm ;
-
 
1604
			nm = DEREF_hashid ( err_arg ( e, a, HASHID ) ) ;
-
 
1605
			fputs_v ( "EAH\t", f ) ;
-
 
1606
			dump_hashid ( nm ) ;
-
 
1607
			break ;
-
 
1608
		    }
-
 
1609
		    case ERR_KEY_IDENTIFIER :
-
 
1610
		    case ERR_KEY_LONG_ID : {
-
 
1611
			IDENTIFIER id ;
-
 
1612
			id = DEREF_id ( err_arg ( e, a, IDENTIFIER ) ) ;
-
 
1613
			fputs_v ( "EAI\t", f ) ;
-
 
1614
			dump_id ( id ) ;
-
 
1615
			break ;
-
 
1616
		    }
-
 
1617
		    case ERR_KEY_LEX : {
-
 
1618
			LEX t = DEREF_int ( err_arg ( e, a, LEX ) ) ;
1808
		ERROR e2 = DEREF_err(err_compound_tail(e));
1619
			fputs_v ( "EAS\t", f ) ;
-
 
1620
			dump_lex ( t ) ;
-
 
1621
			break ;
-
 
1622
		    }
-
 
1623
		    case ERR_KEY_NAMESPACE : {
-
 
1624
			NAMESPACE ns ;
-
 
1625
			ns = DEREF_nspace ( err_arg ( e, a, NAMESPACE ) ) ;
-
 
1626
			fputs_v ( "EAC\t", f ) ;
-
 
1627
			dump_nspace ( ns, 0 ) ;
1809
		if (!dump_error(e1, loc, sev, 1)) {
1628
			break ;
-
 
1629
		    }
-
 
1630
		    case ERR_KEY_NAT : {
-
 
1631
			NAT nat = DEREF_nat ( err_arg ( e, a, NAT ) ) ;
-
 
1632
			fputs_v ( "EAN\t", f ) ;
-
 
1633
			dump_nat ( nat, 0 ) ;
-
 
1634
			break ;
-
 
1635
		    }
-
 
1636
		    case ERR_KEY_PPTOKEN_P : {
-
 
1637
			PPTOKEN_P tok ;
-
 
1638
			tok = DEREF_pptok ( err_arg ( e, a, PPTOKEN_P ) ) ;
-
 
1639
			IGNORE print_pptok ( tok, dump_buff, 0 ) ;
-
 
1640
			fputs_v ( "EAS\t", f ) ;
-
 
1641
			dump_string () ;
-
 
1642
			break ;
-
 
1643
		    }
-
 
1644
		    case ERR_KEY_PTR_LOC : {
-
 
1645
			PTR_LOC ploc ;
-
 
1646
			LOCATION aloc ;
-
 
1647
			ploc = DEREF_ptr ( err_arg ( e, a, PTR_LOC ) ) ;
-
 
1648
			DEREF_loc ( ploc, aloc ) ;
-
 
1649
			fputs_v ( "EAL\t", f ) ;
-
 
1650
			dump_loc ( &aloc ) ;
-
 
1651
			break ;
1810
			return (0);
1652
		    }
-
 
1653
		    case ERR_KEY_QUALIFIER : {
-
 
1654
			CONST char *s ;
-
 
1655
			QUALIFIER qual ;
-
 
1656
			qual = DEREF_qual ( err_arg ( e, a, QUALIFIER ) ) ;
-
 
1657
			if ( qual == qual_full || qual == qual_top ) {
-
 
1658
			    s = "::" ;
-
 
1659
			} else {
-
 
1660
			    s = "" ;
-
 
1661
			}
1811
		}
1662
			fprintf_v ( f, "EAS\t<%s>", s ) ;
-
 
1663
			break ;
-
 
1664
		    }
-
 
1665
		    case ERR_KEY_STRING : {
-
 
1666
			STRING str = DEREF_str ( err_arg ( e, a, STRING ) ) ;
-
 
1667
			IGNORE print_str ( str, dump_buff, 0 ) ;
-
 
1668
			fputs_v ( "EAS\t", f ) ;
-
 
1669
			dump_string () ;
-
 
1670
			break ;
-
 
1671
		    }
-
 
1672
		    case ERR_KEY_TYPE : {
-
 
1673
			TYPE t = DEREF_type ( err_arg ( e, a, TYPE ) ) ;
-
 
1674
			fputs_v ( "EAT\t", f ) ;
-
 
1675
			dump_type ( t ) ;
-
 
1676
			break ;
-
 
1677
		    }
-
 
1678
		    case ERR_KEY_cint : {
-
 
1679
			cint i = DEREF_int ( err_arg ( e, a, cint ) ) ;
1812
		if (!dump_error(e2, NIL(LOCATION), sev, cnt)) {
1680
			fprintf_v ( f, "EAV\t%d", i ) ;
-
 
1681
			break ;
-
 
1682
		    }
-
 
1683
		    case ERR_KEY_plural : {
-
 
1684
			plural i ;
-
 
1685
			i = DEREF_unsigned ( err_arg ( e, a, plural ) ) ;
-
 
1686
			if ( i == 1 ) {
-
 
1687
			    fputs_v ( "EAS\t<>", f ) ;
-
 
1688
			} else {
-
 
1689
			    fputs_v ( "EAS\t<s>", f ) ;
-
 
1690
			}
-
 
1691
			break ;
-
 
1692
		    }
-
 
1693
		    case ERR_KEY_cstring :
-
 
1694
		    case ERR_KEY_string : {
-
 
1695
			string s ;
1813
			return (0);
1696
			s = DEREF_string ( err_arg ( e, a, string ) ) ;
-
 
1697
			if ( s ) {
-
 
1698
			    unsigned d = ( unsigned ) ustrlen ( s ) ;
-
 
1699
			    fprintf_v ( f, "EAS\t&%u<%s>", d, strlit ( s ) ) ;
-
 
1700
			} else {
-
 
1701
			    fputs_v ( "EAS\t<>", f ) ;
-
 
1702
			}
-
 
1703
			break ;
-
 
1704
		    }
-
 
1705
		    case ERR_KEY_ulong :
-
 
1706
		    case ERR_KEY_ucint : {
-
 
1707
			ulong u = DEREF_ulong ( err_arg ( e, a, ulong ) ) ;
-
 
1708
			fprintf_v ( f, "EAV\t%lu", u ) ;
-
 
1709
			break ;
-
 
1710
		    }
-
 
1711
		    case ERR_KEY_unsigned : {
-
 
1712
			unsigned u ;
-
 
1713
			u = DEREF_unsigned ( err_arg ( e, a, unsigned ) ) ;
-
 
1714
			fprintf_v ( f, "EAV\t%u", u ) ;
-
 
1715
			break ;
-
 
1716
		    }
-
 
1717
		    default : {
-
 
1718
			fputs_v ( "EAS\t<>", f ) ;
-
 
1719
			break ;
-
 
1720
		    }
-
 
1721
		}
1814
		}
1722
		fputc_v ( '\n', f ) ;
-
 
1723
	    }
-
 
1724
	}
1815
	}
1725
 
-
 
1726
    } else {
-
 
1727
	/* Composite error message */
-
 
1728
	ERROR e1 = DEREF_err ( err_compound_head ( e ) ) ;
-
 
1729
	ERROR e2 = DEREF_err ( err_compound_tail ( e ) ) ;
-
 
1730
	if ( !dump_error ( e1, loc, sev, 1 ) ) return ( 0 ) ;
-
 
1731
	if ( !dump_error ( e2, NIL ( LOCATION ), sev, cnt ) ) return ( 0 ) ;
-
 
1732
    }
-
 
1733
    return ( 1 ) ;
1816
	return (1);
1734
}
1817
}
1735
 
1818
 
1736
 
1819
 
1737
/*
1820
/*
1738
    DUMP A VARIABLE DESTRUCTOR CALL
1821
    DUMP A VARIABLE DESTRUCTOR CALL
1739
 
1822
 
1740
    This routine adds the call of the destructor for the variable id to
1823
    This routine adds the call of the destructor for the variable id to
1741
    the dump file.
1824
    the dump file.
1742
*/
1825
*/
1743
 
1826
 
1744
void dump_destr
1827
void
1745
    PROTO_N ( ( id, loc ) )
-
 
1746
    PROTO_T ( IDENTIFIER id X LOCATION *loc )
1828
dump_destr(IDENTIFIER id, LOCATION *loc)
1747
{
1829
{
1748
    EXP d = DEREF_exp ( id_variable_etc_term ( id ) ) ;
1830
	EXP d = DEREF_exp(id_variable_etc_term(id));
1749
    if ( !IS_NULL_exp ( d ) ) {
1831
	if (!IS_NULL_exp(d)) {
1750
	unsigned tag = TAG_exp ( d ) ;
1832
		unsigned tag = TAG_exp(d);
1751
	while ( tag == exp_paren_tag ) {
1833
		while (tag == exp_paren_tag) {
1752
	    d = DEREF_exp ( exp_paren_arg ( d ) ) ;
1834
			d = DEREF_exp(exp_paren_arg(d));
1753
	    if ( IS_NULL_exp ( d ) ) return ;
1835
			if (IS_NULL_exp(d)) {
-
 
1836
				return;
-
 
1837
			}
1754
	    tag = TAG_exp ( d ) ;
1838
			tag = TAG_exp(d);
1755
	}
1839
		}
1756
	while ( tag == exp_nof_tag ) {
1840
		while (tag == exp_nof_tag) {
1757
	    d = DEREF_exp ( exp_nof_pad ( d ) ) ;
1841
			d = DEREF_exp(exp_nof_pad(d));
1758
	    tag = TAG_exp ( d ) ;
1842
			tag = TAG_exp(d);
1759
	}
1843
		}
1760
	while ( tag == exp_destr_tag ) {
1844
		while (tag == exp_destr_tag) {
1761
	    d = DEREF_exp ( exp_destr_call ( d ) ) ;
1845
			d = DEREF_exp(exp_destr_call(d));
1762
	    tag = TAG_exp ( d ) ;
1846
			tag = TAG_exp(d);
1763
	}
1847
		}
1764
	if ( tag == exp_func_id_tag ) {
1848
		if (tag == exp_func_id_tag) {
1765
	    IDENTIFIER fn = DEREF_id ( exp_func_id_id ( d ) ) ;
1849
			IDENTIFIER fn = DEREF_id(exp_func_id_id(d));
1766
	    dump_use ( id, loc, 0 ) ;
1850
			dump_use(id, loc, 0);
1767
	    dump_call ( fn, loc, 0 ) ;
1851
			dump_call(fn, loc, 0);
-
 
1852
		}
1768
	}
1853
	}
1769
    }
-
 
1770
    return ;
1854
	return;
1771
}
1855
}
1772
 
1856
 
1773
 
1857
 
1774
/*
1858
/*
1775
    DUMP AN IDENTIFIER DECLARATION
1859
    DUMP AN IDENTIFIER DECLARATION
Line 1777... Line 1861...
1777
    This routine adds the declaration of the identifier id to the dump
1861
    This routine adds the declaration of the identifier id to the dump
1778
    file.  The parameter def is 1 for a definition, 2 for a tentative
1862
    file.  The parameter def is 1 for a definition, 2 for a tentative
1779
    definition, and 0 for a declaration.
1863
    definition, and 0 for a declaration.
1780
*/
1864
*/
1781
 
1865
 
1782
void dump_declare
1866
void
1783
    PROTO_N ( ( id, loc, def ) )
-
 
1784
    PROTO_T ( IDENTIFIER id X LOCATION *loc X int def )
1867
dump_declare(IDENTIFIER id, LOCATION *loc, int def)
1785
{
1868
{
1786
    FILE *f = dump_file ;
1869
	FILE *f = dump_file;
1787
    CONST char *key = dump_key ( id, def ) ;
1870
	CONST char *key = dump_key(id, def);
1788
    if ( key && f ) {
1871
	if (key && f) {
1789
	/* Dump identifier key */
1872
		/* Dump identifier key */
1790
	char d = 'M' ;
1873
		char d = 'M';
1791
	int destr = 0 ;
1874
		int destr = 0;
1792
	DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
1875
		DECL_SPEC ds = DEREF_dspec(id_storage(id));
1793
	if ( dump_implicit || dump_template ) fputc_v ( 'I', f ) ;
1876
		if (dump_implicit || dump_template) {
-
 
1877
			fputc_v('I', f);
-
 
1878
		}
1794
	switch ( def ) {
1879
		switch (def) {
-
 
1880
		case 1:
1795
	    case 1 : d = 'D' ; break ;
1881
			d = 'D';
-
 
1882
			break;
-
 
1883
		case 2:
1796
	    case 2 : d = 'T' ; break ;
1884
			d = 'T';
-
 
1885
			break;
1797
	}
1886
		}
1798
 
1887
 
1799
	/* Dump location and identifier information */
1888
		/* Dump location and identifier information */
1800
	fprintf_v ( f, "%c%s\t", d, key ) ;
1889
		fprintf_v(f, "%c%s\t", d, key);
1801
	dump_loc ( loc ) ;
1890
		dump_loc(loc);
1802
	fputc_v ( '\t', f ) ;
1891
		fputc_v('\t', f);
1803
	dump_id ( id ) ;
1892
		dump_id(id);
1804
	fputc_v ( '\t', f ) ;
1893
		fputc_v('\t', f);
1805
 
1894
 
1806
	/* Dump identifier specific information */
1895
		/* Dump identifier specific information */
1807
	switch ( TAG_id ( id ) ) {
1896
		switch (TAG_id(id)) {
1808
	    case id_obj_macro_tag : {
1897
		case id_obj_macro_tag: {
1809
		/* Object-like macros */
1898
			/* Object-like macros */
1810
		fputs_v ( "ZUO", f ) ;
1899
			fputs_v("ZUO", f);
1811
		break ;
-
 
1812
	    }
-
 
1813
	    case id_func_macro_tag : {
-
 
1814
		/* Function-like macros */
-
 
1815
		unsigned n ;
-
 
1816
		n = DEREF_unsigned ( id_func_macro_no_params ( id ) ) ;
-
 
1817
		fprintf_v ( f, "ZUF%u", n ) ;
-
 
1818
		break ;
-
 
1819
	    }
-
 
1820
	    case id_builtin_tag : {
-
 
1821
		/* Built-in operators */
-
 
1822
		TYPE r = DEREF_type ( id_builtin_ret ( id ) ) ;
-
 
1823
		LIST ( TYPE ) p = DEREF_list ( id_builtin_ptypes ( id ) ) ;
-
 
1824
		fputc_v ( MANGLE_func, f ) ;
-
 
1825
		dump_type ( r ) ;
-
 
1826
		dump_type_list ( p, FUNC_NONE, 1 ) ;
-
 
1827
		fputc_v ( MANGLE_colon, f ) ;
-
 
1828
		fputc_v ( MANGLE_colon, f ) ;
-
 
1829
		break ;
-
 
1830
	    }
-
 
1831
	    case id_class_name_tag :
-
 
1832
	    case id_enum_name_tag :
-
 
1833
	    case id_class_alias_tag :
-
 
1834
	    case id_enum_alias_tag :
-
 
1835
	    case id_type_alias_tag : {
-
 
1836
		/* Type aliases */
-
 
1837
		TYPE t = DEREF_type ( id_class_name_etc_defn ( id ) ) ;
-
 
1838
		if ( ds & dspec_token ) {
-
 
1839
		    /* Tokenised types */
-
 
1840
		    IDENTIFIER tid = find_token ( id ) ;
-
 
1841
		    if ( IS_id_token ( tid ) ) {
-
 
1842
			TOKEN tok = DEREF_tok ( id_token_sort ( tid ) ) ;
-
 
1843
			dump_sort ( tok ) ;
-
 
1844
			break ;
1900
			break;
1845
		    }
-
 
1846
		}
-
 
1847
		dump_type ( t ) ;
-
 
1848
		break ;
-
 
1849
	    }
-
 
1850
	    case id_nspace_name_tag : {
-
 
1851
		/* Namespace names */
-
 
1852
		fputc_v ( '*', f ) ;
-
 
1853
		break ;
-
 
1854
	    }
-
 
1855
	    case id_nspace_alias_tag : {
-
 
1856
		/* Namespace aliases */
-
 
1857
		NAMESPACE ns = DEREF_nspace ( id_nspace_alias_defn ( id ) ) ;
-
 
1858
		dump_nspace ( ns, 0 ) ;
-
 
1859
		break ;
-
 
1860
	    }
-
 
1861
	    case id_variable_tag :
-
 
1862
	    case id_parameter_tag :
-
 
1863
	    case id_stat_member_tag : {
-
 
1864
		/* Variables */
-
 
1865
		TYPE t = DEREF_type ( id_variable_etc_type ( id ) ) ;
-
 
1866
		dump_type ( t ) ;
-
 
1867
		if ( !( ds & dspec_auto ) ) destr = def ;
-
 
1868
		break ;
-
 
1869
	    }
-
 
1870
	    case id_weak_param_tag : {
-
 
1871
		/* Non-prototype function parameters */
-
 
1872
		dump_type ( type_sint ) ;
-
 
1873
		break ;
-
 
1874
	    }
-
 
1875
	    case id_function_tag :
-
 
1876
	    case id_mem_func_tag :
-
 
1877
	    case id_stat_mem_func_tag : {
-
 
1878
		/* Functions */
-
 
1879
		TYPE t = DEREF_type ( id_function_etc_type ( id ) ) ;
-
 
1880
		IDENTIFIER over = DEREF_id ( id_function_etc_over ( id ) ) ;
-
 
1881
		dump_type ( t ) ;
-
 
1882
		if ( !IS_NULL_id ( over ) ) {
-
 
1883
		    fputc_v ( '\t', f ) ;
-
 
1884
		    dump_id ( over ) ;
-
 
1885
		}
1901
		}
-
 
1902
		case id_func_macro_tag: {
-
 
1903
			/* Function-like macros */
-
 
1904
			unsigned n;
-
 
1905
			n = DEREF_unsigned(id_func_macro_no_params(id));
-
 
1906
			fprintf_v(f, "ZUF%u", n);
1886
		break ;
1907
			break;
-
 
1908
		}
-
 
1909
		case id_builtin_tag: {
-
 
1910
			/* Built-in operators */
-
 
1911
			TYPE r = DEREF_type(id_builtin_ret(id));
-
 
1912
			LIST(TYPE)p = DEREF_list(id_builtin_ptypes(id));
-
 
1913
			fputc_v(MANGLE_func, f);
-
 
1914
			dump_type(r);
-
 
1915
			dump_type_list(p, FUNC_NONE, 1);
-
 
1916
			fputc_v(MANGLE_colon, f);
-
 
1917
			fputc_v(MANGLE_colon, f);
-
 
1918
			break;
-
 
1919
		}
-
 
1920
		case id_class_name_tag:
-
 
1921
		case id_enum_name_tag:
-
 
1922
		case id_class_alias_tag:
-
 
1923
		case id_enum_alias_tag:
-
 
1924
		case id_type_alias_tag: {
-
 
1925
			/* Type aliases */
-
 
1926
			TYPE t = DEREF_type(id_class_name_etc_defn(id));
-
 
1927
			if (ds & dspec_token) {
-
 
1928
				/* Tokenised types */
-
 
1929
				IDENTIFIER tid = find_token(id);
-
 
1930
				if (IS_id_token(tid)) {
-
 
1931
					TOKEN tok =
-
 
1932
					    DEREF_tok(id_token_sort(tid));
-
 
1933
					dump_sort(tok);
-
 
1934
					break;
1887
	    }
1935
				}
-
 
1936
			}
-
 
1937
			dump_type(t);
-
 
1938
			break;
-
 
1939
		}
-
 
1940
		case id_nspace_name_tag: {
-
 
1941
			/* Namespace names */
-
 
1942
			fputc_v('*', f);
-
 
1943
			break;
-
 
1944
		}
-
 
1945
		case id_nspace_alias_tag: {
-
 
1946
			/* Namespace aliases */
-
 
1947
			NAMESPACE ns = DEREF_nspace(id_nspace_alias_defn(id));
-
 
1948
			dump_nspace(ns, 0);
-
 
1949
			break;
-
 
1950
		}
-
 
1951
		case id_variable_tag:
-
 
1952
		case id_parameter_tag:
-
 
1953
		case id_stat_member_tag: {
-
 
1954
			/* Variables */
-
 
1955
			TYPE t = DEREF_type(id_variable_etc_type(id));
-
 
1956
			dump_type(t);
-
 
1957
			if (!(ds & dspec_auto))destr = def;
-
 
1958
			break;
-
 
1959
		}
-
 
1960
		case id_weak_param_tag: {
-
 
1961
			/* Non-prototype function parameters */
-
 
1962
			dump_type(type_sint);
-
 
1963
			break;
-
 
1964
		}
-
 
1965
		case id_function_tag:
-
 
1966
		case id_mem_func_tag:
-
 
1967
		case id_stat_mem_func_tag: {
-
 
1968
			/* Functions */
-
 
1969
			TYPE t = DEREF_type(id_function_etc_type(id));
-
 
1970
			IDENTIFIER over = DEREF_id(id_function_etc_over(id));
-
 
1971
			dump_type(t);
-
 
1972
			if (!IS_NULL_id(over)) {
-
 
1973
				fputc_v('\t', f);
-
 
1974
				dump_id(over);
-
 
1975
			}
-
 
1976
			break;
-
 
1977
		}
1888
	    case id_member_tag : {
1978
		case id_member_tag: {
1889
		/* Data members */
1979
			/* Data members */
1890
		TYPE t = DEREF_type ( id_member_type ( id ) ) ;
1980
			TYPE t = DEREF_type(id_member_type(id));
1891
		dump_type ( t ) ;
1981
			dump_type(t);
1892
		break ;
1982
			break;
1893
	    }
1983
		}
1894
	    case id_enumerator_tag : {
1984
		case id_enumerator_tag: {
1895
		/* Enumerators */
1985
			/* Enumerators */
1896
		TYPE t = DEREF_type ( id_enumerator_etype ( id ) ) ;
1986
			TYPE t = DEREF_type(id_enumerator_etype(id));
1897
		dump_type ( t ) ;
1987
			dump_type(t);
1898
		break ;
1988
			break;
1899
	    }
1989
		}
1900
	    case id_token_tag : {
1990
		case id_token_tag: {
1901
		/* Tokens */
1991
			/* Tokens */
1902
		TOKEN tok = DEREF_tok ( id_token_sort ( id ) ) ;
1992
			TOKEN tok = DEREF_tok(id_token_sort(id));
1903
		dump_sort ( tok ) ;
1993
			dump_sort(tok);
1904
		break ;
1994
			break;
1905
	    }
1995
		}
1906
	    default : {
1996
		default : {
1907
		/* Other identifiers */
1997
			/* Other identifiers */
1908
		fputc_v ( '*', f ) ;
1998
			fputc_v('*', f);
1909
		break ;
1999
			break;
1910
	    }
2000
		}
1911
	}
2001
		}
1912
	fputc_v ( '\n', f ) ;
2002
		fputc_v('\n', f);
1913
 
2003
 
1914
	/* Deal with destructors */
2004
		/* Deal with destructors */
1915
	if ( destr && do_usage ) dump_destr ( id, loc ) ;
2005
		if (destr && do_usage) {
-
 
2006
			dump_destr(id, loc);
1916
    }
2007
		}
-
 
2008
	}
1917
    dump_implicit = 0 ;
2009
	dump_implicit = 0;
1918
    return ;
2010
	return;
1919
}
2011
}
1920
 
2012
 
1921
 
2013
 
1922
/*
2014
/*
1923
    DUMP AN IDENTIFIER UNDEFINITION
2015
    DUMP AN IDENTIFIER UNDEFINITION
1924
 
2016
 
1925
    This routine adds the undefinition (indicating the end of a scope)
2017
    This routine adds the undefinition (indicating the end of a scope)
1926
    of the identifier id to the dump file.
2018
    of the identifier id to the dump file.
1927
*/
2019
*/
1928
 
2020
 
1929
void dump_undefine
2021
void
1930
    PROTO_N ( ( id, loc, def ) )
-
 
1931
    PROTO_T ( IDENTIFIER id X LOCATION *loc X int def )
2022
dump_undefine(IDENTIFIER id, LOCATION *loc, int def)
1932
{
2023
{
1933
    FILE *f = dump_file ;
2024
	FILE *f = dump_file;
1934
    CONST char *key = dump_key ( id, def ) ;
2025
	CONST char *key = dump_key(id, def);
1935
    if ( key && f ) {
2026
	if (key && f) {
1936
	if ( def ) {
2027
		if (def) {
1937
	    fprintf_v ( f, "U%s\t", key ) ;
2028
			fprintf_v(f, "U%s\t", key);
1938
	} else {
2029
		} else {
1939
	    fprintf_v ( f, "Q%s\t", key ) ;
2030
			fprintf_v(f, "Q%s\t", key);
-
 
2031
		}
-
 
2032
		dump_loc(loc);
-
 
2033
		fputc_v('\t', f);
-
 
2034
		dump_id(id);
-
 
2035
		fputc_v('\n', f);
1940
	}
2036
	}
1941
	dump_loc ( loc ) ;
-
 
1942
	fputc_v ( '\t', f ) ;
-
 
1943
	dump_id ( id ) ;
-
 
1944
	fputc_v ( '\n', f ) ;
-
 
1945
    }
-
 
1946
    return ;
2037
	return;
1947
}
2038
}
1948
 
2039
 
1949
 
2040
 
1950
/*
2041
/*
1951
    DUMP AN IDENTIFIER USE
2042
    DUMP AN IDENTIFIER USE
1952
 
2043
 
1953
    This routine adds the use of the identifier id to the dump file.
2044
    This routine adds the use of the identifier id to the dump file.
1954
    expl is true for an explicit use.
2045
    expl is true for an explicit use.
1955
*/
2046
*/
1956
 
2047
 
1957
void dump_use
2048
void
1958
    PROTO_N ( ( id, loc, expl ) )
-
 
1959
    PROTO_T ( IDENTIFIER id X LOCATION *loc X int expl )
2049
dump_use(IDENTIFIER id, LOCATION *loc, int expl)
1960
{
2050
{
1961
    FILE *f = dump_file ;
2051
	FILE *f = dump_file;
1962
    CONST char *key = dump_key ( id, 1 ) ;
2052
	CONST char *key = dump_key(id, 1);
1963
    if ( key && f ) {
2053
	if (key && f) {
-
 
2054
		if (!expl) {
1964
	if ( !expl ) fputc_v ( 'I', f ) ;
2055
			fputc_v('I', f);
-
 
2056
		}
1965
	fprintf_v ( f, "L%s\t", key ) ;
2057
		fprintf_v(f, "L%s\t", key);
1966
	dump_loc ( loc ) ;
2058
		dump_loc(loc);
1967
	fputc_v ( '\t', f ) ;
2059
		fputc_v('\t', f);
1968
	dump_id ( id ) ;
2060
		dump_id(id);
1969
	fputc_v ( '\n', f ) ;
2061
		fputc_v('\n', f);
1970
    }
2062
	}
1971
    return ;
2063
	return;
1972
}
2064
}
1973
 
2065
 
1974
 
2066
 
1975
/*
2067
/*
1976
    DUMP AN IDENTIFIER CALL
2068
    DUMP AN IDENTIFIER CALL
1977
 
2069
 
1978
    This routine adds the call of the identifier id to the dump file.
2070
    This routine adds the call of the identifier id to the dump file.
1979
    expl is true for an explicit call.
2071
    expl is true for an explicit call.
1980
*/
2072
*/
1981
 
2073
 
1982
void dump_call
2074
void
1983
    PROTO_N ( ( id, loc, expl ) )
-
 
1984
    PROTO_T ( IDENTIFIER id X LOCATION *loc X int expl )
2075
dump_call(IDENTIFIER id, LOCATION *loc, int expl)
1985
{
2076
{
1986
    FILE *f = dump_file ;
2077
	FILE *f = dump_file;
1987
    CONST char *key = dump_key ( id, 1 ) ;
2078
	CONST char *key = dump_key(id, 1);
1988
    if ( key && f ) {
2079
	if (key && f) {
-
 
2080
		if (!expl) {
1989
	if ( !expl ) fputc_v ( 'I', f ) ;
2081
			fputc_v('I', f);
-
 
2082
		}
1990
	fprintf_v ( f, "C%s\t", key ) ;
2083
		fprintf_v(f, "C%s\t", key);
1991
	dump_loc ( loc ) ;
2084
		dump_loc(loc);
1992
	fputc_v ( '\t', f ) ;
2085
		fputc_v('\t', f);
1993
	dump_id ( id ) ;
2086
		dump_id(id);
1994
	fputc_v ( '\n', f ) ;
2087
		fputc_v('\n', f);
1995
    }
2088
	}
1996
    return ;
2089
	return;
1997
}
2090
}
1998
 
2091
 
1999
 
2092
 
2000
/*
2093
/*
2001
    DUMP A TEMPLATE INSTANCE
2094
    DUMP A TEMPLATE INSTANCE
2002
 
2095
 
2003
    This routine adds the association of the identifier id and the
2096
    This routine adds the association of the identifier id and the
2004
    template instance form to the dump file.
2097
    template instance form to the dump file.
2005
*/
2098
*/
2006
 
2099
 
2007
void dump_instance
2100
void
2008
    PROTO_N ( ( id, form, spec ) )
-
 
2009
    PROTO_T ( IDENTIFIER id X TYPE form X TYPE spec )
2101
dump_instance(IDENTIFIER id, TYPE form, TYPE spec)
2010
{
2102
{
2011
    FILE *f = dump_file ;
2103
	FILE *f = dump_file;
2012
    CONST char *key = dump_key ( id, 1 ) ;
2104
	CONST char *key = dump_key(id, 1);
2013
    if ( key && f ) {
2105
	if (key && f) {
2014
	fprintf_v ( f, "Z%s\t", key ) ;
2106
		fprintf_v(f, "Z%s\t", key);
2015
	dump_id ( id ) ;
2107
		dump_id(id);
2016
	fputc_v ( '\t', f ) ;
2108
		fputc_v('\t', f);
2017
	dump_type ( form ) ;
2109
		dump_type(form);
2018
	if ( !EQ_type ( form, spec ) ) {
2110
		if (!EQ_type(form, spec)) {
2019
	    fputc_v ( '\t', f ) ;
2111
			fputc_v('\t', f);
2020
	    dump_type ( spec ) ;
2112
			dump_type(spec);
2021
	    fputc_v ( '\n', f ) ;
2113
			fputc_v('\n', f);
2022
	} else {
2114
		} else {
2023
	    fputs_v ( "\t*\n", f ) ;
2115
			fputs_v("\t*\n", f);
2024
	}
2116
		}
2025
    }
2117
	}
2026
    return ;
2118
	return;
2027
}
2119
}
2028
 
2120
 
2029
 
2121
 
2030
/*
2122
/*
2031
    DUMP A TOKEN NAME
2123
    DUMP A TOKEN NAME
2032
 
2124
 
2033
    This routine adds the association of the identifier id and the external
2125
    This routine adds the association of the identifier id and the external
2034
    token name tok to the dump file.
2126
    token name tok to the dump file.
2035
*/
2127
*/
2036
 
2128
 
2037
void dump_token
2129
void
2038
    PROTO_N ( ( id, tok ) )
-
 
2039
    PROTO_T ( IDENTIFIER id X IDENTIFIER tok )
2130
dump_token(IDENTIFIER id, IDENTIFIER tok)
2040
{
2131
{
2041
    FILE *f = dump_file ;
2132
	FILE *f = dump_file;
2042
    CONST char *key = dump_key ( id, 1 ) ;
2133
	CONST char *key = dump_key(id, 1);
2043
    if ( key && f ) {
2134
	if (key && f) {
2044
	HASHID nm = DEREF_hashid ( id_name ( tok ) ) ;
2135
		HASHID nm = DEREF_hashid(id_name(tok));
2045
	if ( IS_hashid_name_etc ( nm ) ) {
2136
		if (IS_hashid_name_etc(nm)) {
2046
	    string s = DEREF_string ( hashid_name_etc_text ( nm ) ) ;
2137
			string s = DEREF_string(hashid_name_etc_text(nm));
2047
	    unsigned n = ( unsigned ) ustrlen ( s ) ;
2138
			unsigned n = (unsigned)ustrlen(s);
2048
	    fprintf_v ( f, "X%s\t", key ) ;
2139
			fprintf_v(f, "X%s\t", key);
2049
	    dump_id ( id ) ;
2140
			dump_id(id);
2050
	    fprintf_v ( f, "\t&%u<%s>\n", n, strlit ( s ) ) ;
2141
			fprintf_v(f, "\t&%u<%s>\n", n, strlit(s));
2051
	}
2142
		}
2052
    }
2143
	}
2053
    return ;
2144
	return;
2054
}
2145
}
2055
 
2146
 
2056
 
2147
 
2057
/*
2148
/*
2058
    DUMP A TOKEN PARAMETER
2149
    DUMP A TOKEN PARAMETER
2059
 
2150
 
2060
    This routine adds the declaration of the token or template parameter
2151
    This routine adds the declaration of the token or template parameter
2061
    id to the dump file.
2152
    id to the dump file.
2062
*/
2153
*/
2063
 
2154
 
2064
void dump_token_param
2155
void
2065
    PROTO_N ( ( id ) )
-
 
2066
    PROTO_T ( IDENTIFIER id )
2156
dump_token_param(IDENTIFIER id)
2067
{
2157
{
2068
    dump_declare ( id, &crt_loc, 0 ) ;
2158
	dump_declare(id, &crt_loc, 0);
2069
    if ( IS_id_token ( id ) ) {
2159
	if (IS_id_token(id)) {
2070
	IDENTIFIER alt = DEREF_id ( id_token_alt ( id ) ) ;
2160
		IDENTIFIER alt = DEREF_id(id_token_alt(id));
2071
	ulong n = DEREF_ulong ( id_dump ( id ) ) ;
2161
		ulong n = DEREF_ulong(id_dump(id));
2072
	COPY_ulong ( id_dump ( alt ), n ) ;
2162
		COPY_ulong(id_dump(alt), n);
2073
    }
2163
	}
2074
    return ;
2164
	return;
2075
}
2165
}
2076
 
2166
 
2077
 
2167
 
2078
/*
2168
/*
2079
    DUMP A BUILT-IN OPERATOR
2169
    DUMP A BUILT-IN OPERATOR
2080
 
2170
 
2081
    This routine adds the declaration of the built-in operator id to the
2171
    This routine adds the declaration of the built-in operator id to the
2082
    dump file.
2172
    dump file.
2083
*/
2173
*/
2084
 
2174
 
2085
void dump_builtin
2175
void
2086
    PROTO_N ( ( id ) )
-
 
2087
    PROTO_T ( IDENTIFIER id )
2176
dump_builtin(IDENTIFIER id)
2088
{
2177
{
2089
    if ( IS_id_builtin ( id ) ) {
2178
	if (IS_id_builtin(id)) {
2090
	dump_implicit = 1 ;
2179
		dump_implicit = 1;
2091
	dump_declare ( id, &crt_loc, 0 ) ;
2180
		dump_declare(id, &crt_loc, 0);
2092
    }
2181
	}
2093
    return ;
2182
	return;
2094
}
2183
}
2095
 
2184
 
2096
 
2185
 
2097
/*
2186
/*
2098
    DUMP A PROMOTION TYPE
2187
    DUMP A PROMOTION TYPE
2099
 
2188
 
2100
    This routine adds the fact that the promotion of the integral type
2189
    This routine adds the fact that the promotion of the integral type
2101
    it is ip to the dump file.
2190
    it is ip to the dump file.
2102
*/
2191
*/
2103
 
2192
 
2104
void dump_promote
2193
void
2105
    PROTO_N ( ( it, ip ) )
-
 
2106
    PROTO_T ( INT_TYPE it X INT_TYPE ip )
2194
dump_promote(INT_TYPE it, INT_TYPE ip)
2107
{
2195
{
2108
    FILE *f = dump_file ;
2196
	FILE *f = dump_file;
2109
    if ( f ) {
2197
	if (f) {
2110
	fputs_v ( "P\t", f ) ;
2198
		fputs_v("P\t", f);
2111
	dump_itype ( it ) ;
2199
		dump_itype(it);
2112
	fputc_v ( MANGLE_colon, f ) ;
2200
		fputc_v(MANGLE_colon, f);
2113
	dump_itype ( ip ) ;
2201
		dump_itype(ip);
2114
	fputc_v ( '\n', f ) ;
2202
		fputc_v('\n', f);
2115
    }
2203
	}
2116
    return ;
2204
	return;
2117
}
2205
}
2118
 
2206
 
2119
 
2207
 
2120
/*
2208
/*
2121
    DUMP THE START OF A SCOPE
2209
    DUMP THE START OF A SCOPE
2122
 
2210
 
2123
    This routine adds the start of the scope ns (which may have an associated
2211
    This routine adds the start of the scope ns (which may have an associated
2124
    name, id) to the dump file.  pns gives the enclosing scope, if known.
2212
    name, id) to the dump file.  pns gives the enclosing scope, if known.
2125
*/
2213
*/
2126
 
2214
 
2127
void dump_begin_scope
2215
void
2128
    PROTO_N ( ( id, ns, pns, loc ) )
-
 
2129
    PROTO_T ( IDENTIFIER id X NAMESPACE ns X NAMESPACE pns X LOCATION *loc )
2216
dump_begin_scope(IDENTIFIER id, NAMESPACE ns, NAMESPACE pns, LOCATION *loc)
2130
{
2217
{
2131
    FILE *f = dump_file ;
2218
	FILE *f = dump_file;
2132
    if ( !IS_NULL_nspace ( ns ) && f ) {
2219
	if (!IS_NULL_nspace(ns) && f) {
2133
	ulong n ;
2220
		ulong n;
2134
	HASHID nm ;
2221
		HASHID nm;
2135
	if ( !IS_NULL_id ( id ) ) {
2222
		if (!IS_NULL_id(id)) {
2136
	    /* Named scope */
2223
			/* Named scope */
2137
	    fputs_v ( "SSH\t", f ) ;
2224
			fputs_v("SSH\t", f);
2138
	    n = DEREF_ulong ( id_dump ( id ) ) ;
2225
			n = DEREF_ulong(id_dump(id));
2139
	    if ( n != LINK_NONE ) {
2226
			if (n != LINK_NONE) {
2140
		/* Already used */
2227
				/* Already used */
2141
		dump_loc ( loc ) ;
2228
				dump_loc(loc);
2142
		fprintf_v ( f, "\t%lu\n", n ) ;
2229
				fprintf_v(f, "\t%lu\n", n);
2143
		return ;
2230
				return;
2144
	    }
2231
			}
2145
	    n = dump_id_next++ ;
2232
			n = dump_id_next++;
2146
	    COPY_ulong ( id_dump ( id ), n ) ;
2233
			COPY_ulong(id_dump(id), n);
2147
	    nm = DEREF_hashid ( id_name ( id ) ) ;
2234
			nm = DEREF_hashid(id_name(id));
2148
	} else {
2235
		} else {
2149
	    /* Unnamed scope */
2236
			/* Unnamed scope */
2150
	    fputs_v ( "SSB\t", f ) ;
2237
			fputs_v("SSB\t", f);
2151
	    n = dump_id_next++ ;
2238
			n = dump_id_next++;
2152
	    nm = NULL_hashid ;
2239
			nm = NULL_hashid;
2153
	}
2240
		}
2154
	dump_loc ( loc ) ;
2241
		dump_loc(loc);
2155
	fprintf_v ( f, "\t%lu = ", n ) ;
2242
		fprintf_v(f, "\t%lu = ", n);
2156
	dump_hashid ( nm ) ;
2243
		dump_hashid(nm);
2157
	fputc_v ( '\t', f ) ;
2244
		fputc_v('\t', f);
2158
	dump_nspace ( pns, 1 ) ;
2245
		dump_nspace(pns, 1);
2159
	fputc_v ( '\n', f ) ;
2246
		fputc_v('\n', f);
2160
	COPY_ulong ( nspace_dump ( ns ), n ) ;
2247
		COPY_ulong(nspace_dump(ns), n);
2161
    }
2248
	}
2162
    return ;
2249
	return;
2163
}
2250
}
2164
 
2251
 
2165
 
2252
 
2166
/*
2253
/*
2167
    DUMP THE END OF A SCOPE
2254
    DUMP THE END OF A SCOPE
2168
 
2255
 
2169
    This routine adds the end of the scope ns (which may have an associated
2256
    This routine adds the end of the scope ns (which may have an associated
2170
    name, id) to the dump file.
2257
    name, id) to the dump file.
2171
*/
2258
*/
2172
 
2259
 
2173
void dump_end_scope
2260
void
2174
    PROTO_N ( ( id, ns, loc ) )
-
 
2175
    PROTO_T ( IDENTIFIER id X NAMESPACE ns X LOCATION *loc )
2261
dump_end_scope(IDENTIFIER id, NAMESPACE ns, LOCATION *loc)
2176
{
2262
{
2177
    FILE *f = dump_file ;
2263
	FILE *f = dump_file;
2178
    if ( !IS_NULL_nspace ( ns ) && f ) {
2264
	if (!IS_NULL_nspace(ns) && f) {
2179
	ulong n = DEREF_ulong ( nspace_dump ( ns ) ) ;
2265
		ulong n = DEREF_ulong(nspace_dump(ns));
2180
	if ( !IS_NULL_id ( id ) ) {
2266
		if (!IS_NULL_id(id)) {
2181
	    fputs_v ( "SEH\t", f ) ;
2267
			fputs_v("SEH\t", f);
2182
	} else {
2268
		} else {
2183
	    fputs_v ( "SEB\t", f ) ;
2269
			fputs_v("SEB\t", f);
2184
	}
2270
		}
2185
	dump_loc ( loc ) ;
2271
		dump_loc(loc);
2186
	fprintf_v ( f, "\t%lu\n", n ) ;
2272
		fprintf_v(f, "\t%lu\n", n);
2187
    }
2273
	}
2188
    return ;
2274
	return;
2189
}
2275
}
2190
 
2276
 
2191
 
2277
 
2192
/*
2278
/*
2193
    DUMP A STRING LITERAL
2279
    DUMP A STRING LITERAL
2194
 
2280
 
2195
    This routine adds the string literal of type kind given by the start
2281
    This routine adds the string literal of type kind given by the start
2196
    and end points s and e to the dump file.
2282
    and end points s and e to the dump file.
2197
*/
2283
*/
2198
 
2284
 
2199
void dump_string_lit
2285
void
2200
    PROTO_N ( ( s, e, kind ) )
-
 
2201
    PROTO_T ( string s X string e X unsigned kind )
2286
dump_string_lit(string s, string e, unsigned kind)
2202
{
2287
{
2203
    FILE *f = dump_file ;
2288
	FILE *f = dump_file;
2204
    if ( f ) {
2289
	if (f) {
2205
	unsigned long n = ( unsigned long ) ( e - s ) ;
2290
		unsigned long n = (unsigned long)(e - s);
2206
	fputc_v ( 'A', f ) ;
2291
		fputc_v('A', f);
2207
	if ( kind & STRING_CHAR ) fputc_v ( 'C', f ) ;
2292
		if (kind & STRING_CHAR) {
-
 
2293
			fputc_v('C', f);
-
 
2294
		}
2208
	if ( kind & STRING_WIDE ) fputc_v ( 'L', f ) ;
2295
		if (kind & STRING_WIDE) {
-
 
2296
			fputc_v('L', f);
-
 
2297
		}
2209
	fputc_v ( '\t', f ) ;
2298
		fputc_v('\t', f);
2210
	dump_loc ( &crt_loc ) ;
2299
		dump_loc(&crt_loc);
2211
	fprintf_v ( f, "\t&%lu<", n ) ;
2300
		fprintf_v(f, "\t&%lu<", n);
2212
	while ( s != e ) {
2301
		while (s != e) {
2213
	    int c = ( int ) *( s++ ) ;
2302
			int c = (int)*(s++);
2214
	    fputc_v ( c, f ) ;
2303
			fputc_v(c, f);
2215
	}
2304
		}
2216
	fputs_v ( ">\n", f ) ;
2305
		fputs_v(">\n", f);
2217
    }
2306
	}
2218
    return ;
2307
	return;
2219
}
2308
}
2220
 
2309
 
2221
 
2310
 
2222
/*
2311
/*
2223
    DUMP THE START OF A FILE
2312
    DUMP THE START OF A FILE
2224
 
2313
 
2225
    This routine adds the start of the file loc to the dump file.  dir
2314
    This routine adds the start of the file loc to the dump file.  dir
2226
    gives the directory in which the file was found.
2315
    gives the directory in which the file was found.
2227
*/
2316
*/
2228
 
2317
 
2229
void dump_start
2318
void
2230
    PROTO_N ( ( loc, dir ) )
-
 
2231
    PROTO_T ( LOCATION *loc X INCL_DIR *dir )
2319
dump_start(LOCATION *loc, INCL_DIR *dir)
2232
{
2320
{
2233
    FILE *f = dump_file ;
2321
	FILE *f = dump_file;
2234
    if ( f ) {
2322
	if (f) {
2235
	fputs_v ( "FS\t", f ) ;
2323
		fputs_v("FS\t", f);
2236
	dump_loc ( loc ) ;
2324
		dump_loc(loc);
2237
	if ( dir ) {
2325
		if (dir) {
2238
	    fprintf_v ( f, "\t%lu\n", dir->no ) ;
2326
			fprintf_v(f, "\t%lu\n", dir->no);
2239
	} else {
2327
		} else {
2240
	    fputs_v ( "\t*\n", f ) ;
2328
			fputs_v("\t*\n", f);
2241
	}
2329
		}
2242
    }
2330
	}
2243
    return ;
2331
	return;
2244
}
2332
}
2245
 
2333
 
2246
 
2334
 
2247
/*
2335
/*
2248
    DUMP THE END OF A FILE
2336
    DUMP THE END OF A FILE
2249
 
2337
 
2250
    This routine adds the end of the file loc to the dump file.
2338
    This routine adds the end of the file loc to the dump file.
2251
*/
2339
*/
2252
 
2340
 
2253
void dump_end
2341
void
2254
    PROTO_N ( ( loc ) )
-
 
2255
    PROTO_T ( LOCATION *loc )
2342
dump_end(LOCATION *loc)
2256
{
2343
{
2257
    FILE *f = dump_file ;
2344
	FILE *f = dump_file;
2258
    if ( f ) {
2345
	if (f) {
2259
	fputs_v ( "FE\t", f ) ;
2346
		fputs_v("FE\t", f);
2260
	dump_loc ( loc ) ;
2347
		dump_loc(loc);
2261
	fputc_v ( '\n', f ) ;
2348
		fputc_v('\n', f);
2262
    }
2349
	}
2263
    return ;
2350
	return;
2264
}
2351
}
2265
 
2352
 
2266
 
2353
 
2267
/*
2354
/*
2268
    DUMP A FILE INCLUSION
2355
    DUMP A FILE INCLUSION
2269
 
2356
 
2270
    This routine adds a file inclusion to the dump file.  loc gives the
2357
    This routine adds a file inclusion to the dump file.  loc gives the
2271
    location of the '#include' directive, the following file start gives
2358
    location of the '#include' directive, the following file start gives
2272
    the file included.  st is as in start_include, plus 4 for the
2359
    the file included.  st is as in start_include, plus 4 for the
2273
    resumption of a file after a file has been included.  q is either '"',
2360
    resumption of a file after a file has been included.  q is either '"',
2274
    '>' or ']' depending on the type of inclusion.
2361
    '>' or ']' depending on the type of inclusion.
2275
*/
2362
*/
2276
 
2363
 
2277
void dump_include
2364
void
2278
    PROTO_N ( ( loc, nm, st, q ) )
-
 
2279
    PROTO_T ( LOCATION *loc X string nm X int st X int q )
2365
dump_include(LOCATION *loc, string nm, int st, int q)
2280
{
2366
{
2281
    FILE *f = dump_file ;
2367
	FILE *f = dump_file;
2282
    if ( f ) {
2368
	if (f) {
2283
	CONST char *incl ;
2369
		CONST char *incl;
2284
	switch ( st ) {
2370
		switch (st) {
-
 
2371
		case 2:
2285
	    case 2 : incl = "FIS" ; break ;
2372
			incl = "FIS";
-
 
2373
			break;
-
 
2374
		case 3:
2286
	    case 3 : incl = "FIE" ; break ;
2375
			incl = "FIE";
-
 
2376
			break;
-
 
2377
		case 4:
2287
	    case 4 : incl = "FIR" ; nm = NULL ; break ;
2378
			incl = "FIR";
-
 
2379
			nm = NULL;
-
 
2380
			break;
2288
	    default : {
2381
		default: {
2289
		if ( q == char_quote ) {
2382
			if (q == char_quote) {
2290
		    incl = "FIQ" ;
2383
				incl = "FIQ";
2291
		} else if ( q == char_close_square ) {
2384
			} else if (q == char_close_square) {
2292
		    incl = "FIN" ;
2385
				incl = "FIN";
2293
		} else {
2386
			} else {
2294
		    incl = "FIA" ;
2387
				incl = "FIA";
-
 
2388
			}
-
 
2389
			break;
-
 
2390
		}
-
 
2391
		}
-
 
2392
		fprintf_v(f, "%s\t", incl);
-
 
2393
		dump_loc(loc);
-
 
2394
		if (nm) {
-
 
2395
			/* Output included name */
-
 
2396
			unsigned n = (unsigned)ustrlen(nm);
-
 
2397
			fprintf_v(f, "\t&%u<%s>", n, strlit(nm));
2295
		}
2398
		}
2296
		break ;
-
 
2297
	    }
-
 
2298
	}
-
 
2299
	fprintf_v ( f, "%s\t", incl ) ;
-
 
2300
	dump_loc ( loc ) ;
2399
		fputc_v('\n', f);
2301
	if ( nm ) {
-
 
2302
	    /* Output included name */
-
 
2303
	    unsigned n = ( unsigned ) ustrlen ( nm ) ;
-
 
2304
	    fprintf_v ( f, "\t&%u<%s>", n, strlit ( nm ) ) ;
-
 
2305
	}
2400
	}
2306
	fputc_v ( '\n', f ) ;
-
 
2307
    }
-
 
2308
    return ;
2401
	return;
2309
}
2402
}
2310
 
2403
 
2311
 
2404
 
2312
/*
2405
/*
2313
    OPEN DUMP FILE
2406
    OPEN DUMP FILE
2314
 
2407
 
2315
    This routine opens the dump file nm with dump options given by opt.
2408
    This routine opens the dump file nm with dump options given by opt.
2316
    This corresponds to the command-line option '-dopt=nm'.
2409
    This corresponds to the command-line option '-dopt=nm'.
2317
*/
2410
*/
2318
 
2411
 
2319
void init_dump
2412
void
2320
    PROTO_N ( ( nm, opt ) )
-
 
2321
    PROTO_T ( string nm X string opt )
2413
init_dump(string nm, string opt)
2322
{
2414
{
2323
    if ( nm ) {
2415
	if (nm) {
2324
	/* Open dump file */
2416
		/* Open dump file */
2325
	FILE *f ;
2417
		FILE *f;
2326
	char *p ;
2418
		char *p;
2327
	character c ;
2419
		character c;
2328
	unsigned i, n ;
2420
		unsigned i, n;
2329
	int do_all = 0 ;
2421
		int do_all = 0;
2330
	output_name [ OUTPUT_DUMP ] = nm ;
2422
		output_name[OUTPUT_DUMP] = nm;
2331
	if ( !open_output ( OUTPUT_DUMP, text_mode ) ) {
2423
		if (!open_output(OUTPUT_DUMP, text_mode)) {
2332
	    fail ( ERR_fail_dump ( nm ) ) ;
2424
			fail(ERR_fail_dump(nm));
2333
	    term_error ( 0 ) ;
2425
			term_error(0);
2334
	    return ;
2426
			return;
2335
	}
2427
		}
2336
	f = output_file [ OUTPUT_DUMP ] ;
2428
		f = output_file[OUTPUT_DUMP];
2337
	fprintf_v ( f, "# Dump file for %s %s\n", progname, progvers ) ;
2429
		fprintf_v(f, "# Dump file for %s %s\n", progname, progvers);
2338
	fprintf_v ( f, "V\t%lu\t%lu\t", DUMP_major, DUMP_minor ) ;
2430
		fprintf_v(f, "V\t%lu\t%lu\t", DUMP_major, DUMP_minor );
2339
	fprintf_v ( f, "<%s>\n", LANGUAGE_NAME ) ;
2431
		fprintf_v(f, "<%s>\n", LANGUAGE_NAME);
2340
	dump_file = f ;
2432
		dump_file = f;
2341
 
2433
 
2342
	/* Set dump options */
2434
		/* Set dump options */
2343
	do_dump = 1 ;
2435
		do_dump = 1;
2344
	while ( c = *( opt++ ), ( c && c != '=' ) ) {
2436
		while (c = *(opt++), (c && c != '=')) {
2345
	    switch ( c ) {
2437
			switch (c) {
-
 
2438
			case 'a':
2346
		case 'a' : do_all = 1 ; break ;
2439
				do_all = 1;
-
 
2440
				break;
-
 
2441
			case 'c':
2347
		case 'c' : do_string = 1 ; break ;
2442
				do_string = 1;
-
 
2443
				break;
-
 
2444
			case 'e':
2348
		case 'e' : do_error = 1 ; break ;
2445
				do_error = 1;
-
 
2446
				break;
-
 
2447
			case 'h':
2349
		case 'h' : do_header = 1 ; break ;
2448
				do_header = 1;
-
 
2449
				break;
-
 
2450
			case 'k':
2350
		case 'k' : do_keyword = 1 ; break ;
2451
				do_keyword = 1;
-
 
2452
				break;
-
 
2453
			case 'l':
2351
		case 'l' : do_local = 1 ; break ;
2454
				do_local = 1;
-
 
2455
				break;
-
 
2456
			case 'm':
2352
		case 'm' : do_macro = 1 ; break ;
2457
				do_macro = 1;
-
 
2458
				break;
2353
		case 'p' : break ;
2459
			case 'p':
-
 
2460
				break;
-
 
2461
			case 's':
2354
		case 's' : do_scope = 1 ; break ;
2462
				do_scope = 1;
-
 
2463
				break;
-
 
2464
			case 'u':
2355
		case 'u' : do_usage = 1 ; break ;
2465
				do_usage = 1;
-
 
2466
				break;
2356
		default : {
2467
			default: {
2357
		    /* Unknown dump options */
2468
				/* Unknown dump options */
2358
		    CONST char *err = "Unknown dump option, '%c'" ;
2469
				CONST char *err = "Unknown dump option, '%c'";
2359
		    error ( ERROR_WARNING, err, ( int ) c ) ;
2470
				error(ERROR_WARNING, err,(int)c);
2360
		    break ;
2471
				break;
2361
		}
2472
			}
2362
	    }
2473
			}
2363
	}
2474
		}
2364
	if ( do_all ) {
2475
		if (do_all) {
2365
	    /* Enable all dump options */
2476
			/* Enable all dump options */
2366
	    do_error = 1 ;
2477
			do_error = 1;
2367
	    do_header = 1 ;
2478
			do_header = 1;
2368
	    do_local = 1 ;
2479
			do_local = 1;
2369
	    do_macro = 1 ;
2480
			do_macro = 1;
2370
	    do_usage = 1 ;
2481
			do_usage = 1;
2371
	}
2482
		}
2372
 
2483
 
2373
	/* Allocate table of error numbers */
2484
		/* Allocate table of error numbers */
2374
	n = catalog_size ;
2485
		n = catalog_size;
2375
	p = xmalloc_nof ( char, n ) ;
2486
		p = xmalloc_nof(char, n);
2376
	for ( i = 0 ; i < n ; i++ ) p [i] = 0 ;
2487
		for (i = 0; i < n; i++) {
-
 
2488
			p[i] = 0;
-
 
2489
		}
2377
	err_output = p ;
2490
		err_output = p;
2378
	last_input = ustrlit ( "" ) ;
2491
		last_input = ustrlit("");
2379
	last_file = ustrlit ( "" ) ;
2492
		last_file = ustrlit("");
2380
 
2493
 
2381
	/* Output file inclusion directories */
2494
		/* Output file inclusion directories */
2382
	if ( do_header ) {
2495
		if (do_header) {
2383
	    ulong r = 0 ;
2496
			ulong r = 0;
2384
	    INCL_DIR *d = dir_path ;
2497
			INCL_DIR *d = dir_path;
2385
	    while ( d != NULL ) {
2498
			while (d != NULL) {
2386
		string s = d->path ;
2499
				string s = d->path;
2387
		if ( s ) {
2500
				if (s) {
2388
		    unsigned m = ( unsigned ) ustrlen ( s ) ;
2501
					unsigned m = (unsigned)ustrlen(s);
2389
		    fprintf_v ( f, "FD\t%lu = &%u<%s>", r, m, strlit ( s ) ) ;
2502
					fprintf_v(f, "FD\t%lu = &%u<%s>", r, m,
-
 
2503
						  strlit(s));
2390
		    s = d->name ;
2504
					s = d->name;
2391
		    if ( s ) {
2505
					if (s) {
2392
			m = ( unsigned ) ustrlen ( s ) ;
2506
						m = (unsigned)ustrlen(s);
2393
			fprintf_v ( f, "\t&%u<%s>", m, strlit ( s ) ) ;
2507
						fprintf_v(f, "\t&%u<%s>", m,
-
 
2508
							  strlit(s));
2394
		    }
2509
					}
2395
		    fputc_v ( '\n', f ) ;
2510
					fputc_v('\n', f);
-
 
2511
				}
-
 
2512
				d->no = r++;
-
 
2513
				d = d->next;
-
 
2514
			}
-
 
2515
		}
-
 
2516
		if (do_usage || do_scope) {
-
 
2517
			record_location = 1;
-
 
2518
		}
-
 
2519
		if (do_error) {
-
 
2520
			max_errors = ULONG_MAX;
2396
		}
2521
		}
2397
		d->no = r++ ;
-
 
2398
		d = d->next ;
-
 
2399
	    }
-
 
2400
	}
2522
	}
2401
	if ( do_usage || do_scope ) record_location = 1 ;
-
 
2402
	if ( do_error ) max_errors = ULONG_MAX ;
-
 
2403
    }
-
 
2404
    return ;
2523
	return;
2405
}
2524
}
2406
 
2525
 
2407
 
2526
 
2408
/*
2527
/*
2409
    CLOSE DUMP FILE
2528
    CLOSE DUMP FILE
2410
 
2529
 
2411
    This routine closes the dump file.
2530
    This routine closes the dump file.
2412
*/
2531
*/
2413
 
2532
 
2414
void term_dump
2533
void
2415
    PROTO_Z ()
2534
term_dump(void)
2416
{
2535
{
2417
    if ( do_dump ) {
2536
	if (do_dump) {
2418
	FILE *f = dump_file ;
2537
		FILE *f = dump_file;
2419
	if ( f ) {
2538
		if (f) {
2420
	    dump_file = NULL ;
2539
			dump_file = NULL;
2421
	    fputs_v ( "# End of dump file\n", f ) ;
2540
			fputs_v("# End of dump file\n", f);
2422
	    close_output ( OUTPUT_DUMP ) ;
2541
			close_output(OUTPUT_DUMP);
-
 
2542
		}
-
 
2543
		do_dump = 0;
2423
	}
2544
	}
2424
	do_dump = 0 ;
-
 
2425
    }
-
 
2426
    return ;
2545
	return;
2427
}
2546
}