Subversion Repositories tendra.SVN

Rev

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

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2006 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
29
 
59
 
30
 
60
 
31
#include "config.h"
61
#include "config.h"
32
#include "c_types.h"
62
#include "c_types.h"
33
#include "ctype_ops.h"
63
#include "ctype_ops.h"
Line 59... Line 89...
59
 
89
 
60
    This value is used to keep track of the number of functions skipped
90
    This value is used to keep track of the number of functions skipped
61
    and subsequently compiled.
91
    and subsequently compiled.
62
*/
92
*/
63
 
93
 
64
static int functions_pending = 0 ;
94
static int functions_pending = 0;
65
 
95
 
66
 
96
 
67
/*
97
/*
68
    SKIP A FUNCTION DEFINITION
98
    SKIP A FUNCTION DEFINITION
69
 
99
 
Line 71... Line 101...
71
    the current sequence of lexical tokens.  Note that last_lex_token is
101
    the current sequence of lexical tokens.  Note that last_lex_token is
72
    set to lex_func_Hop to indicate that a function definition has been
102
    set to lex_func_Hop to indicate that a function definition has been
73
    skipped.
103
    skipped.
74
*/
104
*/
75
 
105
 
76
void skip_function
106
void
77
    PROTO_N ( ( id ) )
-
 
78
    PROTO_T ( IDENTIFIER id )
107
skip_function(IDENTIFIER id)
79
{
108
{
80
    EXP e ;
109
	EXP e;
81
    LOCATION loc ;
110
	LOCATION loc;
82
    int t = crt_lex_token ;
111
	int t = crt_lex_token;
83
    PPTOKEN *p = crt_token ;
112
	PPTOKEN *p = crt_token;
84
    PPTOKEN *q = p ;
113
	PPTOKEN *q = p;
85
    int brackets = 0 ;
114
	int brackets = 0;
86
    int try_block = 0 ;
115
	int try_block = 0;
87
 
116
 
88
    /* Check for previous definition */
117
	/* Check for previous definition */
89
    if ( !IS_NULL_id ( id ) ) {
118
	if (!IS_NULL_id(id)) {
90
	PTR ( LOCATION ) ploc = id_loc ( id ) ;
119
		PTR(LOCATION)ploc = id_loc(id);
91
	COPY_loc ( ploc, decl_loc ) ;
120
		COPY_loc(ploc, decl_loc);
92
	e = DEREF_exp ( id_function_etc_defn ( id ) ) ;
121
		e = DEREF_exp(id_function_etc_defn(id));
93
	if ( !IS_NULL_exp ( e ) ) {
122
		if (!IS_NULL_exp(e)) {
94
	    /* Function already defined */
123
			/* Function already defined */
95
	    report ( crt_loc, ERR_basic_odr_def_func ( id, ploc ) ) ;
124
			report(crt_loc, ERR_basic_odr_def_func(id, ploc));
96
	}
-
 
97
    }
-
 
98
 
-
 
99
    /* Skip definition */
-
 
100
    loc = crt_loc ;
-
 
101
    if ( t == lex_try ) try_block = 1 ;
-
 
102
    for ( ; ; ) {
-
 
103
	if ( t == lex_open_Hbrace_H1 || t == lex_open_Hbrace_H2 ) {
-
 
104
	    /* Start of block */
-
 
105
	    brackets++ ;
-
 
106
	} else if ( t == lex_close_Hbrace_H1 || t == lex_close_Hbrace_H2 ) {
-
 
107
	    /* End of block */
-
 
108
	    brackets-- ;
-
 
109
	    if ( brackets <= 0 ) {
-
 
110
		q = crt_token ;
-
 
111
		t = expand_preproc ( EXPAND_AHEAD ) ;
-
 
112
		if ( t != lex_catch || !try_block ) {
-
 
113
		    /* End of function */
-
 
114
		    break ;
-
 
115
		}
125
		}
-
 
126
	}
-
 
127
 
-
 
128
	/* Skip definition */
-
 
129
	loc = crt_loc;
-
 
130
	if (t == lex_try) {
-
 
131
		try_block = 1;
-
 
132
	}
-
 
133
	for (;;) {
-
 
134
		if (t == lex_open_Hbrace_H1 || t == lex_open_Hbrace_H2) {
-
 
135
			/* Start of block */
-
 
136
			brackets++;
-
 
137
		} else if (t == lex_close_Hbrace_H1 ||
-
 
138
			   t == lex_close_Hbrace_H2) {
-
 
139
			/* End of block */
-
 
140
			brackets--;
-
 
141
			if (brackets <= 0) {
-
 
142
				q = crt_token;
-
 
143
				t = expand_preproc(EXPAND_AHEAD);
-
 
144
				if (t != lex_catch || !try_block) {
-
 
145
					/* End of function */
-
 
146
					break;
116
	    }
147
				}
-
 
148
			}
117
	} else if ( t == lex_semicolon && brackets == 0 ) {
149
		} else if (t == lex_semicolon && brackets == 0) {
118
	    /* Premature end of function */
150
			/* Premature end of function */
119
	    break ;
151
			break;
120
	} else if ( t == lex_eof ) {
152
		} else if (t == lex_eof) {
121
	    /* Premature end of file */
153
			/* Premature end of file */
122
	    report ( loc, ERR_class_mfct_eof ( id ) ) ;
154
			report(loc, ERR_class_mfct_eof(id));
123
	    crt_lex_token = t ;
155
			crt_lex_token = t;
124
	    return ;
156
			return;
125
	}
157
		}
126
	q = crt_token ;
158
		q = crt_token;
127
	t = expand_preproc ( EXPAND_AHEAD ) ;
159
		t = expand_preproc(EXPAND_AHEAD);
128
    }
160
	}
129
    last_lex_token = lex_func_Hop ;
161
	last_lex_token = lex_func_Hop;
130
    crt_lex_token = t ;
162
	crt_lex_token = t;
131
    snip_tokens ( p, q ) ;
163
	snip_tokens(p, q);
132
 
164
 
133
    /* Create the definition */
165
	/* Create the definition */
134
    MAKE_exp_uncompiled ( type_void, loc, p, e ) ;
166
	MAKE_exp_uncompiled(type_void, loc, p, e);
135
    if ( !IS_NULL_id ( id ) ) {
167
	if (!IS_NULL_id(id)) {
136
	COPY_exp ( id_function_etc_defn ( id ), e ) ;
168
		COPY_exp(id_function_etc_defn(id), e);
137
	functions_pending++ ;
169
		functions_pending++;
138
    }
170
	}
139
    return ;
171
	return;
140
}
172
}
141
 
173
 
142
 
174
 
143
/*
175
/*
144
    SKIP A DEFAULT ARGUMENT VALUE
176
    SKIP A DEFAULT ARGUMENT VALUE
Line 147... Line 179...
147
    id given by the current sequence of lexical tokens.  It returns an
179
    id given by the current sequence of lexical tokens.  It returns an
148
    expression giving the skipped value which is associated with id by
180
    expression giving the skipped value which is associated with id by
149
    init_param.
181
    init_param.
150
*/
182
*/
151
 
183
 
152
EXP skip_default_arg
184
EXP
153
    PROTO_N ( ( id ) )
-
 
154
    PROTO_T ( IDENTIFIER id )
185
skip_default_arg(IDENTIFIER id)
155
{
186
{
156
    EXP e ;
187
	EXP e;
157
    LOCATION loc ;
188
	LOCATION loc;
158
    int brackets = 0 ;
189
	int brackets = 0;
159
    int t = crt_lex_token ;
190
	int t = crt_lex_token;
160
    PPTOKEN *p = crt_token ;
191
	PPTOKEN *p = crt_token;
161
    PPTOKEN *q = p ;
192
	PPTOKEN *q = p;
162
 
193
 
163
    /* Skip definition */
194
	/* Skip definition */
164
    loc = crt_loc ;
195
	loc = crt_loc;
165
    for ( ; ; ) {
196
	for (;;) {
166
	if ( t == lex_open_Hround || t == lex_open_Htemplate ) {
197
		if (t == lex_open_Hround || t == lex_open_Htemplate) {
167
	    brackets++ ;
198
			brackets++;
168
	} else if ( t == lex_close_Hround || t == lex_close_Htemplate ) {
199
		} else if (t == lex_close_Hround || t == lex_close_Htemplate) {
169
	    if ( brackets == 0 ) break ;
200
			if (brackets == 0) {
-
 
201
				break;
-
 
202
			}
170
	    brackets-- ;
203
			brackets--;
171
	} else if ( t == lex_comma ) {
204
		} else if (t == lex_comma) {
172
	    if ( brackets == 0 ) break ;
205
			if (brackets == 0) {
-
 
206
				break;
-
 
207
			}
173
	} else if ( t == lex_eof ) {
208
		} else if (t == lex_eof) {
174
	    /* Premature end of file */
209
			/* Premature end of file */
175
	    report ( loc, ERR_class_mfct_eof ( id ) ) ;
210
			report(loc, ERR_class_mfct_eof(id));
176
	    crt_lex_token = t ;
211
			crt_lex_token = t;
177
	    return ( NULL_exp ) ;
212
			return (NULL_exp);
178
	}
213
		}
179
	q = crt_token ;
214
		q = crt_token;
180
	t = expand_preproc ( EXPAND_AHEAD ) ;
215
		t = expand_preproc(EXPAND_AHEAD);
181
    }
216
	}
182
    crt_lex_token = t ;
217
	crt_lex_token = t;
183
    snip_tokens ( p, q ) ;
218
	snip_tokens(p, q);
184
 
219
 
185
    /* Create the definition */
220
	/* Create the definition */
186
    MAKE_exp_uncompiled ( type_error, loc, p, e ) ;
221
	MAKE_exp_uncompiled(type_error, loc, p, e);
187
    functions_pending++ ;
222
	functions_pending++;
188
    return ( e ) ;
223
	return (e);
189
}
224
}
190
 
225
 
191
 
226
 
192
/*
227
/*
193
    BRING A SET OF TEMPLATE ARGUMENTS INTO SCOPE
228
    BRING A SET OF TEMPLATE ARGUMENTS INTO SCOPE
194
 
229
 
195
    When rescanning a template member function it is necessary to bring
230
    When rescanning a template member function it is necessary to bring
196
    the template parameters back into scope.  This routine performs this
231
    the template parameters back into scope.  This routine performs this
197
    operation for the template type t.  It returns the non-template
232
    operation for the template type t.  It returns the non-template
198
    component of t.
233
    component of t.
199
*/
234
*/
200
 
235
 
201
TYPE begin_templ_scope
236
TYPE
202
    PROTO_N ( ( t ) )
-
 
203
    PROTO_T ( TYPE t )
237
begin_templ_scope(TYPE t)
204
{
238
{
205
    if ( !IS_NULL_type ( t ) && IS_type_templ ( t ) ) {
239
	if (!IS_NULL_type(t) && IS_type_templ(t)) {
206
	TYPE s = DEREF_type ( type_templ_defn ( t ) ) ;
240
		TYPE s = DEREF_type(type_templ_defn(t));
207
	TOKEN sort = DEREF_tok ( type_templ_sort ( t ) ) ;
241
		TOKEN sort = DEREF_tok(type_templ_sort(t));
208
	NAMESPACE ns = DEREF_nspace ( tok_templ_pars ( sort ) ) ;
242
		NAMESPACE ns = DEREF_nspace(tok_templ_pars(sort));
209
	if ( !IS_NULL_nspace ( ns ) ) {
243
		if (!IS_NULL_nspace(ns)) {
210
	    record_location++ ;
244
			record_location++;
211
	    in_template_decl++ ;
245
			in_template_decl++;
212
	    add_namespace ( ns ) ;
246
			add_namespace(ns);
213
	}
247
		}
214
	t = begin_templ_scope ( s ) ;
248
		t = begin_templ_scope(s);
215
    }
249
	}
216
    return ( t ) ;
250
	return (t);
217
}
251
}
218
 
252
 
219
 
253
 
220
/*
254
/*
221
    TAKE A SET OF TEMPLATE ARGUMENTS OUT OF SCOPE
255
    TAKE A SET OF TEMPLATE ARGUMENTS OUT OF SCOPE
222
 
256
 
223
    This routine removes any template parameters brought into scope by
257
    This routine removes any template parameters brought into scope by
224
    begin_templ_scope.
258
    begin_templ_scope.
225
*/
259
*/
226
 
260
 
227
void end_templ_scope
261
void
228
    PROTO_N ( ( t ) )
-
 
229
    PROTO_T ( TYPE t )
262
end_templ_scope(TYPE t)
230
{
263
{
231
    if ( !IS_NULL_type ( t ) && IS_type_templ ( t ) ) {
264
	if (!IS_NULL_type(t) && IS_type_templ(t)) {
232
	TYPE s = DEREF_type ( type_templ_defn ( t ) ) ;
265
		TYPE s = DEREF_type(type_templ_defn(t));
233
	TOKEN sort = DEREF_tok ( type_templ_sort ( t ) ) ;
266
		TOKEN sort = DEREF_tok(type_templ_sort(t));
234
	NAMESPACE ns = DEREF_nspace ( tok_templ_pars ( sort ) ) ;
267
		NAMESPACE ns = DEREF_nspace(tok_templ_pars(sort));
235
	end_templ_scope ( s ) ;
268
		end_templ_scope(s);
236
	if ( !IS_NULL_nspace ( ns ) ) {
269
		if (!IS_NULL_nspace(ns)) {
237
	    remove_namespace () ;
270
			remove_namespace();
238
	    in_template_decl-- ;
271
			in_template_decl--;
239
	    record_location-- ;
272
			record_location--;
-
 
273
		}
240
	}
274
	}
241
    }
-
 
242
    return ;
275
	return;
243
}
276
}
244
 
277
 
245
 
278
 
246
/*
279
/*
247
    COMPILE A FUNCTION DEFINITION
280
    COMPILE A FUNCTION DEFINITION
248
 
281
 
249
    This routine compiles any previously skipped definition for the
282
    This routine compiles any previously skipped definition for the
250
    function id.
283
    function id.
251
*/
284
*/
252
 
285
 
253
static void rescan_function
286
static void
254
    PROTO_N ( ( id ) )
-
 
255
    PROTO_T ( IDENTIFIER id )
287
rescan_function(IDENTIFIER id)
256
{
288
{
257
    EXP e = DEREF_exp ( id_function_etc_defn ( id ) ) ;
289
	EXP e = DEREF_exp(id_function_etc_defn(id));
258
    if ( !IS_NULL_exp ( e ) && IS_exp_uncompiled ( e ) ) {
290
	if (!IS_NULL_exp(e) && IS_exp_uncompiled(e)) {
259
	PPTOKEN *p ;
291
		PPTOKEN *p;
260
	PARSE_STATE s ;
292
		PARSE_STATE s;
261
	TYPE fn = DEREF_type ( id_function_etc_type ( id ) ) ;
293
		TYPE fn = DEREF_type(id_function_etc_type(id));
262
 
294
 
263
	/* Mark function as inline */
295
		/* Mark function as inline */
264
	DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
296
		DECL_SPEC ds = DEREF_dspec(id_storage(id));
265
	ds |= dspec_inline ;
297
		ds |= dspec_inline;
266
	COPY_dspec ( id_storage ( id ), ds ) ;
298
		COPY_dspec(id_storage(id), ds);
267
 
299
 
268
	/* Save current compiler state */
300
		/* Save current compiler state */
269
	save_state ( &s, 1 ) ;
301
		save_state(&s, 1);
270
 
302
 
271
	/* Set parser to stored definition */
303
		/* Set parser to stored definition */
272
	DEREF_loc ( exp_uncompiled_start ( e ), crt_loc ) ;
304
		DEREF_loc(exp_uncompiled_start(e), crt_loc);
273
	crt_line_changed = 1 ;
305
		crt_line_changed = 1;
274
	crt_file_changed = 1 ;
306
		crt_file_changed = 1;
275
	p = DEREF_pptok ( exp_uncompiled_defn ( e ) ) ;
307
		p = DEREF_pptok(exp_uncompiled_defn(e));
276
	init_parser ( p ) ;
308
		init_parser(p);
277
 
309
 
278
	/* Start function definition */
310
		/* Start function definition */
279
	in_class_defn = 0 ;
311
		in_class_defn = 0;
280
	in_function_defn++ ;
312
		in_function_defn++;
281
	really_in_function_defn++ ;
313
		really_in_function_defn++;
282
	COPY_exp ( id_function_etc_defn ( id ), NULL_exp ) ;
314
		COPY_exp(id_function_etc_defn(id), NULL_exp);
283
	DEREF_loc ( id_loc ( id ), decl_loc ) ;
315
		DEREF_loc(id_loc(id), decl_loc);
284
	IGNORE begin_templ_scope ( fn ) ;
316
		IGNORE begin_templ_scope(fn);
285
	begin_function ( id ) ;
317
		begin_function(id);
286
 
318
 
287
	/* Parse the stored function definition */
319
		/* Parse the stored function definition */
288
	ADVANCE_LEXER ;
320
		ADVANCE_LEXER;
289
	parse_func ( &e ) ;
321
		parse_func(&e);
290
	if ( crt_lex_token != lex_eof && !have_syntax_error ) {
322
		if (crt_lex_token != lex_eof && !have_syntax_error) {
291
	    ERROR err = ERR_lex_parse ( crt_token ) ;
323
			ERROR err = ERR_lex_parse(crt_token);
292
	    report ( crt_loc, err ) ;
324
			report(crt_loc, err);
293
	    unreached_code = 1 ;
325
			unreached_code = 1;
294
	}
326
		}
295
 
327
 
296
	/* End the function definition */
328
		/* End the function definition */
297
	IGNORE end_function ( id, e ) ;
329
		IGNORE end_function(id, e);
298
	end_templ_scope ( fn ) ;
330
		end_templ_scope(fn);
299
 
331
 
300
	/* Reset the parser */
332
		/* Reset the parser */
301
	restore_state ( &s ) ;
333
		restore_state(&s);
302
	p = restore_parser () ;
334
		p = restore_parser();
303
	free_tok_list ( p ) ;
335
		free_tok_list(p);
304
	functions_pending-- ;
336
		functions_pending--;
305
    }
337
	}
306
    return ;
338
	return;
307
}
339
}
308
 
340
 
309
 
341
 
310
/*
342
/*
311
    COMPILE A DEFAULT ARGUMENT VALUE
343
    COMPILE A DEFAULT ARGUMENT VALUE
312
 
344
 
313
    This routine compiles any previously skipped default argument value
345
    This routine compiles any previously skipped default argument value
314
    for the parameter id.
346
    for the parameter id.
315
*/
347
*/
316
 
348
 
317
void rescan_param
349
void
318
    PROTO_N ( ( id, rescan ) )
-
 
319
    PROTO_T ( IDENTIFIER id X int rescan )
350
rescan_param(IDENTIFIER id, int rescan)
320
{
351
{
321
    EXP e = DEREF_exp ( id_parameter_init ( id ) ) ;
352
	EXP e = DEREF_exp(id_parameter_init(id));
322
    if ( !IS_NULL_exp ( e ) && IS_exp_uncompiled ( e ) ) {
353
	if (!IS_NULL_exp(e) && IS_exp_uncompiled(e)) {
323
	PPTOKEN *p ;
354
		PPTOKEN *p;
324
	PARSE_STATE s ;
355
		PARSE_STATE s;
325
	TYPE fn = NULL_type ;
356
		TYPE fn = NULL_type;
326
	NAMESPACE ns = DEREF_nspace ( id_parent ( id ) ) ;
357
		NAMESPACE ns = DEREF_nspace(id_parent(id));
327
	IDENTIFIER pid = DEREF_id ( nspace_name ( ns ) ) ;
358
		IDENTIFIER pid = DEREF_id(nspace_name(ns));
328
	if ( !IS_NULL_id ( pid ) && IS_id_function_etc ( pid ) ) {
359
		if (!IS_NULL_id(pid) && IS_id_function_etc(pid)) {
329
	    fn = DEREF_type ( id_function_etc_type ( pid ) ) ;
360
			fn = DEREF_type(id_function_etc_type(pid));
330
	} else {
361
		} else {
331
	    CLASS_TYPE ct = crt_class ;
362
			CLASS_TYPE ct = crt_class;
332
	    if ( !IS_NULL_ctype ( ct ) ) {
363
			if (!IS_NULL_ctype(ct)) {
333
		pid = DEREF_id ( ctype_name ( ct ) ) ;
364
				pid = DEREF_id(ctype_name(ct));
334
	    } else {
365
			} else {
335
		pid = NULL_id ;
366
				pid = NULL_id;
336
	    }
367
			}
337
	}
368
		}
338
 
369
 
339
	/* Save current compiler state */
370
		/* Save current compiler state */
340
	save_state ( &s, 1 ) ;
371
		save_state(&s, 1);
341
 
372
 
342
	/* Set parser to stored definition */
373
		/* Set parser to stored definition */
343
	DEREF_loc ( exp_uncompiled_start ( e ), crt_loc ) ;
374
		DEREF_loc(exp_uncompiled_start(e), crt_loc);
344
	crt_line_changed = 1 ;
375
		crt_line_changed = 1;
345
	crt_file_changed = 1 ;
376
		crt_file_changed = 1;
346
	p = DEREF_pptok ( exp_uncompiled_defn ( e ) ) ;
377
		p = DEREF_pptok(exp_uncompiled_defn(e));
347
	init_parser ( p ) ;
378
		init_parser(p);
348
 
379
 
349
	/* Start dafault argument value */
380
		/* Start dafault argument value */
350
	in_class_defn = 0 ;
381
		in_class_defn = 0;
351
	COPY_exp ( id_parameter_init ( id ), NULL_exp ) ;
382
		COPY_exp(id_parameter_init(id), NULL_exp);
352
	if ( rescan ) {
383
		if (rescan) {
353
	    IGNORE begin_templ_scope ( fn ) ;
384
			IGNORE begin_templ_scope(fn);
354
	    push_namespace ( ns ) ;
385
			push_namespace(ns);
-
 
386
		}
-
 
387
 
-
 
388
		/* Parse the stored expression */
-
 
389
		ADVANCE_LEXER;
-
 
390
		in_default_arg++;
-
 
391
		parse_exp(&e);
-
 
392
		in_default_arg--;
-
 
393
		if (crt_lex_token != lex_eof && !have_syntax_error) {
-
 
394
			ERROR err = ERR_lex_parse(crt_token);
-
 
395
			report(crt_loc, err);
-
 
396
		}
-
 
397
 
-
 
398
		/* End the default argument value */
-
 
399
		init_param(id, e);
-
 
400
		if (rescan) {
-
 
401
			IGNORE pop_namespace();
-
 
402
			end_templ_scope(fn);
355
	}
403
		}
356
 
404
 
357
	/* Parse the stored expression */
405
		/* Reset the parser */
358
	ADVANCE_LEXER ;
406
		if (crt_access_list.pending) {
359
	in_default_arg++ ;
407
			IGNORE report_access(pid);
-
 
408
		}
360
	parse_exp ( &e ) ;
409
		restore_state(&s);
361
	in_default_arg-- ;
410
		p = restore_parser();
362
	if ( crt_lex_token != lex_eof && !have_syntax_error ) {
-
 
363
	    ERROR err = ERR_lex_parse ( crt_token ) ;
411
		free_tok_list(p);
364
	    report ( crt_loc, err ) ;
412
		functions_pending--;
365
	}
413
	}
366
 
-
 
367
	/* End the default argument value */
-
 
368
	init_param ( id, e ) ;
-
 
369
	if ( rescan ) {
-
 
370
	    IGNORE pop_namespace () ;
-
 
371
	    end_templ_scope ( fn ) ;
-
 
372
	}
-
 
373
 
-
 
374
	/* Reset the parser */
-
 
375
	if ( crt_access_list.pending ) {
-
 
376
	    IGNORE report_access ( pid ) ;
-
 
377
	}
-
 
378
	restore_state ( &s ) ;
-
 
379
	p = restore_parser () ;
-
 
380
	free_tok_list ( p ) ;
-
 
381
	functions_pending-- ;
-
 
382
    }
-
 
383
    return ;
414
	return;
384
}
415
}
385
 
416
 
386
 
417
 
387
/*
418
/*
388
    COMPILE ALL FUNCTIONS IN A NAMESPACE
419
    COMPILE ALL FUNCTIONS IN A NAMESPACE
389
 
420
 
390
    This routine scans through the current class and any nested classes
421
    This routine scans through the current class and any nested classes
391
    compiling any function definitions which remain uncompiled.
422
    compiling any function definitions which remain uncompiled.
392
*/
423
*/
393
 
424
 
-
 
425
void
394
void rescan_functions
426
rescan_functions(void)
395
    PROTO_Z ()
-
 
396
{
427
{
397
    CLASS_TYPE ct = crt_class ;
428
	CLASS_TYPE ct = crt_class;
398
    LIST ( IDENTIFIER ) ft = DEREF_list ( ctype_nest ( ct ) ) ;
429
	LIST(IDENTIFIER) ft = DEREF_list(ctype_nest(ct));
399
    while ( !IS_NULL_list ( ft ) ) {
430
	while (!IS_NULL_list(ft)) {
400
	IDENTIFIER id = DEREF_id ( HEAD_list ( ft ) ) ;
431
		IDENTIFIER id = DEREF_id(HEAD_list(ft));
401
	switch ( TAG_id ( id ) ) {
432
		switch (TAG_id(id)) {
402
	    case id_class_name_tag : {
433
		case id_class_name_tag: {
403
		/* Deal with nested classes */
434
			/* Deal with nested classes */
404
		CLASS_TYPE cs ;
435
			CLASS_TYPE cs;
405
		CLASS_INFO ci ;
436
			CLASS_INFO ci;
406
		NAMESPACE cns ;
437
			NAMESPACE cns;
407
		TYPE t = DEREF_type ( id_class_name_defn ( id ) ) ;
438
			TYPE t = DEREF_type(id_class_name_defn(id));
408
		TYPE s = begin_templ_scope ( t ) ;
439
			TYPE s = begin_templ_scope(t);
409
		cs = DEREF_ctype ( type_compound_defn ( s ) ) ;
440
			cs = DEREF_ctype(type_compound_defn(s));
410
		ci = DEREF_cinfo ( ctype_info ( cs ) ) ;
441
			ci = DEREF_cinfo(ctype_info(cs));
411
		if ( ci & cinfo_complete ) {
442
			if (ci & cinfo_complete) {
412
		    cns = DEREF_nspace ( ctype_member ( cs ) ) ;
443
				cns = DEREF_nspace(ctype_member(cs));
413
		    push_class ( cs ) ;
444
				push_class(cs);
414
		    push_namespace ( cns ) ;
445
				push_namespace(cns);
415
		    rescan_functions () ;
446
				rescan_functions();
416
		    IGNORE pop_namespace () ;
447
				IGNORE pop_namespace();
417
		    pop_class () ;
448
				pop_class();
-
 
449
			}
-
 
450
			end_templ_scope(t);
-
 
451
			break;
-
 
452
		}
-
 
453
		case id_function_tag:
-
 
454
		case id_mem_func_tag:
-
 
455
		case id_stat_mem_func_tag:
-
 
456
			/* Deal with inline functions (including friends) */
-
 
457
			rescan_function(id);
-
 
458
			break;
-
 
459
		case id_parameter_tag:
-
 
460
			/* Deal with default arguments */
-
 
461
			rescan_param(id, 1);
-
 
462
			break;
418
		}
463
		}
419
		end_templ_scope ( t ) ;
464
		ft = TAIL_list(ft);
420
		break ;
-
 
421
	    }
-
 
422
	    case id_function_tag :
-
 
423
	    case id_mem_func_tag :
-
 
424
	    case id_stat_mem_func_tag : {
-
 
425
		/* Deal with inline functions (including friends) */
-
 
426
		rescan_function ( id ) ;
-
 
427
		break ;
-
 
428
	    }
-
 
429
	    case id_parameter_tag : {
-
 
430
		/* Deal with default arguments */
-
 
431
		rescan_param ( id, 1 ) ;
-
 
432
		break ;
-
 
433
	    }
-
 
434
	}
465
	}
435
	ft = TAIL_list ( ft ) ;
-
 
436
    }
-
 
437
    return ;
466
	return;
438
}
467
}