Subversion Repositories tendra.SVN

Rev

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

Rev 5 Rev 6
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2006 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
Line 75... Line 105...
75
#include "symbols.h"
105
#include "symbols.h"
76
#include "syntax.h"
106
#include "syntax.h"
77
#include "token.h"
107
#include "token.h"
78
#include "ustring.h"
108
#include "ustring.h"
79
#include "xalloc.h"
109
#include "xalloc.h"
80
 
110
 
81
 
111
 
82
/*
112
/*
83
    FORWARD DECLARATIONS
113
    FORWARD DECLARATIONS
84
 
114
 
85
    The following forward declarations are required in the spec input
115
    The following forward declarations are required in the spec input
86
    routines.
116
    routines.
87
*/
117
*/
88
 
118
 
89
static EXP load_exp PROTO_S ( ( BITSTREAM *, TYPE ) ) ;
119
static EXP load_exp(BITSTREAM *, TYPE);
90
static TYPE load_type PROTO_S ( ( BITSTREAM *, IDENTIFIER ) ) ;
120
static TYPE load_type(BITSTREAM *, IDENTIFIER);
91
static TYPE load_ctype PROTO_S ( ( BITSTREAM *, IDENTIFIER, CLASS_TYPE * ) ) ;
121
static TYPE load_ctype(BITSTREAM *, IDENTIFIER, CLASS_TYPE *);
92
static IDENTIFIER load_id PROTO_S ( ( BITSTREAM *, NAMESPACE ) ) ;
122
static IDENTIFIER load_id(BITSTREAM *, NAMESPACE);
93
static LIST ( TYPE ) load_type_list PROTO_S ( ( BITSTREAM * ) ) ;
123
static LIST(TYPE)load_type_list(BITSTREAM *);
94
static TOKEN load_tok PROTO_S ( ( BITSTREAM *, int ) ) ;
124
static TOKEN load_tok(BITSTREAM *, int);
95
static void load_nspace PROTO_S ( ( BITSTREAM *, NAMESPACE, int ) ) ;
125
static void load_nspace(BITSTREAM *, NAMESPACE, int);
96
 
126
 
97
 
127
 
98
/*
128
/*
99
    SPEC INPUT ERROR FLAG
129
    SPEC INPUT ERROR FLAG
100
 
130
 
101
    This flag is set to true to indicate a spec input error.
131
    This flag is set to true to indicate a spec input error.
102
*/
132
*/
103
 
133
 
104
static int spec_error = 0 ;
134
static int spec_error = 0;
105
 
135
 
106
 
136
 
107
/*
137
/*
108
    SPEC ERROR ROUTINE
138
    SPEC ERROR ROUTINE
109
 
139
 
110
    This routine is called when a spec input error occurs.  code gives
140
    This routine is called when a spec input error occurs.  code gives
111
    the reason for the error.
141
    the reason for the error.
112
*/
142
*/
113
 
143
 
114
static void spec_fail
144
static void
115
    PROTO_N ( ( code ) )
-
 
116
    PROTO_T ( int code )
145
spec_fail(int code)
117
{
146
{
-
 
147
	if (!spec_error) {
118
    if ( !spec_error ) spec_error = code ;
148
		spec_error = code;
-
 
149
	}
119
    return ;
150
	return;
120
}
151
}
121
 
152
 
122
 
153
 
123
/*
154
/*
124
    SPEC ERROR CODES
155
    SPEC ERROR CODES
125
 
156
 
126
    The spec error codes are given by the corresponding source line.
157
    The spec error codes are given by the corresponding source line.
127
    This macro gives a convenient shorthand for calling spec_fail.
158
    This macro gives a convenient shorthand for calling spec_fail.
128
*/
159
*/
129
 
160
 
130
#ifdef __LINE__
161
#ifdef __LINE__
131
#define SPEC_ERROR()		spec_fail ( __LINE__ )
162
#define SPEC_ERROR()		spec_fail(__LINE__)
132
#else
163
#else
133
#define SPEC_ERROR()		spec_fail ( 100 )
164
#define SPEC_ERROR()		spec_fail(100)
134
#endif
165
#endif
135
 
166
 
136
 
167
 
137
/*
168
/*
138
    SIMPLE READING ROUTINES
169
    SIMPLE READING ROUTINES
139
 
170
 
140
    These macros give the simple reading routines for the enumeration
171
    These macros give the simple reading routines for the enumeration
141
    types etc.  Note that DE_BITS_2 is used for types which occupy more
172
    types etc.  Note that DE_BITS_2 is used for types which occupy more
142
    than 16 bits.
173
    than 16 bits.
143
*/
174
*/
144
 
175
 
145
#define load_btype( A )		( BASE_TYPE ) DE_BITS_2 ( ( A ), BITS_btype )
176
#define load_btype(A)		(BASE_TYPE)DE_BITS_2((A), BITS_btype)
146
#define load_cinfo( A )		( CLASS_INFO ) DE_BITS_2 ( ( A ), BITS_cinfo )
177
#define load_cinfo(A)		(CLASS_INFO)DE_BITS_2((A), BITS_cinfo)
147
#define load_cusage( A )	( CLASS_USAGE ) DE_BITS ( ( A ), BITS_cusage )
178
#define load_cusage(A)	(CLASS_USAGE)DE_BITS((A), BITS_cusage)
148
#define load_cv( A )		( CV_SPEC ) DE_BITS ( ( A ), BITS_cv_qual )
179
#define load_cv(A)		(CV_SPEC)DE_BITS((A), BITS_cv_qual)
149
#define load_dspec( A )		( DECL_SPEC ) DE_BITS_2 ( ( A ), BITS_dspec )
180
#define load_dspec(A)		(DECL_SPEC)DE_BITS_2((A), BITS_dspec)
150
#define load_mqual( A )		( CV_SPEC ) DE_BITS ( ( A ), BITS_cv )
181
#define load_mqual(A)		(CV_SPEC)DE_BITS((A), BITS_cv)
151
#define load_qual( A )		( QUALIFIER ) DE_BITS ( ( A ), BITS_qual )
182
#define load_qual(A)		(QUALIFIER)DE_BITS((A), BITS_qual)
152
 
183
 
153
 
184
 
154
/*
185
/*
155
    READ A LEXICAL TOKEN NUMBER
186
    READ A LEXICAL TOKEN NUMBER
156
 
187
 
157
    This routine reads a lexical token number from the bitstream bs.
188
    This routine reads a lexical token number from the bitstream bs.
158
*/
189
*/
159
 
190
 
160
static int load_lex
191
static int
161
    PROTO_N ( ( bs ) )
-
 
162
    PROTO_T ( BITSTREAM *bs )
192
load_lex(BITSTREAM *bs)
163
{
193
{
164
    int t = ( int ) DE_BITS ( bs, BITS_lex ) ;
194
	int t = (int)DE_BITS(bs, BITS_lex);
165
    if ( t > LAST_TOKEN ) {
195
	if (t > LAST_TOKEN) {
166
	t = lex_unknown ;
196
		t = lex_unknown;
167
	SPEC_ERROR () ;
197
		SPEC_ERROR();
168
    }
198
	}
169
    return ( t ) ;
199
	return (t);
170
}
200
}
171
 
201
 
172
 
202
 
173
/*
203
/*
174
    READ A LIST OF PREPROCESSING TOKENS
204
    READ A LIST OF PREPROCESSING TOKENS
175
 
205
 
176
    This routine reads a list of preprocessing tokens from the
206
    This routine reads a list of preprocessing tokens from the
177
    bitstream bs.
207
    bitstream bs.
178
*/
208
*/
179
 
209
 
180
static PPTOKEN *load_pptoks
210
static PPTOKEN *
181
    PROTO_N ( ( bs ) )
-
 
182
    PROTO_T ( BITSTREAM *bs )
211
load_pptoks(BITSTREAM *bs)
183
{
212
{
184
    /* NOT YET IMPLEMENTED */
213
	/* NOT YET IMPLEMENTED */
185
    UNUSED ( bs ) ;
214
	UNUSED(bs);
186
    return ( NULL ) ;
215
	return (NULL);
187
}
216
}
188
 
217
 
189
 
218
 
190
/*
219
/*
191
    READ A LOCATION
220
    READ A LOCATION
192
 
221
 
193
    This routine reads the current location from the bitstream bs.
222
    This routine reads the current location from the bitstream bs.
194
*/
223
*/
195
 
224
 
196
static void load_loc
225
static void
197
    PROTO_N ( ( bs ) )
-
 
198
    PROTO_T ( BITSTREAM *bs )
226
load_loc(BITSTREAM *bs)
199
{
227
{
200
    if ( DE_BOOL ( bs ) ) {
228
	if (DE_BOOL(bs)) {
201
	/* Line number has changed */
229
		/* Line number has changed */
202
	crt_loc.line = DE_INT ( bs ) ;
230
		crt_loc.line = DE_INT(bs);
203
	crt_loc.column = 0 ;
231
		crt_loc.column = 0;
204
	if ( DE_BOOL ( bs ) ) {
232
		if (DE_BOOL(bs)) {
205
	    /* File position has changed */
233
			/* File position has changed */
206
	    string file ;
234
			string file;
207
	    string input ;
235
			string input;
208
	    ulong date, date2 ;
236
			ulong date, date2;
209
	    STAT_TYPE *fs = NULL ;
237
			STAT_TYPE *fs = NULL;
210
	    PTR ( POSITION ) posn ;
238
			PTR(POSITION)posn;
211
	    PTR ( LOCATION ) from = NULL_ptr ( LOCATION ) ;
239
			PTR(LOCATION)from = NULL_ptr(LOCATION);
212
	    unsigned long off = DE_INT ( bs ) ;
240
			unsigned long off = DE_INT(bs);
213
	    if ( DE_BOOL ( bs ) ) {
241
			if (DE_BOOL(bs)) {
214
		STAT_TYPE fstr ;
242
				STAT_TYPE fstr;
215
		BUFFER *bf = clear_buffer ( &token_buff, NIL ( FILE ) ) ;
243
				BUFFER *bf = clear_buffer(&token_buff,
-
 
244
							  NIL(FILE));
216
		de_tdfstring ( bs, bf ) ;
245
				de_tdfstring(bs, bf);
217
		file = xustrcpy ( bf->start ) ;
246
				file = xustrcpy(bf->start);
218
		if ( DE_BOOL ( bs ) ) {
247
				if (DE_BOOL(bs)) {
219
		    bf = clear_buffer ( &token_buff, NIL ( FILE ) ) ;
248
					bf = clear_buffer(&token_buff,
-
 
249
							  NIL(FILE));
220
		    de_tdfstring ( bs, bf ) ;
250
					de_tdfstring(bs, bf);
221
		    input = xustrcpy ( bf->start ) ;
251
					input = xustrcpy(bf->start);
222
		} else {
252
				} else {
223
		    input = file ;
253
					input = file;
224
		}
254
				}
225
		date = DE_INT ( bs ) ;
255
				date = DE_INT(bs);
226
		fs = stat_func ( strlit ( input ), &fstr ) ;
256
				fs = stat_func(strlit(input), &fstr);
227
		date2 = stat_date ( fs ) ;
257
				date2 = stat_date(fs);
228
	    } else {
258
			} else {
229
		posn = crt_loc.posn ;
259
				posn = crt_loc.posn;
230
		file = DEREF_string ( posn_file ( posn ) ) ;
260
				file = DEREF_string(posn_file(posn));
231
		input = DEREF_string ( posn_input ( posn ) ) ;
261
				input = DEREF_string(posn_input(posn));
232
		date = DEREF_ulong ( posn_datestamp ( posn ) ) ;
262
				date = DEREF_ulong(posn_datestamp(posn));
233
		date2 = date ;
263
				date2 = date;
234
	    }
264
			}
235
	    posn = MAKE_ptr ( SIZE_posn ) ;
265
			posn = MAKE_ptr(SIZE_posn);
236
	    MAKE_posn ( file, input, input, NULL, off, from, date, posn ) ;
266
			MAKE_posn(file, input, input, NULL, off, from, date,
-
 
267
				  posn);
237
	    crt_loc.posn = posn ;
268
			crt_loc.posn = posn;
238
	    if ( date && date2 && date != date2 ) {
269
			if (date && date2 && date != date2) {
239
		/* File has changed on disk */
270
				/* File has changed on disk */
240
		if ( !already_included ( input, fs, 4 ) ) {
271
				if (!already_included(input, fs, 4)) {
241
		    report ( crt_loc, ERR_cpp_include_date () ) ;
272
					report(crt_loc, ERR_cpp_include_date());
242
		}
273
				}
243
	    }
274
			}
244
	}
275
		}
245
    }
276
	}
246
    return ;
277
	return;
247
}
278
}
248
 
279
 
249
 
280
 
250
/*
281
/*
251
    READ AN IDENTIFIER NAME
282
    READ AN IDENTIFIER NAME
252
 
283
 
253
    This routine reads an identifier name from the bitstream bs.  ns gives
284
    This routine reads an identifier name from the bitstream bs.  ns gives
254
    the current namespace.
285
    the current namespace.
255
*/
286
*/
256
 
287
 
257
static HASHID load_hashid
288
static HASHID
258
    PROTO_N ( ( bs, ns ) )
-
 
259
    PROTO_T ( BITSTREAM *bs X NAMESPACE ns )
289
load_hashid(BITSTREAM *bs, NAMESPACE ns)
260
{
290
{
261
    HASHID nm = NULL_hashid ;
291
	HASHID nm = NULL_hashid;
262
    unsigned n = DE_BITS ( bs, BITS_hashid ) ;
292
	unsigned n = DE_BITS(bs, BITS_hashid);
263
    if ( n ) {
293
	if (n) {
264
	if ( n <= ORDER_hashid ) {
294
		if (n <= ORDER_hashid) {
265
	    unsigned tag = n - 1 ;
295
			unsigned tag = n - 1;
266
	    ASSERT ( ORDER_hashid == 7 ) ;
296
			ASSERT(ORDER_hashid == 7);
267
	    switch ( tag ) {
297
			switch (tag) {
268
		case hashid_name_tag :
298
			case hashid_name_tag:
269
		case hashid_ename_tag : {
299
			case hashid_ename_tag: {
270
		    string s ;
300
				string s;
271
		    int ext = 0 ;
301
				int ext = 0;
272
		    unsigned long h ;
302
				unsigned long h;
273
		    BUFFER *bf = clear_buffer ( &token_buff, NIL ( FILE ) ) ;
303
				BUFFER *bf = clear_buffer(&token_buff,
-
 
304
							  NIL(FILE));
274
		    de_tdfstring ( bs, bf ) ;
305
				de_tdfstring(bs, bf);
275
		    s = bf->start ;
306
				s = bf->start;
276
		    h = hash ( s ) ;
307
				h = hash(s);
277
		    if ( tag == hashid_ename_tag ) ext = 1 ;
308
				if (tag == hashid_ename_tag) {
-
 
309
					ext = 1;
-
 
310
				}
278
		    nm = lookup_name ( s, h, ext, lex_unknown ) ;
311
				nm = lookup_name(s, h, ext, lex_unknown);
279
		    break ;
312
				break;
280
		}
313
			}
281
		case hashid_constr_tag : {
314
			case hashid_constr_tag: {
282
		    if ( IS_nspace_ctype ( ns ) ) {
315
				if (IS_nspace_ctype(ns)) {
-
 
316
					IDENTIFIER cid =
283
			IDENTIFIER cid = DEREF_id ( nspace_name ( ns ) ) ;
317
					    DEREF_id(nspace_name(ns));
284
			if ( IS_id_class_name ( cid ) ) {
318
					if (IS_id_class_name(cid)) {
285
			    TYPE t ;
319
						TYPE t;
286
			    t = DEREF_type ( id_class_name_defn ( cid ) ) ;
320
						t = DEREF_type(id_class_name_defn(cid));
287
			    nm = lookup_constr ( t, cid ) ;
321
						nm = lookup_constr(t, cid);
288
			    break ;
322
						break;
-
 
323
					}
-
 
324
				}
-
 
325
				SPEC_ERROR();
-
 
326
				break;
289
			}
327
			}
290
		    }
-
 
291
		    SPEC_ERROR () ;
-
 
292
		    break ;
-
 
293
		}
-
 
294
		case hashid_destr_tag : {
328
			case hashid_destr_tag: {
295
		    if ( IS_nspace_ctype ( ns ) ) {
329
				if (IS_nspace_ctype(ns)) {
-
 
330
					IDENTIFIER cid =
296
			IDENTIFIER cid = DEREF_id ( nspace_name ( ns ) ) ;
331
					    DEREF_id(nspace_name(ns));
297
			if ( IS_id_class_name ( cid ) ) {
332
					if (IS_id_class_name(cid)) {
298
			    TYPE t ;
333
						TYPE t;
299
			    t = DEREF_type ( id_class_name_defn ( cid ) ) ;
334
						t = DEREF_type(id_class_name_defn(cid));
300
			    nm = lookup_destr ( t, cid ) ;
335
						nm = lookup_destr(t, cid);
301
			    break ;
336
						break;
-
 
337
					}
-
 
338
				}
-
 
339
				SPEC_ERROR();
-
 
340
				break;
302
			}
341
			}
-
 
342
			case hashid_conv_tag: {
-
 
343
				TYPE t = load_type(bs, NULL_id);
-
 
344
				if (!IS_NULL_type(t)) {
-
 
345
					nm = lookup_conv(t);
-
 
346
					break;
303
		    }
347
				}
304
		    SPEC_ERROR () ;
348
				SPEC_ERROR();
-
 
349
				break;
-
 
350
			}
-
 
351
			case hashid_op_tag: {
-
 
352
				int op = load_lex(bs);
-
 
353
				nm = lookup_op(op);
-
 
354
				break;
-
 
355
			}
-
 
356
			case hashid_anon_tag: {
-
 
357
				nm = lookup_anon();
305
		    break ;
358
				break;
-
 
359
			}
-
 
360
			}
-
 
361
		} else {
-
 
362
			SPEC_ERROR();
306
		}
363
		}
307
		case hashid_conv_tag : {
-
 
308
		    TYPE t = load_type ( bs, NULL_id ) ;
-
 
309
		    if ( !IS_NULL_type ( t ) ) {
-
 
310
			nm = lookup_conv ( t ) ;
-
 
311
			break ;
-
 
312
		    }
-
 
313
		    SPEC_ERROR () ;
-
 
314
		    break ;
-
 
315
		}
-
 
316
		case hashid_op_tag : {
-
 
317
		    int op = load_lex ( bs ) ;
-
 
318
		    nm = lookup_op ( op ) ;
-
 
319
		    break ;
-
 
320
		}
-
 
321
		case hashid_anon_tag : {
-
 
322
		    nm = lookup_anon () ;
-
 
323
		    break ;
-
 
324
		}
-
 
325
	    }
-
 
326
	} else {
-
 
327
	    SPEC_ERROR () ;
-
 
328
	}
364
	}
329
    }
-
 
330
    return ( nm ) ;
365
	return (nm);
331
}
366
}
332
 
367
 
333
 
368
 
334
/*
369
/*
335
    READ A LIST OF IDENTIFIER NAMES
370
    READ A LIST OF IDENTIFIER NAMES
336
 
371
 
337
    This routine reads a list of identifier names from the bitstream bs.
372
    This routine reads a list of identifier names from the bitstream bs.
338
*/
373
*/
339
 
374
 
340
static LIST ( HASHID ) load_hashid_list
375
static LIST(HASHID)
341
    PROTO_N ( ( bs, ns ) )
-
 
342
    PROTO_T ( BITSTREAM *bs X NAMESPACE ns )
376
load_hashid_list(BITSTREAM *bs, NAMESPACE ns)
343
{
377
{
344
    LIST ( HASHID ) p = NULL_list ( HASHID ) ;
378
	LIST(HASHID)p = NULL_list(HASHID);
345
    while ( DE_BOOL ( bs ) ) {
379
	while (DE_BOOL(bs)) {
346
	HASHID nm = load_hashid ( bs, ns ) ;
380
		HASHID nm = load_hashid(bs, ns);
347
	if ( IS_NULL_hashid ( nm ) ) {
381
		if (IS_NULL_hashid(nm)) {
348
	    SPEC_ERROR () ;
382
			SPEC_ERROR();
349
	    break ;
383
			break;
350
	}
384
		}
351
	CONS_hashid ( nm, p, p ) ;
385
		CONS_hashid(nm, p, p);
352
    }
386
	}
353
    p = REVERSE_list ( p ) ;
387
	p = REVERSE_list(p);
354
    return ( p ) ;
388
	return (p);
355
}
389
}
-
 
390
 
-
 
391
 
-
 
392
/*
-
 
393
    IDENTIFIER LOOK-UP TABLE
-
 
394
 
-
 
395
    These variables give the table which gives the mapping between identifier
-
 
396
    numbers and identifiers.
-
 
397
*/
-
 
398
 
-
 
399
static IDENTIFIER *id_table = NULL;
-
 
400
static ulong id_table_size = 0;
-
 
401
static ulong ids_pending = 0;
356
 
402
 
357
 
403
 
358
/*
404
/*
359
    IDENTIFIER LOOK-UP TABLE
-
 
360
 
-
 
361
    These variables give the table which gives the mapping between identifier
-
 
362
    numbers and identifiers.
-
 
363
*/
-
 
364
 
-
 
365
static IDENTIFIER *id_table = NULL ;
-
 
366
static ulong id_table_size = 0 ;
-
 
367
static ulong ids_pending = 0 ;
-
 
368
 
-
 
369
 
-
 
370
/*
-
 
371
    LOOK UP IDENTIFIER IN TABLE
405
    LOOK UP IDENTIFIER IN TABLE
372
 
406
 
373
    This routine returns a pointer to the dth element of the table above,
407
    This routine returns a pointer to the dth element of the table above,
374
    extending it if necessary.
408
    extending it if necessary.
375
*/
409
*/
376
 
410
 
377
static IDENTIFIER *id_lookup
411
static IDENTIFIER *
378
    PROTO_N ( ( d ) )
-
 
379
    PROTO_T ( ulong d )
412
id_lookup(ulong d)
380
{
413
{
381
    ulong m = id_table_size ;
414
	ulong m = id_table_size;
382
    IDENTIFIER *p = id_table ;
415
	IDENTIFIER *p = id_table;
383
    if ( d >= m ) {
416
	if (d >= m) {
384
	ulong n = d + 100 ;
417
		ulong n = d + 100;
385
	p = xrealloc_nof ( p, IDENTIFIER, n ) ;
418
		p = xrealloc_nof(p, IDENTIFIER, n);
386
	while ( m < n ) {
419
		while (m < n) {
387
	    p [m] = NULL_id ;
420
			p[m] = NULL_id;
388
	    m++ ;
421
			m++;
-
 
422
		}
-
 
423
		id_table_size = n;
-
 
424
		id_table = p;
389
	}
425
	}
390
	id_table_size = n ;
-
 
391
	id_table = p ;
-
 
392
    }
-
 
393
    return ( p + d ) ;
426
	return (p + d);
394
}
427
}
395
 
428
 
396
 
429
 
397
/*
430
/*
398
    READ AN IDENTIFIER NUMBER
431
    READ AN IDENTIFIER NUMBER
399
 
432
 
400
    This routine reads an identifier number from the bitstream bs.  It is
433
    This routine reads an identifier number from the bitstream bs.  It is
401
    possible for an identifier to be used before it is declared using
434
    possible for an identifier to be used before it is declared using
402
    load_id.
435
    load_id.
403
*/
436
*/
404
 
437
 
405
static IDENTIFIER load_use
438
static IDENTIFIER
406
    PROTO_N ( ( bs, tag ) )
-
 
407
    PROTO_T ( BITSTREAM *bs X unsigned tag )
439
load_use(BITSTREAM *bs, unsigned tag)
408
{
440
{
409
    IDENTIFIER id ;
441
	IDENTIFIER id;
410
    IDENTIFIER *pid ;
442
	IDENTIFIER *pid;
411
    ulong d = DE_INT ( bs ) ;
443
	ulong d = DE_INT(bs);
412
    if ( d == 0 ) {
444
	if (d == 0) {
413
	/* Null identifier */
445
		/* Null identifier */
414
	return ( NULL_id ) ;
446
		return (NULL_id);
415
    }
447
	}
416
    pid = id_lookup ( d ) ;
448
	pid = id_lookup(d);
417
    id = *pid ;
449
	id = *pid;
418
    if ( IS_NULL_id ( id ) ) {
450
	if (IS_NULL_id(id)) {
419
	/* Create dummy identifier */
451
		/* Create dummy identifier */
420
	HASHID nm = KEYWORD ( lex_zzzz ) ;
452
		HASHID nm = KEYWORD(lex_zzzz);
421
	MAKE_id_pending ( nm, dspec_none, NULL_nspace, crt_loc,
453
		MAKE_id_pending(nm, dspec_none, NULL_nspace, crt_loc,
422
			  tag, NULL_type, id ) ;
454
				tag, NULL_type, id);
423
	COPY_ulong ( id_dump ( id ), d ) ;
455
		COPY_ulong(id_dump(id), d);
424
	ids_pending++ ;
456
		ids_pending++;
425
	*pid = id ;
457
		*pid = id;
426
    }
458
	}
427
    return ( id ) ;
459
	return (id);
428
}
460
}
429
 
461
 
430
 
462
 
431
/*
463
/*
432
    READ A LIST OF IDENTIFIER NUMBERS
464
    READ A LIST OF IDENTIFIER NUMBERS
433
 
465
 
434
    This routine reads a list of identifier numbers from the bitstream bs.
466
    This routine reads a list of identifier numbers from the bitstream bs.
435
*/
467
*/
436
 
468
 
437
static LIST ( IDENTIFIER ) load_use_list
469
static LIST(IDENTIFIER)
438
    PROTO_N ( ( bs ) )
-
 
439
    PROTO_T ( BITSTREAM *bs )
470
load_use_list(BITSTREAM *bs)
440
{
471
{
441
    LIST ( IDENTIFIER ) p = NULL_list ( IDENTIFIER ) ;
472
	LIST(IDENTIFIER)p = NULL_list(IDENTIFIER);
442
    while ( DE_BOOL ( bs ) ) {
473
	while (DE_BOOL(bs)) {
443
	IDENTIFIER id = load_use ( bs, null_tag ) ;
474
		IDENTIFIER id = load_use(bs, null_tag);
444
	if ( spec_error ) break ;
475
		if (spec_error) {
-
 
476
			break;
-
 
477
		}
445
	CONS_id ( id, p, p ) ;
478
		CONS_id(id, p, p);
446
    }
479
	}
447
    p = REVERSE_list ( p ) ;
480
	p = REVERSE_list(p);
448
    return ( p ) ;
481
	return (p);
449
}
482
}
450
 
483
 
451
 
484
 
452
/*
485
/*
453
    READ A LIST OF TOKENS
486
    READ A LIST OF TOKENS
454
 
487
 
455
    This routine reads a list of tokens from the bitstream bs.  def is
488
    This routine reads a list of tokens from the bitstream bs.  def is
456
    as in load_tok.
489
    as in load_tok.
457
*/
490
*/
458
 
491
 
459
static LIST ( TOKEN ) load_tok_list
492
static LIST(TOKEN)
460
    PROTO_N ( ( bs, def ) )
-
 
461
    PROTO_T ( BITSTREAM *bs X int def )
493
load_tok_list(BITSTREAM *bs, int def)
462
{
494
{
463
    LIST ( TOKEN ) p = NULL_list ( TOKEN ) ;
495
	LIST(TOKEN)p = NULL_list(TOKEN);
464
    while ( DE_BOOL ( bs ) ) {
496
	while (DE_BOOL(bs)) {
465
	TOKEN tok = load_tok ( bs, def ) ;
497
		TOKEN tok = load_tok(bs, def);
466
	if ( spec_error ) break ;
498
		if (spec_error) {
-
 
499
			break;
-
 
500
		}
467
	CONS_tok ( tok, p, p ) ;
501
		CONS_tok(tok, p, p);
468
    }
502
	}
469
    p = REVERSE_list ( p ) ;
503
	p = REVERSE_list(p);
470
    return ( p ) ;
504
	return (p);
471
}
505
}
472
 
506
 
473
 
507
 
474
/*
508
/*
475
    READ AN INTEGER CONSTANT
509
    READ AN INTEGER CONSTANT
476
 
510
 
477
    This routine reads an integer constant from the bitstream bs.
511
    This routine reads an integer constant from the bitstream bs.
478
*/
512
*/
479
 
513
 
480
static NAT load_nat
514
static NAT
481
    PROTO_N ( ( bs ) )
-
 
482
    PROTO_T ( BITSTREAM *bs )
515
load_nat(BITSTREAM *bs)
483
{
516
{
484
    NAT m = NULL_nat ;
517
	NAT m = NULL_nat;
485
    unsigned n = DE_BITS ( bs, BITS_nat ) ;
518
	unsigned n = DE_BITS(bs, BITS_nat);
486
    if ( n == 0 ) {
519
	if (n == 0) {
487
	/* Null constants */
520
		/* Null constants */
488
	return ( m ) ;
521
		return (m);
489
    }
522
	}
490
    if ( n > ORDER_nat ) {
523
	if (n > ORDER_nat) {
491
	SPEC_ERROR () ;
524
		SPEC_ERROR();
492
	return ( m ) ;
525
		return (m);
493
    }
526
	}
494
    ASSERT ( ORDER_nat == 5 ) ;
527
	ASSERT(ORDER_nat == 5);
495
    switch ( n - 1 ) {
528
	switch (n - 1) {
496
	case nat_small_tag : {
529
	case nat_small_tag: {
497
	    unsigned long v = DE_INT ( bs ) ;
530
		unsigned long v = DE_INT(bs);
498
	    m = make_nat_value ( v ) ;
531
		m = make_nat_value(v);
499
	    break ;
532
		break;
500
	}
533
	}
501
	case nat_large_tag : {
534
	case nat_large_tag: {
502
	    int count = 0 ;
535
		int count = 0;
503
	    LIST ( unsigned ) p = NULL_list ( unsigned ) ;
536
		LIST(unsigned)p = NULL_list(unsigned);
504
	    while ( DE_BOOL ( bs ) ) {
537
		while (DE_BOOL(bs)) {
505
		unsigned v = ( unsigned ) DE_INT ( bs ) ;
538
			unsigned v = (unsigned)DE_INT(bs);
506
		CONS_unsigned ( v, p, p ) ;
539
			CONS_unsigned(v, p, p);
507
		if ( ++count == 10 ) {
540
			if (++count == 10) {
508
		    /* Check for end of file */
541
				/* Check for end of file */
509
		    if ( de_eof ( bs ) ) {
542
				if (de_eof(bs)) {
510
			SPEC_ERROR () ;
543
					SPEC_ERROR();
511
			break ;
544
					break;
512
		    }
545
				}
513
		    count = 0 ;
546
				count = 0;
514
		}
547
			}
515
	    }
548
		}
516
	    p = REVERSE_list ( p ) ;
549
		p = REVERSE_list(p);
517
	    m = make_large_nat ( p ) ;
550
		m = make_large_nat(p);
518
	    break ;
551
		break;
519
	}
552
	}
520
	case nat_calc_tag : {
553
	case nat_calc_tag: {
521
	    EXP e = load_exp ( bs, type_sint ) ;
554
		EXP e = load_exp(bs, type_sint);
522
	    if ( !IS_NULL_exp ( e ) ) {
555
		if (!IS_NULL_exp(e)) {
523
		MAKE_nat_calc ( e, m ) ;
556
			MAKE_nat_calc(e, m);
524
		break ;
557
			break;
525
	    }
558
		}
526
	    SPEC_ERROR () ;
559
		SPEC_ERROR();
527
	    break ;
560
		break;
528
	}
561
	}
529
	case nat_neg_tag : {
562
	case nat_neg_tag: {
530
	    m = load_nat ( bs ) ;
563
		m = load_nat(bs);
531
	    if ( !IS_NULL_nat ( m ) ) {
564
		if (!IS_NULL_nat(m)) {
532
		m = negate_nat ( m ) ;
565
			m = negate_nat(m);
533
		break ;
566
			break;
534
	    }
567
		}
535
	    SPEC_ERROR () ;
568
		SPEC_ERROR();
536
	    break ;
569
		break;
537
	}
570
	}
538
	case nat_token_tag : {
571
	case nat_token_tag: {
539
	    IDENTIFIER tok = load_use ( bs, null_tag ) ;
572
		IDENTIFIER tok = load_use(bs, null_tag);
540
	    if ( !IS_NULL_id ( tok ) ) {
573
		if (!IS_NULL_id(tok)) {
541
		LIST ( TOKEN ) args = load_tok_list ( bs, 1 ) ;
574
			LIST(TOKEN)args = load_tok_list(bs, 1);
542
		MAKE_nat_token ( tok, args, m ) ;
575
			MAKE_nat_token(tok, args, m);
543
		break ;
576
			break;
544
	    }
577
		}
545
	    SPEC_ERROR () ;
578
		SPEC_ERROR();
546
	    break ;
579
		break;
547
	}
580
	}
548
    }
581
	}
549
    return ( m ) ;
582
	return (m);
550
}
583
}
551
 
584
 
552
 
585
 
553
/*
586
/*
554
    READ AN OFFSET
587
    READ AN OFFSET
555
 
588
 
556
    This routine reads an offset from the bitstream bs.
589
    This routine reads an offset from the bitstream bs.
557
*/
590
*/
558
 
591
 
559
static OFFSET load_off
592
static OFFSET
560
    PROTO_N ( ( bs ) )
-
 
561
    PROTO_T ( BITSTREAM *bs )
593
load_off(BITSTREAM *bs)
562
{
594
{
563
    /* NOT YET IMPLEMENTED */
595
	/* NOT YET IMPLEMENTED */
564
    UNUSED ( bs ) ;
596
	UNUSED(bs);
565
    return ( NULL_off ) ;
597
	return (NULL_off);
566
}
598
}
567
 
599
 
568
 
600
 
569
/*
601
/*
570
    READ AN EXPRESSION
602
    READ AN EXPRESSION
571
 
603
 
572
    This routine reads an expression from the bitstream bs.
604
    This routine reads an expression from the bitstream bs.
573
*/
605
*/
574
 
606
 
575
static EXP load_exp
607
static EXP
576
    PROTO_N ( ( bs, t ) )
-
 
577
    PROTO_T ( BITSTREAM *bs X TYPE t )
608
load_exp(BITSTREAM *bs, TYPE t)
578
{
609
{
579
    unsigned tag ;
610
	unsigned tag;
580
    EXP e = NULL_exp ;
611
	EXP e = NULL_exp;
581
    unsigned n = DE_BITS ( bs, BITS_exp ) ;
612
	unsigned n = DE_BITS(bs, BITS_exp);
582
    if ( n == 0 ) {
613
	if (n == 0) {
583
	/* Null expressions */
614
		/* Null expressions */
584
	return ( e ) ;
-
 
585
    }
-
 
586
    if ( n > ORDER_exp ) {
-
 
587
	SPEC_ERROR () ;
-
 
588
	return ( e ) ;
615
		return (e);
589
    }
-
 
590
    tag = n - 1 ;
-
 
591
    switch ( tag ) {
-
 
592
	case exp_int_lit_tag : {
-
 
593
	    NAT m = load_nat ( bs ) ;
-
 
594
	    if ( !IS_NULL_nat ( m ) ) {
-
 
595
		unsigned etag = DE_BITS ( bs, BITS_exp ) ;
-
 
596
		if ( etag < ORDER_exp ) {
-
 
597
		    MAKE_exp_int_lit ( t, m, etag, e ) ;
-
 
598
		    break ;
-
 
599
		}
-
 
600
	    }
-
 
601
	    SPEC_ERROR () ;
-
 
602
	    break ;
-
 
603
	}
616
	}
-
 
617
	if (n > ORDER_exp) {
-
 
618
		SPEC_ERROR();
-
 
619
		return (e);
-
 
620
	}
-
 
621
	tag = n - 1;
-
 
622
	switch (tag) {
-
 
623
	case exp_int_lit_tag: {
-
 
624
		NAT m = load_nat(bs);
-
 
625
		if (!IS_NULL_nat(m)) {
-
 
626
			unsigned etag = DE_BITS(bs, BITS_exp);
-
 
627
			if (etag < ORDER_exp) {
-
 
628
				MAKE_exp_int_lit(t, m, etag, e);
-
 
629
				break;
-
 
630
			}
-
 
631
		}
-
 
632
		SPEC_ERROR();
-
 
633
		break;
-
 
634
	}
604
	case exp_token_tag : {
635
	case exp_token_tag: {
605
	    IDENTIFIER tok = load_use ( bs, null_tag ) ;
636
		IDENTIFIER tok = load_use(bs, null_tag);
606
	    if ( !IS_NULL_id ( tok ) ) {
637
		if (!IS_NULL_id(tok)) {
607
		LIST ( TOKEN ) args = load_tok_list ( bs, 1 ) ;
638
			LIST(TOKEN)args = load_tok_list(bs, 1);
608
		MAKE_exp_token ( t, tok, args, e ) ;
639
			MAKE_exp_token(t, tok, args, e);
609
		break ;
640
			break;
610
	    }
641
		}
611
	    SPEC_ERROR () ;
642
		SPEC_ERROR();
612
	    break ;
643
		break;
613
	}
644
	}
614
	default : {
645
	default: {
615
	    /* NOT YET IMPLEMENTED */
646
		/* NOT YET IMPLEMENTED */
616
	    MAKE_exp_value ( t, e ) ;
647
		MAKE_exp_value(t, e);
617
	    break ;
648
		break;
618
	}
649
	}
619
    }
650
	}
620
    return ( e ) ;
651
	return (e);
621
}
652
}
622
 
653
 
623
 
654
 
624
/*
655
/*
625
    READ A BUILT-IN TYPE
656
    READ A BUILT-IN TYPE
626
 
657
 
627
    This routine reads a built-in type number from the bitstream bs.
658
    This routine reads a built-in type number from the bitstream bs.
628
*/
659
*/
629
 
660
 
630
static BUILTIN_TYPE load_ntype
661
static BUILTIN_TYPE
631
    PROTO_N ( ( bs ) )
-
 
632
    PROTO_T ( BITSTREAM *bs )
662
load_ntype(BITSTREAM *bs)
633
{
-
 
634
    BUILTIN_TYPE nt = ( BUILTIN_TYPE ) DE_BITS ( bs, BITS_ntype ) ;
-
 
635
    if ( nt >= ORDER_ntype ) {
-
 
636
	nt = ntype_none ;
-
 
637
	SPEC_ERROR () ;
-
 
638
    }
-
 
639
    return ( nt ) ;
-
 
640
}
-
 
641
 
-
 
642
 
-
 
643
/*
-
 
644
    READ AN INTEGRAL TYPE
-
 
645
 
-
 
646
    This routine reads a integral type from the bitstream bs.  Note that
-
 
647
    the result is returned as a type rather than an integral type.
-
 
648
*/
-
 
649
 
-
 
650
static TYPE load_itype
-
 
651
    PROTO_N ( ( bs, cv, tag ) )
-
 
652
    PROTO_T ( BITSTREAM *bs X CV_SPEC cv X unsigned tag )
-
 
653
{
663
{
654
    TYPE t = NULL_type ;
-
 
655
    unsigned n = DE_BITS ( bs, BITS_itype ) ;
664
	BUILTIN_TYPE nt = (BUILTIN_TYPE)DE_BITS(bs, BITS_ntype);
656
    if ( n == 0 ) {
665
	if (nt >= ORDER_ntype) {
657
	/* Null types */
666
		nt = ntype_none;
658
	return ( t ) ;
-
 
659
    }
-
 
660
    if ( n > ORDER_itype ) {
-
 
661
	SPEC_ERROR () ;
667
		SPEC_ERROR();
662
	return ( t ) ;
-
 
663
    }
-
 
664
    switch ( n - 1 ) {
-
 
665
	case itype_basic_tag : {
-
 
666
	    BUILTIN_TYPE nt = load_ntype ( bs ) ;
-
 
667
	    t = type_builtin [ nt ] ;
-
 
668
	    break ;
-
 
669
	}
668
	}
-
 
669
	return (nt);
-
 
670
}
-
 
671
 
-
 
672
 
-
 
673
/*
-
 
674
    READ AN INTEGRAL TYPE
-
 
675
 
-
 
676
    This routine reads a integral type from the bitstream bs.  Note that
-
 
677
    the result is returned as a type rather than an integral type.
-
 
678
*/
-
 
679
 
-
 
680
static TYPE
-
 
681
load_itype(BITSTREAM *bs, CV_SPEC cv, unsigned tag)
-
 
682
{
-
 
683
	TYPE t = NULL_type;
-
 
684
	unsigned n = DE_BITS(bs, BITS_itype);
-
 
685
	if (n == 0) {
-
 
686
		/* Null types */
-
 
687
		return (t);
-
 
688
	}
-
 
689
	if (n > ORDER_itype) {
-
 
690
		SPEC_ERROR();
-
 
691
		return (t);
-
 
692
	}
-
 
693
	switch (n - 1) {
-
 
694
	case itype_basic_tag: {
-
 
695
		BUILTIN_TYPE nt = load_ntype(bs);
-
 
696
		t = type_builtin[nt];
-
 
697
		break;
-
 
698
	}
670
	case itype_bitfield_tag : {
699
	case itype_bitfield_tag: {
671
	    TYPE s = load_type ( bs, NULL_id ) ;
700
		TYPE s = load_type(bs, NULL_id);
672
	    if ( !IS_NULL_type ( s ) ) {
701
		if (!IS_NULL_type(s)) {
673
		BASE_TYPE bt = load_btype ( bs ) ;
702
			BASE_TYPE bt = load_btype(bs);
674
		NAT m = load_nat ( bs ) ;
703
			NAT m = load_nat(bs);
675
		if ( !IS_NULL_nat ( m ) ) {
704
			if (!IS_NULL_nat(m)) {
676
		    t = check_bitfield_type ( cv, s, bt, m, 1 ) ;
705
				t = check_bitfield_type(cv, s, bt, m, 1);
677
		    cv = cv_none ;
706
				cv = cv_none;
678
		    break ;
707
				break;
679
		}
708
			}
680
	    }
709
		}
681
	    SPEC_ERROR () ;
710
		SPEC_ERROR();
682
	    break ;
711
		break;
683
	}
712
	}
684
	case itype_promote_tag : {
713
	case itype_promote_tag: {
685
	    TYPE s = load_itype ( bs, cv_none, type_integer_tag ) ;
714
		TYPE s = load_itype(bs, cv_none, type_integer_tag);
686
	    if ( !IS_NULL_type ( s ) ) {
715
		if (!IS_NULL_type(s)) {
687
		t = promote_type ( s ) ;
716
			t = promote_type(s);
688
		break ;
717
			break;
689
	    }
718
		}
690
	    SPEC_ERROR () ;
719
		SPEC_ERROR();
691
	    break ;
720
		break;
692
	}
721
	}
693
	case itype_arith_tag : {
722
	case itype_arith_tag: {
694
	    TYPE s = load_itype ( bs, cv_none, type_integer_tag ) ;
723
		TYPE s = load_itype(bs, cv_none, type_integer_tag);
695
	    if ( !IS_NULL_type ( s ) ) {
724
		if (!IS_NULL_type(s)) {
696
		TYPE r = load_itype ( bs, cv_none, type_integer_tag ) ;
725
			TYPE r = load_itype(bs, cv_none, type_integer_tag);
697
		if ( !IS_NULL_type ( r ) ) {
726
			if (!IS_NULL_type(r)) {
698
		    t = arith_itype ( s, r, NULL_exp, NULL_exp ) ;
727
				t = arith_itype(s, r, NULL_exp, NULL_exp);
699
		    break ;
728
				break;
700
		}
729
			}
701
	    }
730
		}
702
	    SPEC_ERROR () ;
731
		SPEC_ERROR();
703
	    break ;
732
		break;
704
	}
733
	}
705
	case itype_literal_tag : {
734
	case itype_literal_tag: {
706
	    NAT m = load_nat ( bs ) ;
735
		NAT m = load_nat(bs);
707
	    if ( !IS_NULL_nat ( m ) ) {
736
		if (!IS_NULL_nat(m)) {
708
		int form = ( int ) DE_BITS ( bs, 2 ) ;
737
			int form = (int)DE_BITS(bs, 2);
709
		if ( form >= 0 && form < BASE_NO ) {
738
			if (form >= 0 && form < BASE_NO) {
710
		    int suff = ( int ) DE_BITS ( bs, 3 ) ;
739
				int suff = (int)DE_BITS(bs, 3);
711
		    if ( suff >= 0 && suff < SUFFIX_NO ) {
740
				if (suff >= 0 && suff < SUFFIX_NO) {
712
			int fit = 0 ;
741
					int fit = 0;
713
			string str = NULL_string ;
742
					string str = NULL_string;
714
			t = find_literal_type ( m, form, suff, str, &fit ) ;
743
					t = find_literal_type(m, form, suff,
-
 
744
							      str, &fit);
715
			break ;
745
					break;
716
		    }
746
				}
717
		}
747
			}
718
	    }
748
		}
719
	    SPEC_ERROR () ;
749
		SPEC_ERROR();
720
	    break ;
750
		break;
721
	}
751
	}
722
	case itype_token_tag : {
752
	case itype_token_tag: {
723
	    IDENTIFIER tok = load_use ( bs, null_tag ) ;
753
		IDENTIFIER tok = load_use(bs, null_tag);
724
	    if ( !IS_NULL_id ( tok ) ) {
754
		if (!IS_NULL_id(tok)) {
725
		LIST ( TOKEN ) args = load_tok_list ( bs, 1 ) ;
755
			LIST(TOKEN)args = load_tok_list(bs, 1);
726
		t = apply_itype_token ( tok, args ) ;
756
			t = apply_itype_token(tok, args);
727
		break ;
757
			break;
728
	    }
758
		}
729
	    SPEC_ERROR () ;
759
		SPEC_ERROR();
730
	    break ;
760
		break;
731
	}
761
	}
732
    }
762
	}
733
    if ( !IS_NULL_type ( t ) ) {
763
	if (!IS_NULL_type(t)) {
734
	if ( TAG_type ( t ) == tag ) {
764
		if (TAG_type(t) == tag) {
-
 
765
			if (cv) {
735
	    if ( cv ) t = qualify_type ( t, cv, 0 ) ;
766
				t = qualify_type(t, cv, 0);
-
 
767
			}
736
	} else {
768
		} else {
737
	    SPEC_ERROR () ;
769
			SPEC_ERROR();
738
	}
770
		}
739
    }
771
	}
740
    return ( t ) ;
772
	return (t);
741
}
773
}
742
 
774
 
743
 
775
 
744
/*
776
/*
745
    READ A FLOATING POINT TYPE
777
    READ A FLOATING POINT TYPE
746
 
778
 
747
    This routine reads a floating point type from the bitstream bs.  Note
779
    This routine reads a floating point type from the bitstream bs.  Note
748
    that the result is returned as a type rather than a floating point type.
780
    that the result is returned as a type rather than a floating point type.
749
*/
781
*/
750
 
782
 
751
static TYPE load_ftype
783
static TYPE
752
    PROTO_N ( ( bs, cv ) )
-
 
753
    PROTO_T ( BITSTREAM *bs X CV_SPEC cv )
784
load_ftype(BITSTREAM *bs, CV_SPEC cv)
754
{
785
{
755
    TYPE t = NULL_type ;
786
	TYPE t = NULL_type;
756
    unsigned n = DE_BITS ( bs, BITS_ftype ) ;
787
	unsigned n = DE_BITS(bs, BITS_ftype);
757
    if ( n == 0 ) {
788
	if (n == 0) {
758
	/* Null types */
789
		/* Null types */
759
	return ( t ) ;
790
		return (t);
760
    }
791
	}
761
    if ( n > ORDER_ftype ) {
792
	if (n > ORDER_ftype) {
762
	SPEC_ERROR () ;
793
		SPEC_ERROR();
763
	return ( t ) ;
794
		return (t);
764
    }
795
	}
765
    ASSERT ( ORDER_ftype == 4 ) ;
796
	ASSERT(ORDER_ftype == 4);
766
    switch ( n - 1 ) {
797
	switch (n - 1) {
767
	case ftype_basic_tag : {
798
	case ftype_basic_tag: {
768
	    BUILTIN_TYPE nt = load_ntype ( bs ) ;
799
		BUILTIN_TYPE nt = load_ntype(bs);
769
	    t = type_builtin [ nt ] ;
800
		t = type_builtin[nt];
770
	    break ;
801
		break;
771
	}
802
	}
772
	case ftype_arg_promote_tag : {
803
	case ftype_arg_promote_tag: {
773
	    TYPE s = load_ftype ( bs, cv_none ) ;
804
		TYPE s = load_ftype(bs, cv_none);
774
	    if ( !IS_NULL_type ( s ) ) {
805
		if (!IS_NULL_type(s)) {
775
		t = arg_promote_type ( s, KILL_err ) ;
806
			t = arg_promote_type(s, KILL_err);
776
		break ;
807
			break;
777
	    }
808
		}
778
	    SPEC_ERROR () ;
809
		SPEC_ERROR();
779
	    break ;
810
		break;
780
	}
811
	}
781
	case ftype_arith_tag : {
812
	case ftype_arith_tag: {
782
	    TYPE s = load_ftype ( bs, cv_none ) ;
813
		TYPE s = load_ftype(bs, cv_none);
783
	    if ( !IS_NULL_type ( s ) ) {
814
		if (!IS_NULL_type(s)) {
784
		TYPE r = load_ftype ( bs, cv_none ) ;
815
			TYPE r = load_ftype(bs, cv_none);
785
		if ( !IS_NULL_type ( r ) ) {
816
			if (!IS_NULL_type(r)) {
786
		    t = arith_ftype ( s, r ) ;
817
				t = arith_ftype(s, r);
787
		    break ;
818
				break;
-
 
819
			}
-
 
820
		}
-
 
821
		SPEC_ERROR();
-
 
822
		break;
-
 
823
	}
-
 
824
	case ftype_token_tag: {
-
 
825
		IDENTIFIER tok = load_use(bs, null_tag);
-
 
826
		if (!IS_NULL_id(tok)) {
-
 
827
			LIST(TOKEN)args = load_tok_list(bs, 1);
-
 
828
			t = apply_ftype_token(tok, args);
-
 
829
			break;
-
 
830
		}
-
 
831
		break;
-
 
832
	}
-
 
833
	}
-
 
834
	if (!IS_NULL_type(t)) {
-
 
835
		if (IS_type_floating(t)) {
-
 
836
			if (cv)t = qualify_type(t, cv, 0);
-
 
837
		} else {
-
 
838
			SPEC_ERROR();
-
 
839
			t = NULL_type;
788
		}
840
		}
789
	    }
-
 
790
	    SPEC_ERROR () ;
-
 
791
	    break ;
-
 
792
	}
841
	}
793
	case ftype_token_tag : {
-
 
794
	    IDENTIFIER tok = load_use ( bs, null_tag ) ;
-
 
795
	    if ( !IS_NULL_id ( tok ) ) {
-
 
796
		LIST ( TOKEN ) args = load_tok_list ( bs, 1 ) ;
-
 
797
		t = apply_ftype_token ( tok, args ) ;
-
 
798
		break ;
-
 
799
	    }
-
 
800
	    break ;
-
 
801
	}
-
 
802
    }
-
 
803
    if ( !IS_NULL_type ( t ) ) {
-
 
804
	if ( IS_type_floating ( t ) ) {
-
 
805
	    if ( cv ) t = qualify_type ( t, cv, 0 ) ;
-
 
806
	} else {
-
 
807
	    SPEC_ERROR () ;
-
 
808
	    t = NULL_type ;
-
 
809
	}
-
 
810
    }
-
 
811
    return ( t ) ;
842
	return (t);
812
}
843
}
813
 
844
 
814
 
845
 
815
/*
846
/*
816
    READ A BASE CLASS GRAPH
847
    READ A BASE CLASS GRAPH
817
 
848
 
818
    This routine reads a base class from the bitstream bs.  gu gives the
849
    This routine reads a base class from the bitstream bs.  gu gives the
819
    parent graph and gt gives the top of the graph.
850
    parent graph and gt gives the top of the graph.
820
*/
851
*/
821
 
852
 
822
static GRAPH load_graph
853
static GRAPH
823
    PROTO_N ( ( bs, gu, gt ) )
-
 
824
    PROTO_T ( BITSTREAM *bs X GRAPH gu X GRAPH gt )
854
load_graph(BITSTREAM *bs, GRAPH gu, GRAPH gt)
825
{
855
{
826
    GRAPH gr ;
856
	GRAPH gr;
827
    LIST ( GRAPH ) br = NULL_list ( GRAPH ) ;
857
	LIST(GRAPH)br = NULL_list(GRAPH);
828
    if ( IS_NULL_graph ( gu ) ) {
858
	if (IS_NULL_graph(gu)) {
829
	/* Top graph node */
859
		/* Top graph node */
830
	gr = gt ;
860
		gr = gt;
831
    } else {
-
 
832
	/* Read graph node */
-
 
833
	CLASS_TYPE ct = NULL_ctype ;
-
 
834
	IGNORE load_ctype ( bs, NULL_id, &ct ) ;
-
 
835
	if ( !IS_NULL_ctype ( ct ) ) {
-
 
836
	    DECL_SPEC acc = load_dspec ( bs ) ;
-
 
837
	    MAKE_graph_basic ( ct, acc, gr ) ;
-
 
838
	} else {
861
	} else {
-
 
862
		/* Read graph node */
-
 
863
		CLASS_TYPE ct = NULL_ctype;
-
 
864
		IGNORE load_ctype(bs, NULL_id, &ct);
-
 
865
		if (!IS_NULL_ctype(ct)) {
-
 
866
			DECL_SPEC acc = load_dspec(bs);
-
 
867
			MAKE_graph_basic(ct, acc, gr);
-
 
868
		} else {
839
	    SPEC_ERROR () ;
869
			SPEC_ERROR();
840
	    return ( NULL_graph ) ;
870
			return (NULL_graph);
-
 
871
		}
-
 
872
	}
-
 
873
	while (DE_BOOL(bs)) {
-
 
874
		/* Read base classes */
-
 
875
		GRAPH gs = load_graph(bs, gr, gt);
-
 
876
		if (IS_NULL_graph(gs)) {
-
 
877
			break;
-
 
878
		}
-
 
879
		CONS_graph(gs, br, br);
841
	}
880
	}
842
    }
-
 
843
    while ( DE_BOOL ( bs ) ) {
-
 
844
	/* Read base classes */
-
 
845
	GRAPH gs = load_graph ( bs, gr, gt ) ;
-
 
846
	if ( IS_NULL_graph ( gs ) ) break ;
-
 
847
	CONS_graph ( gs, br, br ) ;
-
 
848
    }
-
 
849
    br = REVERSE_list ( br ) ;
881
	br = REVERSE_list(br);
850
    COPY_list ( graph_tails ( gr ), br ) ;
882
	COPY_list(graph_tails(gr), br);
851
    COPY_graph ( graph_top ( gr ), gt ) ;
883
	COPY_graph(graph_top(gr), gt);
852
    COPY_graph ( graph_up ( gr ), gu ) ;
884
	COPY_graph(graph_up(gr), gu);
853
    return ( gr ) ;
885
	return (gr);
854
}
886
}
855
 
887
 
856
 
888
 
857
/*
889
/*
858
    READ A CLASS TYPE
890
    READ A CLASS TYPE
859
 
891
 
860
    This routine reads a class type from the bitstream bs.  If def is not
892
    This routine reads a class type from the bitstream bs.  If def is not
861
    null then the full class definition is read, otherwise just a use is
893
    null then the full class definition is read, otherwise just a use is
862
    read.
894
    read.
863
*/
895
*/
864
 
896
 
865
static TYPE load_ctype
897
static TYPE
866
    PROTO_N ( ( bs, def, pct ) )
-
 
867
    PROTO_T ( BITSTREAM *bs X IDENTIFIER def X CLASS_TYPE *pct )
898
load_ctype(BITSTREAM *bs, IDENTIFIER def, CLASS_TYPE *pct)
868
{
899
{
869
    TYPE t = NULL_type ;
900
	TYPE t = NULL_type;
870
    if ( !IS_NULL_id ( def ) ) {
901
	if (!IS_NULL_id(def)) {
871
	if ( IS_id_class_name ( def ) ) {
902
		if (IS_id_class_name(def)) {
872
	    /* Read class definition */
903
			/* Read class definition */
873
	    GRAPH gr ;
904
			GRAPH gr;
874
	    CLASS_TYPE ct ;
905
			CLASS_TYPE ct;
875
	    DECL_SPEC acc ;
906
			DECL_SPEC acc;
876
	    NAMESPACE mns ;
907
			NAMESPACE mns;
877
 
908
 
878
	    /* Read the class information */
909
			/* Read the class information */
879
	    CLASS_INFO ci = load_cinfo ( bs ) ;
910
			CLASS_INFO ci = load_cinfo(bs);
880
	    CLASS_USAGE cu = load_cusage ( bs ) ;
911
			CLASS_USAGE cu = load_cusage(bs);
881
 
912
 
882
	    /* Create the class type */
913
			/* Create the class type */
883
	    acc = ( dspec_public | dspec_defn ) ;
914
			acc = (dspec_public | dspec_defn);
884
	    MAKE_graph_basic ( NULL_ctype, acc, gr ) ;
915
			MAKE_graph_basic(NULL_ctype, acc, gr);
885
	    mns = make_namespace ( def, nspace_ctype_tag, 20 ) ;
916
			mns = make_namespace(def, nspace_ctype_tag, 20);
886
	    MAKE_ctype_basic ( def, ci, cu, mns, gr, 1, NULL_type, ct ) ;
917
			MAKE_ctype_basic(def, ci, cu, mns, gr, 1, NULL_type,
-
 
918
					 ct);
887
	    COPY_ctype ( graph_head ( gr ), ct ) ;
919
			COPY_ctype(graph_head(gr), ct);
888
	    MAKE_type_compound ( cv_none, ct, t ) ;
920
			MAKE_type_compound(cv_none, ct, t);
889
	    COPY_type ( id_class_name_defn ( def ), t ) ;
921
			COPY_type(id_class_name_defn(def), t);
890
	    COPY_id ( type_name ( t ), def ) ;
922
			COPY_id(type_name(t), def);
891
	    IGNORE lookup_constr ( t, def ) ;
923
			IGNORE lookup_constr(t, def);
892
	    IGNORE lookup_destr ( t, def ) ;
924
			IGNORE lookup_destr(t, def);
893
	    crt_class = ct ;
925
			crt_class = ct;
894
	    *pct = ct ;
926
			*pct = ct;
895
 
927
 
896
	    /* Read the base class graph */
928
			/* Read the base class graph */
897
	    IGNORE load_graph ( bs, NULL_graph, gr ) ;
929
			IGNORE load_graph(bs, NULL_graph, gr);
898
	    end_base_class ( ct, 1 ) ;
930
			end_base_class(ct, 1);
899
 
931
 
900
	    /* Read template form */
932
			/* Read template form */
901
	    if ( DE_BOOL ( bs ) ) {
933
			if (DE_BOOL(bs)) {
902
		TYPE form = load_type ( bs, NULL_id ) ;
934
				TYPE form = load_type(bs, NULL_id);
903
		COPY_type ( ctype_form ( ct ), form ) ;
935
				COPY_type(ctype_form(ct), form);
904
	    }
936
			}
905
 
937
 
906
	} else {
938
		} else {
907
	    SPEC_ERROR () ;
939
			SPEC_ERROR();
908
	}
940
		}
909
 
941
 
910
    } else {
942
	} else {
911
	/* Read class name */
943
		/* Read class name */
912
	IDENTIFIER cid = load_use ( bs, id_class_name_tag ) ;
944
		IDENTIFIER cid = load_use(bs, id_class_name_tag);
913
	if ( !IS_NULL_id ( cid ) ) {
945
		if (!IS_NULL_id(cid)) {
914
	    if ( IS_id_class_name ( cid ) ) {
946
			if (IS_id_class_name(cid)) {
915
		t = DEREF_type ( id_class_name_defn ( cid ) ) ;
947
				t = DEREF_type(id_class_name_defn(cid));
916
	    }
948
			}
917
	}
949
		}
918
	if ( !IS_NULL_type ( t ) ) {
950
		if (!IS_NULL_type(t)) {
919
	    while ( IS_type_templ ( t ) ) {
951
			while (IS_type_templ(t)) {
920
		t = DEREF_type ( type_templ_defn ( t ) ) ;
952
				t = DEREF_type(type_templ_defn(t));
921
	    }
953
			}
922
	    if ( IS_type_compound ( t ) ) {
954
			if (IS_type_compound(t)) {
-
 
955
				CLASS_TYPE ct =
923
		CLASS_TYPE ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
956
				    DEREF_ctype(type_compound_defn(t));
924
		*pct = ct ;
957
				*pct = ct;
925
	    } else {
958
			} else {
926
		t = NULL_type ;
959
				t = NULL_type;
927
		SPEC_ERROR () ;
960
				SPEC_ERROR();
928
	    }
961
			}
929
	} else {
962
		} else {
930
	    SPEC_ERROR () ;
963
			SPEC_ERROR();
931
	}
964
		}
932
    }
965
	}
933
    return ( t ) ;
966
	return (t);
934
}
967
}
935
 
968
 
936
 
969
 
937
/*
970
/*
938
    READ AN ENUMERATION TYPE
971
    READ AN ENUMERATION TYPE
939
 
972
 
940
    This routine reads an enumeration type from the bitstream bs.  If def
973
    This routine reads an enumeration type from the bitstream bs.  If def
941
    is not null then the full enumeration definition is read, otherwise
974
    is not null then the full enumeration definition is read, otherwise
942
    just a use is read.
975
    just a use is read.
943
*/
976
*/
944
 
977
 
945
static TYPE load_etype
978
static TYPE
946
    PROTO_N ( ( bs, def, pet ) )
-
 
947
    PROTO_T ( BITSTREAM *bs X IDENTIFIER def X ENUM_TYPE *pet )
979
load_etype(BITSTREAM *bs, IDENTIFIER def, ENUM_TYPE *pet)
948
{
980
{
949
    TYPE t = NULL_type ;
981
	TYPE t = NULL_type;
950
    if ( !IS_NULL_id ( def ) ) {
982
	if (!IS_NULL_id(def)) {
951
	if ( IS_id_enum_name ( def ) ) {
983
		if (IS_id_enum_name(def)) {
952
	    /* Read enumeration definition */
984
			/* Read enumeration definition */
953
	    ENUM_TYPE et ;
985
			ENUM_TYPE et;
954
	    CLASS_INFO ei = load_cinfo ( bs ) ;
986
			CLASS_INFO ei = load_cinfo(bs);
955
	    TYPE s = load_type ( bs, NULL_id ) ;
987
			TYPE s = load_type(bs, NULL_id);
956
	    if ( !IS_NULL_type ( s ) ) {
988
			if (!IS_NULL_type(s)) {
957
		MAKE_etype_basic ( def, ei, s, et ) ;
989
				MAKE_etype_basic(def, ei, s, et);
958
		if ( DE_BOOL ( bs ) ) {
990
				if (DE_BOOL(bs)) {
959
		    TYPE form = load_type ( bs, NULL_id ) ;
991
					TYPE form = load_type(bs, NULL_id);
960
		    COPY_type ( etype_form ( et ), form ) ;
992
					COPY_type(etype_form(et), form);
961
		}
993
				}
962
		MAKE_type_enumerate ( cv_none, et, t ) ;
994
				MAKE_type_enumerate(cv_none, et, t);
963
		COPY_type ( id_enum_name_defn ( def ), t ) ;
995
				COPY_type(id_enum_name_defn(def), t);
964
		COPY_id ( type_name ( t ), def ) ;
996
				COPY_id(type_name(t), def);
965
		*pet = et ;
997
				*pet = et;
966
	    } else {
998
			} else {
967
		SPEC_ERROR () ;
999
				SPEC_ERROR();
968
	    }
1000
			}
969
	} else {
1001
		} else {
970
	    SPEC_ERROR () ;
1002
			SPEC_ERROR();
971
	}
1003
		}
972
    } else {
1004
	} else {
973
	/* Read enumeration name */
1005
		/* Read enumeration name */
974
	IDENTIFIER eid = load_use ( bs, id_enum_name_tag ) ;
1006
		IDENTIFIER eid = load_use(bs, id_enum_name_tag);
975
	if ( !IS_NULL_id ( eid ) ) {
1007
		if (!IS_NULL_id(eid)) {
976
	    if ( IS_id_enum_name ( eid ) ) {
1008
			if (IS_id_enum_name(eid)) {
977
		t = DEREF_type ( id_enum_name_defn ( eid ) ) ;
1009
				t = DEREF_type(id_enum_name_defn(eid));
978
	    }
1010
			}
979
	}
1011
		}
980
	if ( !IS_NULL_type ( t ) && IS_type_enumerate ( t ) ) {
1012
		if (!IS_NULL_type(t) && IS_type_enumerate(t)) {
981
	    ENUM_TYPE et ;
1013
			ENUM_TYPE et;
982
	    et = DEREF_etype ( type_enumerate_defn ( t ) ) ;
1014
			et = DEREF_etype(type_enumerate_defn(t));
983
	    *pet = et ;
1015
			*pet = et;
984
	} else {
1016
		} else {
985
	    t = NULL_type ;
1017
			t = NULL_type;
986
	    SPEC_ERROR () ;
1018
			SPEC_ERROR();
987
	}
1019
		}
988
    }
1020
	}
989
    return ( t ) ;
1021
	return (t);
990
}
1022
}
991
 
1023
 
992
 
1024
 
993
/*
1025
/*
994
    READ A FUNCTION PARAMETER LIST
1026
    READ A FUNCTION PARAMETER LIST
995
 
1027
 
996
    This routine reads a list of function or template parameters (as
1028
    This routine reads a list of function or template parameters (as
997
    indicated by tag) from the bitstream bs into the namespace ns.
1029
    indicated by tag) from the bitstream bs into the namespace ns.
998
*/
1030
*/
999
 
1031
 
1000
static LIST ( IDENTIFIER ) load_param_list
1032
static LIST(IDENTIFIER)
1001
    PROTO_N ( ( bs, ns, tag ) )
-
 
1002
    PROTO_T ( BITSTREAM *bs X NAMESPACE ns X unsigned tag )
1033
load_param_list(BITSTREAM *bs, NAMESPACE ns, unsigned tag)
1003
{
-
 
1004
    LIST ( IDENTIFIER ) pids = NULL_list ( IDENTIFIER ) ;
-
 
1005
    while ( DE_BOOL ( bs ) ) {
-
 
1006
	HASHID nm ;
-
 
1007
	MEMBER mem ;
-
 
1008
	IDENTIFIER pid = load_id ( bs, ns ) ;
-
 
1009
	if ( IS_NULL_id ( pid ) || TAG_id ( pid ) != tag ) {
-
 
1010
	    SPEC_ERROR () ;
-
 
1011
	    break ;
-
 
1012
	}
-
 
1013
	nm = DEREF_hashid ( id_name ( pid ) ) ;
-
 
1014
	mem = search_member ( ns, nm, 1 ) ;
-
 
1015
	COPY_id ( member_id ( mem ), pid ) ;
-
 
1016
	CONS_id ( pid, pids, pids ) ;
-
 
1017
    }
-
 
1018
    pids = REVERSE_list ( pids ) ;
-
 
1019
    return ( pids ) ;
-
 
1020
}
-
 
1021
 
-
 
1022
 
-
 
1023
/*
-
 
1024
    READ A TYPE
-
 
1025
 
-
 
1026
    This routine reads a type from the bitstream bs.  def is passed to
-
 
1027
    load_ctype and load_etype.
-
 
1028
*/
-
 
1029
 
-
 
1030
static TYPE load_type
-
 
1031
    PROTO_N ( ( bs, def ) )
-
 
1032
    PROTO_T ( BITSTREAM *bs X IDENTIFIER def )
-
 
1033
{
1034
{
1034
    unsigned n ;
-
 
1035
    CV_SPEC cv ;
-
 
1036
    unsigned tag ;
-
 
1037
    TYPE t = NULL_type ;
-
 
1038
    if ( DE_BOOL ( bs ) ) {
-
 
1039
	/* Built-in types */
-
 
1040
	BUILTIN_TYPE nt ;
-
 
1041
	cv = load_cv ( bs ) ;
-
 
1042
	nt = load_ntype ( bs ) ;
-
 
1043
	t = type_builtin [ nt ] ;
-
 
1044
	if ( cv ) t = qualify_type ( t, cv, 0 ) ;
-
 
1045
	return ( t ) ;
-
 
1046
    }
-
 
1047
 
-
 
1048
    /* Read type independent fields */
-
 
1049
    n = DE_BITS ( bs, BITS_type ) ;
-
 
1050
    if ( n == 0 ) {
-
 
1051
	/* Null types */
-
 
1052
	return ( t ) ;
-
 
1053
    }
-
 
1054
    if ( n > ORDER_type ) {
-
 
1055
	SPEC_ERROR () ;
-
 
1056
	return ( NULL_type ) ;
-
 
1057
    }
-
 
1058
    tag = n - 1 ;
-
 
1059
    cv = load_cv ( bs ) ;
-
 
1060
 
-
 
1061
    /* Read type dependent fields */
-
 
1062
    ASSERT ( ORDER_type == 18 ) ;
-
 
1063
    switch ( tag ) {
-
 
1064
 
-
 
1065
	case type_pre_tag : {
-
 
1066
	    IDENTIFIER tid = load_use ( bs, null_tag ) ;
1035
	LIST(IDENTIFIER)pids = NULL_list(IDENTIFIER);
1067
	    QUALIFIER qual = load_qual ( bs ) ;
-
 
1068
	    BASE_TYPE bt = load_btype ( bs ) ;
-
 
1069
	    MAKE_type_pre ( cv, bt, qual, t ) ;
-
 
1070
	    COPY_id ( type_name ( t ), tid ) ;
-
 
1071
	    break ;
-
 
1072
	}
-
 
1073
 
-
 
1074
	case type_integer_tag : {
-
 
1075
	    t = load_itype ( bs, cv, tag ) ;
-
 
1076
	    if ( !IS_NULL_type ( t ) ) {
-
 
1077
		if ( DE_BOOL ( bs ) ) {
1036
	while (DE_BOOL(bs)) {
1078
		    TYPE s = load_itype ( bs, cv_none, tag ) ;
-
 
1079
		    if ( !IS_NULL_type ( s ) ) {
-
 
1080
			INT_TYPE it, is ;
-
 
1081
			it = DEREF_itype ( type_integer_rep ( t ) ) ;
-
 
1082
			is = DEREF_itype ( type_integer_rep ( s ) ) ;
-
 
1083
			t = make_itype ( it, is ) ;
-
 
1084
		    }
-
 
1085
		}
-
 
1086
		break ;
-
 
1087
	    }
-
 
1088
	    SPEC_ERROR () ;
-
 
1089
	    break ;
-
 
1090
	}
-
 
1091
 
-
 
1092
	case type_floating_tag : {
-
 
1093
	    t = load_ftype ( bs, cv ) ;
-
 
1094
	    break ;
-
 
1095
	}
-
 
1096
 
-
 
1097
	case type_top_tag :
-
 
1098
	case type_bottom_tag : {
-
 
1099
	    /* Should not happen */
-
 
1100
	    MAKE_type_top_etc ( tag, cv, t ) ;
-
 
1101
	    break ;
-
 
1102
	}
-
 
1103
 
-
 
1104
	case type_ptr_tag :
-
 
1105
	case type_ref_tag : {
-
 
1106
	    /* Pointer and reference types */
-
 
1107
	    TYPE s = load_type ( bs, NULL_id ) ;
-
 
1108
	    if ( !IS_NULL_type ( s ) ) {
-
 
1109
		MAKE_type_ptr_etc ( tag, cv, s, t ) ;
-
 
1110
		break ;
-
 
1111
	    }
-
 
1112
	    SPEC_ERROR () ;
-
 
1113
	    break ;
-
 
1114
	}
-
 
1115
 
-
 
1116
	case type_ptr_mem_tag : {
-
 
1117
	    /* Pointer to member types */
-
 
1118
	    CLASS_TYPE cs = NULL_ctype ;
-
 
1119
	    IGNORE load_ctype ( bs, NULL_id, &cs ) ;
-
 
1120
	    if ( !IS_NULL_ctype ( cs ) ) {
-
 
1121
		TYPE r = load_type ( bs, NULL_id ) ;
-
 
1122
		if ( !IS_NULL_type ( r ) ) {
-
 
1123
		    MAKE_type_ptr_mem ( cv, cs, r, t ) ;
-
 
1124
		    break ;
-
 
1125
		}
-
 
1126
	    }
-
 
1127
	    SPEC_ERROR () ;
-
 
1128
	    break ;
-
 
1129
	}
-
 
1130
 
-
 
1131
	case type_func_tag : {
-
 
1132
	    /* Function types */
-
 
1133
	    TYPE r = load_type ( bs, NULL_id ) ;
-
 
1134
	    if ( !IS_NULL_type ( r ) ) {
-
 
1135
		int ell ;
-
 
1136
		NAMESPACE pns ;
1037
		HASHID nm;
1137
		CV_SPEC mqual ;
1038
		MEMBER mem;
1138
		LIST ( IDENTIFIER ) pids ;
-
 
1139
		CLASS_TYPE cs = NULL_ctype ;
-
 
1140
		LIST ( TYPE ) ex = univ_type_set ;
-
 
1141
		begin_param ( NULL_id ) ;
-
 
1142
		pns = crt_namespace ;
-
 
1143
		pids = load_param_list ( bs, pns, id_parameter_tag ) ;
-
 
1144
		DESTROY_list ( pids, SIZE_id ) ;
1039
		IDENTIFIER pid = load_id(bs, ns);
1145
		ell = ( int ) DE_BITS ( bs, BITS_ellipsis ) ;
-
 
1146
		mqual = load_mqual ( bs ) ;
-
 
1147
		if ( DE_BOOL ( bs ) ) {
-
 
1148
		    /* Read member function type */
-
 
1149
		    IGNORE load_ctype ( bs, NULL_id, &cs ) ;
-
 
1150
		}
-
 
1151
		if ( DE_BOOL ( bs ) ) {
-
 
1152
		    /* Read exception specifier */
-
 
1153
		    ex = load_type_list ( bs ) ;
-
 
1154
		}
-
 
1155
		t = make_func_type ( r, ell, mqual, ex ) ;
-
 
1156
		end_param () ;
-
 
1157
		if ( !IS_NULL_ctype ( cs ) ) {
1040
		if (IS_NULL_id(pid) || TAG_id(pid) != tag) {
1158
		    member_func_type ( cs, id_mem_func_tag, t ) ;
-
 
1159
		}
-
 
1160
		break ;
-
 
1161
	    }
-
 
1162
	    SPEC_ERROR () ;
-
 
1163
	    break ;
-
 
1164
	}
-
 
1165
 
-
 
1166
	case type_array_tag : {
-
 
1167
	    /* Array types */
-
 
1168
	    TYPE s = load_type ( bs, NULL_id ) ;
-
 
1169
	    if ( !IS_NULL_type ( s ) ) {
-
 
1170
		NAT m = load_nat ( bs ) ;
-
 
1171
		MAKE_type_array ( cv, s, m, t ) ;
-
 
1172
		break ;
-
 
1173
	    }
-
 
1174
	    SPEC_ERROR () ;
-
 
1175
	    break ;
-
 
1176
	}
-
 
1177
 
-
 
1178
	case type_bitfield_tag : {
-
 
1179
	    /* Bitfield types */
-
 
1180
	    t = load_itype ( bs, cv, tag ) ;
-
 
1181
	    break ;
-
 
1182
	}
-
 
1183
 
-
 
1184
	case type_compound_tag : {
-
 
1185
	    /* Class types */
-
 
1186
	    CLASS_TYPE ct = NULL_ctype ;
-
 
1187
	    t = load_ctype ( bs, def, &ct ) ;
-
 
1188
	    if ( !IS_NULL_type ( t ) ) {
-
 
1189
		if ( cv ) t = qualify_type ( t, cv, 0 ) ;
-
 
1190
		break ;
-
 
1191
	    }
-
 
1192
	    SPEC_ERROR () ;
-
 
1193
	    break ;
-
 
1194
	}
-
 
1195
 
-
 
1196
	case type_enumerate_tag : {
-
 
1197
	    /* Enumeration types */
-
 
1198
	    ENUM_TYPE et = NULL_etype ;
-
 
1199
	    t = load_etype ( bs, def, &et ) ;
-
 
1200
	    if ( !IS_NULL_type ( t ) ) {
-
 
1201
		if ( cv ) t = qualify_type ( t, cv, 0 ) ;
-
 
1202
		break ;
-
 
1203
	    }
-
 
1204
	    SPEC_ERROR () ;
1041
			SPEC_ERROR();
1205
	    break ;
-
 
1206
	}
-
 
1207
 
-
 
1208
	case type_token_tag : {
-
 
1209
	    IDENTIFIER tok = load_use ( bs, null_tag ) ;
-
 
1210
	    if ( !IS_NULL_id ( tok ) ) {
-
 
1211
		LIST ( TOKEN ) args = load_tok_list ( bs, 1 ) ;
-
 
1212
		MAKE_type_token ( cv, tok, args, t ) ;
-
 
1213
		break ;
1042
			break;
1214
	    }
-
 
1215
	    SPEC_ERROR () ;
-
 
1216
	    break ;
-
 
1217
	}
-
 
1218
 
-
 
1219
	case type_templ_tag : {
-
 
1220
	    TOKEN tok = load_tok ( bs, 0 ) ;
-
 
1221
	    if ( !IS_NULL_tok ( tok ) && IS_tok_templ ( tok ) ) {
-
 
1222
		TYPE s = load_type ( bs, def ) ;
-
 
1223
		if ( !IS_NULL_type ( s ) ) {
-
 
1224
		    int fix = DE_BOOL ( bs ) ;
-
 
1225
		    MAKE_type_templ ( cv, tok, s, fix, t ) ;
-
 
1226
		    break ;
-
 
1227
		}
-
 
1228
	    }
-
 
1229
	    SPEC_ERROR () ;
-
 
1230
	    break ;
-
 
1231
	}
-
 
1232
 
-
 
1233
	case type_instance_tag : {
-
 
1234
	    IDENTIFIER tid = load_use ( bs, null_tag ) ;
-
 
1235
	    if ( !IS_NULL_id ( tid ) ) {
-
 
1236
		IDENTIFIER id = load_use ( bs, null_tag ) ;
-
 
1237
		if ( !IS_NULL_id ( id ) ) {
-
 
1238
		    DECL_SPEC acc = load_dspec ( bs ) ;
-
 
1239
		    MAKE_type_instance ( cv, id, acc, t ) ;
-
 
1240
		    COPY_id ( type_name ( t ), tid ) ;
-
 
1241
		    break ;
-
 
1242
		}
1043
		}
-
 
1044
		nm = DEREF_hashid(id_name(pid));
1243
	    }
1045
		mem = search_member(ns, nm, 1);
1244
	    SPEC_ERROR () ;
1046
		COPY_id(member_id(mem), pid);
1245
	    break ;
1047
		CONS_id(pid, pids, pids);
1246
	}
1048
	}
-
 
1049
	pids = REVERSE_list(pids);
-
 
1050
	return (pids);
-
 
1051
}
1247
 
1052
 
1248
	case type_dummy_tag : {
-
 
1249
	    int tok = ( int ) DE_INT ( bs ) ;
-
 
1250
	    MAKE_type_dummy ( cv, tok, t ) ;
-
 
1251
	    break ;
-
 
1252
	}
-
 
1253
 
1053
 
-
 
1054
/*
-
 
1055
    READ A TYPE
-
 
1056
 
-
 
1057
    This routine reads a type from the bitstream bs.  def is passed to
-
 
1058
    load_ctype and load_etype.
-
 
1059
*/
-
 
1060
 
-
 
1061
static TYPE
-
 
1062
load_type(BITSTREAM *bs, IDENTIFIER def)
-
 
1063
{
-
 
1064
	unsigned n;
-
 
1065
	CV_SPEC cv;
-
 
1066
	unsigned tag;
-
 
1067
	TYPE t = NULL_type;
-
 
1068
	if (DE_BOOL(bs)) {
-
 
1069
		/* Built-in types */
-
 
1070
		BUILTIN_TYPE nt;
-
 
1071
		cv = load_cv(bs);
-
 
1072
		nt = load_ntype(bs);
-
 
1073
		t = type_builtin[nt];
-
 
1074
		if (cv) {
-
 
1075
			t = qualify_type(t, cv, 0);
-
 
1076
		}
-
 
1077
		return (t);
-
 
1078
	}
-
 
1079
 
-
 
1080
	/* Read type independent fields */
-
 
1081
	n = DE_BITS(bs, BITS_type);
-
 
1082
	if (n == 0) {
-
 
1083
		/* Null types */
-
 
1084
		return (t);
-
 
1085
	}
-
 
1086
	if (n > ORDER_type) {
-
 
1087
		SPEC_ERROR();
-
 
1088
		return (NULL_type);
-
 
1089
	}
-
 
1090
	tag = n - 1;
-
 
1091
	cv = load_cv(bs);
-
 
1092
 
-
 
1093
	/* Read type dependent fields */
-
 
1094
	ASSERT(ORDER_type == 18);
-
 
1095
	switch (tag) {
-
 
1096
 
-
 
1097
	case type_pre_tag: {
-
 
1098
		IDENTIFIER tid = load_use(bs, null_tag);
-
 
1099
		QUALIFIER qual = load_qual(bs);
-
 
1100
		BASE_TYPE bt = load_btype(bs);
-
 
1101
		MAKE_type_pre(cv, bt, qual, t);
-
 
1102
		COPY_id(type_name(t), tid);
-
 
1103
		break;
-
 
1104
	}
-
 
1105
 
-
 
1106
	case type_integer_tag: {
-
 
1107
		t = load_itype(bs, cv, tag);
-
 
1108
		if (!IS_NULL_type(t)) {
-
 
1109
			if (DE_BOOL(bs)) {
-
 
1110
				TYPE s = load_itype(bs, cv_none, tag);
-
 
1111
				if (!IS_NULL_type(s)) {
-
 
1112
					INT_TYPE it, is;
-
 
1113
					it = DEREF_itype(type_integer_rep(t));
-
 
1114
					is = DEREF_itype(type_integer_rep(s));
-
 
1115
					t = make_itype(it, is);
-
 
1116
				}
-
 
1117
			}
-
 
1118
			break;
-
 
1119
		}
-
 
1120
		SPEC_ERROR();
-
 
1121
		break;
-
 
1122
	}
-
 
1123
 
-
 
1124
	case type_floating_tag: {
-
 
1125
		t = load_ftype(bs, cv);
-
 
1126
		break;
-
 
1127
	}
-
 
1128
 
-
 
1129
	case type_top_tag:
-
 
1130
	case type_bottom_tag: {
-
 
1131
		/* Should not happen */
-
 
1132
		MAKE_type_top_etc(tag, cv, t);
-
 
1133
		break;
-
 
1134
	}
-
 
1135
 
-
 
1136
	case type_ptr_tag:
-
 
1137
	case type_ref_tag: {
-
 
1138
		/* Pointer and reference types */
-
 
1139
		TYPE s = load_type(bs, NULL_id);
-
 
1140
		if (!IS_NULL_type(s)) {
-
 
1141
			MAKE_type_ptr_etc(tag, cv, s, t);
-
 
1142
			break;
-
 
1143
		}
-
 
1144
		SPEC_ERROR();
-
 
1145
		break;
-
 
1146
	}
-
 
1147
 
-
 
1148
	case type_ptr_mem_tag: {
-
 
1149
		/* Pointer to member types */
-
 
1150
		CLASS_TYPE cs = NULL_ctype;
-
 
1151
		IGNORE load_ctype(bs, NULL_id, &cs);
-
 
1152
		if (!IS_NULL_ctype(cs)) {
-
 
1153
			TYPE r = load_type(bs, NULL_id);
-
 
1154
			if (!IS_NULL_type(r)) {
-
 
1155
				MAKE_type_ptr_mem(cv, cs, r, t);
-
 
1156
				break;
-
 
1157
			}
-
 
1158
		}
-
 
1159
		SPEC_ERROR();
-
 
1160
		break;
-
 
1161
	}
-
 
1162
 
-
 
1163
	case type_func_tag: {
-
 
1164
		/* Function types */
-
 
1165
		TYPE r = load_type(bs, NULL_id);
-
 
1166
		if (!IS_NULL_type(r)) {
-
 
1167
			int ell;
-
 
1168
			NAMESPACE pns;
-
 
1169
			CV_SPEC mqual;
-
 
1170
			LIST(IDENTIFIER)pids;
-
 
1171
			CLASS_TYPE cs = NULL_ctype;
-
 
1172
			LIST(TYPE)ex = univ_type_set;
-
 
1173
			begin_param(NULL_id);
-
 
1174
			pns = crt_namespace;
-
 
1175
			pids = load_param_list(bs, pns, id_parameter_tag);
-
 
1176
			DESTROY_list(pids, SIZE_id);
-
 
1177
			ell = (int)DE_BITS(bs, BITS_ellipsis);
-
 
1178
			mqual = load_mqual(bs);
-
 
1179
			if (DE_BOOL(bs)) {
-
 
1180
				/* Read member function type */
-
 
1181
				IGNORE load_ctype(bs, NULL_id, &cs);
-
 
1182
			}
-
 
1183
			if (DE_BOOL(bs)) {
-
 
1184
				/* Read exception specifier */
-
 
1185
				ex = load_type_list(bs);
-
 
1186
			}
-
 
1187
			t = make_func_type(r, ell, mqual, ex);
-
 
1188
			end_param();
-
 
1189
			if (!IS_NULL_ctype(cs)) {
-
 
1190
				member_func_type(cs, id_mem_func_tag, t);
-
 
1191
			}
-
 
1192
			break;
-
 
1193
		}
-
 
1194
		SPEC_ERROR();
-
 
1195
		break;
-
 
1196
	}
-
 
1197
 
-
 
1198
	case type_array_tag: {
-
 
1199
		/* Array types */
-
 
1200
		TYPE s = load_type(bs, NULL_id);
-
 
1201
		if (!IS_NULL_type(s)) {
-
 
1202
			NAT m = load_nat(bs);
-
 
1203
			MAKE_type_array(cv, s, m, t);
-
 
1204
			break;
-
 
1205
		}
-
 
1206
		SPEC_ERROR();
-
 
1207
		break;
-
 
1208
	}
-
 
1209
 
-
 
1210
	case type_bitfield_tag: {
-
 
1211
		/* Bitfield types */
-
 
1212
		t = load_itype(bs, cv, tag);
-
 
1213
		break;
-
 
1214
	}
-
 
1215
 
-
 
1216
	case type_compound_tag: {
-
 
1217
		/* Class types */
-
 
1218
		CLASS_TYPE ct = NULL_ctype;
-
 
1219
		t = load_ctype(bs, def, &ct);
-
 
1220
		if (!IS_NULL_type(t)) {
-
 
1221
			if (cv)t = qualify_type(t, cv, 0);
-
 
1222
			break;
-
 
1223
		}
-
 
1224
		SPEC_ERROR();
-
 
1225
		break;
-
 
1226
	}
-
 
1227
 
-
 
1228
	case type_enumerate_tag: {
-
 
1229
		/* Enumeration types */
-
 
1230
		ENUM_TYPE et = NULL_etype;
-
 
1231
		t = load_etype(bs, def, &et);
-
 
1232
		if (!IS_NULL_type(t)) {
-
 
1233
			if (cv)t = qualify_type(t, cv, 0);
-
 
1234
			break;
-
 
1235
		}
-
 
1236
		SPEC_ERROR();
-
 
1237
		break;
-
 
1238
	}
-
 
1239
 
-
 
1240
	case type_token_tag: {
-
 
1241
		IDENTIFIER tok = load_use(bs, null_tag);
-
 
1242
		if (!IS_NULL_id(tok)) {
-
 
1243
			LIST(TOKEN)args = load_tok_list(bs, 1);
-
 
1244
			MAKE_type_token(cv, tok, args, t);
-
 
1245
			break;
-
 
1246
		}
-
 
1247
		SPEC_ERROR();
-
 
1248
		break;
-
 
1249
	}
-
 
1250
 
-
 
1251
	case type_templ_tag: {
-
 
1252
		TOKEN tok = load_tok(bs, 0);
-
 
1253
		if (!IS_NULL_tok(tok) && IS_tok_templ(tok)) {
-
 
1254
			TYPE s = load_type(bs, def);
-
 
1255
			if (!IS_NULL_type(s)) {
-
 
1256
				int fix = DE_BOOL(bs);
-
 
1257
				MAKE_type_templ(cv, tok, s, fix, t);
-
 
1258
				break;
-
 
1259
			}
-
 
1260
		}
-
 
1261
		SPEC_ERROR();
-
 
1262
		break;
-
 
1263
	}
-
 
1264
 
-
 
1265
	case type_instance_tag: {
-
 
1266
		IDENTIFIER tid = load_use(bs, null_tag);
-
 
1267
		if (!IS_NULL_id(tid)) {
-
 
1268
			IDENTIFIER id = load_use(bs, null_tag);
-
 
1269
			if (!IS_NULL_id(id)) {
-
 
1270
				DECL_SPEC acc = load_dspec(bs);
-
 
1271
				MAKE_type_instance(cv, id, acc, t);
-
 
1272
				COPY_id(type_name(t), tid);
-
 
1273
				break;
-
 
1274
			}
-
 
1275
		}
-
 
1276
		SPEC_ERROR();
-
 
1277
		break;
-
 
1278
	}
-
 
1279
 
-
 
1280
	case type_dummy_tag: {
-
 
1281
		int tok = (int)DE_INT(bs);
-
 
1282
		MAKE_type_dummy(cv, tok, t);
-
 
1283
		break;
-
 
1284
	}
-
 
1285
 
1254
	case type_error_tag : {
1286
	case type_error_tag: {
1255
	    t = type_error ;
1287
		t = type_error;
1256
	    if ( cv ) t = qualify_type ( t, cv, 0 ) ;
1288
		if (cv)t = qualify_type(t, cv, 0);
1257
	    break ;
1289
		break;
-
 
1290
	}
1258
	}
1291
	}
1259
    }
-
 
1260
    return ( t ) ;
1292
	return (t);
1261
}
1293
}
1262
 
1294
 
1263
 
1295
 
1264
/*
1296
/*
1265
    READ A LIST OF TYPES
1297
    READ A LIST OF TYPES
1266
 
1298
 
1267
    This routine reads a list of types from the bitstream bs.
1299
    This routine reads a list of types from the bitstream bs.
1268
*/
1300
*/
1269
 
1301
 
1270
static LIST ( TYPE ) load_type_list
1302
static LIST(TYPE)
1271
    PROTO_N ( ( bs ) )
-
 
1272
    PROTO_T ( BITSTREAM *bs )
1303
load_type_list(BITSTREAM *bs)
1273
{
1304
{
1274
    LIST ( TYPE ) p = NULL_list ( TYPE ) ;
1305
	LIST(TYPE)p = NULL_list(TYPE);
1275
    while ( DE_BOOL ( bs ) ) {
1306
	while (DE_BOOL(bs)) {
1276
	TYPE t = load_type ( bs, NULL_id ) ;
1307
		TYPE t = load_type(bs, NULL_id);
1277
	if ( spec_error ) break ;
1308
		if (spec_error) {
-
 
1309
			break;
-
 
1310
		}
1278
	CONS_type ( t, p, p ) ;
1311
		CONS_type(t, p, p);
1279
    }
1312
	}
1280
    p = REVERSE_list ( p ) ;
1313
	p = REVERSE_list(p);
1281
    return ( p ) ;
1314
	return (p);
1282
}
1315
}
1283
 
1316
 
1284
 
1317
 
1285
/*
1318
/*
1286
    READ A TOKEN
1319
    READ A TOKEN
1287
 
1320
 
1288
    This routine reads a token from the bitstream bs.  If def is true
1321
    This routine reads a token from the bitstream bs.  If def is true
1289
    then the token value is also read.
1322
    then the token value is also read.
1290
*/
1323
*/
1291
 
1324
 
1292
static TOKEN load_tok
1325
static TOKEN
1293
    PROTO_N ( ( bs, def ) )
-
 
1294
    PROTO_T ( BITSTREAM *bs X int def )
1326
load_tok(BITSTREAM *bs, int def)
1295
{
1327
{
1296
    unsigned tag ;
1328
	unsigned tag;
1297
    TOKEN tok = NULL_tok ;
1329
	TOKEN tok = NULL_tok;
1298
    unsigned n = DE_BITS ( bs, BITS_tok ) ;
1330
	unsigned n = DE_BITS(bs, BITS_tok);
1299
    if ( n == 0 ) {
1331
	if (n == 0) {
1300
	return ( tok ) ;
-
 
1301
    }
-
 
1302
    if ( n > ORDER_tok ) {
-
 
1303
	SPEC_ERROR () ;
-
 
1304
	return ( tok ) ;
1332
		return (tok);
1305
    }
-
 
1306
    ASSERT ( ORDER_tok == 10 ) ;
-
 
1307
    tag = n - 1 ;
-
 
1308
    switch ( tag ) {
-
 
1309
	case tok_exp_tag : {
-
 
1310
	    TYPE t = load_type ( bs, NULL_id ) ;
-
 
1311
	    if ( !IS_NULL_type ( t ) ) {
-
 
1312
		EXP e = NULL_exp ;
-
 
1313
		int c = DE_BOOL ( bs ) ;
-
 
1314
		if ( def ) e = load_exp ( bs, t ) ;
-
 
1315
		MAKE_tok_exp ( t, c, e, tok ) ;
-
 
1316
		break ;
-
 
1317
	    }
-
 
1318
	    SPEC_ERROR () ;
-
 
1319
	    break ;
-
 
1320
	}
-
 
1321
	case tok_stmt_tag : {
-
 
1322
	    EXP e = NULL_exp ;
-
 
1323
	    if ( def ) e = load_exp ( bs, type_void ) ;
-
 
1324
	    MAKE_tok_stmt ( e, tok ) ;
-
 
1325
	    break ;
-
 
1326
	}
-
 
1327
	case tok_nat_tag :
-
 
1328
	case tok_snat_tag : {
-
 
1329
	    NAT m = NULL_nat ;
-
 
1330
	    if ( def ) m = load_nat ( bs ) ;
-
 
1331
	    MAKE_tok_nat_etc ( tag, m, tok ) ;
-
 
1332
	    break ;
-
 
1333
	}
-
 
1334
	case tok_type_tag : {
-
 
1335
	    BASE_TYPE kind = load_btype ( bs ) ;
-
 
1336
	    TYPE s = load_type ( bs, NULL_id ) ;
-
 
1337
	    TYPE t = NULL_type ;
-
 
1338
	    if ( def ) t = load_type ( bs, NULL_id ) ;
-
 
1339
	    MAKE_tok_type ( kind, t, tok ) ;
-
 
1340
	    COPY_type ( tok_type_alt ( tok ), s ) ;
-
 
1341
	    break ;
-
 
1342
	}
-
 
1343
	case tok_func_tag : {
-
 
1344
	    TYPE t = load_type ( bs, NULL_id ) ;
-
 
1345
	    if ( !IS_NULL_type ( t ) && IS_type_func ( t ) ) {
-
 
1346
		TOKEN proc = load_tok ( bs, 0 ) ;
-
 
1347
		IDENTIFIER id = NULL_id ;
-
 
1348
		if ( def ) id = load_use ( bs, null_tag ) ;
-
 
1349
		MAKE_tok_func ( t, tok ) ;
-
 
1350
		COPY_tok ( tok_func_proc ( tok ), proc ) ;
-
 
1351
		COPY_id ( tok_func_defn ( tok ), id ) ;
-
 
1352
		break ;
-
 
1353
	    }
-
 
1354
	    SPEC_ERROR () ;
-
 
1355
	    break ;
-
 
1356
	}
-
 
1357
	case tok_member_tag : {
-
 
1358
	    TYPE s = load_type ( bs, NULL_id ) ;
-
 
1359
	    if ( !IS_NULL_type ( s ) ) {
-
 
1360
		TYPE t = load_type ( bs, NULL_id ) ;
-
 
1361
		if ( !IS_NULL_type ( t ) ) {
-
 
1362
		    OFFSET off = NULL_off ;
-
 
1363
		    if ( def ) off = load_off ( bs ) ;
-
 
1364
		    MAKE_tok_member ( s, t, off, tok ) ;
-
 
1365
		    break ;
-
 
1366
		}
-
 
1367
	    }
-
 
1368
	    SPEC_ERROR () ;
-
 
1369
	    break ;
-
 
1370
	}
-
 
1371
	case tok_class_tag : {
-
 
1372
	    TYPE t = load_type ( bs, NULL_id ) ;
-
 
1373
	    if ( !IS_NULL_type ( t ) ) {
-
 
1374
		TYPE s = load_type ( bs, NULL_id ) ;
-
 
1375
		IDENTIFIER id = NULL_id ;
-
 
1376
		if ( def ) id = load_use ( bs, null_tag ) ;
-
 
1377
		MAKE_tok_class ( t, id, tok ) ;
-
 
1378
		COPY_type ( tok_class_alt ( tok ), s ) ;
-
 
1379
		break ;
-
 
1380
	    }
-
 
1381
	    SPEC_ERROR () ;
-
 
1382
	    break ;
-
 
1383
	}
1333
	}
-
 
1334
	if (n > ORDER_tok) {
-
 
1335
		SPEC_ERROR();
-
 
1336
		return (tok);
-
 
1337
	}
-
 
1338
	ASSERT(ORDER_tok == 10);
-
 
1339
	tag = n - 1;
-
 
1340
	switch (tag) {
-
 
1341
	case tok_exp_tag: {
-
 
1342
		TYPE t = load_type(bs, NULL_id);
-
 
1343
		if (!IS_NULL_type(t)) {
-
 
1344
			EXP e = NULL_exp;
-
 
1345
			int c = DE_BOOL(bs);
-
 
1346
			if (def) {
-
 
1347
				e = load_exp(bs, t);
-
 
1348
			}
-
 
1349
			MAKE_tok_exp(t, c, e, tok);
-
 
1350
			break;
-
 
1351
		}
-
 
1352
		SPEC_ERROR();
-
 
1353
		break;
-
 
1354
	}
-
 
1355
	case tok_stmt_tag: {
-
 
1356
		EXP e = NULL_exp;
-
 
1357
		if (def) {
-
 
1358
			e = load_exp(bs, type_void);
-
 
1359
		}
-
 
1360
		MAKE_tok_stmt(e, tok);
-
 
1361
		break;
-
 
1362
	}
-
 
1363
	case tok_nat_tag:
-
 
1364
	case tok_snat_tag: {
-
 
1365
		NAT m = NULL_nat;
-
 
1366
		if (def) {
-
 
1367
			m = load_nat(bs);
-
 
1368
		}
-
 
1369
		MAKE_tok_nat_etc(tag, m, tok);
-
 
1370
		break;
-
 
1371
	}
-
 
1372
	case tok_type_tag: {
-
 
1373
		BASE_TYPE kind = load_btype(bs);
-
 
1374
		TYPE s = load_type(bs, NULL_id);
-
 
1375
		TYPE t = NULL_type;
-
 
1376
		if (def) {
-
 
1377
			t = load_type(bs, NULL_id);
-
 
1378
		}
-
 
1379
		MAKE_tok_type(kind, t, tok);
-
 
1380
		COPY_type(tok_type_alt(tok), s);
-
 
1381
		break;
-
 
1382
	}
-
 
1383
	case tok_func_tag: {
-
 
1384
		TYPE t = load_type(bs, NULL_id);
-
 
1385
		if (!IS_NULL_type(t) && IS_type_func(t)) {
-
 
1386
			TOKEN proc = load_tok(bs, 0);
-
 
1387
			IDENTIFIER id = NULL_id;
-
 
1388
			if (def) {
-
 
1389
				id = load_use(bs, null_tag);
-
 
1390
			}
-
 
1391
			MAKE_tok_func(t, tok);
-
 
1392
			COPY_tok(tok_func_proc(tok), proc);
-
 
1393
			COPY_id(tok_func_defn(tok), id);
-
 
1394
			break;
-
 
1395
		}
-
 
1396
		SPEC_ERROR();
-
 
1397
		break;
-
 
1398
	}
-
 
1399
	case tok_member_tag: {
-
 
1400
		TYPE s = load_type(bs, NULL_id);
-
 
1401
		if (!IS_NULL_type(s)) {
-
 
1402
			TYPE t = load_type(bs, NULL_id);
-
 
1403
			if (!IS_NULL_type(t)) {
-
 
1404
				OFFSET off = NULL_off;
-
 
1405
				if (def) {
-
 
1406
					off = load_off(bs);
-
 
1407
				}
-
 
1408
				MAKE_tok_member(s, t, off, tok);
-
 
1409
				break;
-
 
1410
			}
-
 
1411
		}
-
 
1412
		SPEC_ERROR();
-
 
1413
		break;
-
 
1414
	}
-
 
1415
	case tok_class_tag: {
-
 
1416
		TYPE t = load_type(bs, NULL_id);
-
 
1417
		if (!IS_NULL_type(t)) {
-
 
1418
			TYPE s = load_type(bs, NULL_id);
-
 
1419
			IDENTIFIER id = NULL_id;
-
 
1420
			if (def) {
-
 
1421
				id = load_use(bs, null_tag);
-
 
1422
			}
-
 
1423
			MAKE_tok_class(t, id, tok);
-
 
1424
			COPY_type(tok_class_alt(tok), s);
-
 
1425
			break;
-
 
1426
		}
-
 
1427
		SPEC_ERROR();
-
 
1428
		break;
-
 
1429
	}
1384
	case tok_proc_tag : {
1430
	case tok_proc_tag: {
1385
	    TOKEN res ;
1431
		TOKEN res;
1386
	    NAMESPACE pns ;
1432
		NAMESPACE pns;
1387
	    int key = lex_identifier ;
1433
		int key = lex_identifier;
1388
	    LIST ( IDENTIFIER ) bids ;
1434
		LIST(IDENTIFIER)bids;
1389
	    LIST ( IDENTIFIER ) pids ;
1435
		LIST(IDENTIFIER)pids;
1390
	    begin_param ( NULL_id ) ;
1436
		begin_param(NULL_id);
1391
	    pns = crt_namespace ;
1437
		pns = crt_namespace;
1392
	    bids = load_param_list ( bs, pns, id_token_tag ) ;
1438
		bids = load_param_list(bs, pns, id_token_tag);
1393
	    if ( DE_BOOL ( bs ) ) {
1439
		if (DE_BOOL(bs)) {
1394
		pids = bids ;
1440
			pids = bids;
1395
	    } else {
1441
		} else {
1396
		pids = load_use_list ( bs ) ;
1442
			pids = load_use_list(bs);
1397
	    }
1443
		}
1398
	    end_param () ;
1444
		end_param();
1399
	    res = load_tok ( bs, def ) ;
1445
		res = load_tok(bs, def);
-
 
1446
		if (DE_BOOL(bs)) {
1400
	    if ( DE_BOOL ( bs ) ) key = load_lex ( bs ) ;
1447
			key = load_lex(bs);
-
 
1448
		}
1401
	    if ( !IS_NULL_tok ( res ) ) {
1449
		if (!IS_NULL_tok(res)) {
1402
		MAKE_tok_proc ( res, pns, key, tok ) ;
1450
			MAKE_tok_proc(res, pns, key, tok);
1403
		tok = cont_proc_token ( tok, bids, pids ) ;
1451
			tok = cont_proc_token(tok, bids, pids);
1404
	    } else {
1452
		} else {
1405
		SPEC_ERROR () ;
1453
			SPEC_ERROR();
-
 
1454
		}
-
 
1455
		break;
-
 
1456
	}
-
 
1457
	case tok_templ_tag: {
-
 
1458
		DECL_SPEC ex = load_dspec(bs);
-
 
1459
		if (DE_BOOL(bs)) {
-
 
1460
			NAMESPACE pns;
-
 
1461
			LIST(TOKEN)dargs;
-
 
1462
			LIST(IDENTIFIER)pids;
-
 
1463
			pns = make_namespace(NULL_id, nspace_templ_tag, 0);
-
 
1464
			pids = load_param_list(bs, pns, id_token_tag);
-
 
1465
			set_proc_token(pids);
-
 
1466
			dargs = load_tok_list(bs, 1);
-
 
1467
			MAKE_tok_templ(ex, pns, tok);
-
 
1468
			COPY_list(tok_templ_pids(tok), pids);
-
 
1469
			COPY_list(tok_templ_dargs(tok), dargs);
-
 
1470
		} else {
-
 
1471
			MAKE_tok_templ(ex, NULL_nspace, tok);
1406
	    }
1472
		}
1407
	    break ;
1473
		break;
1408
	}
1474
	}
1409
	case tok_templ_tag : {
-
 
1410
	    DECL_SPEC ex = load_dspec ( bs ) ;
-
 
1411
	    if ( DE_BOOL ( bs ) ) {
-
 
1412
		NAMESPACE pns ;
-
 
1413
		LIST ( TOKEN ) dargs ;
-
 
1414
		LIST ( IDENTIFIER ) pids ;
-
 
1415
		pns = make_namespace ( NULL_id, nspace_templ_tag, 0 ) ;
-
 
1416
		pids = load_param_list ( bs, pns, id_token_tag ) ;
-
 
1417
		set_proc_token ( pids ) ;
-
 
1418
		dargs = load_tok_list ( bs, 1 ) ;
-
 
1419
		MAKE_tok_templ ( ex, pns, tok ) ;
-
 
1420
		COPY_list ( tok_templ_pids ( tok ), pids ) ;
-
 
1421
		COPY_list ( tok_templ_dargs ( tok ), dargs ) ;
-
 
1422
	    } else {
-
 
1423
		MAKE_tok_templ ( ex, NULL_nspace, tok ) ;
-
 
1424
	    }
-
 
1425
	    break ;
-
 
1426
	}
1475
	}
1427
    }
-
 
1428
    return ( tok ) ;
1476
	return (tok);
1429
}
1477
}
1430
 
1478
 
1431
 
1479
 
1432
/*
1480
/*
1433
    READ AN IDENTIFIER
1481
    READ AN IDENTIFIER
1434
 
1482
 
1435
    This routine reads a member of the namespace ns from the bitstream bs.
1483
    This routine reads a member of the namespace ns from the bitstream bs.
1436
*/
1484
*/
1437
 
1485
 
1438
static IDENTIFIER load_id
1486
static IDENTIFIER
1439
    PROTO_N ( ( bs, ns ) )
-
 
1440
    PROTO_T ( BITSTREAM *bs X NAMESPACE ns )
1487
load_id(BITSTREAM *bs, NAMESPACE ns)
1441
{
-
 
1442
    ulong d ;
-
 
1443
    HASHID nm ;
-
 
1444
    unsigned n ;
-
 
1445
    unsigned tag ;
-
 
1446
    DECL_SPEC ds ;
-
 
1447
    IDENTIFIER qid ;
-
 
1448
    IDENTIFIER *pid ;
-
 
1449
    IDENTIFIER id = NULL_id ;
-
 
1450
    IDENTIFIER lid = NULL_id ;
-
 
1451
 
-
 
1452
    /* Read identifier number */
-
 
1453
    d = DE_INT ( bs ) ;
-
 
1454
    if ( d == 0 ) {
-
 
1455
	/* Null identifiers */
-
 
1456
	return ( id ) ;
-
 
1457
    }
-
 
1458
 
-
 
1459
    /* Read identifier tag */
-
 
1460
    n = DE_BITS ( bs, BITS_id ) ;
-
 
1461
    if ( n == 0 ) {
-
 
1462
	/* Null identifiers */
-
 
1463
	return ( id ) ;
-
 
1464
    }
-
 
1465
    if ( n > ORDER_id ) {
-
 
1466
	SPEC_ERROR () ;
-
 
1467
	return ( id ) ;
-
 
1468
    }
-
 
1469
 
-
 
1470
    /* Check previous look-up */
-
 
1471
    pid = id_lookup ( d ) ;
-
 
1472
    qid = *pid ;
-
 
1473
    if ( !IS_NULL_id ( qid ) ) {
-
 
1474
	if ( !IS_id_pending ( qid ) ) {
-
 
1475
	    SPEC_ERROR () ;
-
 
1476
	    qid = NULL_id ;
-
 
1477
	}
-
 
1478
    }
-
 
1479
 
-
 
1480
    /* Read identifier independent information */
-
 
1481
    nm = load_hashid ( bs, ns ) ;
-
 
1482
    if ( IS_NULL_hashid ( nm ) ) {
-
 
1483
	SPEC_ERROR () ;
-
 
1484
	return ( id ) ;
-
 
1485
    }
-
 
1486
    tag = n - 1 ;
-
 
1487
    ds = load_dspec ( bs ) ;
-
 
1488
    load_loc ( bs ) ;
-
 
1489
    if ( DE_BOOL ( bs ) ) {
-
 
1490
	/* Read alias */
-
 
1491
	lid = load_use ( bs, tag ) ;
-
 
1492
    }
-
 
1493
 
-
 
1494
    /* Read identifier dependent information */
-
 
1495
    ASSERT ( ORDER_id == 28 ) ;
-
 
1496
    switch ( tag ) {
-
 
1497
 
-
 
1498
	case id_dummy_tag : {
-
 
1499
	    id = DEREF_id ( hashid_id ( nm ) ) ;
-
 
1500
	    id = underlying_id ( id ) ;
-
 
1501
	    break ;
-
 
1502
	}
-
 
1503
 
-
 
1504
	case id_keyword_tag :
-
 
1505
	case id_iso_keyword_tag :
-
 
1506
	case id_reserved_tag : {
-
 
1507
	    int key = load_lex ( bs ) ;
-
 
1508
	    id = make_keyword ( nm, key, NULL_id ) ;
-
 
1509
	    break ;
-
 
1510
	}
-
 
1511
 
-
 
1512
	case id_builtin_tag : {
-
 
1513
	    TYPE r = load_type ( bs, NULL_id ) ;
-
 
1514
	    if ( !IS_NULL_type ( r ) ) {
-
 
1515
		LIST ( TYPE ) p = load_type_list ( bs ) ;
-
 
1516
		MAKE_id_builtin ( nm, ds, ns, crt_loc, r, p, id ) ;
-
 
1517
		break ;
-
 
1518
	    }
-
 
1519
	    SPEC_ERROR () ;
-
 
1520
	    break ;
-
 
1521
	}
-
 
1522
 
-
 
1523
	case id_obj_macro_tag : {
-
 
1524
	    PPTOKEN *def = load_pptoks ( bs ) ;
-
 
1525
	    MAKE_id_obj_macro ( nm, ds, ns, crt_loc, def, id ) ;
-
 
1526
	    break ;
-
 
1527
	}
-
 
1528
 
-
 
1529
	case id_func_macro_tag : {
-
 
1530
	    PPTOKEN *def = load_pptoks ( bs ) ;
-
 
1531
	    LIST ( HASHID ) pars = load_hashid_list ( bs, NULL_nspace ) ;
-
 
1532
	    unsigned npars = LENGTH_list ( pars ) ;
-
 
1533
	    MAKE_id_func_macro ( nm, ds, ns, crt_loc, def, pars, npars, id ) ;
-
 
1534
	    break ;
-
 
1535
	}
-
 
1536
 
-
 
1537
	case id_predicate_tag : {
-
 
1538
	    /* NOT YET IMPLEMENTED */
-
 
1539
	    MAKE_id_undef ( nm, ds, ns, crt_loc, id ) ;
-
 
1540
	    break ;
-
 
1541
	}
-
 
1542
 
-
 
1543
	case id_class_name_tag : {
-
 
1544
	    /* Class names */
-
 
1545
	    TYPE t = type_error ;
-
 
1546
	    MAKE_id_class_name ( nm, ds, ns, crt_loc, t, id ) ;
-
 
1547
	    if ( ds & dspec_implicit ) {
-
 
1548
		if ( !IS_NULL_id ( lid ) && IS_id_class_name ( lid ) ) {
-
 
1549
		    t = DEREF_type ( id_class_name_defn ( lid ) ) ;
-
 
1550
		}
-
 
1551
	    } else {
-
 
1552
		*pid = id ;
-
 
1553
		t = load_type ( bs, id ) ;
-
 
1554
	    }
-
 
1555
	    if ( type_tag ( t ) == type_compound_tag ) {
-
 
1556
		COPY_type ( id_class_name_defn ( id ), t ) ;
-
 
1557
		break ;
-
 
1558
	    }
-
 
1559
	    SPEC_ERROR () ;
-
 
1560
	    break ;
-
 
1561
	}
-
 
1562
 
-
 
1563
	case id_enum_name_tag : {
-
 
1564
	    /* Enumeration names */
-
 
1565
	    TYPE t = type_error ;
-
 
1566
	    MAKE_id_enum_name ( nm, ds, ns, crt_loc, t, id ) ;
-
 
1567
	    t = load_type ( bs, id ) ;
-
 
1568
	    if ( type_tag ( t ) == type_enumerate_tag ) {
-
 
1569
		COPY_type ( id_enum_name_defn ( id ), t ) ;
-
 
1570
		break ;
-
 
1571
	    }
-
 
1572
	    SPEC_ERROR () ;
-
 
1573
	    break ;
-
 
1574
	}
-
 
1575
 
-
 
1576
	case id_class_alias_tag :
-
 
1577
	case id_enum_alias_tag :
-
 
1578
	case id_type_alias_tag : {
-
 
1579
	    /* Type aliases */
-
 
1580
	    TYPE t = load_type ( bs, NULL_id ) ;
-
 
1581
	    if ( !IS_NULL_type ( t ) ) {
-
 
1582
		id = make_typedef ( ns, nm, t, ds ) ;
-
 
1583
		if ( TAG_id ( id ) != tag ) SPEC_ERROR () ;
-
 
1584
		break ;
-
 
1585
	    }
-
 
1586
	    SPEC_ERROR () ;
-
 
1587
	    break ;
-
 
1588
	}
-
 
1589
 
-
 
1590
	case id_nspace_name_tag : {
-
 
1591
	    /* Namespace names */
-
 
1592
	    NAMESPACE pns = NULL_nspace ;
-
 
1593
	    unsigned ntag = nspace_named_tag ;
-
 
1594
	    if ( IS_hashid_anon ( nm ) ) ntag = nspace_unnamed_tag ;
-
 
1595
	    MAKE_id_nspace_name ( nm, ds, ns, crt_loc, pns, id ) ;
-
 
1596
	    pns = make_namespace ( id, ntag, 50 ) ;
-
 
1597
	    COPY_nspace ( id_nspace_name_defn ( id ), pns ) ;
-
 
1598
	    break ;
-
 
1599
	}
-
 
1600
 
-
 
1601
	case id_nspace_alias_tag : {
-
 
1602
	    /* Namespace aliases */
-
 
1603
	    IDENTIFIER nid = load_use ( bs, id_nspace_name_tag ) ;
-
 
1604
	    if ( !IS_NULL_id ( nid ) ) {
-
 
1605
		NAMESPACE pns = find_namespace ( nid ) ;
-
 
1606
		if ( !IS_NULL_nspace ( pns ) ) {
-
 
1607
		    MAKE_id_nspace_alias ( nm, ds, ns, crt_loc, pns, id ) ;
-
 
1608
		    break ;
-
 
1609
		}
-
 
1610
	    }
-
 
1611
	    SPEC_ERROR () ;
-
 
1612
	    break ;
-
 
1613
	}
-
 
1614
 
-
 
1615
	case id_variable_tag :
-
 
1616
	case id_parameter_tag :
-
 
1617
	case id_stat_member_tag : {
-
 
1618
	    TYPE t = load_type ( bs, NULL_id ) ;
-
 
1619
	    if ( !IS_NULL_type ( t ) ) {
-
 
1620
		MAKE_id_variable_etc ( tag, nm, ds, ns, crt_loc, t, id ) ;
-
 
1621
		break ;
-
 
1622
	    }
-
 
1623
	    SPEC_ERROR () ;
-
 
1624
	    break ;
-
 
1625
	}
-
 
1626
 
-
 
1627
	case id_function_tag :
-
 
1628
	case id_mem_func_tag :
-
 
1629
	case id_stat_mem_func_tag : {
-
 
1630
	    TYPE t = load_type ( bs, NULL_id ) ;
-
 
1631
	    if ( !IS_NULL_type ( t ) ) {
-
 
1632
		MAKE_id_function_etc ( tag, nm, ds, ns, crt_loc, t,
-
 
1633
				       NULL_id, id ) ;
-
 
1634
		*pid = id ;
-
 
1635
		if ( DE_BOOL ( bs ) ) {
-
 
1636
		    /* Read function template form */
-
 
1637
		    TYPE form = load_type ( bs, NULL_id ) ;
-
 
1638
		    COPY_type ( id_function_etc_form ( id ), form ) ;
-
 
1639
		}
-
 
1640
		break ;
-
 
1641
	    }
-
 
1642
	    SPEC_ERROR () ;
-
 
1643
	    break ;
-
 
1644
	}
-
 
1645
 
-
 
1646
	case id_member_tag : {
-
 
1647
	    TYPE t = load_type ( bs, NULL_id ) ;
-
 
1648
	    if ( !IS_NULL_type ( t ) ) {
-
 
1649
		MAKE_id_member ( nm, ds, ns, crt_loc, t, id ) ;
-
 
1650
		break ;
-
 
1651
	    }
-
 
1652
	    SPEC_ERROR () ;
-
 
1653
	    break ;
-
 
1654
	}
-
 
1655
 
-
 
1656
	case id_enumerator_tag : {
-
 
1657
	    TYPE t = load_type ( bs, NULL_id ) ;
-
 
1658
	    if ( !IS_NULL_type ( t ) ) {
-
 
1659
		EXP e = load_exp ( bs, t ) ;
-
 
1660
		if ( !IS_NULL_exp ( e ) ) {
-
 
1661
		    MAKE_id_enumerator ( nm, ds, ns, crt_loc, t, e, id ) ;
-
 
1662
		    break ;
-
 
1663
		}
-
 
1664
	    }
-
 
1665
	    SPEC_ERROR () ;
-
 
1666
	    break ;
-
 
1667
	}
-
 
1668
 
-
 
1669
	case id_label_tag :
-
 
1670
	case id_weak_param_tag : {
-
 
1671
	    /* NOT YET IMPLEMENTED */
-
 
1672
	    MAKE_id_undef ( nm, ds, ns, crt_loc, id ) ;
-
 
1673
	    break ;
-
 
1674
	}
-
 
1675
 
-
 
1676
	case id_token_tag : {
-
 
1677
	    TOKEN tok = load_tok ( bs, 0 ) ;
-
 
1678
	    if ( !IS_NULL_tok ( tok ) ) {
-
 
1679
		MAKE_id_token ( nm, ds, ns, crt_loc, tok, NULL_id, id ) ;
-
 
1680
		COPY_id ( id_token_alt ( id ), id ) ;
-
 
1681
		break ;
-
 
1682
	    }
-
 
1683
	    break ;
-
 
1684
	}
-
 
1685
 
-
 
1686
	case id_ambig_tag : {
-
 
1687
	    LIST ( IDENTIFIER ) ids = load_use_list ( bs ) ;
-
 
1688
	    int over = DE_BOOL ( bs ) ;
-
 
1689
	    MAKE_id_ambig ( nm, ds, ns, crt_loc, ids, over, id ) ;
-
 
1690
	    break ;
-
 
1691
	}
-
 
1692
 
-
 
1693
	case id_undef_tag : {
-
 
1694
	    MAKE_id_undef ( nm, ds, ns, crt_loc, id ) ;
-
 
1695
	    if ( DE_BOOL ( bs ) ) {
-
 
1696
		TYPE form = load_type ( bs, NULL_id ) ;
-
 
1697
		COPY_type ( id_undef_form ( id ), form ) ;
-
 
1698
	    }
-
 
1699
	    break ;
-
 
1700
	}
-
 
1701
 
-
 
1702
	case id_pending_tag : {
-
 
1703
	    /* This shouldn't happen */
-
 
1704
	    SPEC_ERROR () ;
-
 
1705
	    break ;
-
 
1706
	}
-
 
1707
    }
-
 
1708
 
-
 
1709
    /* Set identifier look up */
-
 
1710
    if ( !IS_NULL_id ( id ) ) {
-
 
1711
	if ( !IS_NULL_id ( lid ) ) {
-
 
1712
	    COPY_id ( id_alias ( id ), lid ) ;
-
 
1713
	}
-
 
1714
	if ( !IS_NULL_id ( qid ) ) {
-
 
1715
	    COPY_id ( id_alias ( qid ), id ) ;
-
 
1716
	    ids_pending-- ;
-
 
1717
	}
-
 
1718
	*pid = id ;
-
 
1719
    }
-
 
1720
    return ( id ) ;
-
 
1721
}
-
 
1722
 
-
 
1723
 
-
 
1724
/*
-
 
1725
    READ NAMESPACE MEMBERS
-
 
1726
 
-
 
1727
    This routine reads the members of a class or namespace and the instances
-
 
1728
    of a template class or template function.
-
 
1729
*/
-
 
1730
 
-
 
1731
static void load_members
-
 
1732
    PROTO_N ( ( bs, id ) )
-
 
1733
    PROTO_T ( BITSTREAM *bs X IDENTIFIER id )
-
 
1734
{
1488
{
-
 
1489
	ulong d;
-
 
1490
	HASHID nm;
-
 
1491
	unsigned n;
-
 
1492
	unsigned tag;
-
 
1493
	DECL_SPEC ds;
-
 
1494
	IDENTIFIER qid;
-
 
1495
	IDENTIFIER *pid;
-
 
1496
	IDENTIFIER id = NULL_id;
-
 
1497
	IDENTIFIER lid = NULL_id;
-
 
1498
 
-
 
1499
	/* Read identifier number */
-
 
1500
	d = DE_INT(bs);
-
 
1501
	if (d == 0) {
-
 
1502
		/* Null identifiers */
-
 
1503
		return (id);
-
 
1504
	}
-
 
1505
 
-
 
1506
	/* Read identifier tag */
-
 
1507
	n = DE_BITS(bs, BITS_id);
-
 
1508
	if (n == 0) {
-
 
1509
		/* Null identifiers */
-
 
1510
		return (id);
-
 
1511
	}
-
 
1512
	if (n > ORDER_id) {
-
 
1513
		SPEC_ERROR();
-
 
1514
		return (id);
-
 
1515
	}
-
 
1516
 
-
 
1517
	/* Check previous look-up */
-
 
1518
	pid = id_lookup(d);
-
 
1519
	qid = *pid;
1735
    switch ( TAG_id ( id ) ) {
1520
	if (!IS_NULL_id(qid)) {
-
 
1521
		if (!IS_id_pending(qid)) {
-
 
1522
			SPEC_ERROR();
-
 
1523
			qid = NULL_id;
-
 
1524
		}
-
 
1525
	}
-
 
1526
 
-
 
1527
	/* Read identifier independent information */
-
 
1528
	nm = load_hashid(bs, ns);
-
 
1529
	if (IS_NULL_hashid(nm)) {
-
 
1530
		SPEC_ERROR();
-
 
1531
		return (id);
-
 
1532
	}
-
 
1533
	tag = n - 1;
-
 
1534
	ds = load_dspec(bs);
-
 
1535
	load_loc(bs);
-
 
1536
	if (DE_BOOL(bs)) {
-
 
1537
		/* Read alias */
-
 
1538
		lid = load_use(bs, tag);
-
 
1539
	}
-
 
1540
 
-
 
1541
	/* Read identifier dependent information */
-
 
1542
	ASSERT(ORDER_id == 28);
-
 
1543
	switch (tag) {
-
 
1544
 
-
 
1545
	case id_dummy_tag: {
-
 
1546
		id = DEREF_id(hashid_id(nm));
-
 
1547
		id = underlying_id(id);
-
 
1548
		break;
-
 
1549
	}
-
 
1550
 
-
 
1551
	case id_keyword_tag:
-
 
1552
	case id_iso_keyword_tag:
-
 
1553
	case id_reserved_tag: {
-
 
1554
		int key = load_lex(bs);
-
 
1555
		id = make_keyword(nm, key, NULL_id);
-
 
1556
		break;
-
 
1557
	}
-
 
1558
 
-
 
1559
	case id_builtin_tag: {
-
 
1560
		TYPE r = load_type(bs, NULL_id);
-
 
1561
		if (!IS_NULL_type(r)) {
-
 
1562
			LIST(TYPE)p = load_type_list(bs);
-
 
1563
			MAKE_id_builtin(nm, ds, ns, crt_loc, r, p, id);
-
 
1564
			break;
-
 
1565
		}
-
 
1566
		SPEC_ERROR();
-
 
1567
		break;
-
 
1568
	}
-
 
1569
 
-
 
1570
	case id_obj_macro_tag: {
-
 
1571
		PPTOKEN *def = load_pptoks(bs);
-
 
1572
		MAKE_id_obj_macro(nm, ds, ns, crt_loc, def, id);
-
 
1573
		break;
-
 
1574
	}
-
 
1575
 
-
 
1576
	case id_func_macro_tag: {
-
 
1577
		PPTOKEN *def = load_pptoks(bs);
-
 
1578
		LIST(HASHID)pars = load_hashid_list(bs, NULL_nspace);
-
 
1579
		unsigned npars = LENGTH_list(pars);
-
 
1580
		MAKE_id_func_macro(nm, ds, ns, crt_loc, def, pars, npars, id);
-
 
1581
		break;
-
 
1582
	}
-
 
1583
 
-
 
1584
	case id_predicate_tag: {
-
 
1585
		/* NOT YET IMPLEMENTED */
-
 
1586
		MAKE_id_undef(nm, ds, ns, crt_loc, id);
-
 
1587
		break;
-
 
1588
	}
-
 
1589
 
1736
	case id_class_name_tag : {
1590
	case id_class_name_tag: {
1737
	    /* Read class members */
1591
		/* Class names */
-
 
1592
		TYPE t = type_error;
1738
	    DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
1593
		MAKE_id_class_name(nm, ds, ns, crt_loc, t, id);
1739
	    if ( !( ds & dspec_implicit ) ) {
1594
		if (ds & dspec_implicit) {
-
 
1595
			if (!IS_NULL_id(lid) && IS_id_class_name(lid)) {
-
 
1596
				t = DEREF_type(id_class_name_defn(lid));
-
 
1597
			}
-
 
1598
		} else {
1740
		int templ = 0 ;
1599
			*pid = id;
-
 
1600
			t = load_type(bs, id);
-
 
1601
		}
-
 
1602
		if (type_tag(t) == type_compound_tag) {
1741
		TYPE t = DEREF_type ( id_class_name_defn ( id ) ) ;
1603
			COPY_type(id_class_name_defn(id), t);
-
 
1604
			break;
-
 
1605
		}
-
 
1606
		SPEC_ERROR();
-
 
1607
		break;
-
 
1608
	}
-
 
1609
 
-
 
1610
	case id_enum_name_tag: {
-
 
1611
		/* Enumeration names */
-
 
1612
		TYPE t = type_error;
-
 
1613
		MAKE_id_enum_name(nm, ds, ns, crt_loc, t, id);
-
 
1614
		t = load_type(bs, id);
-
 
1615
		if (type_tag(t) == type_enumerate_tag) {
-
 
1616
			COPY_type(id_enum_name_defn(id), t);
-
 
1617
			break;
-
 
1618
		}
-
 
1619
		SPEC_ERROR();
-
 
1620
		break;
-
 
1621
	}
-
 
1622
 
-
 
1623
	case id_class_alias_tag:
-
 
1624
	case id_enum_alias_tag:
1742
		while ( IS_type_templ ( t ) ) {
1625
	case id_type_alias_tag: {
1743
		    templ = 1 ;
1626
		/* Type aliases */
-
 
1627
		TYPE t = load_type(bs, NULL_id);
-
 
1628
		if (!IS_NULL_type(t)) {
1744
		    t = DEREF_type ( type_templ_defn ( t ) ) ;
1629
			id = make_typedef(ns, nm, t, ds);
-
 
1630
			if (TAG_id(id) != tag) {
-
 
1631
				SPEC_ERROR();
-
 
1632
			}
-
 
1633
			break;
1745
		}
1634
		}
-
 
1635
		SPEC_ERROR();
-
 
1636
		break;
-
 
1637
	}
-
 
1638
 
-
 
1639
	case id_nspace_name_tag: {
-
 
1640
		/* Namespace names */
-
 
1641
		NAMESPACE pns = NULL_nspace;
-
 
1642
		unsigned ntag = nspace_named_tag;
1746
		if ( IS_type_compound ( t ) ) {
1643
		if (IS_hashid_anon(nm)) {
-
 
1644
			ntag = nspace_unnamed_tag;
-
 
1645
		}
-
 
1646
		MAKE_id_nspace_name(nm, ds, ns, crt_loc, pns, id);
-
 
1647
		pns = make_namespace(id, ntag, 50);
-
 
1648
		COPY_nspace(id_nspace_name_defn(id), pns);
-
 
1649
		break;
-
 
1650
	}
-
 
1651
 
-
 
1652
	case id_nspace_alias_tag: {
-
 
1653
		/* Namespace aliases */
1747
		    CLASS_TYPE ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
1654
		IDENTIFIER nid = load_use(bs, id_nspace_name_tag);
-
 
1655
		if (!IS_NULL_id(nid)) {
1748
		    NAMESPACE cns = DEREF_nspace ( ctype_member ( ct ) ) ;
1656
			NAMESPACE pns = find_namespace(nid);
-
 
1657
			if (!IS_NULL_nspace(pns)) {
-
 
1658
				MAKE_id_nspace_alias(nm, ds, ns, crt_loc, pns,
-
 
1659
						     id);
-
 
1660
				break;
-
 
1661
			}
-
 
1662
		}
-
 
1663
		SPEC_ERROR();
-
 
1664
		break;
-
 
1665
	}
-
 
1666
 
-
 
1667
	case id_variable_tag:
-
 
1668
	case id_parameter_tag:
-
 
1669
	case id_stat_member_tag: {
-
 
1670
		TYPE t = load_type(bs, NULL_id);
-
 
1671
		if (!IS_NULL_type(t)) {
-
 
1672
			MAKE_id_variable_etc(tag, nm, ds, ns, crt_loc, t, id);
-
 
1673
			break;
-
 
1674
		}
-
 
1675
		SPEC_ERROR();
-
 
1676
		break;
-
 
1677
	}
-
 
1678
 
-
 
1679
	case id_function_tag:
-
 
1680
	case id_mem_func_tag:
-
 
1681
	case id_stat_mem_func_tag: {
1749
		    load_nspace ( bs, cns, 0 ) ;
1682
		TYPE t = load_type(bs, NULL_id);
-
 
1683
		if (!IS_NULL_type(t)) {
-
 
1684
			MAKE_id_function_etc(tag, nm, ds, ns, crt_loc, t,
-
 
1685
					     NULL_id, id);
-
 
1686
			*pid = id;
1750
		    if ( templ ) {
1687
			if (DE_BOOL(bs)) {
1751
			/* Read template class instances */
1688
				/* Read function template form */
-
 
1689
				TYPE form = load_type(bs, NULL_id);
-
 
1690
				COPY_type(id_function_etc_form(id), form);
-
 
1691
			}
-
 
1692
			break;
-
 
1693
		}
-
 
1694
		SPEC_ERROR();
-
 
1695
		break;
-
 
1696
	}
-
 
1697
 
-
 
1698
	case id_member_tag: {
-
 
1699
		TYPE t = load_type(bs, NULL_id);
-
 
1700
		if (!IS_NULL_type(t)) {
1752
			NAMESPACE ns = DEREF_nspace ( id_parent ( id ) ) ;
1701
			MAKE_id_member(nm, ds, ns, crt_loc, t, id);
-
 
1702
			break;
-
 
1703
		}
-
 
1704
		SPEC_ERROR();
-
 
1705
		break;
-
 
1706
	}
-
 
1707
 
-
 
1708
	case id_enumerator_tag: {
1753
			load_nspace ( bs, ns, 1 ) ;
1709
		TYPE t = load_type(bs, NULL_id);
-
 
1710
		if (!IS_NULL_type(t)) {
-
 
1711
			EXP e = load_exp(bs, t);
-
 
1712
			if (!IS_NULL_exp(e)) {
-
 
1713
				MAKE_id_enumerator(nm, ds, ns, crt_loc, t, e,
-
 
1714
						   id);
-
 
1715
				break;
1754
		    }
1716
			}
-
 
1717
		}
-
 
1718
		SPEC_ERROR();
-
 
1719
		break;
-
 
1720
	}
-
 
1721
 
-
 
1722
	case id_label_tag:
-
 
1723
	case id_weak_param_tag: {
-
 
1724
		/* NOT YET IMPLEMENTED */
-
 
1725
		MAKE_id_undef(nm, ds, ns, crt_loc, id);
-
 
1726
		break;
-
 
1727
	}
-
 
1728
 
-
 
1729
	case id_token_tag: {
-
 
1730
		TOKEN tok = load_tok(bs, 0);
-
 
1731
		if (!IS_NULL_tok(tok)) {
-
 
1732
			MAKE_id_token(nm, ds, ns, crt_loc, tok, NULL_id, id);
-
 
1733
			COPY_id(id_token_alt(id), id);
-
 
1734
			break;
-
 
1735
		}
-
 
1736
		break;
-
 
1737
	}
-
 
1738
 
-
 
1739
	case id_ambig_tag: {
-
 
1740
		LIST(IDENTIFIER)ids = load_use_list(bs);
-
 
1741
		int over = DE_BOOL(bs);
-
 
1742
		MAKE_id_ambig(nm, ds, ns, crt_loc, ids, over, id);
-
 
1743
		break;
-
 
1744
	}
-
 
1745
 
-
 
1746
	case id_undef_tag: {
-
 
1747
		MAKE_id_undef(nm, ds, ns, crt_loc, id);
-
 
1748
		if (DE_BOOL(bs)) {
-
 
1749
			TYPE form = load_type(bs, NULL_id);
-
 
1750
			COPY_type(id_undef_form(id), form);
-
 
1751
		}
-
 
1752
		break;
-
 
1753
	}
-
 
1754
 
-
 
1755
	case id_pending_tag: {
-
 
1756
		/* This shouldn't happen */
-
 
1757
		SPEC_ERROR();
-
 
1758
		break;
-
 
1759
	}
-
 
1760
	}
-
 
1761
 
-
 
1762
	/* Set identifier look up */
-
 
1763
	if (!IS_NULL_id(id)) {
-
 
1764
		if (!IS_NULL_id(lid)) {
-
 
1765
			COPY_id(id_alias(id), lid);
1755
		}
1766
		}
-
 
1767
		if (!IS_NULL_id(qid)) {
-
 
1768
			COPY_id(id_alias(qid), id);
-
 
1769
			ids_pending--;
-
 
1770
		}
-
 
1771
		*pid = id;
-
 
1772
	}
-
 
1773
	return (id);
-
 
1774
}
-
 
1775
 
-
 
1776
 
-
 
1777
/*
-
 
1778
    READ NAMESPACE MEMBERS
-
 
1779
 
-
 
1780
    This routine reads the members of a class or namespace and the instances
-
 
1781
    of a template class or template function.
-
 
1782
*/
-
 
1783
 
-
 
1784
static void
-
 
1785
load_members(BITSTREAM *bs, IDENTIFIER id)
-
 
1786
{
-
 
1787
	switch (TAG_id(id)) {
-
 
1788
	case id_class_name_tag: {
-
 
1789
		/* Read class members */
-
 
1790
		DECL_SPEC ds = DEREF_dspec(id_storage(id));
-
 
1791
		if (!(ds & dspec_implicit)) {
-
 
1792
			int templ = 0;
-
 
1793
			TYPE t = DEREF_type(id_class_name_defn(id));
-
 
1794
			while (IS_type_templ(t)) {
-
 
1795
				templ = 1;
-
 
1796
				t = DEREF_type(type_templ_defn(t));
-
 
1797
			}
-
 
1798
			if (IS_type_compound(t)) {
-
 
1799
				CLASS_TYPE ct =
-
 
1800
				    DEREF_ctype(type_compound_defn(t));
-
 
1801
				NAMESPACE cns = DEREF_nspace(ctype_member(ct));
-
 
1802
				load_nspace(bs, cns, 0);
-
 
1803
				if (templ) {
-
 
1804
					/* Read template class instances */
-
 
1805
					NAMESPACE ns =
-
 
1806
					    DEREF_nspace(id_parent(id));
-
 
1807
					load_nspace(bs, ns, 1);
1756
	    }
1808
				}
-
 
1809
			}
-
 
1810
		}
-
 
1811
		break;
-
 
1812
	}
-
 
1813
	case id_nspace_name_tag: {
-
 
1814
		/* Read namespace members */
-
 
1815
		NAMESPACE cns = DEREF_nspace(id_nspace_name_defn(id));
-
 
1816
		load_nspace(bs, cns, 0);
-
 
1817
		break;
-
 
1818
	}
-
 
1819
	case id_function_tag:
-
 
1820
	case id_mem_func_tag:
-
 
1821
	case id_stat_mem_func_tag: {
-
 
1822
		TYPE t = DEREF_type(id_function_etc_type(id));
-
 
1823
		if (IS_type_templ(t)) {
-
 
1824
			/* Read template function instances */
-
 
1825
			NAMESPACE ns = DEREF_nspace(id_parent(id));
-
 
1826
			load_nspace(bs, ns, 1);
-
 
1827
		}
1757
	    break ;
1828
		break;
1758
	}
1829
	}
1759
	case id_nspace_name_tag : {
-
 
1760
	    /* Read namespace members */
-
 
1761
	    NAMESPACE cns = DEREF_nspace ( id_nspace_name_defn ( id ) ) ;
-
 
1762
	    load_nspace ( bs, cns, 0 ) ;
-
 
1763
	    break ;
-
 
1764
	}
-
 
1765
	case id_function_tag :
-
 
1766
	case id_mem_func_tag :
-
 
1767
	case id_stat_mem_func_tag : {
-
 
1768
	    TYPE t = DEREF_type ( id_function_etc_type ( id ) ) ;
-
 
1769
	    if ( IS_type_templ ( t ) ) {
-
 
1770
		/* Read template function instances */
-
 
1771
		NAMESPACE ns = DEREF_nspace ( id_parent ( id ) ) ;
-
 
1772
		load_nspace ( bs, ns, 1 ) ;
-
 
1773
	    }
-
 
1774
	    break ;
-
 
1775
	}
1830
	}
1776
    }
-
 
1777
    return ;
1831
	return;
1778
}
1832
}
1779
 
1833
 
1780
 
1834
 
1781
/*
1835
/*
1782
    READ A LIST OF NAMESPACE MEMBERS
1836
    READ A LIST OF NAMESPACE MEMBERS
1783
 
1837
 
1784
    This routine reads the members of the namespace ns from the bitstream
1838
    This routine reads the members of the namespace ns from the bitstream
1785
    bs.  The list is terminated by a null identifier.  The routine is
1839
    bs.  The list is terminated by a null identifier.  The routine is
1786
    also used with inst true to read a list of template instances.
1840
    also used with inst true to read a list of template instances.
1787
*/
1841
*/
1788
 
1842
 
1789
static void load_nspace
1843
static void
1790
    PROTO_N ( ( bs, ns, inst ) )
-
 
1791
    PROTO_T ( BITSTREAM *bs X NAMESPACE ns X int inst )
1844
load_nspace(BITSTREAM *bs, NAMESPACE ns, int inst)
1792
{
1845
{
1793
    int v = verbose ;
1846
	int v = verbose;
1794
    for ( ; ; ) {
1847
	for (;;) {
1795
	/* Read identifier */
1848
		/* Read identifier */
1796
	IDENTIFIER id = load_id ( bs, ns ) ;
1849
		IDENTIFIER id = load_id(bs, ns);
1797
	if ( IS_NULL_id ( id ) || spec_error ) break ;
1850
		if (IS_NULL_id(id) || spec_error) {
-
 
1851
			break;
-
 
1852
		}
-
 
1853
		if (v) {
1798
	if ( v ) commentary ( id ) ;
1854
			commentary(id);
-
 
1855
		}
1799
 
1856
 
1800
	/* Set namespace member */
1857
		/* Set namespace member */
1801
	if ( !IS_NULL_nspace ( ns ) && !inst ) {
1858
		if (!IS_NULL_nspace(ns) && !inst) {
1802
	    DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
1859
			DECL_SPEC ds = DEREF_dspec(id_storage(id));
1803
	    if ( ( ds & dspec_extern ) || IS_nspace_block_etc ( ns ) ) {
1860
			if ((ds & dspec_extern) || IS_nspace_block_etc(ns)) {
1804
		/* External linkage */
1861
				/* External linkage */
1805
		HASHID nm = DEREF_hashid ( id_name ( id ) ) ;
1862
				HASHID nm = DEREF_hashid(id_name(id));
1806
		MEMBER mem = search_member ( ns, nm, 1 ) ;
1863
				MEMBER mem = search_member(ns, nm, 1);
1807
		IDENTIFIER pid = DEREF_id ( member_id ( mem ) ) ;
1864
				IDENTIFIER pid = DEREF_id(member_id(mem));
1808
		if ( is_tagged_type ( id ) ) {
1865
				if (is_tagged_type(id)) {
1809
		    /* Type members */
1866
					/* Type members */
1810
		    COPY_id ( member_alt ( mem ), id ) ;
1867
					COPY_id(member_alt(mem), id);
1811
		    if ( IS_NULL_id ( pid ) ) {
1868
					if (IS_NULL_id(pid)) {
1812
			COPY_id ( member_id ( mem ), id ) ;
1869
						COPY_id(member_id(mem), id);
1813
		    }
1870
					}
1814
		} else {
1871
				} else {
1815
		    /* Non-type members */
1872
					/* Non-type members */
-
 
1873
					if (!IS_NULL_id(pid) &&
1816
		    if ( !IS_NULL_id ( pid ) && IS_id_function_etc ( pid ) ) {
1874
					    IS_id_function_etc(pid)) {
1817
			if ( IS_id_function_etc ( id ) ) {
1875
						if (IS_id_function_etc(id)) {
1818
			    /* Allow for overloaded functions */
1876
							/* Allow for overloaded
-
 
1877
							 * functions */
1819
			    COPY_id ( id_function_etc_over ( id ), pid ) ;
1878
							COPY_id(id_function_etc_over(id), pid);
1820
			}
1879
						}
1821
		    }
1880
					}
1822
		    COPY_id ( member_id ( mem ), id ) ;
1881
					COPY_id(member_id(mem), id);
1823
		}
1882
				}
1824
	    } else {
1883
			} else {
1825
		/* Internal linkage */
1884
				/* Internal linkage */
1826
		LIST ( IDENTIFIER ) ids ;
1885
				LIST(IDENTIFIER)ids;
1827
		ids = DEREF_list ( nspace_named_etc_extra ( ns ) ) ;
1886
				ids = DEREF_list(nspace_named_etc_extra(ns));
1828
		CONS_id ( id, ids, ids ) ;
1887
				CONS_id(id, ids, ids);
1829
		COPY_list ( nspace_named_etc_extra ( ns ), ids ) ;
1888
				COPY_list(nspace_named_etc_extra(ns), ids);
1830
	    }
1889
			}
1831
	}
1890
		}
1832
 
1891
 
1833
	/* Check for classes, namespaces and templates */
1892
		/* Check for classes, namespaces and templates */
1834
	load_members ( bs, id ) ;
1893
		load_members(bs, id);
1835
    }
1894
	}
1836
    return ;
1895
	return;
1837
}
1896
}
1838
 
1897
 
1839
 
1898
 
1840
/*
1899
/*
1841
    READ A SPEC FILE
1900
    READ A SPEC FILE
Line 1843... Line 1902...
1843
    This routine reads a spec file from the input file.  It returns zero
1902
    This routine reads a spec file from the input file.  It returns zero
1844
    for a legal spec file.  The identifiers are initially read into a
1903
    for a legal spec file.  The identifiers are initially read into a
1845
    dummy namespace which is then merged with the existing namespace.
1904
    dummy namespace which is then merged with the existing namespace.
1846
*/
1905
*/
1847
 
1906
 
1848
int read_spec
1907
int
1849
    PROTO_Z ()
1908
read_spec(void)
1850
{
1909
{
1851
    /* Read file identifier */
1910
	/* Read file identifier */
1852
    int e = 0 ;
1911
	int e = 0;
1853
    char buff [20] ;
1912
	char buff[20];
1854
    CONST char *msg = NULL ;
1913
	CONST char *msg = NULL;
1855
    NAMESPACE gns = NULL_nspace ;
1914
	NAMESPACE gns = NULL_nspace;
1856
    BITSTREAM *bs = start_bitstream ( input_file, NULL_gen_ptr ) ;
1915
	BITSTREAM *bs = start_bitstream(input_file, NULL_gen_ptr);
1857
    unsigned c1 = DE_BITS ( bs, BYTE_SIZE ) ;
1916
	unsigned c1 = DE_BITS(bs, BYTE_SIZE);
1858
    unsigned c2 = DE_BITS ( bs, BYTE_SIZE ) ;
1917
	unsigned c2 = DE_BITS(bs, BYTE_SIZE);
1859
    unsigned c3 = DE_BITS ( bs, BYTE_SIZE ) ;
1918
	unsigned c3 = DE_BITS(bs, BYTE_SIZE);
1860
    unsigned c4 = DE_BITS ( bs, BYTE_SIZE ) ;
1919
	unsigned c4 = DE_BITS(bs, BYTE_SIZE);
1861
    if ( c1 == ascii_T && c2 == ascii_D && c3 == ascii_F && c4 == ascii_K ) {
1920
	if (c1 == ascii_T && c2 == ascii_D && c3 == ascii_F && c4 == ascii_K) {
1862
	unsigned long n1 = DE_INT ( bs ) ;
1921
		unsigned long n1 = DE_INT(bs);
1863
	unsigned long n2 = DE_INT ( bs ) ;
1922
		unsigned long n2 = DE_INT(bs);
1864
	unsigned long n3 = DE_INT ( bs ) ;
1923
		unsigned long n3 = DE_INT(bs);
1865
	DE_ALIGN ( bs ) ;
1924
		DE_ALIGN(bs);
1866
	if ( n1 == SPEC_major && n2 <= SPEC_minor ) {
1925
		if (n1 == SPEC_major && n2 <= SPEC_minor) {
1867
	    /* Read main file body */
1926
			/* Read main file body */
1868
	    if ( n3 > LANGUAGE_CPP ) {
1927
			if (n3 > LANGUAGE_CPP) {
1869
		msg = "bad source language" ;
1928
				msg = "bad source language";
1870
		e = 1 ;
1929
				e = 1;
1871
	    }
1930
			}
1872
	    if ( e == 0 ) {
1931
			if (e == 0) {
1873
		int d = do_dump ;
1932
				int d = do_dump;
1874
		do_dump = 0 ;
1933
				do_dump = 0;
1875
		spec_error = 0 ;
1934
				spec_error = 0;
1876
		gns = make_global_nspace ( "<global>", 50 ) ;
1935
				gns = make_global_nspace("<global>", 50);
1877
		load_nspace ( bs, gns, 0 ) ;
1936
				load_nspace(bs, gns, 0);
1878
		if ( ids_pending ) SPEC_ERROR () ;
1937
				if (ids_pending) {
-
 
1938
					SPEC_ERROR();
-
 
1939
				}
1879
		crt_class = NULL_ctype ;
1940
				crt_class = NULL_ctype;
1880
		e = spec_error ;
1941
				e = spec_error;
1881
		if ( e == 0 ) {
1942
				if (e == 0) {
1882
		    DE_ALIGN ( bs ) ;
1943
					DE_ALIGN(bs);
1883
		    if ( !de_eof ( bs ) ) {
1944
					if (!de_eof(bs)) {
1884
			msg = "end of file expected" ;
1945
						msg = "end of file expected";
1885
			e = 1 ;
1946
						e = 1;
1886
		    }
1947
					}
-
 
1948
				} else {
-
 
1949
					sprintf_v(buff, "code %d", e);
-
 
1950
					msg = buff;
-
 
1951
				}
-
 
1952
				do_dump = d;
-
 
1953
			}
1887
		} else {
1954
		} else {
1888
		    sprintf_v ( buff, "code %d", e ) ;
1955
			msg = "bad version number";
1889
		    msg = buff ;
1956
			e = 1;
1890
		}
1957
		}
1891
		do_dump = d ;
-
 
1892
	    }
-
 
1893
	} else {
1958
	} else {
1894
	    msg = "bad version number" ;
1959
		msg = "bad magic number";
1895
	    e = 1 ;
1960
		e = 1;
1896
	}
1961
	}
1897
    } else {
-
 
1898
	msg = "bad magic number" ;
-
 
1899
	e = 1 ;
-
 
1900
    }
-
 
1901
 
-
 
1902
    /* Check for errors */
-
 
1903
    if ( msg ) fail ( ERR_fail_spec_bad ( input_name, ustrlit ( msg ) ) ) ;
-
 
1904
    if ( !output_spec ) e = 1 ;
-
 
1905
    xfree_nof ( id_table ) ;
-
 
1906
    id_table_size = 0 ;
-
 
1907
    id_table = NULL ;
-
 
1908
    spec_error = 0 ;
-
 
1909
 
1962
 
-
 
1963
	/* Check for errors */
-
 
1964
	if (msg) {
-
 
1965
		fail(ERR_fail_spec_bad(input_name, ustrlit(msg)));
-
 
1966
	}
-
 
1967
	if (!output_spec) {
-
 
1968
		e = 1;
-
 
1969
	}
-
 
1970
	xfree_nof(id_table);
-
 
1971
	id_table_size = 0;
-
 
1972
	id_table = NULL;
-
 
1973
	spec_error = 0;
-
 
1974
 
1910
    /* Merge read identifiers */
1975
	/* Merge read identifiers */
1911
    if ( !IS_NULL_nspace ( gns ) ) {
1976
	if (!IS_NULL_nspace(gns)) {
1912
	merge_namespaces ( global_namespace, gns ) ;
1977
		merge_namespaces(global_namespace, gns);
1913
    }
1978
	}
1914
    return ( e ) ;
1979
	return (e);
1915
}
1980
}