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

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

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

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

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

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

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

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

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251
WebSVN – tendra.SVN – Diff – /trunk/src/producers/common/output/diag2.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, 1998
32
    		 Crown Copyright (c) 1997, 1998
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
*/
Line 75... Line 105...
75
#include "throw.h"
105
#include "throw.h"
76
#include "tok.h"
106
#include "tok.h"
77
#include "typeid.h"
107
#include "typeid.h"
78
#include "ustring.h"
108
#include "ustring.h"
79
#include "virtual.h"
109
#include "virtual.h"
80
#if ( TDF_OUTPUT && TDF_NEW_DIAG )
110
#if (TDF_OUTPUT && TDF_NEW_DIAG)
81
 
111
 
82
 
112
 
83
/*
113
/*
84
    DWARF TAG VALUES
114
    DWARF TAG VALUES
85
 
115
 
86
    Certain values used within the diagnostic format are actually DWARF
116
    Certain values used within the diagnostic format are actually DWARF
87
    tag values.  These macros give the values used.
117
    tag values.  These macros give the values used.
88
*/
118
*/
89
 
119
 
90
#define DWARF_LANG_TRAD_C		1
120
#define DWARF_LANG_TRAD_C		1
91
#define DWARF_LANG_ANSI_C		2
121
#define DWARF_LANG_ANSI_C		2
92
#define DWARF_LANG_CPP			4
122
#define DWARF_LANG_CPP			4
93
 
123
 
Line 115... Line 145...
115
#define DWARF_NO_CALL			2
145
#define DWARF_NO_CALL			2
116
#define DWARF_RUN_TIME			3
146
#define DWARF_RUN_TIME			3
117
 
147
 
118
#define DWARF_CASE_SENSITIVE		0
148
#define DWARF_CASE_SENSITIVE		0
119
 
149
 
120
 
150
 
121
/*
151
/*
122
    ENCODE A DIAGNOSTIC FILE NAME
152
    ENCODE A DIAGNOSTIC FILE NAME
123
 
153
 
124
    This routine adds the diagnostic file name given by posn to the
154
    This routine adds the diagnostic file name given by posn to the
125
    bitstream bs.
155
    bitstream bs.
126
*/
156
*/
127
 
157
 
128
static BITSTREAM *enc_dg_filename
158
static BITSTREAM *
129
    PROTO_N ( ( bs, posn ) )
-
 
130
    PROTO_T ( BITSTREAM *bs X PTR ( POSITION ) posn )
159
enc_dg_filename(BITSTREAM *bs, PTR(POSITION)posn)
131
{
160
{
132
    ulong n = DEREF_ulong ( posn_tok ( posn ) ) ;
161
	ulong n = DEREF_ulong(posn_tok(posn));
133
    if ( n == LINK_NONE ) {
162
	if (n == LINK_NONE) {
134
	BITSTREAM *ts ;
163
		BITSTREAM *ts;
135
	string bn = DEREF_string ( posn_base ( posn ) ) ;
164
		string bn = DEREF_string(posn_base(posn));
136
	string mn = ustrlit ( find_machine () ) ;
165
		string mn = ustrlit(find_machine());
137
	ulong date = DEREF_ulong ( posn_datestamp ( posn ) ) ;
166
		ulong date = DEREF_ulong(posn_datestamp(posn));
138
	n = capsule_no ( NULL_string, VAR_token ) ;
167
		n = capsule_no(NULL_string, VAR_token);
139
	COPY_ulong ( posn_tok ( posn ), n ) ;
168
		COPY_ulong(posn_tok(posn), n);
140
	if ( !output_date ) date = 0 ;
169
		if (!output_date) {
-
 
170
			date = 0;
-
 
171
		}
141
	ts = enc_tokdef_start ( n, "Q", NIL ( ulong ), 0 ) ;
172
		ts = enc_tokdef_start(n, "Q", NIL(ulong), 0);
142
	ENC_make_dg_filename ( ts ) ;
173
		ENC_make_dg_filename(ts);
143
	ENC_make_nat ( ts ) ;
174
		ENC_make_nat(ts);
144
	ENC_INT ( ts, date ) ;
175
		ENC_INT(ts, date);
145
	ENC_make_string ( ts ) ;
176
		ENC_make_string(ts);
146
	ts = enc_ustring ( ts, mn ) ;
177
		ts = enc_ustring(ts, mn);
147
	ENC_make_string ( ts ) ;
178
		ENC_make_string(ts);
148
	if ( is_full_pathname ( bn ) ) {
179
		if (is_full_pathname(bn)) {
149
	    ts = enc_ustring ( ts, ustrlit ( "" ) ) ;
180
			ts = enc_ustring(ts, ustrlit(""));
150
	} else {
181
		} else {
151
	    string dn = DEREF_string ( posn_dir ( posn ) ) ;
182
			string dn = DEREF_string(posn_dir(posn));
152
	    if ( dn == NULL ) {
183
			if (dn == NULL) {
153
		string en = ustrlit ( find_cwd () ) ;
184
				string en = ustrlit(find_cwd());
154
		ts = enc_ustring ( ts, en ) ;
185
				ts = enc_ustring(ts, en);
155
	    } else if ( is_full_pathname ( dn ) ) {
186
			} else if (is_full_pathname(dn)) {
156
		ts = enc_ustring ( ts, dn ) ;
187
				ts = enc_ustring(ts, dn);
157
	    } else {
188
			} else {
158
		string en = ustrlit ( find_cwd () ) ;
189
				string en = ustrlit(find_cwd());
159
		BUFFER *bf = clear_buffer ( &incl_buff, NIL ( FILE ) ) ;
190
				BUFFER *bf = clear_buffer(&incl_buff, NIL(FILE));
160
		bfprintf ( bf, "%s/%s", en, dn ) ;
191
				bfprintf(bf, "%s/%s", en, dn);
161
		ts = enc_ustring ( ts, bf->start ) ;
192
				ts = enc_ustring(ts, bf->start);
162
	    }
193
			}
-
 
194
		}
-
 
195
		ENC_make_string(ts);
-
 
196
		ts = enc_ustring(ts, bn);
-
 
197
		enc_tokdef_end(n, ts);
163
	}
198
	}
164
	ENC_make_string ( ts ) ;
-
 
165
	ts = enc_ustring ( ts, bn ) ;
-
 
166
	enc_tokdef_end ( n, ts ) ;
-
 
167
    }
-
 
168
 
199
 
169
    /* Encode token application */
200
	/* Encode token application */
170
    ENC_dg_filename_apply_token ( bs ) ;
201
	ENC_dg_filename_apply_token(bs);
171
    n = link_no ( bs, n, VAR_token ) ;
202
	n = link_no(bs, n, VAR_token);
172
    ENC_make_tok ( bs, n ) ;
203
	ENC_make_tok(bs, n);
173
    ENC_LEN_SMALL ( bs, 0 ) ;
204
	ENC_LEN_SMALL(bs, 0);
174
    return ( bs ) ;
205
	return (bs);
175
}
206
}
176
 
207
 
177
 
208
 
178
/*
209
/*
179
    ENCODE A DIAGNOSTIC SOURCE POSITION
210
    ENCODE A DIAGNOSTIC SOURCE POSITION
180
 
211
 
181
    This routine adds the source position given by the span from p to q
212
    This routine adds the source position given by the span from p to q
182
    to the bitstream bs.
213
    to the bitstream bs.
183
*/
214
*/
184
 
215
 
185
static BITSTREAM *enc_dg_loc
216
static BITSTREAM *
186
    PROTO_N ( ( bs, p, q ) )
-
 
187
    PROTO_T ( BITSTREAM *bs X PTR ( LOCATION ) p X PTR ( LOCATION ) q )
217
enc_dg_loc(BITSTREAM *bs, PTR(LOCATION)p, PTR(LOCATION)q)
188
{
218
{
189
    if ( IS_NULL_ptr ( p ) || IS_NULL_ptr ( q ) ) {
219
	if (IS_NULL_ptr(p) || IS_NULL_ptr(q)) {
190
	ENC_dg_null_sourcepos ( bs ) ;
220
		ENC_dg_null_sourcepos(bs);
191
    } else {
-
 
192
	ulong lp = DEREF_ulong ( loc_line ( p ) ) ;
-
 
193
	ulong lq = DEREF_ulong ( loc_line ( q ) ) ;
-
 
194
	ulong cp = DEREF_ulong ( loc_column ( p ) ) ;
-
 
195
	ulong cq = DEREF_ulong ( loc_column ( q ) ) ;
-
 
196
	PTR ( POSITION ) fp = DEREF_ptr ( loc_posn ( p ) ) ;
-
 
197
	PTR ( POSITION ) fq = DEREF_ptr ( loc_posn ( q ) ) ;
-
 
198
	if ( EQ_ptr ( p, q ) ) {
-
 
199
	    ENC_dg_mark_sourcepos ( bs ) ;
-
 
200
	} else if ( lp == lq && cp == cq && EQ_ptr ( fp, fq ) ) {
-
 
201
	    ENC_dg_mark_sourcepos ( bs ) ;
-
 
202
	    q = p ;
-
 
203
	} else {
221
	} else {
-
 
222
		ulong lp = DEREF_ulong(loc_line(p));
-
 
223
		ulong lq = DEREF_ulong(loc_line(q));
-
 
224
		ulong cp = DEREF_ulong(loc_column(p));
-
 
225
		ulong cq = DEREF_ulong(loc_column(q));
-
 
226
		PTR(POSITION)fp = DEREF_ptr(loc_posn(p));
-
 
227
		PTR(POSITION)fq = DEREF_ptr(loc_posn(q));
-
 
228
		if (EQ_ptr(p, q)) {
-
 
229
			ENC_dg_mark_sourcepos(bs);
-
 
230
		} else if (lp == lq && cp == cq && EQ_ptr(fp, fq)) {
-
 
231
			ENC_dg_mark_sourcepos(bs);
-
 
232
			q = p;
-
 
233
		} else {
204
	    ENC_dg_span_sourcepos ( bs ) ;
234
			ENC_dg_span_sourcepos(bs);
-
 
235
		}
-
 
236
		bs = enc_dg_filename(bs, fp);
-
 
237
		ENC_make_nat(bs);
-
 
238
		ENC_INT(bs, lp);
-
 
239
		ENC_make_nat(bs);
-
 
240
		ENC_INT(bs, cp);
-
 
241
		if (!EQ_ptr(p, q)) {
-
 
242
			if (EQ_ptr(fp, fq)) {
-
 
243
				ENC_OFF(bs);
-
 
244
			} else {
-
 
245
				ENC_ON(bs);
-
 
246
				bs = enc_dg_filename(bs, fq);
-
 
247
			}
-
 
248
			ENC_make_nat(bs);
-
 
249
			ENC_INT(bs, lq);
-
 
250
			ENC_make_nat(bs);
-
 
251
			ENC_INT(bs, cq);
-
 
252
		}
205
	}
253
	}
206
	bs = enc_dg_filename ( bs, fp ) ;
-
 
207
	ENC_make_nat ( bs ) ;
-
 
208
	ENC_INT ( bs, lp ) ;
-
 
209
	ENC_make_nat ( bs ) ;
-
 
210
	ENC_INT ( bs, cp ) ;
-
 
211
	if ( !EQ_ptr ( p, q ) ) {
-
 
212
	    if ( EQ_ptr ( fp, fq ) ) {
-
 
213
		ENC_OFF ( bs ) ;
-
 
214
	    } else {
-
 
215
		ENC_ON ( bs ) ;
-
 
216
		bs = enc_dg_filename ( bs, fq ) ;
-
 
217
	    }
-
 
218
	    ENC_make_nat ( bs ) ;
-
 
219
	    ENC_INT ( bs, lq ) ;
-
 
220
	    ENC_make_nat ( bs ) ;
-
 
221
	    ENC_INT ( bs, cq ) ;
-
 
222
	}
-
 
223
    }
-
 
224
    return ( bs ) ;
254
	return (bs);
225
}
255
}
226
 
256
 
227
 
257
 
228
/*
258
/*
229
    FIND THE START OR END OF A BLOCK
259
    FIND THE START OR END OF A BLOCK
230
 
260
 
231
    This routine returns the location of the start or end of the block e.
261
    This routine returns the location of the start or end of the block e.
232
*/
262
*/
233
 
263
 
234
static PTR ( LOCATION ) block_loc
264
static
235
    PROTO_N ( ( e, end ) )
-
 
236
    PROTO_T ( EXP e X int end )
265
PTR(LOCATION)block_loc(EXP e, int end)
237
{
266
{
238
    PTR ( LOCATION ) loc = NULL_ptr ( LOCATION ) ;
267
	PTR(LOCATION)loc = NULL_ptr(LOCATION);
239
    if ( !IS_NULL_exp ( e ) ) {
268
	if (!IS_NULL_exp(e)) {
240
	if ( IS_exp_solve_stmt ( e ) ) {
269
		if (IS_exp_solve_stmt(e)) {
241
	    e = DEREF_exp ( exp_solve_stmt_body ( e ) ) ;
270
			e = DEREF_exp(exp_solve_stmt_body(e));
-
 
271
		}
-
 
272
		if (IS_exp_sequence(e)) {
-
 
273
			EXP a;
-
 
274
			LIST(EXP)p;
-
 
275
			if (end) {
-
 
276
				p = DEREF_list(exp_sequence_last(e));
-
 
277
			} else {
-
 
278
				p = DEREF_list(exp_sequence_first(e));
-
 
279
			}
-
 
280
			a = DEREF_exp(HEAD_list(p));
-
 
281
			if (!IS_NULL_exp(a) && IS_exp_location(a)) {
-
 
282
				loc = exp_location_end(a);
-
 
283
			}
-
 
284
		}
242
	}
285
	}
243
	if ( IS_exp_sequence ( e ) ) {
-
 
244
	    EXP a ;
-
 
245
	    LIST ( EXP ) p ;
-
 
246
	    if ( end ) {
-
 
247
		p = DEREF_list ( exp_sequence_last ( e ) ) ;
-
 
248
	    } else {
-
 
249
		p = DEREF_list ( exp_sequence_first ( e ) ) ;
-
 
250
	    }
-
 
251
	    a = DEREF_exp ( HEAD_list ( p ) ) ;
-
 
252
	    if ( !IS_NULL_exp ( a ) && IS_exp_location ( a ) ) {
-
 
253
		loc = exp_location_end ( a ) ;
-
 
254
	    }
-
 
255
	}
-
 
256
    }
-
 
257
    return ( loc ) ;
286
	return (loc);
258
}
287
}
259
 
288
 
260
 
289
 
261
/*
290
/*
262
    ENCODE THE START OF A NAMESPACE
291
    ENCODE THE START OF A NAMESPACE
263
 
292
 
264
    This routine adds the start of a list of names derived from the
293
    This routine adds the start of a list of names derived from the
265
    namespace ns to the bitstream bs.
294
    namespace ns to the bitstream bs.
266
*/
295
*/
267
 
296
 
268
static BITSTREAM *enc_dg_namelist
297
static BITSTREAM *
269
    PROTO_N ( ( bs, ns ) )
-
 
270
    PROTO_T ( BITSTREAM *bs X NAMESPACE ns )
298
enc_dg_namelist(BITSTREAM *bs, NAMESPACE ns)
271
{
299
{
272
    ulong n = capsule_no ( NULL_string, VAR_dgtag ) ;
300
	ulong n = capsule_no(NULL_string, VAR_dgtag);
273
    IDENTIFIER id = DEREF_id ( nspace_name ( ns ) ) ;
301
	IDENTIFIER id = DEREF_id(nspace_name(ns));
-
 
302
	if (!IS_NULL_id(id)) {
274
    if ( !IS_NULL_id ( id ) ) COPY_ulong ( id_no ( id ), n ) ;
303
		COPY_ulong(id_no(id), n);
-
 
304
	}
275
    record_usage ( n, VAR_dgtag, USAGE_DEFN ) ;
305
	record_usage(n, VAR_dgtag, USAGE_DEFN);
276
    ENC_dg_tag_namelist ( bs ) ;
306
	ENC_dg_tag_namelist(bs);
277
    n = link_no ( bs, n, VAR_dgtag ) ;
307
	n = link_no(bs, n, VAR_dgtag);
278
    ENC_make_dg_tag ( bs, n ) ;
308
	ENC_make_dg_tag(bs, n);
279
    ENC_make_dg_namelist ( bs ) ;
309
	ENC_make_dg_namelist(bs);
280
    ENC_LIST_SMALL ( bs, 0 ) ;
310
	ENC_LIST_SMALL(bs, 0);
281
    return ( bs ) ;
311
	return (bs);
282
}
312
}
283
 
313
 
284
 
314
 
285
/*
315
/*
286
    ENCODE COMMAND-LINE OPTIONS
316
    ENCODE COMMAND-LINE OPTIONS
287
 
317
 
288
    This routine adds the revelant command-line options as a list of
318
    This routine adds the revelant command-line options as a list of
289
    strings to the bitstream bs.
319
    strings to the bitstream bs.
290
*/
320
*/
291
 
321
 
292
static BITSTREAM *enc_dg_options
322
static BITSTREAM *
293
    PROTO_N ( ( bs ) )
-
 
294
    PROTO_T ( BITSTREAM *bs )
323
enc_dg_options(BITSTREAM *bs)
295
{
324
{
296
    unsigned n = 0 ;
325
	unsigned n = 0;
297
    INCL_DIR *d = dir_path ;
326
	INCL_DIR *d = dir_path;
298
    while ( d != NULL ) {
327
	while (d != NULL) {
299
	n++ ;
328
		n++;
300
	d = d->next ;
329
		d = d->next;
301
    }
330
	}
302
    ENC_LIST ( bs, n ) ;
331
	ENC_LIST(bs, n);
303
    d = dir_path ;
332
	d = dir_path;
304
    while ( d != NULL ) {
333
	while (d != NULL) {
305
	BUFFER *bf = clear_buffer ( &incl_buff, NIL ( FILE ) ) ;
334
		BUFFER *bf = clear_buffer(&incl_buff, NIL(FILE));
306
	ENC_make_string ( bs ) ;
335
		ENC_make_string(bs);
307
	bfprintf ( bf, "-I%s", d->path ) ;
336
		bfprintf(bf, "-I%s", d->path);
308
	bs = enc_ustring ( bs, bf->start ) ;
337
		bs = enc_ustring(bs, bf->start);
309
	d = d->next ;
338
		d = d->next;
310
    }
339
	}
311
    return ( bs ) ;
340
	return (bs);
312
}
341
}
313
 
342
 
314
 
343
 
315
/*
344
/*
316
    ENCODE A COMPILATION UNIT
345
    ENCODE A COMPILATION UNIT
317
 
346
 
318
    This routine adds the top-level compilation unit information to the
347
    This routine adds the top-level compilation unit information to the
319
    bitstream bs.  The current location gives information about the
348
    bitstream bs.  The current location gives information about the
320
    primary source file.
349
    primary source file.
321
*/
350
*/
322
 
351
 
323
BITSTREAM *enc_dg_compilation
352
BITSTREAM *
324
    PROTO_N ( ( bs ) )
-
 
325
    PROTO_T ( BITSTREAM *bs )
353
enc_dg_compilation(BITSTREAM *bs)
326
{
354
{
327
    LOCATION loc ;
355
	LOCATION loc;
328
    ulong date = crt_time ;
356
	ulong date = crt_time;
329
    string vers = report_version ( 0 ) ;
357
	string vers = report_version(0);
330
    ENC_make_dg_compilation ( bs ) ;
358
	ENC_make_dg_compilation(bs);
331
    bs = enc_dg_filename ( bs, crt_loc.posn ) ;
359
	bs = enc_dg_filename(bs, crt_loc.posn);
332
    ENC_LIST_SMALL ( bs, 0 ) ;
360
	ENC_LIST_SMALL(bs, 0);
333
    ENC_LIST_SMALL ( bs, 0 ) ;
361
	ENC_LIST_SMALL(bs, 0);
334
    loc = crt_loc ;
362
	loc = crt_loc;
335
    IGNORE set_crt_loc ( ustrlit ( "" ), 0 ) ;
363
	IGNORE set_crt_loc(ustrlit(""), 0);
336
    bs = enc_dg_filename ( bs, crt_loc.posn ) ;
364
	bs = enc_dg_filename(bs, crt_loc.posn);
337
    crt_loc = loc ;
365
	crt_loc = loc;
338
    if ( !output_date ) date = 0 ;
-
 
339
    ENC_make_nat ( bs ) ;
-
 
340
    ENC_INT ( bs, date ) ;
-
 
341
    ENC_make_nat ( bs ) ;
-
 
342
    ENC_INT ( bs, DWARF_LANG ) ;
-
 
343
    ENC_make_nat ( bs ) ;
-
 
344
    ENC_INT ( bs, DWARF_CASE_SENSITIVE ) ;
-
 
345
    ENC_make_string ( bs ) ;
-
 
346
    bs = enc_ustring ( bs, vers ) ;
-
 
347
    bs = enc_dg_options ( bs ) ;
-
 
348
    bs = enc_dg_namelist ( bs, global_namespace ) ;
-
 
349
 
-
 
350
    /* Output basic type definitions */
-
 
351
    if ( output_builtin ) {
366
	if (!output_date) {
352
	CV_SPEC cv ;
-
 
353
	BUILTIN_TYPE n ;
-
 
354
	for ( n = ntype_char ; n < ntype_ellipsis ; n++ ) {
-
 
355
	    TYPE t = type_builtin [n] ;
-
 
356
	    switch ( TAG_type ( t ) ) {
-
 
357
		case type_integer_tag :
-
 
358
		case type_floating_tag : {
-
 
359
		    IGNORE enc_dg_basetype ( t, 1 ) ;
-
 
360
		    break ;
367
		date = 0;
361
		}
-
 
362
	    }
-
 
363
	}
-
 
364
	for ( cv = cv_none ; cv <= cv_qual ; cv++ ) {
-
 
365
	    TYPE t = qualify_type ( type_void, cv, 0 ) ;
-
 
366
	    MAKE_type_ptr ( cv_none, t, t ) ;
-
 
367
	    IGNORE enc_dg_basetype ( t, 1 ) ;
-
 
368
	}
368
	}
-
 
369
	ENC_make_nat(bs);
-
 
370
	ENC_INT(bs, date);
-
 
371
	ENC_make_nat(bs);
-
 
372
	ENC_INT(bs, DWARF_LANG);
-
 
373
	ENC_make_nat(bs);
-
 
374
	ENC_INT(bs, DWARF_CASE_SENSITIVE);
-
 
375
	ENC_make_string(bs);
-
 
376
	bs = enc_ustring(bs, vers);
-
 
377
	bs = enc_dg_options(bs);
-
 
378
	bs = enc_dg_namelist(bs, global_namespace);
-
 
379
 
-
 
380
	/* Output basic type definitions */
-
 
381
	if (output_builtin) {
-
 
382
		CV_SPEC cv;
-
 
383
		BUILTIN_TYPE n;
-
 
384
		for (n = ntype_char; n < ntype_ellipsis; n++) {
-
 
385
			TYPE t = type_builtin[n];
-
 
386
			switch (TAG_type(t)) {
-
 
387
			case type_integer_tag:
-
 
388
			case type_floating_tag: {
-
 
389
				IGNORE enc_dg_basetype(t, 1);
-
 
390
				break;
369
    }
391
			}
-
 
392
			}
-
 
393
		}
-
 
394
		for (cv = cv_none; cv <= cv_qual; cv++) {
-
 
395
			TYPE t = qualify_type(type_void, cv, 0);
-
 
396
			MAKE_type_ptr(cv_none, t, t);
-
 
397
			IGNORE enc_dg_basetype(t, 1);
-
 
398
		}
-
 
399
	}
370
    return ( bs ) ;
400
	return (bs);
371
}
401
}
372
 
402
 
373
 
403
 
374
/*
404
/*
375
    ENCODE A DIAGNOSTIC ACCESS SPECIFIER
405
    ENCODE A DIAGNOSTIC ACCESS SPECIFIER
376
 
406
 
377
    This routine adds the access specifier component of ds to the bitstream
407
    This routine adds the access specifier component of ds to the bitstream
378
    bs.  All access specifiers are optional, the default being public.
408
    bs.  All access specifiers are optional, the default being public.
379
*/
409
*/
380
 
410
 
381
static BITSTREAM *enc_dg_access
411
static BITSTREAM *
382
    PROTO_N ( ( bs, ds ) )
-
 
383
    PROTO_T ( BITSTREAM *bs X DECL_SPEC ds )
412
enc_dg_access(BITSTREAM *bs, DECL_SPEC ds)
384
{
413
{
385
    DECL_SPEC acc = ( ds & dspec_access ) ;
414
	DECL_SPEC acc = (ds & dspec_access);
386
    if ( acc == dspec_private ) {
415
	if (acc == dspec_private) {
387
	ENC_ON ( bs ) ;
416
		ENC_ON(bs);
388
	ENC_dg_private_accessibility ( bs ) ;
417
		ENC_dg_private_accessibility(bs);
389
    } else if ( acc == dspec_protected ) {
418
	} else if (acc == dspec_protected) {
390
	ENC_ON ( bs ) ;
419
		ENC_ON(bs);
391
	ENC_dg_protected_accessibility ( bs ) ;
420
		ENC_dg_protected_accessibility(bs);
392
    } else {
421
	} else {
393
	ENC_OFF ( bs ) ;
422
		ENC_OFF(bs);
394
    }
423
	}
395
    return ( bs ) ;
424
	return (bs);
396
}
425
}
397
 
426
 
398
 
427
 
399
/*
428
/*
400
    ENCODE A DIAGNOSTIC VIRTUAL SPECIFIER
429
    ENCODE A DIAGNOSTIC VIRTUAL SPECIFIER
401
 
430
 
402
    This routine adds the virtual specifier component of ds to the bitstream
431
    This routine adds the virtual specifier component of ds to the bitstream
403
    bs.  All virtual specifiers are optional, the default being non-virtual.
432
    bs.  All virtual specifiers are optional, the default being non-virtual.
404
*/
433
*/
405
 
434
 
406
static BITSTREAM *enc_dg_virtual
435
static BITSTREAM *
407
    PROTO_N ( ( bs, ds ) )
-
 
408
    PROTO_T ( BITSTREAM *bs X DECL_SPEC ds )
436
enc_dg_virtual(BITSTREAM *bs, DECL_SPEC ds)
409
{
437
{
410
    if ( ds & dspec_virtual ) {
438
	if (ds & dspec_virtual) {
411
	ENC_ON ( bs ) ;
439
		ENC_ON(bs);
412
	if ( ds & dspec_pure ) {
440
		if (ds & dspec_pure) {
413
	    ENC_dg_abstract_virtuality ( bs ) ;
441
			ENC_dg_abstract_virtuality(bs);
414
	} else {
442
		} else {
415
	    ENC_dg_virtual_virtuality ( bs ) ;
443
			ENC_dg_virtual_virtuality(bs);
416
	}
444
		}
417
    } else {
445
	} else {
418
	ENC_OFF ( bs ) ;
446
		ENC_OFF(bs);
419
    }
447
	}
420
    return ( bs ) ;
448
	return (bs);
421
}
449
}
422
 
450
 
423
 
451
 
424
/*
452
/*
425
    ENCODE A TEMPLATE ARGUMENT
453
    ENCODE A TEMPLATE ARGUMENT
426
 
454
 
427
    Template arguments are encoded as dummy object or type names.
455
    Template arguments are encoded as dummy object or type names.
428
*/
456
*/
429
 
457
 
430
static BITSTREAM *enc_dg_token_arg
458
static BITSTREAM *
431
    PROTO_N ( ( bs, tok ) )
-
 
432
    PROTO_T ( BITSTREAM *bs X TOKEN tok )
459
enc_dg_token_arg(BITSTREAM *bs, TOKEN tok)
433
{
460
{
434
    int is_type = 0 ;
461
	int is_type = 0;
435
    EXP e = NULL_exp ;
462
	EXP e = NULL_exp;
436
    TYPE t = NULL_type ;
463
	TYPE t = NULL_type;
437
    if ( !IS_NULL_tok ( tok ) ) {
464
	if (!IS_NULL_tok(tok)) {
438
	switch ( TAG_tok ( tok ) ) {
465
		switch (TAG_tok(tok)) {
439
	    case tok_exp_tag : {
466
		case tok_exp_tag: {
440
		int c = DEREF_int ( tok_exp_constant ( tok ) ) ;
467
			int c = DEREF_int(tok_exp_constant(tok));
-
 
468
			if (c) {
441
		if ( c ) e = DEREF_exp ( tok_exp_value ( tok ) ) ;
469
				e = DEREF_exp(tok_exp_value(tok));
-
 
470
			}
442
		break ;
471
			break;
443
	    }
472
		}
444
	    case tok_nat_tag :
473
		case tok_nat_tag:
445
	    case tok_snat_tag : {
474
		case tok_snat_tag: {
446
		NAT n = DEREF_nat ( tok_nat_etc_value ( tok ) ) ;
475
			NAT n = DEREF_nat(tok_nat_etc_value(tok));
447
		e = calc_nat_value ( n, type_sint ) ;
476
			e = calc_nat_value(n, type_sint);
448
		break ;
477
			break;
449
	    }
478
		}
450
	    case tok_type_tag : {
479
		case tok_type_tag: {
451
		t = DEREF_type ( tok_type_value ( tok ) ) ;
480
			t = DEREF_type(tok_type_value(tok));
452
		is_type = 1 ;
481
			is_type = 1;
453
		break ;
482
			break;
454
	    }
483
		}
455
	    case tok_class_tag : {
484
		case tok_class_tag: {
456
		is_type = 1 ;
485
			is_type = 1;
457
		break ;
486
			break;
-
 
487
		}
458
	    }
488
		}
459
	}
489
	}
460
    }
-
 
461
    if ( is_type ) {
490
	if (is_type) {
462
	/* Type name */
491
		/* Type name */
463
	ENC_dg_type_name ( bs ) ;
492
		ENC_dg_type_name(bs);
464
	ENC_OFF ( bs ) ;
493
		ENC_OFF(bs);
465
	ENC_dg_null_sourcepos ( bs ) ;
494
		ENC_dg_null_sourcepos(bs);
466
	ENC_OFF ( bs ) ;
495
		ENC_OFF(bs);
467
	if ( !IS_NULL_type ( t ) ) {
496
		if (!IS_NULL_type(t)) {
468
	    ENC_ON ( bs ) ;
497
			ENC_ON(bs);
469
	    bs = enc_dg_type ( bs, t, 0 ) ;
498
			bs = enc_dg_type(bs, t, 0);
-
 
499
		} else {
-
 
500
			ENC_OFF(bs);
-
 
501
		}
-
 
502
		ENC_false(bs);
-
 
503
		ENC_OFFS(bs, 2);
470
	} else {
504
	} else {
471
	    ENC_OFF ( bs ) ;
-
 
472
	}
-
 
473
	ENC_false ( bs ) ;
-
 
474
	ENC_OFFS ( bs, 2 ) ;
-
 
475
    } else {
-
 
476
	/* Object name */
505
		/* Object name */
477
	ENC_dg_object_name ( bs ) ;
506
		ENC_dg_object_name(bs);
478
	bs = enc_dg_name ( bs, NULL_id, NULL_type ) ;
507
		bs = enc_dg_name(bs, NULL_id, NULL_type);
479
	ENC_dg_null_sourcepos ( bs ) ;
508
		ENC_dg_null_sourcepos(bs);
480
	if ( !IS_NULL_exp ( e ) ) {
509
		if (!IS_NULL_exp(e)) {
481
	    t = DEREF_type ( exp_type ( e ) ) ;
510
			t = DEREF_type(exp_type(e));
482
	    bs = enc_dg_type ( bs, t, 0 ) ;
511
			bs = enc_dg_type(bs, t, 0);
483
	    ENC_ON ( bs ) ;
512
			ENC_ON(bs);
484
	    bs = enc_exp ( bs, e ) ;
513
			bs = enc_exp(bs, e);
485
	} else {
514
		} else {
486
	    bs = enc_dg_type ( bs, t, 0 ) ;
515
			bs = enc_dg_type(bs, t, 0);
487
	    ENC_OFF ( bs ) ;
516
			ENC_OFF(bs);
-
 
517
		}
-
 
518
		ENC_OFF(bs);
488
	}
519
	}
489
	ENC_OFF ( bs ) ;
-
 
490
    }
-
 
491
    return ( bs ) ;
520
	return (bs);
492
}
521
}
493
 
522
 
494
 
523
 
495
/*
524
/*
496
    ENCODE AN ARTIFICIAL IDENTIFIER NAME
525
    ENCODE AN ARTIFICIAL IDENTIFIER NAME
497
 
526
 
498
    This routine adds the artificial identifier name s to the bitstream bs.
527
    This routine adds the artificial identifier name s to the bitstream bs.
499
*/
528
*/
500
 
529
 
501
static BITSTREAM *enc_dg_artificial
530
static BITSTREAM *
502
    PROTO_N ( ( bs, s ) )
-
 
503
    PROTO_T ( BITSTREAM *bs X CONST char *s )
531
enc_dg_artificial(BITSTREAM *bs, CONST char *s)
504
{
532
{
505
    ENC_dg_artificial_idname ( bs ) ;
533
	ENC_dg_artificial_idname(bs);
506
    ENC_ON ( bs ) ;
534
	ENC_ON(bs);
507
    ENC_make_string ( bs ) ;
535
	ENC_make_string(bs);
508
    bs = enc_ustring ( bs, ustrlit ( s ) ) ;
536
	bs = enc_ustring(bs, ustrlit(s));
509
    return ( bs ) ;
537
	return (bs);
510
}
538
}
511
 
539
 
512
 
540
 
513
/*
541
/*
514
    ENCODE A DIAGNOSTIC IDENTIFIER NAME
542
    ENCODE A DIAGNOSTIC IDENTIFIER NAME
515
 
543
 
516
    This routine adds the name of the identifier id to the bitstream bs.
544
    This routine adds the name of the identifier id to the bitstream bs.
517
*/
545
*/
518
 
546
 
519
BITSTREAM *enc_dg_name
547
BITSTREAM *
520
    PROTO_N ( ( bs, id, form ) )
-
 
521
    PROTO_T ( BITSTREAM *bs X IDENTIFIER id X TYPE form )
548
enc_dg_name(BITSTREAM *bs, IDENTIFIER id, TYPE form)
522
{
549
{
523
    if ( !IS_NULL_type ( form ) && IS_type_token ( form ) ) {
550
	if (!IS_NULL_type(form) && IS_type_token(form)) {
524
	/* Template instance name */
551
		/* Template instance name */
525
	IDENTIFIER tid = DEREF_id ( type_token_tok ( form ) ) ;
552
		IDENTIFIER tid = DEREF_id(type_token_tok(form));
526
	LIST ( TOKEN ) args = DEREF_list ( type_token_args ( form ) ) ;
553
		LIST(TOKEN)args = DEREF_list(type_token_args(form));
527
	if ( !IS_id_token ( tid ) ) {
554
		if (!IS_id_token(tid)) {
528
	    ENC_dg_instance_idname ( bs ) ;
555
			ENC_dg_instance_idname(bs);
529
	    ENC_OFF ( bs ) ;
556
			ENC_OFF(bs);
530
	    bs = enc_dg_name ( bs, tid, NULL_type ) ;
557
			bs = enc_dg_name(bs, tid, NULL_type);
531
	    bs = enc_dg_loc ( bs, id_loc ( tid ), id_loc ( tid ) ) ;
558
			bs = enc_dg_loc(bs, id_loc(tid), id_loc(tid));
532
	    ENC_LIST ( bs, LENGTH_list ( args ) ) ;
559
			ENC_LIST(bs, LENGTH_list(args));
533
	    while ( !IS_NULL_list ( args ) ) {
560
			while (!IS_NULL_list(args)) {
534
		TOKEN arg = DEREF_tok ( HEAD_list ( args ) ) ;
561
				TOKEN arg = DEREF_tok(HEAD_list(args));
535
		bs = enc_dg_token_arg ( bs, arg ) ;
562
				bs = enc_dg_token_arg(bs, arg);
536
		args = TAIL_list ( args ) ;
563
				args = TAIL_list(args);
537
	    }
564
			}
538
	    return ( bs ) ;
565
			return (bs);
539
	}
566
		}
540
    }
567
	}
541
    if ( !IS_NULL_id ( id ) ) {
568
	if (!IS_NULL_id(id)) {
542
	string s ;
569
		string s;
543
	HASHID nm = DEREF_hashid ( id_name ( id ) ) ;
570
		HASHID nm = DEREF_hashid(id_name(id));
544
	switch ( TAG_hashid ( nm ) ) {
571
		switch (TAG_hashid(nm)) {
545
	    case hashid_name_tag : {
572
		case hashid_name_tag: {
546
		/* Simple case */
573
			/* Simple case */
547
		s = DEREF_string ( hashid_name_text ( nm ) ) ;
574
			s = DEREF_string(hashid_name_text(nm));
548
		break ;
575
			break;
549
	    }
576
		}
550
	    case hashid_ename_tag : {
577
		case hashid_ename_tag: {
551
		/* Extended case */
578
			/* Extended case */
552
		if ( EQ_KEYWORD ( nm, lex_this_Hname ) ) {
579
			if (EQ_KEYWORD(nm, lex_this_Hname)) {
553
		    bs = enc_dg_artificial ( bs, "this" ) ;
580
				bs = enc_dg_artificial(bs, "this");
554
		    return ( bs ) ;
581
				return (bs);
-
 
582
			}
-
 
583
			s = DEREF_string(hashid_ename_text(nm));
-
 
584
			break;
-
 
585
		}
-
 
586
		case hashid_anon_tag: {
-
 
587
			/* Anonymous case */
-
 
588
			ENC_dg_anonymous_idname(bs);
-
 
589
			ENC_OFF(bs);
-
 
590
			return (bs);
-
 
591
		}
-
 
592
		default : {
-
 
593
			/* Other cases */
-
 
594
			BUFFER *bf;
-
 
595
			bf = clear_buffer(&mangle_buff, NIL(FILE));
-
 
596
			IGNORE print_hashid(nm, 0, 0, bf, 0);
-
 
597
			s = bf->start;
-
 
598
			break;
-
 
599
		}
-
 
600
		}
-
 
601
		if (has_linkage(id)) {
-
 
602
			ENC_dg_external_idname(bs);
-
 
603
		} else {
-
 
604
			ENC_dg_sourcestring_idname(bs);
555
		}
605
		}
556
		s = DEREF_string ( hashid_ename_text ( nm ) ) ;
606
		ENC_make_string(bs);
557
		break ;
607
		bs = enc_ustring(bs, s);
558
	    }
608
	} else {
559
	    case hashid_anon_tag : {
-
 
560
		/* Anonymous case */
-
 
561
		ENC_dg_anonymous_idname ( bs ) ;
609
		ENC_dg_anonymous_idname(bs);
562
		ENC_OFF ( bs ) ;
610
		ENC_OFF(bs);
563
		return ( bs ) ;
-
 
564
	    }
-
 
565
	    default : {
-
 
566
		/* Other cases */
-
 
567
		BUFFER *bf ;
-
 
568
		bf = clear_buffer ( &mangle_buff, NIL ( FILE ) ) ;
-
 
569
		IGNORE print_hashid ( nm, 0, 0, bf, 0 ) ;
-
 
570
		s = bf->start ;
-
 
571
		break ;
-
 
572
	    }
-
 
573
	}
611
	}
574
	if ( has_linkage ( id ) ) {
-
 
575
	    ENC_dg_external_idname ( bs ) ;
-
 
576
	} else {
-
 
577
	    ENC_dg_sourcestring_idname ( bs ) ;
-
 
578
	}
-
 
579
	ENC_make_string ( bs ) ;
-
 
580
	bs = enc_ustring ( bs, s ) ;
-
 
581
    } else {
-
 
582
	ENC_dg_anonymous_idname ( bs ) ;
-
 
583
	ENC_OFF ( bs ) ;
-
 
584
    }
-
 
585
    return ( bs ) ;
612
	return (bs);
586
}
613
}
587
 
614
 
588
 
615
 
589
/*
616
/*
590
    ENCODE A DIAGNOSTIC IDENTIFIER
617
    ENCODE A DIAGNOSTIC IDENTIFIER
591
 
618
 
592
    This routine adds the diagnostics for the identifier id to the
619
    This routine adds the diagnostics for the identifier id to the
593
    bitstream bs.  use indicates whether a declaration or a definition
620
    bitstream bs.  use indicates whether a declaration or a definition
594
    should be output.
621
    should be output.
722
	}
750
	}
723
 
751
 
724
	case id_class_name_tag :
752
	case id_class_name_tag:
725
	case id_enum_name_tag :
753
	case id_enum_name_tag:
726
	case id_class_alias_tag :
754
	case id_class_alias_tag:
727
	case id_enum_alias_tag :
755
	case id_enum_alias_tag:
728
	case id_type_alias_tag : {
756
	case id_type_alias_tag: {
729
	    /* Type names */
757
		/* Type names */
730
	    TYPE t = DEREF_type ( id_class_name_etc_defn ( id ) ) ;
758
		TYPE t = DEREF_type(id_class_name_etc_defn(id));
731
	    ENC_dg_type_name ( bs ) ;
759
		ENC_dg_type_name(bs);
732
	    if ( tagged ) {
760
		if (tagged) {
733
		ENC_OFF ( bs ) ;
761
			ENC_OFF(bs);
734
	    } else {
-
 
735
		TYPE form = NULL_type ;
-
 
736
		if ( IS_type_compound ( t ) ) {
-
 
737
		    CLASS_TYPE ct ;
-
 
738
		    ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
-
 
739
		    form = DEREF_type ( ctype_form ( ct ) ) ;
-
 
740
		}
-
 
741
		ENC_ON ( bs ) ;
-
 
742
		bs = enc_dg_name ( bs, id, form ) ;
-
 
743
	    }
-
 
744
	    bs = enc_dg_loc ( bs, id_loc ( id ), id_loc ( id ) ) ;
-
 
745
	    bs = enc_dg_access ( bs, ds ) ;
-
 
746
	    ENC_ON ( bs ) ;
-
 
747
	    if ( tagged ) {
-
 
748
		ulong m = link_no ( bs, n, VAR_dgtag ) ;
-
 
749
		if ( use & USAGE_USE ) {
-
 
750
		    ENC_dg_spec_ref_type ( bs ) ;
-
 
751
		} else {
762
		} else {
-
 
763
			TYPE form = NULL_type;
-
 
764
			if (IS_type_compound(t)) {
-
 
765
				CLASS_TYPE ct;
-
 
766
				ct = DEREF_ctype(type_compound_defn(t));
-
 
767
				form = DEREF_type(ctype_form(ct));
-
 
768
			}
-
 
769
			ENC_ON(bs);
752
		    ENC_dg_tag_type ( bs ) ;
770
			bs = enc_dg_name(bs, id, form);
753
		}
771
		}
-
 
772
		bs = enc_dg_loc(bs, id_loc(id), id_loc(id));
-
 
773
		bs = enc_dg_access(bs, ds);
-
 
774
		ENC_ON(bs);
-
 
775
		if (tagged) {
-
 
776
			ulong m = link_no(bs, n, VAR_dgtag);
-
 
777
			if (use & USAGE_USE) {
-
 
778
				ENC_dg_spec_ref_type(bs);
-
 
779
			} else {
-
 
780
				ENC_dg_tag_type(bs);
-
 
781
			}
754
		ENC_make_dg_tag ( bs, m ) ;
782
			ENC_make_dg_tag(bs, m);
755
		if ( use & USAGE_DEFN ) {
783
			if (use & USAGE_DEFN) {
756
		    record_usage ( n, VAR_dgtag, USAGE_DEFN ) ;
784
				record_usage(n, VAR_dgtag, USAGE_DEFN);
757
		} else {
785
			} else {
758
		    record_usage ( n, VAR_dgtag, USAGE_DECL ) ;
786
				record_usage(n, VAR_dgtag, USAGE_DECL);
-
 
787
			}
-
 
788
		}
-
 
789
		bs = enc_dg_type(bs, t, force);
-
 
790
		ENC_false(bs);
-
 
791
		ENC_OFFS(bs, 2);
-
 
792
		break;
-
 
793
	}
-
 
794
 
-
 
795
	case id_nspace_name_tag: {
-
 
796
		/* Namespace names */
-
 
797
		IDENTIFIER nid = id;
-
 
798
		NAMESPACE ns = DEREF_nspace(id_nspace_name_defn(id));
-
 
799
		if (IS_nspace_unnamed(ns)) {
-
 
800
			nid = NULL_id;
759
		}
801
		}
760
	    }
802
		ENC_dg_namespace_name(bs);
761
	    bs = enc_dg_type ( bs, t, force ) ;
803
		bs = enc_dg_name(bs, nid, NULL_type);
762
	    ENC_false ( bs ) ;
804
		bs = enc_dg_loc(bs, id_loc(id), id_loc(id));
763
	    ENC_OFFS ( bs, 2 ) ;
805
		bs = enc_dg_namelist(bs, ns);
764
	    break ;
806
		break;
765
	}
807
	}
-
 
808
	}
-
 
809
	if (spec) {
-
 
810
		ENC_OFF(bs);
-
 
811
	}
-
 
812
	return (bs);
-
 
813
}
766
 
814
 
767
	case id_nspace_name_tag : {
-
 
768
	    /* Namespace names */
-
 
769
	    IDENTIFIER nid = id ;
-
 
770
	    NAMESPACE ns = DEREF_nspace ( id_nspace_name_defn ( id ) ) ;
-
 
771
	    if ( IS_nspace_unnamed ( ns ) ) nid = NULL_id ;
-
 
772
	    ENC_dg_namespace_name ( bs ) ;
-
 
773
	    bs = enc_dg_name ( bs, nid, NULL_type ) ;
-
 
774
	    bs = enc_dg_loc ( bs, id_loc ( id ), id_loc ( id ) ) ;
-
 
775
	    bs = enc_dg_namelist ( bs, ns ) ;
-
 
776
	    break ;
-
 
777
	}
-
 
778
    }
-
 
779
    if ( spec ) ENC_OFF ( bs ) ;
-
 
780
    return ( bs ) ;
-
 
781
}
-
 
782
 
-
 
783
 
815
 
784
/*
816
/*
785
    ENCODE DIAGNOSTICS FOR A TOKEN DEFINITION
817
    ENCODE DIAGNOSTICS FOR A TOKEN DEFINITION
786
 
818
 
787
    This routine outputs any diagnostic information for the token id
819
    This routine outputs any diagnostic information for the token id
788
    to the appropriate diagnostic units.  It is only called if id is
820
    to the appropriate diagnostic units.  It is only called if id is
789
    defined.  The type t may be used to override the type of id.
821
    defined.  The type t may be used to override the type of id.
790
*/
822
*/
791
 
823
 
792
void enc_dg_token
824
void
793
    PROTO_N ( ( id, t ) )
-
 
794
    PROTO_T ( IDENTIFIER id X TYPE t )
825
enc_dg_token(IDENTIFIER id, TYPE t)
795
{
826
{
796
    UNUSED ( id ) ;
827
	UNUSED(id);
797
    UNUSED ( t ) ;
828
	UNUSED(t);
798
    return ;
829
	return;
799
}
830
}
800
 
831
 
801
 
832
 
802
/*
833
/*
803
    LIST OF INCOMPLETE CLASSES
834
    LIST OF INCOMPLETE CLASSES
804
 
835
 
805
    This list is used to hold all the classes which are used while they
836
    This list is used to hold all the classes which are used while they
806
    are incomplete.  A diagnostic tag is introduced for each such class
837
    are incomplete.  A diagnostic tag is introduced for each such class
807
    which may be defined later if the class is completed.
838
    which may be defined later if the class is completed.
808
*/
839
*/
809
 
840
 
810
static LIST ( IDENTIFIER ) dg_classes = NULL_list ( IDENTIFIER ) ;
841
static LIST(IDENTIFIER)dg_classes = NULL_list(IDENTIFIER);
811
 
842
 
812
 
843
 
813
/*
844
/*
814
    DEFINE INCOMPLETE CLASSES
845
    DEFINE INCOMPLETE CLASSES
815
 
846
 
816
    This routine defines the diagnostic tags for the incomplete classes
847
    This routine defines the diagnostic tags for the incomplete classes
817
    in the list above.
848
    in the list above.
818
*/
849
*/
819
 
850
 
-
 
851
int
820
int enc_dg_pending
852
enc_dg_pending(void)
821
    PROTO_Z ()
-
 
822
{
853
{
823
    int changed = 0 ;
854
	int changed = 0;
824
    LIST ( IDENTIFIER ) p ;
855
	LIST(IDENTIFIER)p;
825
    while ( p = dg_classes, !IS_NULL_list ( p ) ) {
856
	while (p = dg_classes, !IS_NULL_list(p)) {
826
	dg_classes = NULL_list ( IDENTIFIER ) ;
857
		dg_classes = NULL_list(IDENTIFIER);
827
	while ( !IS_NULL_list ( p ) ) {
858
		while (!IS_NULL_list(p)) {
828
	    IDENTIFIER id ;
859
			IDENTIFIER id;
829
	    DESTROY_CONS_id ( destroy, id, p, p ) ;
860
			DESTROY_CONS_id(destroy, id, p, p);
830
	    enc_dg_id ( id, 2 ) ;
861
			enc_dg_id(id, 2);
831
	    changed = 1 ;
862
			changed = 1;
832
	}
863
		}
833
    }
864
	}
834
    return ( changed ) ;
865
	return (changed);
835
}
866
}
836
 
867
 
837
 
868
 
838
/*
869
/*
839
    FIND A DIAGNOSTIC TAG USAGE
870
    FIND A DIAGNOSTIC TAG USAGE
840
 
871
 
841
    This routine determines the usage for the diagnostic tag associated
872
    This routine determines the usage for the diagnostic tag associated
842
    with the identifier id in the context given by def (true for
873
    with the identifier id in the context given by def (true for
843
    definitions, false for declarations).  The value returned indicates
874
    definitions, false for declarations).  The value returned indicates
844
    whether the diagnostic tag should be declared or defined.
875
    whether the diagnostic tag should be declared or defined.
845
*/
876
*/
846
 
877
 
847
static unsigned find_dg_usage
878
static unsigned
848
    PROTO_N ( ( id, pn, def ) )
-
 
849
    PROTO_T ( IDENTIFIER id X ulong *pn X int def )
879
find_dg_usage(IDENTIFIER id, ulong *pn, int def)
850
{
880
{
851
    unsigned use = USAGE_NONE ;
881
	unsigned use = USAGE_NONE;
852
    switch ( TAG_id ( id ) ) {
882
	switch (TAG_id(id)) {
853
	case id_class_name_tag :
883
	case id_class_name_tag:
854
	case id_enum_name_tag :
884
	case id_enum_name_tag:
855
	case id_class_alias_tag :
885
	case id_class_alias_tag:
856
	case id_enum_alias_tag :
886
	case id_enum_alias_tag:
857
	case id_type_alias_tag : {
887
	case id_type_alias_tag: {
858
	    /* Type names */
888
		/* Type names */
859
	    TYPE t ;
889
		TYPE t;
860
	    ulong n = DEREF_ulong ( id_no ( id ) ) ;
890
		ulong n = DEREF_ulong(id_no(id));
861
	    if ( n == LINK_NONE ) {
891
		if (n == LINK_NONE) {
862
		/* Introduce diagnostic tag for type */
892
			/* Introduce diagnostic tag for type */
863
		NAMESPACE ns ;
893
			NAMESPACE ns;
864
		string s = NULL ;
894
			string s = NULL;
-
 
895
			if (def == 0) {
865
		if ( def == 0 ) return ( USAGE_NONE ) ;
896
				return (USAGE_NONE);
-
 
897
			}
866
		t = DEREF_type ( id_class_name_etc_defn ( id ) ) ;
898
			t = DEREF_type(id_class_name_etc_defn(id));
867
		if ( IS_type_top_etc ( t ) ) {
899
			if (IS_type_top_etc(t)) {
868
		    /* Ignore 'void' types */
900
				/* Ignore 'void' types */
-
 
901
				return (USAGE_NONE);
-
 
902
			}
-
 
903
			ns = DEREF_nspace(id_parent(id));
-
 
904
			if (is_local_nspace(ns) == 2) {
869
		    return ( USAGE_NONE ) ;
905
				return (USAGE_NONE);
-
 
906
			}
-
 
907
			if (output_all) {
-
 
908
				s = mangle_tname("__dg__", t);
-
 
909
			}
-
 
910
			n = capsule_no(s, VAR_dgtag);
-
 
911
			COPY_ulong(id_no(id), n);
-
 
912
		} else {
-
 
913
			use = USAGE_USE;
-
 
914
		}
-
 
915
		if (is_defined(id, &t, 0)) {
-
 
916
			/* Only define each type once */
-
 
917
			unsigned prev = find_usage(n, VAR_dgtag);
-
 
918
			if (prev & USAGE_DEFN) {
-
 
919
				use = USAGE_NONE;
-
 
920
			} else {
-
 
921
				use |= (USAGE_DECL | USAGE_DEFN);
-
 
922
			}
-
 
923
		} else {
-
 
924
			/* Only declare each type once */
-
 
925
			if (use == USAGE_USE) {
-
 
926
				use = USAGE_NONE;
-
 
927
			} else {
-
 
928
				CONS_id(id, dg_classes, dg_classes);
-
 
929
				use = USAGE_DECL;
-
 
930
			}
870
		}
931
		}
871
		ns = DEREF_nspace ( id_parent ( id ) ) ;
-
 
872
		if ( is_local_nspace ( ns ) == 2 ) return ( USAGE_NONE ) ;
-
 
873
		if ( output_all ) s = mangle_tname ( "__dg__", t ) ;
-
 
874
		n = capsule_no ( s, VAR_dgtag ) ;
-
 
875
		COPY_ulong ( id_no ( id ), n ) ;
-
 
876
	    } else {
-
 
877
		use = USAGE_USE ;
-
 
878
	    }
-
 
879
	    if ( is_defined ( id, &t, 0 ) ) {
-
 
880
		/* Only define each type once */
-
 
881
		unsigned prev = find_usage ( n, VAR_dgtag ) ;
-
 
882
		if ( prev & USAGE_DEFN ) {
-
 
883
		    use = USAGE_NONE ;
-
 
884
		} else {
-
 
885
		    use |= ( USAGE_DECL | USAGE_DEFN ) ;
-
 
886
		}
-
 
887
	    } else {
-
 
888
		/* Only declare each type once */
-
 
889
		if ( use == USAGE_USE ) {
-
 
890
		    use = USAGE_NONE ;
-
 
891
		} else {
-
 
892
		    CONS_id ( id, dg_classes, dg_classes ) ;
-
 
893
		    use = USAGE_DECL ;
-
 
894
		}
-
 
895
	    }
-
 
896
	    *pn = n ;
932
		*pn = n;
897
	    break ;
933
		break;
898
	}
934
	}
899
	case id_variable_tag :
935
	case id_variable_tag:
900
	case id_stat_member_tag :
936
	case id_stat_member_tag:
901
	case id_function_tag :
937
	case id_function_tag:
902
	case id_mem_func_tag :
938
	case id_mem_func_tag:
903
	case id_stat_mem_func_tag : {
939
	case id_stat_mem_func_tag: {
904
	    /* Tag names */
940
		/* Tag names */
905
	    ulong n = get_diag_tag ( id, VAR_tag ) ;
941
		ulong n = get_diag_tag(id, VAR_tag);
906
	    if ( n == LINK_NONE ) {
942
		if (n == LINK_NONE) {
907
		/* Introduce diagnostic tag for tag */
943
			/* Introduce diagnostic tag for tag */
908
		string s = NULL ;
944
			string s = NULL;
-
 
945
			if (output_all) {
909
		if ( output_all ) s = mangle_name ( id, VAR_dgtag, 0 ) ;
946
				s = mangle_name(id, VAR_dgtag, 0);
-
 
947
			}
910
		n = capsule_no ( s, VAR_dgtag ) ;
948
			n = capsule_no(s, VAR_dgtag);
911
		set_diag_tag ( id, VAR_tag, n ) ;
949
			set_diag_tag(id, VAR_tag, n);
912
		use = USAGE_DECL ;
950
			use = USAGE_DECL;
-
 
951
			if (def) {
913
		if ( def ) use |= USAGE_DEFN ;
952
				use |= USAGE_DEFN;
-
 
953
			}
914
	    } else {
954
		} else {
915
		/* Only declare each tag once */
955
			/* Only declare each tag once */
916
		if ( def ) {
956
			if (def) {
917
		    unsigned prev = find_usage ( n, VAR_dgtag ) ;
957
				unsigned prev = find_usage(n, VAR_dgtag);
918
		    if ( prev & USAGE_DEFN ) {
958
				if (prev & USAGE_DEFN) {
919
			use = USAGE_NONE ;
959
					use = USAGE_NONE;
920
		    } else {
960
				} else {
921
			use = ( USAGE_USE | USAGE_DECL | USAGE_DEFN ) ;
961
					use = (USAGE_USE | USAGE_DECL | USAGE_DEFN);
922
		    }
962
				}
923
		}
963
			}
924
	    }
964
		}
925
	    *pn = n ;
965
		*pn = n;
-
 
966
		break;
-
 
967
	}
-
 
968
	case id_nspace_name_tag: {
-
 
969
		/* Namespace names */
-
 
970
		use = USAGE_DEFN;
926
	    break ;
971
		break;
927
	}
972
	}
928
	case id_nspace_name_tag : {
-
 
929
	    /* Namespace names */
-
 
930
	    use = USAGE_DEFN ;
-
 
931
	    break ;
-
 
932
	}
973
	}
933
    }
-
 
934
    return ( use ) ;
974
	return (use);
935
}
975
}
936
 
976
 
937
 
977
 
938
/*
978
/*
939
    ENCODE A GLOBAL DIAGNOSTIC IDENTIFIER
979
    ENCODE A GLOBAL DIAGNOSTIC IDENTIFIER
940
 
980
 
941
    This routine adds the diagnostic information for the global identifier
981
    This routine adds the diagnostic information for the global identifier
942
    id to the diagnostic definition unit.  def is true for a definition.
982
    id to the diagnostic definition unit.  def is true for a definition.
943
*/
983
*/
944
 
984
 
945
void enc_dg_id
985
void
946
    PROTO_N ( ( id, def ) )
-
 
947
    PROTO_T ( IDENTIFIER id X int def )
986
enc_dg_id(IDENTIFIER id, int def)
948
{
987
{
949
    ulong n ;
988
	ulong n;
950
    NAMESPACE ns ;
989
	NAMESPACE ns;
951
    BITSTREAM *bs ;
990
	BITSTREAM *bs;
952
    IDENTIFIER pid ;
991
	IDENTIFIER pid;
953
 
992
 
954
    /* Check the identifier */
993
	/* Check the identifier */
955
    ulong m = LINK_NONE ;
994
	ulong m = LINK_NONE;
956
    unsigned use = find_dg_usage ( id, &m, def ) ;
995
	unsigned use = find_dg_usage(id, &m, def);
957
    if ( use == USAGE_NONE ) return ;
996
	if (use == USAGE_NONE) {
-
 
997
		return;
-
 
998
	}
958
 
999
 
959
    /* Find the parent namespace */
1000
	/* Find the parent namespace */
960
    ns = DEREF_nspace ( id_parent ( id ) ) ;
1001
	ns = DEREF_nspace(id_parent(id));
961
    while ( !IS_NULL_nspace ( ns ) && IS_nspace_ctype ( ns ) ) {
1002
	while (!IS_NULL_nspace(ns) && IS_nspace_ctype(ns)) {
962
	pid = DEREF_id ( nspace_name ( ns ) ) ;
1003
		pid = DEREF_id(nspace_name(ns));
963
	enc_dg_id ( pid, 1 ) ;
1004
		enc_dg_id(pid, 1);
964
	if ( m != LINK_NONE ) {
1005
		if (m != LINK_NONE) {
965
	    /* Check for inline definitions */
1006
			/* Check for inline definitions */
966
	    unsigned prev = find_usage ( m, VAR_dgtag ) ;
1007
			unsigned prev = find_usage(m, VAR_dgtag);
967
	    if ( prev & USAGE_DEFN ) return ;
1008
			if (prev & USAGE_DEFN) {
-
 
1009
				return;
-
 
1010
			}
-
 
1011
		}
-
 
1012
		ns = DEREF_nspace(id_parent(pid));
-
 
1013
	}
-
 
1014
	if (IS_NULL_nspace(ns) || !IS_nspace_named_etc(ns)) {
-
 
1015
		/* Ignore local identifiers */
-
 
1016
		return;
-
 
1017
	}
-
 
1018
	pid = DEREF_id(nspace_name(ns));
-
 
1019
	if (IS_NULL_id(pid)) {
-
 
1020
		return;
-
 
1021
	}
-
 
1022
	n = DEREF_ulong(id_no(pid));
-
 
1023
	if (n == LINK_NONE) {
-
 
1024
		/* Allocate namespace list number */
-
 
1025
		enc_dg_id(pid, 1);
-
 
1026
		n = DEREF_ulong(id_no(pid));
-
 
1027
		if (n == LINK_NONE) {
-
 
1028
			return;
-
 
1029
		}
968
	}
1030
	}
969
	ns = DEREF_nspace ( id_parent ( pid ) ) ;
-
 
970
    }
-
 
971
    if ( IS_NULL_nspace ( ns ) || !IS_nspace_named_etc ( ns ) ) {
-
 
972
	/* Ignore local identifiers */
-
 
973
	return ;
-
 
974
    }
-
 
975
    pid = DEREF_id ( nspace_name ( ns ) ) ;
-
 
976
    if ( IS_NULL_id ( pid ) ) return ;
-
 
977
    n = DEREF_ulong ( id_no ( pid ) ) ;
-
 
978
    if ( n == LINK_NONE ) {
-
 
979
	/* Allocate namespace list number */
-
 
980
	enc_dg_id ( pid, 1 ) ;
-
 
981
	n = DEREF_ulong ( id_no ( pid ) ) ;
-
 
982
	if ( n == LINK_NONE ) return ;
-
 
983
    }
-
 
984
 
1031
 
985
    /* Add the identifier to the namespace */
1032
	/* Add the identifier to the namespace */
986
    bs = start_bitstream ( NIL ( FILE ), diagcomp_unit->link ) ;
1033
	bs = start_bitstream(NIL(FILE), diagcomp_unit->link);
987
    ENC_dg_name_append ( bs ) ;
1034
	ENC_dg_name_append(bs);
988
    n = link_no ( bs, n, VAR_dgtag ) ;
1035
	n = link_no(bs, n, VAR_dgtag);
989
    ENC_make_dg_tag ( bs, n ) ;
1036
	ENC_make_dg_tag(bs, n);
990
    bs = enc_dg_decl ( bs, id, m, use ) ;
1037
	bs = enc_dg_decl(bs, id, m, use);
991
    count_item ( bs ) ;
1038
	count_item(bs);
992
    diagcomp_unit = join_bitstreams ( diagcomp_unit, bs ) ;
1039
	diagcomp_unit = join_bitstreams(diagcomp_unit, bs);
993
    return ;
1040
	return;
994
}
1041
}
995
 
1042
 
996
 
1043
 
997
/*
1044
/*
998
    DIAGNOSTICS FOR POINTER TO VOID
1045
    DIAGNOSTICS FOR POINTER TO VOID
999
 
1046
 
1000
    This table gives the diagnostic tag numbers used to represent the types
1047
    This table gives the diagnostic tag numbers used to represent the types
1001
    'cv void *'  for the various cv-qualifiers, cv.
1048
    'cv void *'  for the various cv-qualifiers, cv.
1002
*/
1049
*/
1003
 
1050
 
1004
static ulong diag_ptr_void [4] = {
1051
static ulong diag_ptr_void[4] = {
1005
    LINK_NONE, LINK_NONE, LINK_NONE, LINK_NONE
1052
	LINK_NONE, LINK_NONE, LINK_NONE, LINK_NONE
1006
} ;
1053
};
1007
 
1054
 
1008
 
1055
 
1009
/*
1056
/*
1010
    ENCODE A BUILT-IN DIAGNOSTIC TYPE
1057
    ENCODE A BUILT-IN DIAGNOSTIC TYPE
1011
 
1058
 
1012
    This routine adds the diagnostics for the definition of the built-in
1059
    This routine adds the diagnostics for the definition of the built-in
1013
    type t to the diagnostic  bs.  This includes 'void *' as well as the
1060
    type t to the diagnostic  bs.  This includes 'void *' as well as the
1014
    more obvious integer and floating point types.
1061
    more obvious integer and floating point types.
1015
*/
1062
*/
1016
 
1063
 
1017
ulong enc_dg_basetype
1064
ulong
1018
    PROTO_N ( ( t, def ) )
-
 
1019
    PROTO_T ( TYPE t X int def )
1065
enc_dg_basetype(TYPE t, int def)
1020
{
1066
{
1021
    BITSTREAM *bs = NULL ;
1067
	BITSTREAM *bs = NULL;
1022
    CV_SPEC cv = cv_none ;
1068
	CV_SPEC cv = cv_none;
1023
    BASE_TYPE bt = btype_none ;
1069
	BASE_TYPE bt = btype_none;
1024
    unsigned tag = TAG_type ( t ) ;
1070
	unsigned tag = TAG_type(t);
1025
    string nm = mangle_tname ( "__dg__", t ) ;
1071
	string nm = mangle_tname("__dg__", t);
1026
    ulong n = capsule_no ( nm, VAR_dgtag ) ;
1072
	ulong n = capsule_no(nm, VAR_dgtag);
1027
 
1073
 
1028
    /* Introduce dummy type name */
1074
	/* Introduce dummy type name */
1029
    if ( def ) {
1075
	if (def) {
1030
	IDENTIFIER gid = DEREF_id ( nspace_name ( global_namespace ) ) ;
1076
		IDENTIFIER gid = DEREF_id(nspace_name(global_namespace));
1031
	ulong m = DEREF_ulong ( id_no ( gid ) ) ;
1077
		ulong m = DEREF_ulong(id_no(gid));
1032
	record_usage ( n, VAR_dgtag, USAGE_DEFN ) ;
1078
		record_usage(n, VAR_dgtag, USAGE_DEFN);
1033
	bs = start_bitstream ( NIL ( FILE ), diagcomp_unit->link ) ;
1079
		bs = start_bitstream(NIL(FILE), diagcomp_unit->link);
1034
	ENC_dg_name_append ( bs ) ;
1080
		ENC_dg_name_append(bs);
1035
	m = link_no ( bs, m, VAR_dgtag ) ;
1081
		m = link_no(bs, m, VAR_dgtag);
1036
	ENC_make_dg_tag ( bs, m ) ;
1082
		ENC_make_dg_tag(bs, m);
1037
	ENC_dg_type_name ( bs ) ;
1083
		ENC_dg_type_name(bs);
1038
	ENC_OFF ( bs ) ;
1084
		ENC_OFF(bs);
1039
	ENC_dg_global_sourcepos ( bs ) ;
1085
		ENC_dg_global_sourcepos(bs);
1040
	ENC_OFF ( bs ) ;
1086
		ENC_OFF(bs);
1041
	ENC_ON ( bs ) ;
1087
		ENC_ON(bs);
1042
	ENC_dg_tag_type ( bs ) ;
1088
		ENC_dg_tag_type(bs);
1043
	m = link_no ( bs, n, VAR_dgtag ) ;
1089
		m = link_no(bs, n, VAR_dgtag);
1044
	ENC_make_dg_tag ( bs, m ) ;
1090
		ENC_make_dg_tag(bs, m);
1045
    }
1091
	}
1046
 
1092
 
1047
    /* Encode type definition */
1093
	/* Encode type definition */
1048
    switch ( tag ) {
1094
	switch (tag) {
1049
	case type_integer_tag : {
1095
	case type_integer_tag: {
1050
	    INT_TYPE it = DEREF_itype ( type_integer_rep ( t ) ) ;
1096
		INT_TYPE it = DEREF_itype(type_integer_rep(t));
1051
	    COPY_ulong ( itype_diag ( it ), n ) ;
1097
		COPY_ulong(itype_diag(it), n);
1052
	    if ( IS_itype_basic ( it ) ) {
1098
		if (IS_itype_basic(it)) {
1053
		bt = DEREF_btype ( itype_basic_rep ( it ) ) ;
1099
			bt = DEREF_btype(itype_basic_rep(it));
1054
	    }
1100
		}
1055
	    if ( def ) {
1101
		if (def) {
1056
		if ( bt & ( btype_char | btype_wchar_t ) ) {
1102
			if (bt & (btype_char | btype_wchar_t)) {
1057
		    ENC_dg_char_type ( bs ) ;
1103
				ENC_dg_char_type(bs);
1058
		} else if ( bt & btype_bool ) {
1104
			} else if (bt & btype_bool) {
1059
		    ENC_dg_boolean_type ( bs ) ;
1105
				ENC_dg_boolean_type(bs);
-
 
1106
			} else {
-
 
1107
				ENC_dg_integer_type(bs);
-
 
1108
			}
-
 
1109
		}
-
 
1110
		break;
-
 
1111
	}
-
 
1112
	case type_floating_tag: {
-
 
1113
		FLOAT_TYPE ft = DEREF_ftype(type_floating_rep(t));
-
 
1114
		COPY_ulong(ftype_diag(ft), n);
-
 
1115
		if (IS_ftype_basic(ft)) {
-
 
1116
			bt = DEREF_btype(ftype_basic_rep(ft));
-
 
1117
		}
-
 
1118
		if (def) {
-
 
1119
			ENC_dg_float_type(bs);
-
 
1120
		}
-
 
1121
		break;
-
 
1122
	}
-
 
1123
	case type_ptr_tag: {
-
 
1124
		TYPE s = DEREF_type(type_ptr_sub(t));
-
 
1125
		cv = DEREF_cv(type_qual(s));
-
 
1126
		cv &= cv_qual;
-
 
1127
		diag_ptr_void[cv] = n;
-
 
1128
		bt = (btype_void | btype_star);
-
 
1129
		if (def) {
-
 
1130
			ENC_dg_address_type(bs);
-
 
1131
		}
-
 
1132
		break;
-
 
1133
	}
-
 
1134
	}
-
 
1135
	if (def) {
-
 
1136
		if (bt == btype_none) {
-
 
1137
			bs = enc_dg_name(bs, NULL_id, NULL_type);
1060
		} else {
1138
		} else {
-
 
1139
			int sp = 0;
-
 
1140
			BUFFER *bf = clear_buffer(&mangle_buff, NIL(FILE));
1061
		    ENC_dg_integer_type ( bs ) ;
1141
			ENC_dg_external_idname(bs);
-
 
1142
			ENC_make_string(bs);
-
 
1143
			if (cv) {
-
 
1144
				sp = print_cv(cv, bf, sp);
-
 
1145
			}
-
 
1146
			IGNORE print_btype(bt, bf, sp);
-
 
1147
			bs = enc_ustring(bs, bf->start);
-
 
1148
		}
-
 
1149
		switch (tag) {
-
 
1150
		case type_integer_tag: {
-
 
1151
			bs = enc_variety(bs, t);
-
 
1152
			break;
-
 
1153
		}
-
 
1154
		case type_floating_tag: {
-
 
1155
			bs = enc_flvar(bs, t);
-
 
1156
			break;
-
 
1157
		}
-
 
1158
		case type_ptr_tag: {
-
 
1159
			bs = enc_shape(bs, t);
-
 
1160
			break;
1062
		}
1161
		}
1063
	    }
-
 
1064
	    break ;
-
 
1065
	}
1162
		}
1066
	case type_floating_tag : {
-
 
1067
	    FLOAT_TYPE ft = DEREF_ftype ( type_floating_rep ( t ) ) ;
-
 
1068
	    COPY_ulong ( ftype_diag ( ft ), n ) ;
-
 
1069
	    if ( IS_ftype_basic ( ft ) ) {
-
 
1070
		bt = DEREF_btype ( ftype_basic_rep ( ft ) ) ;
-
 
1071
	    }
-
 
1072
	    if ( def ) ENC_dg_float_type ( bs ) ;
-
 
1073
	    break ;
1163
		ENC_true(bs);
1074
	}
-
 
1075
	case type_ptr_tag : {
-
 
1076
	    TYPE s = DEREF_type ( type_ptr_sub ( t ) ) ;
-
 
1077
	    cv = DEREF_cv ( type_qual ( s ) ) ;
-
 
1078
	    cv &= cv_qual ;
1164
		ENC_OFFS(bs, 2);
1079
	    diag_ptr_void [ cv ] = n ;
-
 
1080
	    bt = ( btype_void | btype_star ) ;
-
 
1081
	    if ( def ) ENC_dg_address_type ( bs ) ;
-
 
1082
	    break ;
-
 
1083
	}
-
 
1084
    }
-
 
1085
    if ( def ) {
-
 
1086
	if ( bt == btype_none ) {
-
 
1087
	    bs = enc_dg_name ( bs, NULL_id, NULL_type ) ;
-
 
1088
	} else {
-
 
1089
	    int sp = 0 ;
1165
		count_item(bs);
1090
	    BUFFER *bf = clear_buffer ( &mangle_buff, NIL ( FILE ) ) ;
-
 
1091
	    ENC_dg_external_idname ( bs ) ;
-
 
1092
	    ENC_make_string ( bs ) ;
-
 
1093
	    if ( cv ) sp = print_cv ( cv, bf, sp ) ;
1166
		diagcomp_unit = join_bitstreams(diagcomp_unit, bs);
1094
	    IGNORE print_btype ( bt, bf, sp ) ;
-
 
1095
	    bs = enc_ustring ( bs, bf->start ) ;
-
 
1096
	}
-
 
1097
	switch ( tag ) {
-
 
1098
	    case type_integer_tag : {
-
 
1099
		bs = enc_variety ( bs, t ) ;
-
 
1100
		break ;
-
 
1101
	    }
-
 
1102
	    case type_floating_tag : {
-
 
1103
		bs = enc_flvar ( bs, t ) ;
-
 
1104
		break ;
-
 
1105
	    }
-
 
1106
	    case type_ptr_tag : {
-
 
1107
		bs = enc_shape ( bs, t ) ;
-
 
1108
		break ;
-
 
1109
	    }
-
 
1110
	}
1167
	}
1111
	ENC_true ( bs ) ;
-
 
1112
	ENC_OFFS ( bs, 2 ) ;
-
 
1113
	count_item ( bs ) ;
-
 
1114
	diagcomp_unit = join_bitstreams ( diagcomp_unit, bs ) ;
-
 
1115
    }
-
 
1116
    return ( n ) ;
1168
	return (n);
1117
}
1169
}
1118
 
1170
 
1119
 
1171
 
1120
/*
1172
/*
1121
    ENCODE A DIAGNOSTIC CLASS TAG
1173
    ENCODE A DIAGNOSTIC CLASS TAG
1122
 
1174
 
1123
    This routine adds the diagnostic tag corresponding to the class ct
1175
    This routine adds the diagnostic tag corresponding to the class ct
1124
    to the bitstream bs.
1176
    to the bitstream bs.
1125
*/
1177
*/
1126
 
1178
 
1127
static BITSTREAM *enc_dg_ctype
1179
static BITSTREAM *
1128
    PROTO_N ( ( bs, ct ) )
-
 
1129
    PROTO_T ( BITSTREAM *bs X CLASS_TYPE ct )
1180
enc_dg_ctype(BITSTREAM *bs, CLASS_TYPE ct)
1130
{
1181
{
1131
    ulong n ;
1182
	ulong n;
1132
    IDENTIFIER cid = DEREF_id ( ctype_name ( ct ) ) ;
1183
	IDENTIFIER cid = DEREF_id(ctype_name(ct));
1133
    cid = DEREF_id ( id_alias ( cid ) ) ;
1184
	cid = DEREF_id(id_alias(cid));
1134
    n = DEREF_ulong ( id_no ( cid ) ) ;
1185
	n = DEREF_ulong(id_no(cid));
1135
    if ( n == LINK_NONE ) {
1186
	if (n == LINK_NONE) {
1136
	enc_dg_id ( cid, 1 ) ;
1187
		enc_dg_id(cid, 1);
1137
	n = DEREF_ulong ( id_no ( cid ) ) ;
1188
		n = DEREF_ulong(id_no(cid));
1138
    }
1189
	}
1139
    n = link_no ( bs, n, VAR_dgtag ) ;
1190
	n = link_no(bs, n, VAR_dgtag);
1140
    ENC_make_dg_tag ( bs, n ) ;
1191
	ENC_make_dg_tag(bs, n);
1141
    return ( bs ) ;
1192
	return (bs);
1142
}
1193
}
1143
 
1194
 
1144
 
1195
 
1145
/*
1196
/*
1146
    ENCODE A DIAGNOSTIC OFFSET TOKEN
1197
    ENCODE A DIAGNOSTIC OFFSET TOKEN
1147
 
1198
 
1148
    This routine adds the offset off plus the offset token tok to the
1199
    This routine adds the offset off plus the offset token tok to the
1149
    bitstream bs in the form of a token with one expression parameter
1200
    bitstream bs in the form of a token with one expression parameter
1150
    which returns the parameter plus the offset (allowing for virtual
1201
    which returns the parameter plus the offset (allowing for virtual
1151
    indirections etc.).
1202
    indirections etc.).
1152
*/
1203
*/
1153
 
1204
 
1154
static BITSTREAM *enc_dg_offset
1205
static BITSTREAM *
1155
    PROTO_N ( ( bs, off, tok, spec ) )
-
 
1156
    PROTO_T ( BITSTREAM *bs X OFFSET off X ulong tok X int spec )
1206
enc_dg_offset(BITSTREAM *bs, OFFSET off, ulong tok, int spec)
1157
{
-
 
1158
    BITSTREAM *ts, *us ;
-
 
1159
    ulong m = LINK_NONE ;
-
 
1160
    ulong n = capsule_no ( NULL_string, VAR_token ) ;
-
 
1161
    ts = enc_tokdef_start ( n, "EE", &m, 1 ) ;
-
 
1162
    if ( spec == -1 ) {
-
 
1163
	us = ts ;
-
 
1164
    } else {
-
 
1165
	ts = enc_special ( ts, spec ) ;
-
 
1166
	us = start_bitstream ( NIL ( FILE ), ts->link ) ;
-
 
1167
    }
-
 
1168
    if ( tok == LINK_NONE ) {
-
 
1169
	us = enc_add_ptr ( us, NULL_exp, m, off, 1 ) ;
-
 
1170
    } else {
-
 
1171
	ENC_add_to_ptr ( us ) ;
-
 
1172
	us = enc_add_ptr ( us, NULL_exp, m, off, 1 ) ;
-
 
1173
	tok = link_no ( us, tok, VAR_token ) ;
-
 
1174
	ENC_exp_apply_token ( us ) ;
-
 
1175
	ENC_make_tok ( us, tok ) ;
-
 
1176
	ENC_LEN_SMALL ( us, 0 ) ;
-
 
1177
    }
-
 
1178
    if ( spec == -1 ) {
-
 
1179
	ts = us ;
-
 
1180
    } else {
-
 
1181
	ts = enc_bitstream ( ts, us ) ;
-
 
1182
    }
-
 
1183
    enc_tokdef_end ( n, ts ) ;
-
 
1184
    n = link_no ( bs, n, VAR_token ) ;
-
 
1185
    ENC_make_tok ( bs, n ) ;
-
 
1186
    return ( bs ) ;
-
 
1187
}
-
 
1188
 
-
 
1189
 
-
 
1190
/*
-
 
1191
    ENCODE A LIST OF DIAGNOSTIC BASE CLASSES
-
 
1192
 
-
 
1193
    This routine adds the list of diagnostic base classes given by br
-
 
1194
    to the bitstream bs.
-
 
1195
*/
-
 
1196
 
-
 
1197
static BITSTREAM *enc_dg_bases
-
 
1198
    PROTO_N ( ( bs, br ) )
-
 
1199
    PROTO_T ( BITSTREAM *bs X LIST ( GRAPH ) br )
-
 
1200
{
1207
{
1201
    ENC_LIST ( bs, LENGTH_list ( br ) ) ;
1208
	BITSTREAM *ts, *us;
1202
    while ( !IS_NULL_list ( br ) ) {
1209
	ulong m = LINK_NONE;
1203
	GRAPH gs = DEREF_graph ( HEAD_list ( br ) ) ;
1210
	ulong n = capsule_no(NULL_string, VAR_token);
1204
	OFFSET off = DEREF_off ( graph_off ( gs ) ) ;
-
 
1205
	CLASS_TYPE cs = DEREF_ctype ( graph_head ( gs ) ) ;
-
 
1206
	DECL_SPEC acc = DEREF_dspec ( graph_access ( gs ) ) ;
-
 
1207
	ENC_make_dg_class_base ( bs ) ;
-
 
1208
	bs = enc_dg_ctype ( bs, cs ) ;
1211
	ts = enc_tokdef_start(n, "EE", &m, 1);
1209
	ENC_OFF ( bs ) ;
1212
	if (spec == -1) {
1210
	if ( is_zero_offset ( off ) ) {
-
 
1211
	    ENC_OFF ( bs ) ;
1213
		us = ts;
1212
	} else {
1214
	} else {
1213
	    /* Base class offset */
1215
		ts = enc_special(ts, spec);
-
 
1216
		us = start_bitstream(NIL(FILE), ts->link);
-
 
1217
	}
1214
	    ENC_ON ( bs ) ;
1218
	if (tok == LINK_NONE) {
-
 
1219
		us = enc_add_ptr(us, NULL_exp, m, off, 1);
-
 
1220
	} else {
-
 
1221
		ENC_add_to_ptr(us);
1215
	    bs = enc_dg_offset ( bs, off, LINK_NONE, -1 ) ;
1222
		us = enc_add_ptr(us, NULL_exp, m, off, 1);
-
 
1223
		tok = link_no(us, tok, VAR_token);
-
 
1224
		ENC_exp_apply_token(us);
-
 
1225
		ENC_make_tok(us, tok);
-
 
1226
		ENC_LEN_SMALL(us, 0);
-
 
1227
	}
-
 
1228
	if (spec == -1) {
-
 
1229
		ts = us;
-
 
1230
	} else {
-
 
1231
		ts = enc_bitstream(ts, us);
1216
	}
1232
	}
1217
	bs = enc_dg_access ( bs, acc ) ;
1233
	enc_tokdef_end(n, ts);
1218
	bs = enc_dg_virtual ( bs, acc ) ;
1234
	n = link_no(bs, n, VAR_token);
1219
	br = TAIL_list ( br ) ;
1235
	ENC_make_tok(bs, n);
1220
    }
-
 
1221
    return ( bs ) ;
1236
	return (bs);
1222
}
1237
}
1223
 
1238
 
1224
 
1239
 
1225
/*
1240
/*
1226
    ENCODE A DIAGNOSTIC CLASS MEMBER
1241
    ENCODE A LIST OF DIAGNOSTIC BASE CLASSES
1227
 
1242
 
1228
    This routine adds the class member id to the bitstream bs as a
1243
    This routine adds the list of diagnostic base classes given by br
1229
    DG_CLASSMEM if ct is not null, or as a DG_FIELD otherwise.  The
-
 
1230
    number of members is recorded in pm.  The routine is also used to
-
 
1231
    handle type members of blocks when blk is true.
1244
    to the bitstream bs.
1232
*/
1245
*/
1233
 
1246
 
1234
static BITSTREAM *enc_dg_member
1247
static BITSTREAM *
1235
    PROTO_N ( ( bs, id, pm, ct, blk ) )
-
 
1236
    PROTO_T ( BITSTREAM *bs X IDENTIFIER id X unsigned *pm X
1248
enc_dg_bases(BITSTREAM *bs, LIST(GRAPH)br)
1237
	      CLASS_TYPE ct X int blk )
-
 
1238
{
1249
{
1239
    int def = 0 ;
-
 
1240
    unsigned done = 0 ;
-
 
1241
    DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
-
 
1242
    if ( IS_id_function_etc ( id ) ) {
1250
	ENC_LIST(bs, LENGTH_list(br));
1243
	/* Allow for overloaded functions */
-
 
1244
	IDENTIFIER fid = DEREF_id ( id_function_etc_over ( id ) ) ;
-
 
1245
	if ( !IS_NULL_id ( fid ) ) {
1251
	while (!IS_NULL_list(br)) {
1246
	    bs = enc_dg_member ( bs, fid, pm, ct, blk ) ;
-
 
1247
	}
-
 
1248
    }
-
 
1249
    if ( ds & ( dspec_alias | dspec_inherit | dspec_token ) ) {
-
 
1250
	/* Ignore inherited members */
-
 
1251
	return ( bs ) ;
-
 
1252
    }
-
 
1253
    if ( ds & dspec_defn ) def = 1 ;
-
 
1254
    switch ( TAG_id ( id ) ) {
-
 
1255
	case id_member_tag : {
-
 
1256
	    /* Data members */
-
 
1257
	    HASHID nm = DEREF_hashid ( id_name ( id ) ) ;
1252
		GRAPH gs = DEREF_graph(HEAD_list(br));
1258
	    if ( !IS_hashid_anon ( nm ) ) {
1253
		OFFSET off = DEREF_off(graph_off(gs));
1259
		TYPE t = DEREF_type ( id_member_type ( id ) ) ;
1254
		CLASS_TYPE cs = DEREF_ctype(graph_head(gs));
1260
		OFFSET off = DEREF_off ( id_member_off ( id ) ) ;
1255
		DECL_SPEC acc = DEREF_dspec(graph_access(gs));
1261
		ENC_dg_field_classmem ( bs ) ;
1256
		ENC_make_dg_class_base(bs);
1262
		bs = enc_dg_name ( bs, id, NULL_type ) ;
-
 
1263
		bs = enc_dg_loc ( bs, id_loc ( id ), id_loc ( id ) ) ;
-
 
1264
		bs = enc_offset ( bs, off ) ;
-
 
1265
		bs = enc_dg_type ( bs, t, 0 ) ;
1257
		bs = enc_dg_ctype(bs, cs);
1266
		bs = enc_dg_access ( bs, ds ) ;
-
 
1267
		ENC_OFFS ( bs, 2 ) ;
1258
		ENC_OFF(bs);
1268
		done = 1 ;
-
 
1269
	    }
-
 
1270
	    break ;
-
 
1271
	}
-
 
1272
	case id_stat_member_tag : {
-
 
1273
	    /* Static data members */
-
 
1274
	    if ( !IS_NULL_ctype ( ct ) ) {
-
 
1275
		ulong m = LINK_NONE ;
-
 
1276
		unsigned use = find_dg_usage ( id, &m, def ) ;
-
 
1277
		ENC_dg_name_classmem ( bs ) ;
-
 
1278
		bs = enc_dg_decl ( bs, id, m, ( use | USAGE_DECL ) ) ;
-
 
1279
		done = 1 ;
-
 
1280
	    }
-
 
1281
	    break ;
-
 
1282
	}
-
 
1283
	case id_mem_func_tag : {
-
 
1284
	    /* Member functions */
-
 
1285
	    if ( !IS_NULL_ctype ( ct ) && !( ds & dspec_trivial ) ) {
-
 
1286
		ulong m = LINK_NONE ;
-
 
1287
		unsigned use = find_dg_usage ( id, &m, def ) ;
-
 
1288
		ENC_dg_function_classmem ( bs ) ;
-
 
1289
		bs = enc_dg_decl ( bs, id, m, ( use | USAGE_DECL ) ) ;
-
 
1290
		if ( ds & dspec_virtual ) {
1259
		if (is_zero_offset(off)) {
1291
		    /* Offset from start of virtual function table */
-
 
1292
		    BITSTREAM *ts ;
-
 
1293
		    VIRTUAL vt = DEREF_virt ( ctype_virt ( ct ) ) ;
-
 
1294
		    ulong n = virtual_no ( id, vt ) ;
-
 
1295
		    ENC_ON ( bs ) ;
-
 
1296
		    ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
-
 
1297
		    bs = enc_special ( bs, TOK_vtab_off ) ;
-
 
1298
		    ts = enc_make_snat ( ts, ( int ) n ) ;
-
 
1299
		    bs = enc_bitstream ( bs, ts ) ;
-
 
1300
		} else {
-
 
1301
		    ENC_OFF ( bs ) ;
1260
			ENC_OFF(bs);
1302
		}
-
 
1303
		done = 1 ;
-
 
1304
	    }
-
 
1305
	    break ;
-
 
1306
	}
-
 
1307
	case id_stat_mem_func_tag : {
-
 
1308
	    /* Static member functions */
-
 
1309
	    if ( !IS_NULL_ctype ( ct ) ) {
-
 
1310
		ulong m = LINK_NONE ;
-
 
1311
		unsigned use = find_dg_usage ( id, &m, def ) ;
-
 
1312
		ENC_dg_name_classmem ( bs ) ;
-
 
1313
		bs = enc_dg_decl ( bs, id, m, ( use | USAGE_DECL ) ) ;
-
 
1314
		done = 1 ;
-
 
1315
	    }
-
 
1316
	    break ;
-
 
1317
	}
-
 
1318
	case id_class_name_tag :
-
 
1319
	case id_enum_name_tag :
-
 
1320
	case id_class_alias_tag :
-
 
1321
	case id_enum_alias_tag :
-
 
1322
	case id_type_alias_tag : {
-
 
1323
	    /* Nested types */
-
 
1324
	    if ( !IS_NULL_ctype ( ct ) || blk ) {
-
 
1325
		ulong m = LINK_NONE ;
-
 
1326
		unsigned use = find_dg_usage ( id, &m, 1 ) ;
-
 
1327
		if ( blk ) {
-
 
1328
		    use = ( ( use & USAGE_DEFN ) | USAGE_DECL ) ;
-
 
1329
		    ENC_name_decl_dg ( bs ) ;
-
 
1330
		} else {
1261
		} else {
1331
		    ENC_dg_name_classmem ( bs ) ;
1262
			/* Base class offset */
-
 
1263
			ENC_ON(bs);
-
 
1264
			bs = enc_dg_offset(bs, off, LINK_NONE, -1);
1332
		}
1265
		}
1333
		bs = enc_dg_decl ( bs, id, m, use ) ;
1266
		bs = enc_dg_access(bs, acc);
1334
		done = 1 ;
1267
		bs = enc_dg_virtual(bs, acc);
1335
	    }
-
 
1336
	    break ;
1268
		br = TAIL_list(br);
1337
	}
1269
	}
-
 
1270
	return (bs);
-
 
1271
}
-
 
1272
 
-
 
1273
 
-
 
1274
/*
-
 
1275
    ENCODE A DIAGNOSTIC CLASS MEMBER
-
 
1276
 
-
 
1277
    This routine adds the class member id to the bitstream bs as a
-
 
1278
    DG_CLASSMEM if ct is not null, or as a DG_FIELD otherwise.  The
-
 
1279
    number of members is recorded in pm.  The routine is also used to
-
 
1280
    handle type members of blocks when blk is true.
-
 
1281
*/
-
 
1282
 
-
 
1283
static BITSTREAM *
-
 
1284
enc_dg_member(BITSTREAM *bs, IDENTIFIER id, unsigned *pm, CLASS_TYPE ct,
-
 
1285
	      int blk)
-
 
1286
{
-
 
1287
	int def = 0;
-
 
1288
	unsigned done = 0;
-
 
1289
	DECL_SPEC ds = DEREF_dspec(id_storage(id));
-
 
1290
	if (IS_id_function_etc(id)) {
-
 
1291
		/* Allow for overloaded functions */
-
 
1292
		IDENTIFIER fid = DEREF_id(id_function_etc_over(id));
-
 
1293
		if (!IS_NULL_id(fid)) {
-
 
1294
			bs = enc_dg_member(bs, fid, pm, ct, blk);
-
 
1295
		}
-
 
1296
	}
-
 
1297
	if (ds & (dspec_alias | dspec_inherit | dspec_token)) {
-
 
1298
		/* Ignore inherited members */
-
 
1299
		return (bs);
-
 
1300
	}
-
 
1301
	if (ds & dspec_defn) {
-
 
1302
		def = 1;
-
 
1303
	}
-
 
1304
	switch (TAG_id(id)) {
-
 
1305
	case id_member_tag: {
-
 
1306
		/* Data members */
-
 
1307
		HASHID nm = DEREF_hashid(id_name(id));
-
 
1308
		if (!IS_hashid_anon(nm)) {
-
 
1309
			TYPE t = DEREF_type(id_member_type(id));
-
 
1310
			OFFSET off = DEREF_off(id_member_off(id));
-
 
1311
			ENC_dg_field_classmem(bs);
-
 
1312
			bs = enc_dg_name(bs, id, NULL_type);
-
 
1313
			bs = enc_dg_loc(bs, id_loc(id), id_loc(id));
-
 
1314
			bs = enc_offset(bs, off);
-
 
1315
			bs = enc_dg_type(bs, t, 0);
-
 
1316
			bs = enc_dg_access(bs, ds);
-
 
1317
			ENC_OFFS(bs, 2);
-
 
1318
			done = 1;
-
 
1319
		}
-
 
1320
		break;
-
 
1321
	}
-
 
1322
	case id_stat_member_tag: {
-
 
1323
		/* Static data members */
-
 
1324
		if (!IS_NULL_ctype(ct)) {
-
 
1325
			ulong m = LINK_NONE;
-
 
1326
			unsigned use = find_dg_usage(id, &m, def);
-
 
1327
			ENC_dg_name_classmem(bs);
-
 
1328
			bs = enc_dg_decl(bs, id, m,(use | USAGE_DECL));
-
 
1329
			done = 1;
-
 
1330
		}
-
 
1331
		break;
-
 
1332
	}
-
 
1333
	case id_mem_func_tag: {
-
 
1334
		/* Member functions */
-
 
1335
		if (!IS_NULL_ctype(ct) && !(ds & dspec_trivial)) {
-
 
1336
			ulong m = LINK_NONE;
-
 
1337
			unsigned use = find_dg_usage(id, &m, def);
-
 
1338
			ENC_dg_function_classmem(bs);
-
 
1339
			bs = enc_dg_decl(bs, id, m,(use | USAGE_DECL));
-
 
1340
			if (ds & dspec_virtual) {
-
 
1341
				/* Offset from start of virtual function table */
-
 
1342
				BITSTREAM *ts;
-
 
1343
				VIRTUAL vt = DEREF_virt(ctype_virt(ct));
-
 
1344
				ulong n = virtual_no(id, vt);
-
 
1345
				ENC_ON(bs);
-
 
1346
				ts = start_bitstream(NIL(FILE), bs->link);
-
 
1347
				bs = enc_special(bs, TOK_vtab_off);
-
 
1348
				ts = enc_make_snat(ts,(int)n);
-
 
1349
				bs = enc_bitstream(bs, ts);
-
 
1350
			} else {
-
 
1351
				ENC_OFF(bs);
-
 
1352
			}
-
 
1353
			done = 1;
-
 
1354
		}
-
 
1355
		break;
-
 
1356
	}
-
 
1357
	case id_stat_mem_func_tag: {
-
 
1358
		/* Static member functions */
-
 
1359
		if (!IS_NULL_ctype(ct)) {
-
 
1360
			ulong m = LINK_NONE;
-
 
1361
			unsigned use = find_dg_usage(id, &m, def);
-
 
1362
			ENC_dg_name_classmem(bs);
-
 
1363
			bs = enc_dg_decl(bs, id, m,(use | USAGE_DECL));
-
 
1364
			done = 1;
-
 
1365
		}
-
 
1366
		break;
-
 
1367
	}
-
 
1368
	case id_class_name_tag:
-
 
1369
	case id_enum_name_tag:
-
 
1370
	case id_class_alias_tag:
-
 
1371
	case id_enum_alias_tag:
-
 
1372
	case id_type_alias_tag: {
-
 
1373
		/* Nested types */
-
 
1374
		if (!IS_NULL_ctype(ct) || blk) {
-
 
1375
			ulong m = LINK_NONE;
-
 
1376
			unsigned use = find_dg_usage(id, &m, 1);
-
 
1377
			if (blk) {
-
 
1378
				use = ((use & USAGE_DEFN) | USAGE_DECL);
-
 
1379
				ENC_name_decl_dg(bs);
-
 
1380
			} else {
-
 
1381
				ENC_dg_name_classmem(bs);
1338
    }
1382
			}
-
 
1383
			bs = enc_dg_decl(bs, id, m, use);
-
 
1384
			done = 1;
-
 
1385
		}
-
 
1386
		break;
-
 
1387
	}
-
 
1388
	}
1339
    *pm += done ;
1389
	*pm += done;
1340
    return ( bs ) ;
1390
	return (bs);
1341
}
1391
}
1342
 
1392
 
1343
 
1393
 
1344
/*
1394
/*
1345
    ENCODE A LIST OF DIAGNOSTIC MEMBERS
1395
    ENCODE A LIST OF DIAGNOSTIC MEMBERS
1346
 
1396
 
1347
    This routine calls enc_dg_member for all the members of the
1397
    This routine calls enc_dg_member for all the members of the
1348
    namespace ns.
1398
    namespace ns.
1349
*/
1399
*/
1350
 
1400
 
1351
static BITSTREAM *enc_dg_namespace
1401
static BITSTREAM *
1352
    PROTO_N ( ( bs, ns, pm, ct ) )
-
 
1353
    PROTO_T ( BITSTREAM *bs X NAMESPACE ns X unsigned *pm X CLASS_TYPE ct )
1402
enc_dg_namespace(BITSTREAM *bs, NAMESPACE ns, unsigned *pm, CLASS_TYPE ct)
1354
{
1403
{
1355
    MEMBER mem ;
1404
	MEMBER mem;
1356
    int blk = 0 ;
1405
	int blk = 0;
1357
    if ( IS_nspace_ctype ( ns ) ) {
1406
	if (IS_nspace_ctype(ns)) {
1358
	mem = DEREF_member ( nspace_ctype_first ( ns ) ) ;
1407
		mem = DEREF_member(nspace_ctype_first(ns));
1359
    } else {
1408
	} else {
1360
	mem = DEREF_member ( nspace_last ( ns ) ) ;
1409
		mem = DEREF_member(nspace_last(ns));
1361
	blk = 1 ;
1410
		blk = 1;
1362
    }
1411
	}
1363
    while ( !IS_NULL_member ( mem ) ) {
1412
	while (!IS_NULL_member(mem)) {
1364
	/* Class members */
1413
		/* Class members */
1365
	IDENTIFIER mid = DEREF_id ( member_id ( mem ) ) ;
1414
		IDENTIFIER mid = DEREF_id(member_id(mem));
1366
	IDENTIFIER nid = DEREF_id ( member_alt ( mem ) ) ;
1415
		IDENTIFIER nid = DEREF_id(member_alt(mem));
1367
	if ( !IS_NULL_id ( mid ) ) {
1416
		if (!IS_NULL_id(mid)) {
1368
	    bs = enc_dg_member ( bs, mid, pm, ct, blk ) ;
1417
			bs = enc_dg_member(bs, mid, pm, ct, blk);
1369
	}
1418
		}
1370
	if ( !IS_NULL_id ( nid ) && !EQ_id ( nid, mid ) ) {
1419
		if (!IS_NULL_id(nid) && !EQ_id(nid, mid)) {
1371
	    bs = enc_dg_member ( bs, nid, pm, ct, blk ) ;
1420
			bs = enc_dg_member(bs, nid, pm, ct, blk);
-
 
1421
		}
-
 
1422
		mem = DEREF_member(member_next(mem));
1372
	}
1423
	}
1373
	mem = DEREF_member ( member_next ( mem ) ) ;
-
 
1374
    }
-
 
1375
    return ( bs ) ;
1424
	return (bs);
1376
}
1425
}
1377
 
1426
 
1378
 
1427
 
1379
/*
1428
/*
1380
    ENCODE VIRTUAL FUNCTION TABLE INFORMATION
1429
    ENCODE VIRTUAL FUNCTION TABLE INFORMATION
1381
 
1430
 
1382
    This routine adds the information for the virtual function table
1431
    This routine adds the information for the virtual function table
1383
    and run-time type information associated with the polymorphic class
1432
    and run-time type information associated with the polymorphic class
1384
    t to the bitstream bs in the form of a number of dummy class members.
1433
    t to the bitstream bs in the form of a number of dummy class members.
1385
    Information on these members is returned via vtags.
1434
    Information on these members is returned via vtags.
1491
}
1539
}
1492
 
1540
 
1493
#endif
1541
#endif
1494
 
1542
 
1495
 
1543
 
1496
/*
1544
/*
1497
    ENCODE A DIAGNOSTIC CLASS
1545
    ENCODE A DIAGNOSTIC CLASS
1498
 
1546
 
1499
    This routine adds the definition of the class type t to the bitstream
1547
    This routine adds the definition of the class type t to the bitstream
1500
    bs.  force is 2 to indicate that a tag name should be output for this
1548
    bs.  force is 2 to indicate that a tag name should be output for this
1501
    class.
1549
    class.
1502
*/
1550
*/
1503
 
1551
 
1504
static BITSTREAM *enc_dg_class
1552
static BITSTREAM *
1505
    PROTO_N ( ( bs, t, force ) )
-
 
1506
    PROTO_T ( BITSTREAM *bs X TYPE t X int force )
1553
enc_dg_class(BITSTREAM *bs, TYPE t, int force)
1507
{
1554
{
1508
    BITSTREAM *ts ;
1555
	BITSTREAM *ts;
1509
    unsigned m = 0 ;
1556
	unsigned m = 0;
1510
    ulong vtags [4] ;
1557
	ulong vtags[4];
1511
    CLASS_TYPE cs = NULL_ctype ;
1558
	CLASS_TYPE cs = NULL_ctype;
1512
    CLASS_TYPE ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
1559
	CLASS_TYPE ct = DEREF_ctype(type_compound_defn(t));
1513
    CLASS_INFO ci = DEREF_cinfo ( ctype_info ( ct ) ) ;
1560
	CLASS_INFO ci = DEREF_cinfo(ctype_info(ct));
1514
    NAMESPACE ns = DEREF_nspace ( ctype_member ( ct ) ) ;
1561
	NAMESPACE ns = DEREF_nspace(ctype_member(ct));
1515
    if ( force == 0 ) {
1562
	if (force == 0) {
1516
	ENC_dg_unknown_type ( bs ) ;
1563
		ENC_dg_unknown_type(bs);
1517
	bs = enc_shape ( bs, t ) ;
1564
		bs = enc_shape(bs, t);
1518
	return ( bs ) ;
1565
		return (bs);
1519
    }
1566
	}
1520
    if ( ( ci & cinfo_complete ) && ( ci & cinfo_defined ) ) {
1567
	if ((ci & cinfo_complete) && (ci & cinfo_defined)) {
1521
	/* Complete class */
1568
		/* Complete class */
1522
	IGNORE compile_class ( ct ) ;
1569
		IGNORE compile_class(ct);
1523
	if ( ci & ( cinfo_static | cinfo_function | cinfo_base ) ) {
1570
		if (ci & (cinfo_static | cinfo_function | cinfo_base)) {
1524
	    cs = ct ;
1571
			cs = ct;
1525
	} else if ( ( ci & cinfo_trivial ) != cinfo_trivial ) {
1572
		} else if ((ci & cinfo_trivial)!= cinfo_trivial) {
1526
	    cs = ct ;
1573
			cs = ct;
1527
	} else {
1574
		} else {
1528
	    LIST ( IDENTIFIER ) ft ;
1575
			LIST(IDENTIFIER)ft;
1529
	    ft = DEREF_list ( ctype_nest ( ct ) ) ;
1576
			ft = DEREF_list(ctype_nest(ct));
1530
	    if ( !IS_NULL_list ( ft ) ) cs = ct ;
1577
			if (!IS_NULL_list(ft)) {
-
 
1578
				cs = ct;
-
 
1579
			}
1531
	    ft = DEREF_list ( ctype_pals ( ct ) ) ;
1580
			ft = DEREF_list(ctype_pals(ct));
1532
	    if ( !IS_NULL_list ( ft ) ) cs = ct ;
1581
			if (!IS_NULL_list(ft)) {
-
 
1582
				cs = ct;
-
 
1583
			}
1533
	}
1584
		}
1534
    } else {
1585
	} else {
1535
	/* Incomplete class */
1586
		/* Incomplete class */
1536
	ENC_dg_is_spec_type ( bs ) ;
1587
		ENC_dg_is_spec_type(bs);
1537
	t = NULL_type ;
1588
		t = NULL_type;
1538
    }
1589
	}
1539
    if ( !IS_NULL_ctype ( cs ) ) {
1590
	if (!IS_NULL_ctype(cs)) {
1540
	/* Class type */
1591
		/* Class type */
1541
	GRAPH gr = DEREF_graph ( ctype_base ( ct ) ) ;
1592
		GRAPH gr = DEREF_graph(ctype_base(ct));
1542
	LIST ( GRAPH ) br = DEREF_list ( graph_tails ( gr ) ) ;
1593
		LIST(GRAPH)br = DEREF_list(graph_tails(gr));
1543
	ENC_dg_class_type ( bs ) ;
1594
		ENC_dg_class_type(bs);
1544
	bs = enc_dg_bases ( bs, br ) ;
1595
		bs = enc_dg_bases(bs, br);
1545
    } else {
1596
	} else {
1546
	/* Structure type */
1597
		/* Structure type */
1547
	ENC_dg_struct_type ( bs ) ;
1598
		ENC_dg_struct_type(bs);
1548
    }
1599
	}
1549
    vtags [0] = LINK_NONE ;
1600
	vtags[0] = LINK_NONE;
1550
    vtags [1] = LINK_NONE ;
1601
	vtags[1] = LINK_NONE;
1551
    vtags [2] = LINK_NONE ;
1602
	vtags[2] = LINK_NONE;
1552
    vtags [3] = LINK_NONE ;
1603
	vtags[3] = LINK_NONE;
1553
    ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
1604
	ts = start_bitstream(NIL(FILE), bs->link);
1554
    ts = enc_dg_namespace ( ts, ns, &m, cs ) ;
1605
	ts = enc_dg_namespace(ts, ns, &m, cs);
1555
#if LANGUAGE_CPP
1606
#if LANGUAGE_CPP
1556
    if ( !IS_NULL_ctype ( cs ) ) {
1607
	if (!IS_NULL_ctype(cs)) {
1557
	if ( ci & cinfo_polymorphic ) {
1608
		if (ci & cinfo_polymorphic) {
1558
	    ts = enc_dg_vtable ( ts, t, vtags ) ;
1609
			ts = enc_dg_vtable(ts, t, vtags);
1559
	    if ( output_rtti ) m += 2 ;
1610
			if (output_rtti) {
1560
	    m += 2 ;
1611
				m += 2;
-
 
1612
			}
-
 
1613
			m += 2;
1561
	}
1614
		}
1562
    }
1615
	}
1563
#endif
1616
#endif
1564
    ENC_LIST ( bs, m ) ;
1617
	ENC_LIST(bs, m);
1565
    bs = join_bitstreams ( bs, ts ) ;
1618
	bs = join_bitstreams(bs, ts);
1566
    if ( !IS_NULL_ctype ( cs ) ) {
1619
	if (!IS_NULL_ctype(cs)) {
1567
	/* Friends */
1620
		/* Friends */
1568
	ENC_OFF ( bs ) ;
1621
		ENC_OFF(bs);
1569
	ENC_LIST_SMALL ( bs, 0 ) ;
1622
		ENC_LIST_SMALL(bs, 0);
1570
    }
1623
	}
1571
    if ( !IS_NULL_type ( t ) ) {
1624
	if (!IS_NULL_type(t)) {
1572
	/* Class shape */
1625
		/* Class shape */
1573
	ENC_ON ( bs ) ;
1626
		ENC_ON(bs);
1574
	bs = enc_shape ( bs, t ) ;
1627
		bs = enc_shape(bs, t);
1575
    } else {
1628
	} else {
1576
	ENC_OFF ( bs ) ;
1629
		ENC_OFF(bs);
1577
    }
1630
	}
1578
    if ( !IS_NULL_ctype ( cs ) ) {
1631
	if (!IS_NULL_ctype(cs)) {
1579
	/* Virtual function table information */
1632
		/* Virtual function table information */
1580
	if ( vtags [0] == LINK_NONE ) {
1633
		if (vtags[0] == LINK_NONE) {
1581
	    ENC_OFFS ( bs, 2 ) ;
1634
			ENC_OFFS(bs, 2);
-
 
1635
		} else {
-
 
1636
			ENC_ON(bs);
-
 
1637
			vtags[2] = link_no(bs, vtags[2], VAR_dgtag);
-
 
1638
			ENC_make_dg_tag(bs, vtags[2]);
-
 
1639
			ENC_ON(bs);
-
 
1640
			vtags[0] = link_no(bs, vtags[0], VAR_dgtag);
-
 
1641
			ENC_make_dg_tag(bs, vtags[0]);
-
 
1642
		}
-
 
1643
	}
-
 
1644
	if (force == 2) {
-
 
1645
		/* Output tag name */
-
 
1646
		IDENTIFIER cid = DEREF_id(ctype_name(ct));
-
 
1647
		TYPE form = DEREF_type(ctype_form(ct));
-
 
1648
		ENC_ON(bs);
-
 
1649
		bs = enc_dg_name(bs, cid, form);
-
 
1650
		ENC_ON(bs);
-
 
1651
		bs = enc_dg_loc(bs, id_loc(cid), id_loc(cid));
1582
	} else {
1652
	} else {
1583
	    ENC_ON ( bs ) ;
-
 
1584
	    vtags [2] = link_no ( bs, vtags [2], VAR_dgtag ) ;
-
 
1585
	    ENC_make_dg_tag ( bs, vtags [2] ) ;
-
 
1586
	    ENC_ON ( bs ) ;
1653
		ENC_OFFS(bs, 2);
1587
	    vtags [0] = link_no ( bs, vtags [0], VAR_dgtag ) ;
-
 
1588
	    ENC_make_dg_tag ( bs, vtags [0] ) ;
-
 
1589
	}
1654
	}
1590
    }
-
 
1591
    if ( force == 2 ) {
1655
	if (IS_NULL_ctype(cs)) {
1592
	/* Output tag name */
-
 
1593
	IDENTIFIER cid = DEREF_id ( ctype_name ( ct ) ) ;
-
 
1594
	TYPE form = DEREF_type ( ctype_form ( ct ) ) ;
-
 
1595
	ENC_ON ( bs ) ;
-
 
1596
	bs = enc_dg_name ( bs, cid, form ) ;
-
 
1597
	ENC_ON ( bs ) ;
1656
		ENC_OFF(bs);
1598
	bs = enc_dg_loc ( bs, id_loc ( cid ), id_loc ( cid ) ) ;
-
 
1599
    } else {
-
 
1600
	ENC_OFFS ( bs, 2 ) ;
-
 
1601
    }
1657
	}
1602
    if ( IS_NULL_ctype ( cs ) ) ENC_OFF ( bs ) ;
-
 
1603
    bs = enc_bool ( bs, ( ( ci & cinfo_union ) ? 1 : 0 ) ) ;
1658
	bs = enc_bool(bs,((ci & cinfo_union)? 1 : 0));
1604
    if ( !IS_NULL_ctype ( cs ) ) {
1659
	if (!IS_NULL_ctype(cs)) {
1605
	/* Run-time type information */
1660
		/* Run-time type information */
1606
	if ( vtags [1] == LINK_NONE ) {
1661
		if (vtags[1] == LINK_NONE) {
1607
	    ENC_OFFS ( bs, 2 ) ;
1662
			ENC_OFFS(bs, 2);
1608
	} else {
1663
		} else {
1609
	    ENC_ON ( bs ) ;
1664
			ENC_ON(bs);
1610
	    vtags [3] = link_no ( bs, vtags [3], VAR_dgtag ) ;
1665
			vtags[3] = link_no(bs, vtags[3], VAR_dgtag);
1611
	    ENC_make_dg_tag ( bs, vtags [3] ) ;
1666
			ENC_make_dg_tag(bs, vtags[3]);
1612
	    ENC_ON ( bs ) ;
1667
			ENC_ON(bs);
1613
	    vtags [1] = link_no ( bs, vtags [1], VAR_dgtag ) ;
1668
			vtags[1] = link_no(bs, vtags[1], VAR_dgtag);
1614
	    ENC_make_dg_tag ( bs, vtags [1] ) ;
1669
			ENC_make_dg_tag(bs, vtags[1]);
-
 
1670
		}
-
 
1671
	}
-
 
1672
	bs = enc_bool(bs, LANGUAGE_CPP);
-
 
1673
	if (!IS_NULL_ctype(cs)) {
-
 
1674
		ENC_OFF(bs);
1615
	}
1675
	}
1616
    }
-
 
1617
    bs = enc_bool ( bs, LANGUAGE_CPP ) ;
-
 
1618
    if ( !IS_NULL_ctype ( cs ) ) ENC_OFF ( bs ) ;
-
 
1619
    return ( bs ) ;
1676
	return (bs);
1620
}
1677
}
1621
 
1678
 
1622
 
1679
 
1623
/*
1680
/*
1624
    ENCODE A DIAGNOSTIC ENUMERATION TYPE
1681
    ENCODE A DIAGNOSTIC ENUMERATION TYPE
Line 1626... Line 1683...
1626
    This routine adds the definition of the enumeration type t to the
1683
    This routine adds the definition of the enumeration type t to the
1627
    bitstream bs.  force is 2 to indicate that a tag name should be
1684
    bitstream bs.  force is 2 to indicate that a tag name should be
1628
    output for this enumeration type.
1685
    output for this enumeration type.
1629
*/
1686
*/
1630
 
1687
 
1631
static BITSTREAM *enc_dg_etype
1688
static BITSTREAM *
1632
    PROTO_N ( ( bs, t, force ) )
-
 
1633
    PROTO_T ( BITSTREAM *bs X TYPE t X int force )
1689
enc_dg_etype(BITSTREAM *bs, TYPE t, int force)
1634
{
1690
{
1635
    ENUM_TYPE et = DEREF_etype ( type_enumerate_defn ( t ) ) ;
1691
	ENUM_TYPE et = DEREF_etype(type_enumerate_defn(t));
1636
    LIST ( IDENTIFIER ) p = DEREF_list ( etype_values ( et ) ) ;
1692
	LIST(IDENTIFIER)p = DEREF_list(etype_values(et));
1637
    CLASS_INFO ei = DEREF_cinfo ( etype_info ( et ) ) ;
1693
	CLASS_INFO ei = DEREF_cinfo(etype_info(et));
1638
    if ( !( ei & cinfo_complete ) || force == 0 ) {
1694
	if (!(ei & cinfo_complete) || force == 0) {
1639
	t = DEREF_type ( etype_rep ( et ) ) ;
1695
		t = DEREF_type(etype_rep(et));
1640
	bs = enc_dg_type ( bs, t, 0 ) ;
1696
		bs = enc_dg_type(bs, t, 0);
1641
	return ( bs ) ;
1697
		return (bs);
1642
    }
1698
	}
1643
    ENC_dg_enum_type ( bs ) ;
1699
	ENC_dg_enum_type(bs);
1644
    ENC_LIST ( bs, LENGTH_list ( p ) ) ;
1700
	ENC_LIST(bs, LENGTH_list(p));
1645
    while ( !IS_NULL_list ( p ) ) {
1701
	while (!IS_NULL_list(p)) {
1646
	IDENTIFIER pid = DEREF_id ( HEAD_list ( p ) ) ;
1702
		IDENTIFIER pid = DEREF_id(HEAD_list(p));
1647
	EXP e = DEREF_exp ( id_enumerator_value ( pid ) ) ;
1703
		EXP e = DEREF_exp(id_enumerator_value(pid));
1648
	ENC_make_dg_enum ( bs ) ;
1704
		ENC_make_dg_enum(bs);
1649
	bs = enc_exp ( bs, e ) ;
1705
		bs = enc_exp(bs, e);
1650
	bs = enc_dg_name ( bs, pid, NULL_type ) ;
1706
		bs = enc_dg_name(bs, pid, NULL_type);
1651
	bs = enc_dg_loc ( bs, id_loc ( pid ), id_loc ( pid ) ) ;
1707
		bs = enc_dg_loc(bs, id_loc(pid), id_loc(pid));
1652
	p = TAIL_list ( p ) ;
1708
		p = TAIL_list(p);
1653
    }
1709
	}
1654
    if ( force == 2 ) {
1710
	if (force == 2) {
1655
	/* Output tag name */
1711
		/* Output tag name */
1656
	IDENTIFIER eid = DEREF_id ( etype_name ( et ) ) ;
1712
		IDENTIFIER eid = DEREF_id(etype_name(et));
1657
	ENC_ON ( bs ) ;
1713
		ENC_ON(bs);
1658
	bs = enc_dg_name ( bs, eid, NULL_type ) ;
1714
		bs = enc_dg_name(bs, eid, NULL_type);
1659
	ENC_ON ( bs ) ;
1715
		ENC_ON(bs);
1660
	bs = enc_dg_loc ( bs, id_loc ( eid ), id_loc ( eid ) ) ;
1716
		bs = enc_dg_loc(bs, id_loc(eid), id_loc(eid));
1661
    } else {
1717
	} else {
1662
	ENC_OFFS ( bs, 2 ) ;
1718
		ENC_OFFS(bs, 2);
1663
    }
1719
	}
1664
    bs = enc_shape ( bs, t ) ;
1720
	bs = enc_shape(bs, t);
1665
    bs = enc_bool ( bs, LANGUAGE_CPP ) ;
1721
	bs = enc_bool(bs, LANGUAGE_CPP);
1666
    return ( bs ) ;
1722
	return (bs);
1667
}
1723
}
1668
 
1724
 
1669
 
1725
 
1670
/*
1726
/*
1671
    ENCODE A DIAGNOSTIC TYPE
1727
    ENCODE A DIAGNOSTIC TYPE
1672
 
1728
 
1673
    This routine adds the diagnostic information for the type t to the
1729
    This routine adds the diagnostic information for the type t to the
1674
    bitstream bs.
1730
    bitstream bs.
1675
*/
1731
*/
1676
 
1732
 
1677
BITSTREAM *enc_dg_type
1733
BITSTREAM *
1678
    PROTO_N ( ( bs, t, force ) )
-
 
1679
    PROTO_T ( BITSTREAM *bs X TYPE t X int force )
1734
enc_dg_type(BITSTREAM *bs, TYPE t, int force)
1680
{
1735
{
1681
    ulong n ;
1736
	ulong n;
1682
    CV_SPEC cv ;
1737
	CV_SPEC cv;
1683
    if ( IS_NULL_type ( t ) ) {
1738
	if (IS_NULL_type(t)) {
1684
	ENC_dg_void_type ( bs ) ;
1739
		ENC_dg_void_type(bs);
1685
	return ( bs ) ;
1740
		return (bs);
1686
    }
1741
	}
1687
    cv = DEREF_cv ( type_qual ( t ) ) ;
1742
	cv = DEREF_cv(type_qual(t));
1688
    if ( cv & cv_const ) {
1743
	if (cv & cv_const) {
1689
	/* Allow for const qualifier */
1744
		/* Allow for const qualifier */
1690
	ENC_dg_qualified_type ( bs ) ;
1745
		ENC_dg_qualified_type(bs);
1691
	ENC_dg_const_qualifier ( bs ) ;
1746
		ENC_dg_const_qualifier(bs);
1692
    }
1747
	}
1693
    if ( cv & cv_volatile ) {
1748
	if (cv & cv_volatile) {
1694
	/* Allow for volatile qualifier */
1749
		/* Allow for volatile qualifier */
1695
	ENC_dg_qualified_type ( bs ) ;
1750
		ENC_dg_qualified_type(bs);
1696
	ENC_dg_volatile_qualifier ( bs ) ;
1751
		ENC_dg_volatile_qualifier(bs);
1697
    }
1752
	}
1698
 
1753
 
1699
    /* Check type name */
1754
	/* Check type name */
1700
    if ( !force ) {
1755
	if (!force) {
1701
	IDENTIFIER tid = DEREF_id ( type_name ( t ) ) ;
1756
		IDENTIFIER tid = DEREF_id(type_name(t));
1702
	if ( !IS_NULL_id ( tid ) ) {
1757
		if (!IS_NULL_id(tid)) {
1703
	    tid = DEREF_id ( id_alias ( tid ) ) ;
1758
			tid = DEREF_id(id_alias(tid));
1704
	    n = DEREF_ulong ( id_no ( tid ) ) ;
1759
			n = DEREF_ulong(id_no(tid));
1705
	    if ( n == LINK_NONE ) {
1760
			if (n == LINK_NONE) {
1706
		enc_dg_id ( tid, 1 ) ;
1761
				enc_dg_id(tid, 1);
1707
		n = DEREF_ulong ( id_no ( tid ) ) ;
1762
				n = DEREF_ulong(id_no(tid));
1708
		if ( n == LINK_NONE ) goto type_label ;
1763
				if (n == LINK_NONE) {
-
 
1764
					goto type_label;
1709
	    }
1765
				}
-
 
1766
			}
1710
	    ENC_dg_named_type ( bs ) ;
1767
			ENC_dg_named_type(bs);
1711
	    n = link_no ( bs, n, VAR_dgtag ) ;
1768
			n = link_no(bs, n, VAR_dgtag);
1712
	    ENC_make_dg_tag ( bs, n ) ;
1769
			ENC_make_dg_tag(bs, n);
1713
	    return ( bs ) ;
1770
			return (bs);
-
 
1771
		}
1714
	}
1772
	}
1715
    }
-
 
1716
 
1773
 
1875
		    }
1906
		    }
-
 
1907
		    case type_array_tag: {
-
 
1908
			    /* Array types */
-
 
1909
			    TYPE s = DEREF_type(type_array_sub(t));
-
 
1910
			    NAT m = DEREF_nat(type_array_size(t));
-
 
1911
			    ENC_dg_array_type(bs);
-
 
1912
			    bs = enc_dg_type(bs, s, 0);
-
 
1913
			    bs = enc_shape_offset(bs, s);
-
 
1914
			    ENC_OFF(bs);
-
 
1915
			    ENC_LIST_SMALL(bs, 1);
-
 
1916
			    if (IS_NULL_nat(m)) {
-
 
1917
				    ENC_dg_unspecified_dim(bs);
-
 
1918
			    } else {
-
 
1919
				    TYPE i = type_sint;
-
 
1920
				    unsigned long v = get_nat_value(m);
-
 
1921
				    ENC_dg_bounds_dim(bs);
-
 
1922
				    ENC_dg_static_bound(bs);
-
 
1923
				    bs = enc_make_int(bs, i, 0);
-
 
1924
				    ENC_dg_static_bound(bs);
-
 
1925
				    if (v < SMALL_ARRAY_BOUND) {
-
 
1926
					    /* Small value */
-
 
1927
					    if (v) {
-
 
1928
						    v--;
-
 
1929
					    }
-
 
1930
					    bs = enc_make_int(bs, i, (int)v);
-
 
1931
				    } else {
-
 
1932
					    ENC_minus(bs);
-
 
1933
					    bs = enc_error_treatment(bs, i);
-
 
1934
					    ENC_make_int(bs);
-
 
1935
					    bs = enc_variety(bs, i);
-
 
1936
					    bs = enc_snat(bs, m, 0, 1);
-
 
1937
					    bs = enc_make_int(bs, i, 1);
-
 
1938
				    }
1876
		    bs = enc_dg_type ( bs, i, 0 ) ;
1939
				    bs = enc_dg_type(bs, i, 0);
1877
		}
1940
			    }
1878
		break ;
1941
			    break;
1879
	    }
1942
		    }
1880
	    case type_bitfield_tag : {
1943
		    case type_bitfield_tag: {
1881
		/* Bitfield types */
1944
			    /* Bitfield types */
1882
		INT_TYPE bf = DEREF_itype ( type_bitfield_defn ( t ) ) ;
1945
			    INT_TYPE bf = DEREF_itype(type_bitfield_defn(t));
1883
		TYPE s = DEREF_type ( itype_bitfield_sub ( bf ) ) ;
1946
			    TYPE s = DEREF_type(itype_bitfield_sub(bf));
1884
		ENC_dg_bitfield_type ( bs ) ;
1947
			    ENC_dg_bitfield_type(bs);
1885
		bs = enc_dg_type ( bs, s, 0 ) ;
1948
			    bs = enc_dg_type(bs, s, 0);
1886
		bs = enc_bfvar ( bs, t ) ;
1949
			    bs = enc_bfvar(bs, t);
1887
		bs = enc_shape ( bs, s ) ;
1950
			    bs = enc_shape(bs, s);
1888
		break ;
1951
			    break;
1889
	    }
1952
		    }
1890
	    case type_compound_tag : {
1953
		    case type_compound_tag: {
1891
		/* Class types */
1954
			    /* Class types */
1892
		bs = enc_dg_class ( bs, t, force ) ;
1955
			    bs = enc_dg_class(bs, t, force);
1893
		break ;
1956
			    break;
1894
	    }
1957
		    }
1895
	    case type_enumerate_tag : {
1958
		    case type_enumerate_tag: {
1896
		/* Enumeration types */
1959
			    /* Enumeration types */
1897
		bs = enc_dg_etype ( bs, t, force ) ;
1960
			    bs = enc_dg_etype(bs, t, force);
1898
		break ;
1961
			    break;
1899
	    }
1962
		    }
1900
	    default : {
1963
		    default: {
1901
		/* Other types */
1964
			    /* Other types */
1902
		ENC_dg_unknown_type ( bs ) ;
1965
			    ENC_dg_unknown_type(bs);
1903
		bs = enc_shape ( bs, t ) ;
1966
			    bs = enc_shape(bs, t);
1904
		break ;
1967
			    break;
1905
	    }
1968
		    }
1906
	}
1969
		    }
1907
    }
1970
	    }
1908
    return ( bs ) ;
1971
	    return (bs);
1909
}
1972
}
1910
 
1973
 
1911
 
1974
 
1912
/*
1975
/*
1913
    ENCODE A LOCAL DIAGNOSTIC IDENTIFIER
1976
    ENCODE A LOCAL DIAGNOSTIC IDENTIFIER
1914
 
1977
 
1915
    This routine adds the diagnostic information for the local identifier
1978
    This routine adds the diagnostic information for the local identifier
1916
    id to the bitstream bs.  ts gives the encoding of the scope of id.
1979
    id to the bitstream bs.  ts gives the encoding of the scope of id.
1917
*/
1980
*/
1918
 
1981
 
1919
BITSTREAM *enc_dg_local
1982
BITSTREAM *
1920
    PROTO_N ( ( bs, id, ts ) )
-
 
1921
    PROTO_T ( BITSTREAM *bs X IDENTIFIER id X BITSTREAM *ts )
1983
enc_dg_local(BITSTREAM *bs, IDENTIFIER id, BITSTREAM *ts)
1922
{
1984
{
1923
    bs = enc_diag_start ( bs ) ;
1985
	bs = enc_diag_start(bs);
1924
    ENC_name_decl_dg ( ts ) ;
1986
	ENC_name_decl_dg(ts);
1925
    ts = enc_dg_decl ( ts, id, LINK_NONE, USAGE_DEFN ) ;
1987
	ts = enc_dg_decl(ts, id, LINK_NONE, USAGE_DEFN);
1926
    bs = enc_bitstream ( bs, ts ) ;
1988
	bs = enc_bitstream(bs, ts);
1927
    return ( bs ) ;
1989
	return (bs);
1928
}
1990
}
1929
 
1991
 
1930
 
1992
 
1931
/*
1993
/*
1932
    ENCODE A LIST OF DIAGNOSTIC PARAMETERS
1994
    ENCODE A LIST OF DIAGNOSTIC PARAMETERS
1933
 
1995
 
1934
    This routine adds the diagnostic information for the list of function
1996
    This routine adds the diagnostic information for the list of function
1935
    parameters p to the bitstream bs.  ts and e give the function body.
1997
    parameters p to the bitstream bs.  ts and e give the function body.
1936
*/
1998
*/
1937
 
1999
 
1938
BITSTREAM *enc_dg_params
2000
BITSTREAM *
1939
    PROTO_N ( ( bs, p, ts, e ) )
-
 
1940
    PROTO_T ( BITSTREAM *bs X LIST ( IDENTIFIER ) p X BITSTREAM *ts X EXP e )
2001
enc_dg_params(BITSTREAM *bs, LIST(IDENTIFIER)p, BITSTREAM *ts, EXP e)
1941
{
2002
{
1942
    bs = enc_diag_start ( bs ) ;
2003
	bs = enc_diag_start(bs);
1943
    ENC_list_dg ( ts ) ;
2004
	ENC_list_dg(ts);
1944
    ENC_LIST_SMALL ( ts, 2 ) ;
2005
	ENC_LIST_SMALL(ts, 2);
1945
    ENC_params_dg ( ts ) ;
2006
	ENC_params_dg(ts);
1946
    ENC_LIST ( ts, LENGTH_list ( p ) ) ;
2007
	ENC_LIST(ts, LENGTH_list(p));
1947
    while ( !IS_NULL_list ( p ) ) {
2008
	while (!IS_NULL_list(p)) {
1948
	IDENTIFIER pid = DEREF_id ( HEAD_list ( p ) ) ;
2009
		IDENTIFIER pid = DEREF_id(HEAD_list(p));
1949
	ts = enc_dg_decl ( ts, pid, LINK_NONE, USAGE_DEFN ) ;
2010
		ts = enc_dg_decl(ts, pid, LINK_NONE, USAGE_DEFN);
1950
	p = TAIL_list ( p ) ;
2011
		p = TAIL_list(p);
1951
    }
2012
	}
1952
    ENC_OFF ( ts ) ;
2013
	ENC_OFF(ts);
1953
    ts = enc_dg_stmt ( ts, e, 1 ) ;
2014
	ts = enc_dg_stmt(ts, e, 1);
1954
    bs = enc_bitstream ( bs, ts ) ;
2015
	bs = enc_bitstream(bs, ts);
1955
    return ( bs ) ;
2016
	return (bs);
1956
}
2017
}
1957
 
2018
 
1958
 
2019
 
1959
/*
2020
/*
1960
    ENCODE A DIAGNOSTIC STATEMENT
2021
    ENCODE A DIAGNOSTIC STATEMENT
1961
 
2022
 
1962
    This routine adds the diagnostic information associated with the
2023
    This routine adds the diagnostic information associated with the
1963
    statement e to the bitstream bs.
2024
    statement e to the bitstream bs.
1964
*/
2025
*/
1965
 
2026
 
1966
BITSTREAM *enc_dg_stmt
2027
BITSTREAM *
1967
    PROTO_N ( ( bs, e, stmt ) )
-
 
1968
    PROTO_T ( BITSTREAM *bs X EXP e X int stmt )
2028
enc_dg_stmt(BITSTREAM *bs, EXP e, int stmt)
1969
{
2029
{
1970
    PTR ( LOCATION ) loc = crt_enc_loc ;
2030
	PTR(LOCATION)loc = crt_enc_loc;
1971
    if ( !IS_NULL_exp ( e ) ) {
2031
	if (!IS_NULL_exp(e)) {
1972
	switch ( TAG_exp ( e ) ) {
2032
		switch (TAG_exp(e)) {
1973
	    case exp_sequence_tag : {
2033
		case exp_sequence_tag: {
1974
		/* Lexical block */
2034
			/* Lexical block */
1975
		int blk = DEREF_int ( exp_sequence_block ( e ) ) ;
2035
			int blk = DEREF_int(exp_sequence_block(e));
1976
		NAMESPACE ns = DEREF_nspace ( exp_sequence_decl ( e ) ) ;
2036
			NAMESPACE ns = DEREF_nspace(exp_sequence_decl(e));
1977
		if ( blk ) {
2037
			if (blk) {
1978
		    BITSTREAM *ts ;
2038
				BITSTREAM *ts;
1979
		    unsigned m = 0 ;
2039
				unsigned m = 0;
1980
		    PTR ( LOCATION ) start_loc = block_loc ( e, 0 ) ;
2040
				PTR(LOCATION)start_loc = block_loc(e, 0);
1981
		    ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
2041
				ts = start_bitstream(NIL(FILE), bs->link);
1982
		    ts = enc_dg_namespace ( ts, ns, &m, NULL_ctype ) ;
2042
				ts = enc_dg_namespace(ts, ns, &m, NULL_ctype);
1983
		    if ( blk > 1 ) m++ ;
2043
				if (blk > 1) {
-
 
2044
					m++;
-
 
2045
				}
1984
		    if ( m != 1 ) {
2046
				if (m != 1) {
1985
			ENC_list_dg ( bs ) ;
2047
					ENC_list_dg(bs);
1986
			ENC_LIST ( bs, m ) ;
2048
					ENC_LIST(bs, m);
1987
		    }
2049
				}
1988
		    if ( blk > 1 ) {
2050
				if (blk > 1) {
1989
			ENC_lexical_block_dg ( bs ) ;
2051
					ENC_lexical_block_dg(bs);
1990
			ENC_OFF ( bs ) ;
2052
					ENC_OFF(bs);
1991
			bs = enc_dg_loc ( bs, start_loc, loc ) ;
2053
					bs = enc_dg_loc(bs, start_loc, loc);
1992
		    }
2054
				}
1993
		    bs = join_bitstreams ( bs, ts ) ;
2055
				bs = join_bitstreams(bs, ts);
1994
		    return ( bs ) ;
2056
				return (bs);
1995
		}
2057
			}
1996
		break ;
2058
			break;
1997
	    }
2059
		}
1998
	    case exp_solve_stmt_tag : {
2060
		case exp_solve_stmt_tag: {
1999
		EXP a = DEREF_exp ( exp_solve_stmt_body ( e ) ) ;
2061
			EXP a = DEREF_exp(exp_solve_stmt_body(e));
2000
		bs = enc_dg_stmt ( bs, a, stmt ) ;
2062
			bs = enc_dg_stmt(bs, a, stmt);
2001
		return ( bs ) ;
2063
			return (bs);
2002
	    }
2064
		}
2003
	    case exp_decl_stmt_tag : {
2065
		case exp_decl_stmt_tag: {
2004
		IDENTIFIER id = DEREF_id ( exp_decl_stmt_id ( e ) ) ;
2066
			IDENTIFIER id = DEREF_id(exp_decl_stmt_id(e));
2005
		loc = id_loc ( id ) ;
2067
			loc = id_loc(id);
2006
		break ;
2068
			break;
2007
	    }
2069
		}
2008
	    case exp_label_stmt_tag : {
2070
		case exp_label_stmt_tag: {
2009
		IDENTIFIER id = DEREF_id ( exp_label_stmt_label ( e ) ) ;
2071
			IDENTIFIER id = DEREF_id(exp_label_stmt_label(e));
2010
		HASHID nm = DEREF_hashid ( id_name ( id ) ) ;
2072
			HASHID nm = DEREF_hashid(id_name(id));
2011
		loc = id_loc ( id ) ;
2073
			loc = id_loc(id);
2012
		if ( !IS_hashid_anon ( nm ) ) {
2074
			if (!IS_hashid_anon(nm)) {
2013
		    /* Named label */
2075
				/* Named label */
2014
		    ENC_label_dg ( bs ) ;
2076
				ENC_label_dg(bs);
2015
		    bs = enc_dg_name ( bs, id, NULL_type ) ;
2077
				bs = enc_dg_name(bs, id, NULL_type);
2016
		    bs = enc_dg_loc ( bs, loc, loc ) ;
2078
				bs = enc_dg_loc(bs, loc, loc);
2017
		    return ( bs ) ;
2079
				return (bs);
2018
		}
2080
			}
2019
		break ;
2081
			break;
2020
	    }
2082
		}
2021
#if LANGUAGE_CPP
2083
#if LANGUAGE_CPP
2022
	    case exp_try_block_tag : {
2084
		case exp_try_block_tag: {
2023
		/* Try block */
2085
			/* Try block */
2024
		EXP a ;
2086
			EXP a;
2025
		unsigned np ;
2087
			unsigned np;
2026
		LIST ( EXP ) p ;
2088
			LIST(EXP)p;
2027
		a = DEREF_exp ( exp_try_block_ellipsis ( e ) ) ;
2089
			a = DEREF_exp(exp_try_block_ellipsis(e));
2028
		p = DEREF_list ( exp_try_block_handlers ( e ) ) ;
2090
			p = DEREF_list(exp_try_block_handlers(e));
2029
		np = LENGTH_list ( p ) ;
2091
			np = LENGTH_list(p);
2030
		if ( IS_exp_handler ( a ) ) np++ ;
2092
			if (IS_exp_handler(a)) {
-
 
2093
				np++;
-
 
2094
			}
2031
		ENC_list_dg ( bs ) ;
2095
			ENC_list_dg(bs);
2032
		ENC_LIST_SMALL ( bs, 2 ) ;
2096
			ENC_LIST_SMALL(bs, 2);
2033
		ENC_exception_scope_dg ( bs ) ;
2097
			ENC_exception_scope_dg(bs);
2034
		ENC_LIST ( bs, np ) ;
2098
			ENC_LIST(bs, np);
2035
		while ( !IS_NULL_list ( p ) ) {
2099
			while (!IS_NULL_list(p)) {
2036
		    EXP b = DEREF_exp ( HEAD_list ( p ) ) ;
2100
				EXP b = DEREF_exp(HEAD_list(p));
2037
		    ulong m = capsule_no ( NULL_string, VAR_dgtag ) ;
2101
				ulong m = capsule_no(NULL_string, VAR_dgtag);
2038
		    COPY_ulong ( exp_handler_diag ( b ), m ) ;
2102
				COPY_ulong(exp_handler_diag(b), m);
2039
		    m = link_no ( bs, m, VAR_dgtag ) ;
2103
				m = link_no(bs, m, VAR_dgtag);
2040
		    ENC_make_dg_tag ( bs, m ) ;
2104
				ENC_make_dg_tag(bs, m);
2041
		    p = TAIL_list ( p ) ;
2105
				p = TAIL_list(p);
-
 
2106
			}
-
 
2107
			if (IS_exp_handler(a)) {
-
 
2108
				ulong m = capsule_no(NULL_string, VAR_dgtag);
-
 
2109
				COPY_ulong(exp_handler_diag(a), m);
-
 
2110
				m = link_no(bs, m, VAR_dgtag);
-
 
2111
				ENC_make_dg_tag(bs, m);
-
 
2112
			}
-
 
2113
			e = DEREF_exp(exp_try_block_body(e));
-
 
2114
			bs = enc_dg_stmt(bs, e, stmt);
-
 
2115
			return (bs);
-
 
2116
		}
-
 
2117
		case exp_handler_tag: {
-
 
2118
			/* Exception handler */
-
 
2119
			ulong m = DEREF_ulong(exp_handler_diag(e));
-
 
2120
			IDENTIFIER id = DEREF_id(exp_handler_except(e));
-
 
2121
			record_usage(m, VAR_dgtag, USAGE_DEFN);
-
 
2122
			ENC_list_dg(bs);
-
 
2123
			ENC_LIST_SMALL(bs, 2);
-
 
2124
			ENC_make_tag_dg(bs);
-
 
2125
			m = link_no(bs, m, VAR_dgtag);
-
 
2126
			ENC_make_dg_tag(bs, m);
-
 
2127
			ENC_exception_handler_dg(bs);
-
 
2128
			if (!IS_NULL_id(id)) {
-
 
2129
				ENC_ON(bs);
-
 
2130
				bs = enc_dg_decl(bs, id, LINK_NONE, USAGE_DEFN);
-
 
2131
			} else {
-
 
2132
				ENC_OFF(bs);
-
 
2133
			}
-
 
2134
			e = DEREF_exp(exp_handler_body(e));
-
 
2135
			bs = enc_dg_stmt(bs, e, stmt);
-
 
2136
			return (bs);
2042
		}
2137
		}
2043
		if ( IS_exp_handler ( a ) ) {
-
 
2044
		    ulong m = capsule_no ( NULL_string, VAR_dgtag ) ;
-
 
2045
		    COPY_ulong ( exp_handler_diag ( a ), m ) ;
-
 
2046
		    m = link_no ( bs, m, VAR_dgtag ) ;
-
 
2047
		    ENC_make_dg_tag ( bs, m ) ;
-
 
2048
		}
-
 
2049
		e = DEREF_exp ( exp_try_block_body ( e ) ) ;
-
 
2050
		bs = enc_dg_stmt ( bs, e, stmt ) ;
-
 
2051
		return ( bs ) ;
-
 
2052
	    }
2138
#endif
2053
	    case exp_handler_tag : {
-
 
2054
		/* Exception handler */
-
 
2055
		ulong m = DEREF_ulong ( exp_handler_diag ( e ) ) ;
-
 
2056
		IDENTIFIER id = DEREF_id ( exp_handler_except ( e ) ) ;
-
 
2057
		record_usage ( m, VAR_dgtag, USAGE_DEFN ) ;
-
 
2058
		ENC_list_dg ( bs ) ;
-
 
2059
		ENC_LIST_SMALL ( bs, 2 ) ;
-
 
2060
		ENC_make_tag_dg ( bs ) ;
-
 
2061
		m = link_no ( bs, m, VAR_dgtag ) ;
-
 
2062
		ENC_make_dg_tag ( bs, m ) ;
-
 
2063
		ENC_exception_handler_dg ( bs ) ;
-
 
2064
		if ( !IS_NULL_id ( id ) ) {
-
 
2065
		    ENC_ON ( bs ) ;
-
 
2066
		    bs = enc_dg_decl ( bs, id, LINK_NONE, USAGE_DEFN ) ;
-
 
2067
		} else {
-
 
2068
		    ENC_OFF ( bs ) ;
-
 
2069
		}
2139
		}
2070
		e = DEREF_exp ( exp_handler_body ( e ) ) ;
-
 
2071
		bs = enc_dg_stmt ( bs, e, stmt ) ;
-
 
2072
		return ( bs ) ;
-
 
2073
	    }
-
 
2074
#endif
-
 
2075
	}
2140
	}
2076
    }
-
 
2077
    if ( stmt == 2 ) {
2141
	if (stmt == 2) {
2078
	/* Used to mark conditionals */
2142
		/* Used to mark conditionals */
2079
	ENC_list_dg ( bs ) ;
2143
		ENC_list_dg(bs);
2080
	ENC_LIST_SMALL ( bs, 2 ) ;
2144
		ENC_LIST_SMALL(bs, 2);
2081
	ENC_branch_dg ( bs ) ;
2145
		ENC_branch_dg(bs);
2082
	bs = enc_dg_loc ( bs, loc, loc ) ;
2146
		bs = enc_dg_loc(bs, loc, loc);
2083
    }
2147
	}
2084
    ENC_singlestep_dg ( bs ) ;
2148
	ENC_singlestep_dg(bs);
2085
    bs = enc_dg_loc ( bs, loc, loc ) ;
2149
	bs = enc_dg_loc(bs, loc, loc);
2086
    return ( bs ) ;
2150
	return (bs);
2087
}
2151
}
2088
 
2152
 
2089
 
2153
 
2090
#endif /* TDF_OUTPUT && TDF_NEW_DIAG */
2154
#endif /* TDF_OUTPUT && TDF_NEW_DIAG */