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

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

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

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

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

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

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

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

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251
WebSVN – tendra.SVN – Diff – /branches/tendra5/src/producers/common/utility/debug.c – Rev 5 and 6

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
*/
29
 
59
 
30
 
60
 
31
#include "config.h"
61
#include "config.h"
32
#include "c_types.h"
62
#include "c_types.h"
33
#include "exp_ops.h"
63
#include "exp_ops.h"
34
#include "hashid_ops.h"
64
#include "hashid_ops.h"
35
#include "id_ops.h"
65
#include "id_ops.h"
Line 62... Line 92...
62
 
92
 
63
/*
93
/*
64
    EXTENDED DEBUGGING FLAG
94
    EXTENDED DEBUGGING FLAG
65
 
95
 
66
    This flag enables the extended debug printing routines.
96
    This flag enables the extended debug printing routines.
67
*/
97
*/
68
 
98
 
69
int debugging = 0 ;
99
int debugging = 0;
70
 
100
 
71
 
101
 
72
/*
102
/*
73
    EXTENDED OFFSET PRINTING
103
    EXTENDED OFFSET PRINTING
74
 
104
 
75
    This routine deals with those cases in print_offset which are only
105
    This routine deals with those cases in print_offset which are only
76
    output in debugging mode.
106
    output in debugging mode.
77
*/
107
*/
78
 
108
 
79
int print_offset_aux
109
int
80
    PROTO_N ( ( off, bf, sp ) )
-
 
81
    PROTO_T ( OFFSET off X BUFFER *bf X int sp )
110
print_offset_aux(OFFSET off, BUFFER *bf, int sp)
82
{
111
{
83
    if ( !IS_NULL_off ( off ) ) {
112
	if (!IS_NULL_off(off)) {
84
	switch ( TAG_off ( off ) ) {
113
		switch (TAG_off(off)) {
85
	    case off_type_tag : {
114
		case off_type_tag: {
86
		TYPE t = DEREF_type ( off_type_type ( off ) ) ;
115
			TYPE t = DEREF_type(off_type_type(off));
87
		sp = print_type ( t, bf, sp ) ;
116
			sp = print_type(t, bf, sp);
88
		break ;
117
			break;
89
	    }
118
		}
90
	    default : {
119
		default: {
91
		sp = print_lex ( lex_member_Hcap, bf, sp ) ;
120
			sp = print_lex(lex_member_Hcap, bf, sp);
92
		break ;
121
			break;
-
 
122
		}
93
	    }
123
		}
94
	}
124
	}
95
    }
-
 
96
    return ( sp ) ;
125
	return (sp);
97
}
126
}
98
 
127
 
99
 
128
 
100
/*
129
/*
101
    PRINT A UNARY OPERATION
130
    PRINT A UNARY OPERATION
102
 
131
 
103
    This routine prints the unary operation 'op a' to the buffer bf.
132
    This routine prints the unary operation 'op a' to the buffer bf.
104
*/
133
*/
105
 
134
 
106
static int print_unary
135
static int
107
    PROTO_N ( ( a, op, bf, sp ) )
-
 
108
    PROTO_T ( EXP a X int op X BUFFER *bf X int sp )
136
print_unary(EXP a, int op, BUFFER *bf, int sp)
109
{
-
 
110
    IGNORE print_lex ( op, bf, sp ) ;
-
 
111
    sp = print_exp ( a, 1, bf, 0 ) ;
-
 
112
    return ( sp ) ;
-
 
113
}
-
 
114
 
-
 
115
 
-
 
116
/*
-
 
117
    PRINT A BINARY OPERATION
-
 
118
 
-
 
119
    This routine prints the binary operation 'a op b' to the buffer bf.
-
 
120
*/
-
 
121
 
-
 
122
static int print_binary
-
 
123
    PROTO_N ( ( a, b, op, bf, sp ) )
-
 
124
    PROTO_T ( EXP a X EXP b X int op X BUFFER *bf X int sp )
-
 
125
{
137
{
126
    sp = print_exp ( a, 1, bf, sp ) ;
-
 
127
    sp = print_lex ( op, bf, sp ) ;
138
	IGNORE print_lex(op, bf, sp);
128
    sp = print_exp ( b, 1, bf, sp ) ;
139
	sp = print_exp(a, 1, bf, 0);
129
    return ( sp ) ;
140
	return (sp);
130
}
141
}
131
 
142
 
132
 
143
 
-
 
144
/*
-
 
145
    PRINT A BINARY OPERATION
-
 
146
 
-
 
147
    This routine prints the binary operation 'a op b' to the buffer bf.
-
 
148
*/
-
 
149
 
-
 
150
static int
-
 
151
print_binary(EXP a, EXP b, int op, BUFFER *bf, int sp)
-
 
152
{
-
 
153
	sp = print_exp(a, 1, bf, sp);
-
 
154
	sp = print_lex(op, bf, sp);
-
 
155
	sp = print_exp(b, 1, bf, sp);
-
 
156
	return (sp);
-
 
157
}
-
 
158
 
-
 
159
 
133
/*
160
/*
134
    PRINT A CAST OPERATION
161
    PRINT A CAST OPERATION
135
 
162
 
136
    This routine prints the cast operation 'op < t > ( a )' to the
163
    This routine prints the cast operation 'op < t > ( a )' to the
137
    buffer bf.
164
    buffer bf.
138
*/
165
*/
139
 
166
 
140
static int print_cast
167
static int
141
    PROTO_N ( ( t, a, op, bf, sp ) )
-
 
142
    PROTO_T ( TYPE t X EXP a X int op X BUFFER *bf X int sp )
168
print_cast(TYPE t, EXP a, int op, BUFFER *bf, int sp)
143
{
169
{
144
    sp = print_lex ( op, bf, sp ) ;
170
	sp = print_lex(op, bf, sp);
145
    sp = print_lex ( lex_less, bf, sp ) ;
171
	sp = print_lex(lex_less, bf, sp);
146
    sp = print_type ( t, bf, sp ) ;
172
	sp = print_type(t, bf, sp);
147
    sp = print_lex ( lex_greater, bf, sp ) ;
173
	sp = print_lex(lex_greater, bf, sp);
148
    sp = print_exp ( a, 1, bf, sp ) ;
174
	sp = print_exp(a, 1, bf, sp);
149
    return ( sp ) ;
175
	return (sp);
150
}
176
}
151
 
177
 
152
 
178
 
153
/*
179
/*
154
    PRINT A LIST OF EXPRESSIONS
180
    PRINT A LIST OF EXPRESSIONS
155
 
181
 
156
    This routine prints the list of expressions p, enclosed in brackets,
182
    This routine prints the list of expressions p, enclosed in brackets,
157
    to the buffer bf.
183
    to the buffer bf.
158
*/
184
*/
159
 
185
 
160
static int print_exp_list
186
static int
161
    PROTO_N ( ( p, bf, sp ) )
-
 
162
    PROTO_T ( LIST ( EXP ) p X BUFFER *bf X int sp )
187
print_exp_list(LIST(EXP)p, BUFFER *bf, int sp)
163
{
188
{
164
    sp = print_lex ( lex_open_Hround, bf, sp ) ;
189
	sp = print_lex(lex_open_Hround, bf, sp);
165
    if ( IS_NULL_list ( p ) ) {
190
	if (IS_NULL_list(p)) {
166
	sp = 0 ;
191
		sp = 0;
167
    } else {
192
	} else {
168
	while ( !IS_NULL_list ( p ) ) {
193
		while (!IS_NULL_list(p)) {
169
	    EXP a = DEREF_exp ( HEAD_list ( p ) ) ;
194
			EXP a = DEREF_exp(HEAD_list(p));
170
	    sp = print_exp ( a, 1, bf, sp ) ;
195
			sp = print_exp(a, 1, bf, sp);
171
	    bfputc ( bf, ',' ) ;
196
			bfputc(bf, ',');
172
	    p = TAIL_list ( p ) ;
197
			p = TAIL_list(p);
-
 
198
		}
173
	}
199
	}
174
    }
-
 
175
    sp = print_lex ( lex_close_Hround, bf, sp ) ;
200
	sp = print_lex(lex_close_Hround, bf, sp);
176
    return ( sp ) ;
201
	return (sp);
177
}
202
}
178
 
203
 
179
 
204
 
180
/*
205
/*
181
    EXTENDED EXPRESSION PRINTING
206
    EXTENDED EXPRESSION PRINTING
182
 
207
 
183
    This routine deals with those cases in print_exp which are only
208
    This routine deals with those cases in print_exp which are only
184
    output in debugging mode.
209
    output in debugging mode.
185
*/
210
*/
186
 
211
 
187
int print_exp_aux
212
int
188
    PROTO_N ( ( e, paren, bf, sp ) )
-
 
189
    PROTO_T ( EXP e X int paren X BUFFER *bf X int sp )
213
print_exp_aux(EXP e, int paren, BUFFER *bf, int sp)
190
{
214
{
191
    if ( !IS_NULL_exp ( e ) ) {
215
	if (!IS_NULL_exp(e)) {
192
	ASSERT ( ORDER_exp == 88 ) ;
216
		ASSERT(ORDER_exp == 88);
193
	if ( paren ) sp = print_lex ( lex_open_Hround, bf, sp ) ;
-
 
194
	switch ( TAG_exp ( e ) ) {
-
 
195
	    case exp_paren_tag : {
-
 
196
		EXP a = DEREF_exp ( exp_paren_arg ( e ) ) ;
-
 
197
		sp = print_exp ( a, !paren, bf, sp ) ;
-
 
198
		break ;
-
 
199
	    }
-
 
200
	    case exp_copy_tag : {
-
 
201
		EXP a = DEREF_exp ( exp_copy_arg ( e ) ) ;
-
 
202
		sp = print_exp ( a, 0, bf, sp ) ;
-
 
203
		break ;
-
 
204
	    }
-
 
205
	    case exp_assign_tag : {
-
 
206
		EXP a = DEREF_exp ( exp_assign_ref ( e ) ) ;
-
 
207
		EXP b = DEREF_exp ( exp_assign_arg ( e ) ) ;
-
 
208
		sp = print_binary ( a, b, lex_assign, bf, sp ) ;
-
 
209
		break ;
-
 
210
	    }
-
 
211
	    case exp_init_tag : {
-
 
212
		IDENTIFIER id = DEREF_id ( exp_init_id ( e ) ) ;
-
 
213
		EXP a = DEREF_exp ( exp_init_arg ( e ) ) ;
-
 
214
		sp = print_id_short ( id, qual_none, bf, sp ) ;
-
 
215
		sp = print_lex ( lex_assign, bf, sp ) ;
-
 
216
		sp = print_exp ( a, 0, bf, sp ) ;
-
 
217
		break ;
-
 
218
	    }
-
 
219
	    case exp_preinc_tag : {
-
 
220
		EXP a = DEREF_exp ( exp_preinc_ref ( e ) ) ;
-
 
221
		EXP b = DEREF_exp ( exp_preinc_op ( e ) ) ;
-
 
222
		sp = print_binary ( a, b, lex_assign, bf, sp ) ;
-
 
223
		break ;
-
 
224
	    }
-
 
225
	    case exp_postinc_tag : {
-
 
226
		EXP a = DEREF_exp ( exp_postinc_ref ( e ) ) ;
-
 
227
		EXP b = DEREF_exp ( exp_postinc_op ( e ) ) ;
-
 
228
		sp = print_binary ( a, b, lex_assign, bf, sp ) ;
-
 
229
		break ;
-
 
230
	    }
-
 
231
	    case exp_indir_tag : {
-
 
232
		EXP a = DEREF_exp ( exp_indir_ptr ( e ) ) ;
-
 
233
		sp = print_unary ( a, lex_star, bf, sp ) ;
-
 
234
		break ;
-
 
235
	    }
-
 
236
	    case exp_address_tag : {
-
 
237
		EXP a = DEREF_exp ( exp_address_arg ( e ) ) ;
-
 
238
		sp = print_unary ( a, lex_and_H1, bf, sp ) ;
-
 
239
		break ;
-
 
240
	    }
-
 
241
	    case exp_address_mem_tag : {
-
 
242
		EXP a = DEREF_exp ( exp_address_mem_arg ( e ) ) ;
-
 
243
		sp = print_unary ( a, lex_and_H1, bf, sp ) ;
-
 
244
		break ;
217
		if (paren) {
245
	    }
-
 
246
	    case exp_func_tag : {
-
 
247
		EXP a = DEREF_exp ( exp_func_fn ( e ) ) ;
-
 
248
		LIST ( EXP ) p = DEREF_list ( exp_func_args ( e ) ) ;
-
 
249
		sp = print_exp ( a, 1, bf, sp ) ;
-
 
250
		sp = print_exp_list ( p, bf, sp ) ;
-
 
251
		break ;
-
 
252
	    }
-
 
253
	    case exp_func_id_tag : {
-
 
254
		IDENTIFIER id = DEREF_id ( exp_func_id_id ( e ) ) ;
-
 
255
		LIST ( EXP ) p = DEREF_list ( exp_func_id_args ( e ) ) ;
-
 
256
		sp = print_id_short ( id, qual_none, bf, sp ) ;
-
 
257
		sp = print_exp_list ( p, bf, sp ) ;
-
 
258
		break ;
-
 
259
	    }
-
 
260
	    case exp_call_tag : {
-
 
261
		EXP a = DEREF_exp ( exp_call_ptr ( e ) ) ;
-
 
262
		EXP b = DEREF_exp ( exp_call_arg ( e ) ) ;
-
 
263
		sp = print_binary ( a, b, lex_dot_Hstar, bf, sp ) ;
-
 
264
		break ;
-
 
265
	    }
-
 
266
	    case exp_negate_tag :
-
 
267
	    case exp_compl_tag :
-
 
268
	    case exp_not_tag :
-
 
269
	    case exp_abs_tag : {
-
 
270
		int op = op_token ( e, lex_unknown ) ;
-
 
271
		EXP a = DEREF_exp ( exp_negate_etc_arg ( e ) ) ;
-
 
272
		sp = print_unary ( a, op, bf, sp ) ;
-
 
273
		break ;
-
 
274
	    }
-
 
275
	    case exp_plus_tag :
-
 
276
	    case exp_minus_tag :
-
 
277
	    case exp_mult_tag :
-
 
278
	    case exp_div_tag :
-
 
279
	    case exp_rem_tag :
-
 
280
	    case exp_and_tag :
-
 
281
	    case exp_or_tag :
-
 
282
	    case exp_xor_tag :
-
 
283
	    case exp_log_and_tag :
-
 
284
	    case exp_log_or_tag :
-
 
285
	    case exp_lshift_tag :
-
 
286
	    case exp_rshift_tag :
-
 
287
	    case exp_max_tag :
-
 
288
	    case exp_min_tag : {
-
 
289
		int op = op_token ( e, lex_unknown ) ;
-
 
290
		EXP a = DEREF_exp ( exp_plus_etc_arg1 ( e ) ) ;
-
 
291
		EXP b = DEREF_exp ( exp_plus_etc_arg2 ( e ) ) ;
-
 
292
		sp = print_binary ( a, b, op, bf, sp ) ;
-
 
293
		break ;
-
 
294
	    }
-
 
295
	    case exp_test_tag : {
-
 
296
		int op = op_token ( e, lex_unknown ) ;
-
 
297
		EXP a = DEREF_exp ( exp_test_arg ( e ) ) ;
-
 
298
		sp = print_exp ( a, 1, bf, sp ) ;
-
 
299
		IGNORE print_lex ( op, bf, sp ) ;
-
 
300
		bfprintf ( bf, " 0" ) ;
-
 
301
		sp = 1 ;
-
 
302
		break ;
-
 
303
	    }
-
 
304
	    case exp_compare_tag : {
-
 
305
		int op = op_token ( e, lex_unknown ) ;
-
 
306
		EXP a = DEREF_exp ( exp_compare_arg1 ( e ) ) ;
-
 
307
		EXP b = DEREF_exp ( exp_compare_arg2 ( e ) ) ;
-
 
308
		sp = print_binary ( a, b, op, bf, sp ) ;
-
 
309
		break ;
-
 
310
	    }
-
 
311
	    case exp_cast_tag : {
-
 
312
		TYPE t = DEREF_type ( exp_type ( e ) ) ;
-
 
313
		EXP a = DEREF_exp ( exp_cast_arg ( e ) ) ;
-
 
314
		sp = print_cast ( t, a, lex_cast, bf, sp ) ;
-
 
315
		break ;
-
 
316
	    }
-
 
317
	    case exp_base_cast_tag : {
-
 
318
		TYPE t = DEREF_type ( exp_type ( e ) ) ;
-
 
319
		EXP a = DEREF_exp ( exp_base_cast_arg ( e ) ) ;
-
 
320
		sp = print_cast ( t, a, lex_cast, bf, sp ) ;
-
 
321
		break ;
-
 
322
	    }
-
 
323
	    case exp_dyn_cast_tag : {
-
 
324
		TYPE t = DEREF_type ( exp_type ( e ) ) ;
-
 
325
		EXP a = DEREF_exp ( exp_dyn_cast_arg ( e ) ) ;
-
 
326
		sp = print_cast ( t, a, lex_dynamic_Hcast, bf, sp ) ;
-
 
327
		break ;
-
 
328
	    }
-
 
329
	    case exp_add_ptr_tag : {
-
 
330
		EXP a = DEREF_exp ( exp_add_ptr_ptr ( e ) ) ;
-
 
331
		OFFSET off = DEREF_off ( exp_add_ptr_off ( e ) ) ;
-
 
332
		sp = print_exp ( a, 0, bf, sp ) ;
-
 
333
		sp = print_lex ( lex_plus, bf, sp ) ;
-
 
334
		sp = print_offset ( off, bf, sp ) ;
-
 
335
		break ;
-
 
336
	    }
-
 
337
	    case exp_offset_size_tag : {
-
 
338
		OFFSET off = DEREF_off ( exp_offset_size_off ( e ) ) ;
-
 
339
		TYPE t = DEREF_type ( exp_offset_size_step ( e ) ) ;
-
 
340
		sp = print_offset ( off, bf, sp ) ;
-
 
341
		sp = print_lex ( lex_div, bf, sp ) ;
-
 
342
		sp = print_type ( t, bf, sp ) ;
-
 
343
		break ;
-
 
344
	    }
-
 
345
	    case exp_constr_tag : {
-
 
346
		EXP a = DEREF_exp ( exp_constr_call ( e ) ) ;
-
 
347
		sp = print_exp ( a, 0, bf, sp ) ;
-
 
348
		break ;
-
 
349
	    }
-
 
350
	    case exp_destr_tag : {
-
 
351
		EXP a = DEREF_exp ( exp_destr_call ( e ) ) ;
-
 
352
		sp = print_exp ( a, 0, bf, sp ) ;
-
 
353
		break ;
-
 
354
	    }
-
 
355
	    case exp_alloc_tag : {
-
 
356
		EXP a = DEREF_exp ( exp_alloc_call ( e ) ) ;
-
 
357
		sp = print_exp ( a, 0, bf, sp ) ;
-
 
358
		break ;
-
 
359
	    }
-
 
360
	    case exp_dealloc_tag : {
-
 
361
		EXP a = DEREF_exp ( exp_dealloc_call ( e ) ) ;
-
 
362
		sp = print_exp ( a, 0, bf, sp ) ;
-
 
363
		break ;
-
 
364
	    }
-
 
365
	    case exp_rtti_tag : {
-
 
366
		EXP a = DEREF_exp ( exp_rtti_arg ( e ) ) ;
-
 
367
		int op = DEREF_int ( exp_rtti_op ( e ) ) ;
-
 
368
		sp = print_lex ( op, bf, sp ) ;
-
 
369
		sp = print_exp ( a, 1, bf, sp ) ;
-
 
370
		break ;
-
 
371
	    }
-
 
372
	    case exp_rtti_type_tag : {
-
 
373
		TYPE t = DEREF_type ( exp_rtti_type_arg ( e ) ) ;
-
 
374
		int op = DEREF_int ( exp_rtti_type_op ( e ) ) ;
-
 
375
		sp = print_lex ( op, bf, sp ) ;
-
 
376
		sp = print_type ( t, bf, sp ) ;
-
 
377
		break ;
-
 
378
	    }
-
 
379
	    case exp_rtti_no_tag : {
-
 
380
		TYPE t = DEREF_type ( exp_rtti_no_arg ( e ) ) ;
-
 
381
		sp = print_lex ( lex_typeid, bf, sp ) ;
218
			sp = print_lex(lex_open_Hround, bf, sp);
382
		sp = print_type ( t, bf, sp ) ;
-
 
383
		break ;
-
 
384
	    }
-
 
385
	    case exp_dynamic_tag : {
-
 
386
		EXP a = DEREF_exp ( exp_dynamic_arg ( e ) ) ;
-
 
387
		sp = print_exp ( a, 0, bf, sp ) ;
-
 
388
		break ;
-
 
389
	    }
-
 
390
	    case exp_aggregate_tag : {
-
 
391
		LIST ( EXP ) p = DEREF_list ( exp_aggregate_args ( e ) ) ;
-
 
392
		sp = print_lex ( lex_initialization, bf, sp ) ;
-
 
393
		sp = print_exp_list ( p, bf, sp ) ;
-
 
394
		break ;
-
 
395
	    }
-
 
396
	    case exp_initialiser_tag : {
-
 
397
		LIST ( EXP ) p = DEREF_list ( exp_initialiser_args ( e ) ) ;
-
 
398
		sp = print_lex ( lex_initialization, bf, sp ) ;
-
 
399
		sp = print_exp_list ( p, bf, sp ) ;
-
 
400
		break ;
-
 
401
	    }
-
 
402
	    case exp_nof_tag : {
-
 
403
		EXP a = DEREF_exp ( exp_nof_start ( e ) ) ;
-
 
404
		EXP b = DEREF_exp ( exp_nof_pad ( e ) ) ;
-
 
405
		EXP c = DEREF_exp ( exp_nof_end ( e ) ) ;
-
 
406
		if ( !IS_NULL_exp ( a ) ) {
-
 
407
		    sp = print_exp ( a, 0, bf, sp ) ;
-
 
408
		    bfprintf ( bf, ", " ) ;
-
 
409
		}
-
 
410
		sp = print_exp ( b, 0, bf, sp ) ;
-
 
411
		bfprintf ( bf, ", ..." ) ;
-
 
412
		if ( !IS_NULL_exp ( c ) ) {
-
 
413
		    bfprintf ( bf, ", " ) ;
-
 
414
		    sp = print_exp ( c, 0, bf, sp ) ;
-
 
415
		}
219
		}
460
		}
521
		}
461
		break ;
-
 
462
	    }
-
 
463
	    case exp_opn_tag : {
-
 
464
		int op = DEREF_int ( exp_opn_lex ( e ) ) ;
-
 
465
		LIST ( EXP ) p = DEREF_list ( exp_opn_args ( e ) ) ;
-
 
466
		sp = print_lex ( op, bf, sp ) ;
-
 
467
		sp = print_exp_list ( p, bf, sp ) ;
-
 
468
		break ;
-
 
469
	    }
-
 
470
	    case exp_uncompiled_tag : {
-
 
471
		if ( sp ) bfputc ( bf, ' ' ) ;
-
 
472
		bfprintf ( bf, "..." ) ;
-
 
473
		sp = 1 ;
-
 
474
		break ;
-
 
475
	    }
-
 
476
	    case exp_fail_tag : {
-
 
477
		string s = DEREF_string ( exp_fail_msg ( e ) ) ;
-
 
478
		if ( sp ) bfputc ( bf, ' ' ) ;
-
 
479
		bfputs ( bf, s ) ;
-
 
480
		sp = 1 ;
-
 
481
		break ;
-
 
482
	    }
-
 
483
	    case exp_dummy_tag : {
-
 
484
		EXP a = DEREF_exp ( exp_dummy_value ( e ) ) ;
-
 
485
		if ( IS_NULL_exp ( a ) ) {
-
 
486
		    sp = print_lex ( lex_exp_Hcap, bf, sp ) ;
-
 
487
		} else {
-
 
488
		    sp = print_exp ( a, 0, bf, sp ) ;
-
 
489
		}
522
		}
490
		break ;
-
 
491
	    }
-
 
492
	    default : {
-
 
493
		sp = print_lex ( lex_exp_Hcap, bf, sp ) ;
523
		if (paren)sp = print_lex(lex_close_Hround, bf, sp);
494
		break ;
-
 
495
	    }
-
 
496
	}
524
	}
497
	if ( paren ) sp = print_lex ( lex_close_Hround, bf, sp ) ;
-
 
498
    }
-
 
499
    return ( sp ) ;
525
	return (sp);
500
}
526
}
501
 
527
 
502
 
528
 
503
/*
529
/*
504
    PRINT AN INDENTED STRING
530
    PRINT AN INDENTED STRING
505
 
531
 
506
    This routine prints an indentation of indent steps followed by the
532
    This routine prints an indentation of indent steps followed by the
507
    string text to the file f.
533
    string text to the file f.
508
*/
534
*/
509
 
535
 
510
static void print_indent
536
static void
511
    PROTO_N ( ( indent, text, f ) )
-
 
512
    PROTO_T ( int indent X CONST char *text X FILE *f )
537
print_indent(int indent, CONST char *text, FILE *f)
513
{
538
{
514
    while ( indent > 1 ) {
539
	while (indent > 1) {
515
	fputc_v ( '\t', f ) ;
540
		fputc_v('\t', f);
516
	indent -= 2 ;
541
		indent -= 2;
517
    }
542
	}
518
    if ( indent ) {
543
	if (indent) {
519
	unsigned long i = tab_width / 2 ;
544
		unsigned long i = tab_width / 2;
520
	while ( i ) {
545
		while (i) {
521
	    fputc_v ( ' ', f ) ;
546
			fputc_v(' ', f);
522
	    i-- ;
547
			i--;
523
	}
548
		}
524
    }
549
	}
525
    fputs_v ( text, f ) ;
550
	fputs_v(text, f);
526
    return ;
551
	return;
527
}
552
}
528
 
553
 
529
 
554
 
530
/*
555
/*
531
    PRINT AN EXPRESSION
556
    PRINT AN EXPRESSION
532
 
557
 
533
    This routine prints the expression e, enclosed in parentheses if paren
558
    This routine prints the expression e, enclosed in parentheses if paren
534
    is true and preceded by a space if sp is true, to the file f.
559
    is true and preceded by a space if sp is true, to the file f.
535
*/
560
*/
536
 
561
 
537
static void print_expr
562
static void
538
    PROTO_N ( ( e, paren, sp, f ) )
-
 
539
    PROTO_T ( EXP e X int paren X int sp X FILE *f )
563
print_expr(EXP e, int paren, int sp, FILE *f)
540
{
564
{
541
    BUFFER *bf = clear_buffer ( &print_buff, f ) ;
565
	BUFFER *bf = clear_buffer(&print_buff, f);
-
 
566
	if (paren) {
542
    if ( paren ) sp = print_lex ( lex_open_Hround, bf, sp ) ;
567
		sp = print_lex(lex_open_Hround, bf, sp);
-
 
568
	}
543
    IGNORE print_exp ( e, 0, bf, sp ) ;
569
	IGNORE print_exp(e, 0, bf, sp);
-
 
570
	if (paren) {
544
    if ( paren ) IGNORE print_lex ( lex_close_Hround, bf, sp ) ;
571
		IGNORE print_lex(lex_close_Hround, bf, sp);
-
 
572
	}
545
    output_buffer ( bf, 1 ) ;
573
	output_buffer(bf, 1);
546
    return ;
574
	return;
547
}
575
}
548
 
576
 
549
 
577
 
550
/*
578
/*
551
    PRINT AN INTEGER CONSTANT
579
    PRINT AN INTEGER CONSTANT
552
 
580
 
553
    This routine prints the integer constant n to the file f.
581
    This routine prints the integer constant n to the file f.
554
*/
582
*/
555
 
583
 
556
static void print_nat_val
584
static void
557
    PROTO_N ( ( n, f ) )
-
 
558
    PROTO_T ( NAT n X FILE *f )
585
print_nat_val(NAT n, FILE *f)
559
{
586
{
560
    BUFFER *bf = clear_buffer ( &print_buff, f ) ;
587
	BUFFER *bf = clear_buffer(&print_buff, f);
561
    IGNORE print_nat ( n, 0, bf, 0 ) ;
588
	IGNORE print_nat(n, 0, bf, 0);
562
    output_buffer ( bf, 1 ) ;
589
	output_buffer(bf, 1);
563
    return ;
590
	return;
564
}
591
}
565
 
592
 
566
 
593
 
567
/*
594
/*
568
    PRINT A DECLARATION
595
    PRINT A DECLARATION
569
 
596
 
570
    This routine prints the declaration id to the file f.
597
    This routine prints the declaration id to the file f.
571
*/
598
*/
572
 
599
 
573
static void print_decl
600
static void
574
    PROTO_N ( ( id, f ) )
-
 
575
    PROTO_T ( IDENTIFIER id X FILE *f )
601
print_decl(IDENTIFIER id, FILE *f)
576
{
602
{
577
    EXP e ;
603
	EXP e;
578
    BUFFER *bf = clear_buffer ( &print_buff, f ) ;
604
	BUFFER *bf = clear_buffer(&print_buff, f);
579
    print_id_desc++ ;
605
	print_id_desc++;
580
    IGNORE print_id_long ( id, qual_none, bf, 0 ) ;
606
	IGNORE print_id_long(id, qual_none, bf, 0);
581
    print_id_desc-- ;
607
	print_id_desc--;
582
    e = DEREF_exp ( id_variable_init ( id ) ) ;
608
	e = DEREF_exp(id_variable_init(id));
583
    if ( !IS_NULL_exp ( e ) ) {
609
	if (!IS_NULL_exp(e)) {
584
	bfprintf ( bf, " = " ) ;
610
		bfprintf(bf, " = ");
585
	IGNORE print_exp ( e, 0, bf, 0 ) ;
611
		IGNORE print_exp(e, 0, bf, 0);
586
    }
612
	}
587
    output_buffer ( bf, 1 ) ;
613
	output_buffer(bf, 1);
588
    return ;
614
	return;
589
}
615
}
590
 
616
 
591
 
617
 
592
/*
618
/*
593
    PRINT A LABEL
619
    PRINT A LABEL
594
 
620
 
595
    This routine prints the label lab to the file f.
621
    This routine prints the label lab to the file f.
596
*/
622
*/
597
 
623
 
598
static void print_label
624
static void
599
    PROTO_N ( ( lab, f ) )
-
 
600
    PROTO_T ( IDENTIFIER lab X FILE *f )
625
print_label(IDENTIFIER lab, FILE *f)
601
{
626
{
602
    int op = DEREF_int ( id_label_op ( lab ) ) ;
627
	int op = DEREF_int(id_label_op(lab));
603
    if ( op == lex_identifier ) {
628
	if (op == lex_identifier) {
604
	HASHID nm = DEREF_hashid ( id_name ( lab ) ) ;
629
		HASHID nm = DEREF_hashid(id_name(lab));
605
	if ( IS_hashid_name_etc ( nm ) ) {
630
		if (IS_hashid_name_etc(nm)) {
606
	    string s = DEREF_string ( hashid_name_etc_text ( nm ) ) ;
631
			string s = DEREF_string(hashid_name_etc_text(nm));
607
	    fputs_v ( strlit ( s ), f ) ;
632
			fputs_v(strlit(s), f);
608
	} else {
633
		} else {
609
	    fputs_v ( "????", f ) ;
634
			fputs_v("????", f);
-
 
635
		}
-
 
636
	} else if (op == lex_case) {
-
 
637
		NAT n = find_case_nat(lab);
-
 
638
		fputs_v("case ", f);
-
 
639
		print_nat_val(n, f);
-
 
640
	} else {
-
 
641
		fputs_v(token_names[op], f);
610
	}
642
	}
611
    } else if ( op == lex_case ) {
-
 
612
	NAT n = find_case_nat ( lab ) ;
-
 
613
	fputs_v ( "case ", f ) ;
-
 
614
	print_nat_val ( n, f ) ;
-
 
615
    } else {
-
 
616
	fputs_v ( token_names [ op ], f ) ;
-
 
617
    }
-
 
618
    return ;
643
	return;
619
}
644
}
620
 
645
 
621
 
646
 
622
/*
647
/*
623
    PRINT A STATEMENT
648
    PRINT A STATEMENT
624
 
649
 
625
    This routine prints the statement e at an indentation of indent to the
650
    This routine prints the statement e at an indentation of indent to the
626
    file f.  block is false to suppress braces around compound statements.
651
    file f.  block is false to suppress braces around compound statements.
820
	}
850
	}
821
	case exp_location_tag : {
851
	case exp_location_tag: {
822
	    /* Location statements */
852
		/* Location statements */
823
	    EXP a = DEREF_exp ( exp_location_arg ( e ) ) ;
853
		EXP a = DEREF_exp(exp_location_arg(e));
824
	    print_stmt ( a, indent, block, f ) ;
854
		print_stmt(a, indent, block, f);
825
	    break ;
855
		break;
826
	}
856
	}
827
	default : {
857
	default : {
828
	    /* Expression statements */
858
		/* Expression statements */
829
	    print_indent ( indent, "", f ) ;
859
		print_indent(indent, "", f);
830
	    print_expr ( e, 0, 0, f ) ;
860
		print_expr(e, 0, 0, f);
831
	    fputs_v ( " ;\n", f ) ;
861
		fputs_v(" ;\n", f);
832
	    break ;
862
		break;
833
	}
863
	}
834
    }
864
	}
835
    return ;
865
	return;
836
}
866
}
837
 
867
 
838
 
868
 
839
/*
869
/*
840
    PRINT A BITMASK TYPE
870
    PRINT A BITMASK TYPE
841
 
871
 
842
    This routine prints the bitmask value n using the attribute names
872
    This routine prints the bitmask value n using the attribute names
843
    given by s.
873
    given by s.
844
*/
874
*/
845
 
875
 
846
static void print_bitmask
876
static void
847
    PROTO_N ( ( n, s ) )
-
 
848
    PROTO_T ( unsigned long n X CONST char **s )
877
print_bitmask(unsigned long n, CONST char **s)
849
{
878
{
850
    int sp = 0 ;
879
	int sp = 0;
851
    FILE *f = DEBUG_file ;
880
	FILE *f = DEBUG_file;
852
    if ( n ) {
881
	if (n) {
853
	int i ;
882
		int i;
854
	unsigned long m = 1 ;
883
		unsigned long m = 1;
855
	for ( i = 0 ; i < 32 ; i++ ) {
884
		for (i = 0; i < 32; i++) {
856
	    if ( n & m ) {
885
			if (n & m) {
857
		CONST char *c = s [i] ;
886
				CONST char *c = s[i];
858
		if ( c ) {
887
				if (c) {
-
 
888
					if (sp) {
859
		    if ( sp ) fputs_v ( " | ", f ) ;
889
						fputs_v(" | ", f);
-
 
890
					}
860
		    fputs_v ( c, f ) ;
891
					fputs_v(c, f);
861
		    sp = 1 ;
892
					sp = 1;
-
 
893
				}
-
 
894
			}
-
 
895
			m <<= 1;
862
		}
896
		}
863
	    }
-
 
864
	    m <<= 1 ;
-
 
865
	}
897
	}
866
    }
898
	if (!sp) {
867
    if ( !sp ) fputs_v ( "none", f ) ;
899
		fputs_v("none", f);
-
 
900
	}
868
    fputc_v ( '\n', f ) ;
901
	fputc_v('\n', f);
869
    fflush_v ( f ) ;
902
	fflush_v(f);
870
    return ;
903
	return;
871
}
904
}
872
 
905
 
873
 
906
 
874
/*
907
/*
875
    PRINT A BITSTREAM
908
    PRINT A BITSTREAM
876
 
909
 
877
    This routine prints the contents of the bitstream bs to the file f.
910
    This routine prints the contents of the bitstream bs to the file f.
878
*/
911
*/
879
 
912
 
880
static void print_bitstream
913
static void
881
    PROTO_N ( ( bs, f ) )
-
 
882
    PROTO_T ( BITSTREAM *bs X FILE *f )
914
print_bitstream(BITSTREAM *bs, FILE *f)
883
{
915
{
884
    if ( bs ) {
916
	if (bs) {
885
	string s = bs->text ;
917
		string s = bs->text;
886
	unsigned i = bs->bits ;
918
		unsigned i = bs->bits;
887
	unsigned n = bs->bytes ;
919
		unsigned n = bs->bytes;
888
	print_bitstream ( bs->prev, f ) ;
920
		print_bitstream(bs->prev, f);
889
	fprintf_v ( f, "0x%p = { ", ( gen_ptr ) bs ) ;
921
		fprintf_v(f, "0x%p = { ",(gen_ptr)bs);
890
	while ( n ) {
922
		while (n) {
891
	    unsigned j ;
923
			unsigned j;
892
	    unsigned c = ( unsigned ) *s ;
924
			unsigned c = (unsigned)*s;
893
	    for ( j = 0 ; j < 8 ; j++ ) {
925
			for (j = 0; j < 8; j++) {
894
		fputc_v ( ( ( c & 0x80 ) ? '1' : '0' ), f ) ;
926
				fputc_v(((c & 0x80) ? '1' : '0'), f);
895
		c <<= 1 ;
927
				c <<= 1;
896
	    }
928
			}
897
	    fputc_v ( ' ', f ) ;
929
			fputc_v(' ', f);
898
	    n-- ;
930
			n--;
899
	    s++ ;
931
			s++;
-
 
932
		}
-
 
933
		if (i) {
-
 
934
			unsigned j;
-
 
935
			unsigned c = (unsigned)*s;
-
 
936
			for (j = 0; j < i; j++) {
-
 
937
				fputc_v(((c & 0x80) ? '1' : '0'), f);
-
 
938
				c <<= 1;
-
 
939
			}
-
 
940
		}
-
 
941
		fputs_v(" }\n", f);
900
	}
942
	}
901
	if ( i ) {
-
 
902
	    unsigned j ;
-
 
903
	    unsigned c = ( unsigned ) *s ;
-
 
904
	    for ( j = 0 ; j < i ; j++ ) {
-
 
905
		fputc_v ( ( ( c & 0x80 ) ? '1' : '0' ), f ) ;
-
 
906
		c <<= 1 ;
-
 
907
	    }
-
 
908
	}
-
 
909
	fputs_v ( " }\n", f ) ;
-
 
910
    }
-
 
911
    return ;
943
	return;
912
}
944
}
913
 
945
 
914
 
946
 
915
/*
947
/*
916
    TYPE DEBUGGING ROUTINES
948
    TYPE DEBUGGING ROUTINES
917
 
949
 
918
    These routines are used during debugging for printing objects of various
950
    These routines are used during debugging for printing objects of various
919
    types.
951
    types.
1498
}
1475
}
1499
 
1476
 
-
 
1477
void
-
 
1478
DEBUG_virt(VIRTUAL vt)
-
 
1479
{
-
 
1480
	if (!IS_NULL_virt(vt)) {
-
 
1481
		if (IS_virt_table(vt)) {
-
 
1482
			unsigned n = 1;
-
 
1483
			LIST(VIRTUAL)vs = DEREF_list(virt_table_entries(vt));
-
 
1484
			while (!IS_NULL_list(vs)) {
-
 
1485
				vt = DEREF_virt(HEAD_list(vs));
-
 
1486
				fprintf_v(DEBUG_file, "%u: ", n);
1500
void DEBUG_where
1487
				DEBUG_virt(vt);
-
 
1488
				n++;
-
 
1489
				vs = TAIL_list(vs);
-
 
1490
			}
1501
    PROTO_Z ()
1491
		} else {
-
 
1492
			IDENTIFIER fn = DEREF_id(virt_func(vt));
-
 
1493
			DEBUG_id_long(fn);
-
 
1494
		}
-
 
1495
	}
-
 
1496
	return;
-
 
1497
}
-
 
1498
 
-
 
1499
void
-
 
1500
DEBUG_where(void)
1502
{
1501
{
1503
    update_column () ;
1502
	update_column();
1504
    DEBUG_loc ( &crt_loc ) ;
1503
	DEBUG_loc(&crt_loc);
1505
    return ;
1504
	return;
1506
}
1505
}
1507
 
1506
 
1508
 
1507
 
1509
/*
1508
/*
1510
    GENERIC TYPE DEBUGGING ROUTINE
1509
    GENERIC TYPE DEBUGGING ROUTINE
1511
 
1510
 
1512
    This routine is a generic debugging routine for printing any c_class
1511
    This routine is a generic debugging routine for printing any c_class
1513
    object.  It relies on run-time type information to determine the
1512
    object.  It relies on run-time type information to determine the
1514
    static type of p.
1513
    static type of p.
1515
*/
1514
*/
1516
 
1515
 
1517
#if c_class_IMPLEMENTATION
1516
#if c_class_IMPLEMENTATION
1518
 
1517
 
1519
void DEBUG_c_class
1518
void
1520
    PROTO_N ( ( p, indent ) )
-
 
1521
    PROTO_T ( c_class *p X int indent )
1519
DEBUG_c_class(c_class *p, int indent)
1522
{
1520
{
1523
    FILE *f = DEBUG_file ;
1521
	FILE *f = DEBUG_file;
1524
    debugging++ ;
1522
	debugging++;
1525
    if ( p ) {
1523
	if (p) {
1526
	unsigned n = TYPEID ( p ) ;
1524
		unsigned n = TYPEID(p);
1527
	switch ( n ) {
1525
		switch (n) {
1528
	    case TYPEID_ptr : {
1526
		case TYPEID_ptr: {
1529
		DEBUG_c_class ( p->ag_ptr, indent ) ;
1527
			DEBUG_c_class(p->ag_ptr, indent);
1530
		break ;
1528
			break;
1531
	    }
-
 
1532
	    case TYPEID_list :
-
 
1533
	    case TYPEID_stack : {
-
 
1534
		print_indent ( indent, "{\n", f ) ;
-
 
1535
		while ( !IS_NULL_list ( p ) ) {
-
 
1536
		    c_class *q = ( HEAD_list ( p ) )->ag_ptr ;
-
 
1537
		    DEBUG_c_class ( q, indent + 1 ) ;
-
 
1538
		    p = TAIL_list ( p ) ;
-
 
1539
		}
1529
		}
1540
		print_indent ( indent, "}\n", f ) ;
-
 
1541
		break ;
-
 
1542
	    }
-
 
1543
	    case TYPEID_exp : {
1530
		case TYPEID_list:
1544
		print_stmt ( p, indent, 1, f ) ;
-
 
1545
		break ;
-
 
1546
	    }
-
 
1547
	    default : {
1531
		case TYPEID_stack: {
1548
		print_indent ( indent, "", f ) ;
1532
			print_indent(indent, "{\n", f);
1549
		switch ( n ) {
1533
			while (!IS_NULL_list(p)) {
1550
		    case TYPEID_ctype : DEBUG_ctype ( p ) ; break ;
-
 
1551
		    case TYPEID_err : report ( crt_loc, p ) ; break ;
-
 
1552
		    case TYPEID_etype : DEBUG_etype ( p ) ; break ;
-
 
1553
		    case TYPEID_flt : DEBUG_flt ( p ) ; break ;
-
 
1554
		    case TYPEID_ftype : DEBUG_ftype ( p ) ; break ;
-
 
1555
		    case TYPEID_graph : DEBUG_graph ( p ) ; break ;
-
 
1556
		    case TYPEID_hashid : DEBUG_hashid ( p ) ; break ;
-
 
1557
		    case TYPEID_id : DEBUG_id_long ( p ) ; break ;
-
 
1558
		    case TYPEID_inst : DEBUG_inst ( p ) ; break ;
1534
				c_class *q = (HEAD_list(p))->ag_ptr;
1559
		    case TYPEID_itype : DEBUG_itype ( p ) ; break ;
-
 
1560
		    case TYPEID_member : DEBUG_member ( p ) ; break ;
-
 
1561
		    case TYPEID_nat : DEBUG_nat ( p ) ; break ;
1535
				DEBUG_c_class(q, indent + 1);
1562
		    case TYPEID_nspace : DEBUG_nspace ( p ) ; break ;
-
 
1563
		    case TYPEID_off : DEBUG_offset ( p ) ; break ;
-
 
1564
		    case TYPEID_str : DEBUG_str ( p ) ; break ;
1536
				p = TAIL_list(p);
1565
		    case TYPEID_tok : DEBUG_sort ( p ) ; break ;
-
 
1566
		    case TYPEID_type : DEBUG_type ( p ) ; break ;
-
 
1567
		    case TYPEID_virt : DEBUG_virt ( p ) ; break ;
-
 
-
 
1537
			}
1568
		    case TYPEID_free : fputs_v ( "FREE\n", f ) ; break ;
1538
			print_indent(indent, "}\n", f);
1569
		    default : fputs_v ( "UNKNOWN\n", f ) ; break ;
1539
			break;
1570
		}
1540
		}
-
 
1541
		case TYPEID_exp: {
-
 
1542
			print_stmt(p, indent, 1, f);
1571
		break ;
1543
			break;
-
 
1544
		}
-
 
1545
		default : {
-
 
1546
			print_indent(indent, "", f);
-
 
1547
			switch (n) {
-
 
1548
			case TYPEID_ctype:
-
 
1549
				DEBUG_ctype(p);
-
 
1550
				break;
-
 
1551
			case TYPEID_err:
-
 
1552
				report(crt_loc, p);
-
 
1553
				break;
-
 
1554
			case TYPEID_etype:
-
 
1555
				DEBUG_etype(p);
-
 
1556
				break;
-
 
1557
			case TYPEID_flt:
-
 
1558
				DEBUG_flt(p);
-
 
1559
				break;
-
 
1560
			case TYPEID_ftype:
-
 
1561
				DEBUG_ftype(p);
-
 
1562
				break;
-
 
1563
			case TYPEID_graph:
-
 
1564
				DEBUG_graph(p);
-
 
1565
				break;
-
 
1566
			case TYPEID_hashid:
-
 
1567
				DEBUG_hashid(p);
-
 
1568
				break;
-
 
1569
			case TYPEID_id:
-
 
1570
				DEBUG_id_long(p);
-
 
1571
				break;
-
 
1572
			case TYPEID_inst:
-
 
1573
				DEBUG_inst(p);
-
 
1574
				break;
-
 
1575
			case TYPEID_itype:
-
 
1576
				DEBUG_itype(p);
-
 
1577
				break;
-
 
1578
			case TYPEID_member:
-
 
1579
				DEBUG_member(p);
-
 
1580
				break;
-
 
1581
			case TYPEID_nat:
-
 
1582
				DEBUG_nat(p);
-
 
1583
				break;
-
 
1584
			case TYPEID_nspace:
-
 
1585
				DEBUG_nspace(p);
-
 
1586
				break;
-
 
1587
			case TYPEID_off:
-
 
1588
				DEBUG_offset(p);
-
 
1589
				break;
-
 
1590
			case TYPEID_str:
-
 
1591
				DEBUG_str(p);
-
 
1592
				break;
-
 
1593
			case TYPEID_tok:
-
 
1594
				DEBUG_sort(p);
-
 
1595
				break;
-
 
1596
			case TYPEID_type:
-
 
1597
				DEBUG_type(p);
-
 
1598
				break;
-
 
1599
			case TYPEID_virt:
-
 
1600
				DEBUG_virt(p);
-
 
1601
				break;
-
 
1602
			case TYPEID_free:
-
 
1603
				fputs_v("FREE\n", f);
-
 
1604
				break;
-
 
1605
			default:
-
 
1606
				fputs_v("UNKNOWN\n", f);
-
 
1607
				break;
1572
	    }
1608
			}
-
 
1609
			break;
-
 
1610
		}
-
 
1611
		}
-
 
1612
	} else {
-
 
1613
		print_indent(indent, "NULL\n", f);
1573
	}
1614
	}
1574
    } else {
-
 
1575
	print_indent ( indent, "NULL\n", f ) ;
-
 
1576
    }
-
 
1577
    fflush_v ( f ) ;
1615
	fflush_v(f);
1578
    debugging-- ;
1616
	debugging--;
1579
    return ;
1617
	return;
1580
}
1618
}
1581
 
1619
 
1582
void debug
1620
void
1583
    PROTO_N ( ( p ) )
-
 
1584
    PROTO_T ( c_class *p )
1621
debug(c_class *p)
1585
{
1622
{
1586
    DEBUG_c_class ( p, 0 ) ;
1623
	DEBUG_c_class(p, 0);
1587
    return ;
1624
	return;
1588
}
1625
}
1589
 
1626
 
1590
#ifdef DEBUG
1627
#ifdef DEBUG
1591
#undef DEBUG
1628
#undef DEBUG
1592
#endif
1629
#endif
1593
 
1630
 
1594
void DEBUG
1631
void
1595
    PROTO_N ( ( p ) )
-
 
1596
    PROTO_T ( c_class *p )
1632
DEBUG(c_class *p)
1597
{
1633
{
1598
    DEBUG_c_class ( p, 0 ) ;
1634
	DEBUG_c_class(p, 0);
1599
    return ;
1635
	return;
1600
}
1636
}
1601
 
1637
 
1602
#endif /* c_class_IMPLEMENTATION */
1638
#endif /* c_class_IMPLEMENTATION */
1603
 
1639
 
1604
 
1640
 
Line 1608... Line 1644...
1608
    The terminals used in the parser are listed in two places - in symbols.h
1644
    The terminals used in the parser are listed in two places - in symbols.h
1609
    and in syntax.sid.
1645
    and in syntax.sid.
1610
*/
1646
*/
1611
 
1647
 
1612
#if FS_STDC_HASH
1648
#if FS_STDC_HASH
1613
#define LEX_TOKEN( A, B, C )	print_terminal ( ( A ), #A, m ) ;
1649
#define LEX_TOKEN(A, B, C)	print_terminal((A), #A, m);
1614
#else
1650
#else
1615
#define LEX_TOKEN( A, B, C )	print_terminal ( ( A ), "A", m ) ;
1651
#define LEX_TOKEN(A, B, C)	print_terminal((A), "A", m);
1616
#endif
1652
#endif
1617
 
1653
 
1618
 
1654
 
1619
/*
1655
/*
1620
    TERMINAL COUNT
1656
    TERMINAL COUNT
1621
 
1657
 
1622
    This variable is used to keep count of the number of lexical tokens
1658
    This variable is used to keep count of the number of lexical tokens
1623
    printed.
1659
    printed.
1624
*/
1660
*/
1625
 
1661
 
1626
static int terminal_no = 0 ;
1662
static int terminal_no = 0;
1627
 
1663
 
1628
 
1664
 
1629
/*
1665
/*
1630
    PRINT A TERMINAL
1666
    PRINT A TERMINAL
1631
 
1667
 
1632
    This routine prints the single terminal, term, with the given return
1668
    This routine prints the single terminal, term, with the given return
1633
    type.  The use argument may be set to false to indicate that the
1669
    type.  The use argument may be set to false to indicate that the
1634
    terminal is not used in the sid parser.
1670
    terminal is not used in the sid parser.
1635
*/
1671
*/
1636
 
1672
 
1637
static void print_terminal
1673
static void
1638
    PROTO_N ( ( t, term, m ) )
-
 
1639
    PROTO_T ( int t X char *term X int m )
1674
print_terminal(int t, char *term, int m)
1640
{
1675
{
1641
    char c ;
1676
	char c;
1642
    FILE *f = DEBUG_file ;
1677
	FILE *f = DEBUG_file;
1643
    unsigned long col = 0 ;
1678
	unsigned long col = 0;
1644
    unsigned long tab = tab_width ;
1679
	unsigned long tab = tab_width;
1645
    while ( *term == ' ' ) term++ ;
1680
	while (*term == ' ')term++;
1646
    if ( t != terminal_no ) {
1681
	if (t != terminal_no) {
1647
	error ( ERROR_WARNING, "Value of '%s' wrong", term ) ;
1682
		error(ERROR_WARNING, "Value of '%s' wrong", term);
1648
    }
-
 
1649
    if ( m ) {
-
 
1650
	term += strlen ( "lex_" ) ;
-
 
1651
    } else {
-
 
1652
	fprintf_v ( f, "#define " ) ;
-
 
1653
	col = ( unsigned long ) strlen ( "#define " ) ;
-
 
1654
    }
-
 
1655
    while ( c = *( term++ ), ( c != 0 && c != ' ' ) ) {
-
 
1656
	if ( c == '_' && m ) c = '-' ;
-
 
1657
	fputc_v ( c, f ) ;
-
 
1658
	col++ ;
-
 
1659
    }
-
 
1660
    if ( m ) {
-
 
1661
	fprintf_v ( f, " ;\n" ) ;
-
 
1662
    } else {
-
 
1663
	while ( col < 5 * tab ) {
-
 
1664
	    fputc_v ( '\t', f ) ;
-
 
1665
	    col = tab * ( col / tab + 1 ) ;
-
 
1666
	}
1683
	}
-
 
1684
	if (m) {
-
 
1685
		term += strlen("lex_");
-
 
1686
	} else {
-
 
1687
		fprintf_v(f, "#define ");
-
 
1688
		col = (unsigned long)strlen("#define ");
-
 
1689
	}
-
 
1690
	while (c = *(term++), (c != 0 && c != ' ')) {
-
 
1691
		if (c == '_' && m) {
-
 
1692
			c = '-';
-
 
1693
		}
-
 
1694
		fputc_v(c, f);
-
 
1695
		col++;
-
 
1696
	}
-
 
1697
	if (m) {
-
 
1698
		fprintf_v(f, " ;\n");
-
 
1699
	} else {
-
 
1700
		while (col < 5 * tab) {
-
 
1701
			fputc_v('\t', f);
-
 
1702
			col = tab *(col / tab + 1);
-
 
1703
		}
1667
	fprintf_v ( f, "%d\n", terminal_no ) ;
1704
		fprintf_v(f, "%d\n", terminal_no);
1668
    }
1705
	}
1669
    terminal_no++ ;
1706
	terminal_no++;
1670
    return ;
1707
	return;
1671
}
1708
}
1672
 
1709
 
1673
 
1710
 
1674
/*
1711
/*
1675
    PRINT ALL THE TERMINALS
1712
    PRINT ALL THE TERMINALS
1676
 
1713
 
1677
    This routine prints all the terminals in a form acceptable to sid.
1714
    This routine prints all the terminals in a form acceptable to sid.
1678
*/
1715
*/
1679
 
1716
 
1680
static void sid_terminals
1717
static void
1681
    PROTO_N ( ( m ) )
-
 
1682
    PROTO_T ( int m )
1718
sid_terminals(int m)
1683
{
1719
{
1684
    FILE *f = DEBUG_file ;
1720
	FILE *f = DEBUG_file;
1685
    terminal_no = 0 ;
1721
	terminal_no = 0;
1686
    fprintf_v ( f, "/* Automatically generated list of terminals */\n" ) ;
1722
	fprintf_v ( f, "/* Automatically generated list of terminals */\n" ) ;
1687
#include "symbols.h"
1723
#include "symbols.h"
1688
#undef LEX_TOKEN
1724
#undef LEX_TOKEN
1689
    return ;
1725
	return;
1690
}
1726
}
1691
 
1727
 
1692
 
1728
 
1693
/*
1729
/*
1694
    PRINT ALL THE ERRORS
1730
    PRINT ALL THE ERRORS
1695
 
1731
 
1696
    This routine lists all the error names.
1732
    This routine lists all the error names.
1697
*/
1733
*/
1698
 
1734
 
1699
static void list_errors
1735
static void
1700
    PROTO_Z ()
1736
list_errors(void)
1701
{
1737
{
1702
    FILE *f = DEBUG_file ;
1738
	FILE *f = DEBUG_file;
1703
    ERR_DATA *p = ERR_CATALOG ;
1739
	ERR_DATA *p = ERR_CATALOG;
1704
    init_option ( 0 ) ;
1740
	init_option(0);
1705
    while ( p->name ) {
1741
	while (p->name) {
1706
	fprintf_v ( f, "%s\n", p->name ) ;
1742
		fprintf_v(f, "%s\n", p->name);
1707
	p++ ;
1743
		p++;
1708
    }
1744
	}
1709
    return ;
1745
	return;
1710
}
1746
}
1711
 
1747
 
1712
 
1748
 
1713
/*
1749
/*
1714
    PRINT ALL THE OPTIONS
1750
    PRINT ALL THE OPTIONS
1715
 
1751
 
1716
    This routine lists all the option names.
1752
    This routine lists all the option names.
1717
*/
1753
*/
1718
 
1754
 
1719
static void list_options
1755
static void
1720
    PROTO_Z ()
1756
list_options(void)
1721
{
1757
{
1722
    FILE *f = DEBUG_file ;
1758
	FILE *f = DEBUG_file;
1723
    OPT_DATA *p = OPT_CATALOG ;
1759
	OPT_DATA *p = OPT_CATALOG;
1724
    while ( p->name ) {
1760
	while (p->name) {
1725
	fprintf_v ( f, "%s\n", p->name ) ;
1761
		fprintf_v(f, "%s\n", p->name);
1726
	p++ ;
1762
		p++;
1727
    }
1763
	}
1728
    return ;
1764
	return;
1729
}
1765
}
1730
 
1766
 
1731
 
1767
 
1732
/*
1768
/*
1733
    DEFINE ALL THE OPTION VALUES
1769
    DEFINE ALL THE OPTION VALUES
1734
 
1770
 
1735
    This routine prints a list of all option values in a form suitable
1771
    This routine prints a list of all option values in a form suitable
1736
    as a usage list in the error catalogue.
1772
    as a usage list in the error catalogue.
1737
*/
1773
*/
1738
 
1774
 
1739
static void define_options
1775
static void
1740
    PROTO_Z ()
1776
define_options(void)
1741
{
1777
{
1742
    int col = 0 ;
1778
	int col = 0;
1743
    int comma = 0 ;
1779
	int comma = 0;
1744
    CONST char *s ;
1780
	CONST char *s;
1745
    FILE *f = DEBUG_file ;
1781
	FILE *f = DEBUG_file;
1746
    OPT_DATA *p = OPT_CATALOG ;
1782
	OPT_DATA *p = OPT_CATALOG;
1747
    fprintf_v ( f, "    " ) ;
1783
	fprintf_v(f, "    ");
1748
    while ( s = p->name, s != NULL ) {
1784
	while (s = p->name, s != NULL) {
1749
	char c ;
1785
		char c;
1750
	if ( comma ) {
1786
		if (comma) {
1751
	    fputc_v ( ',', f ) ;
1787
			fputc_v(',', f);
-
 
1788
			col++;
-
 
1789
		}
-
 
1790
		if (col > 60) {
-
 
1791
			fprintf_v(f, "\n    ");
-
 
1792
			comma = 0;
-
 
1793
			col = 0;
-
 
1794
		}
-
 
1795
		if (comma) {
-
 
1796
			fputc_v(' ', f);
-
 
1797
			col++;
-
 
1798
		}
-
 
1799
		while (c = *(s++), c != 0) {
-
 
1800
			if (c == '.') {
-
 
1801
				c = '_';
-
 
1802
			}
-
 
1803
			fputc_v(c, f);
1752
	    col++ ;
1804
			col++;
-
 
1805
		}
-
 
1806
		comma = 1;
-
 
1807
		p++;
1753
	}
1808
	}
1754
	if ( col > 60 ) {
-
 
1755
	    fprintf_v ( f, "\n    " ) ;
-
 
1756
	    comma = 0 ;
-
 
1757
	    col = 0 ;
-
 
1758
	}
-
 
1759
	if ( comma ) {
-
 
1760
	    fputc_v ( ' ', f ) ;
-
 
1761
	    col++ ;
-
 
1762
	}
-
 
1763
	while ( c = *( s++ ), c != 0 ) {
-
 
1764
	    if ( c == '.' ) c = '_' ;
-
 
1765
	    fputc_v ( c, f ) ;
-
 
1766
	    col++ ;
-
 
1767
	}
-
 
1768
	comma = 1 ;
-
 
1769
	p++ ;
-
 
1770
    }
-
 
1771
    fputc_v ( '\n', f ) ;
1809
	fputc_v('\n', f);
1772
    return ;
1810
	return;
1773
}
1811
}
1774
 
1812
 
1775
 
1813
 
1776
/*
1814
/*
1777
    HANDLE DEBUGGING OPTIONS
1815
    HANDLE DEBUGGING OPTIONS
1778
 
1816
 
1779
    This routine is called to handle the debug option '-d arg'.
1817
    This routine is called to handle the debug option '-d arg'.
1780
*/
1818
*/
1781
 
1819
 
1782
void debug_option
1820
void
1783
    PROTO_N ( ( arg ) )
-
 
1784
    PROTO_T ( char *arg )
1821
debug_option(char *arg)
1785
{
1822
{
1786
    if ( streq ( arg, "error" ) ) {
1823
	if (streq(arg, "error")) {
1787
	list_errors () ;
1824
		list_errors();
1788
    } else if ( streq ( arg, "lex" ) ) {
1825
	} else if (streq(arg, "lex")) {
1789
	sid_terminals ( 0 ) ;
1826
		sid_terminals(0);
1790
    } else if ( streq ( arg, "opt" ) ) {
1827
	} else if (streq(arg, "opt")) {
1791
	define_options () ;
1828
		define_options();
1792
    } else if ( streq ( arg, "option" ) ) {
1829
	} else if (streq(arg, "option")) {
1793
	list_options () ;
1830
		list_options();
1794
    } else if ( streq ( arg, "sid" ) ) {
1831
	} else if (streq(arg, "sid")) {
1795
	sid_terminals ( 1 ) ;
1832
		sid_terminals(1);
1796
    } else {
1833
	} else {
1797
	error ( ERROR_WARNING, "Unknown option, '-d%s'", arg ) ;
1834
		error(ERROR_WARNING, "Unknown option, '-d%s'", arg);
1798
    }
1835
	}
1799
    return ;
1836
	return;
1800
}
1837
}
1801
 
1838
 
1802
 
1839
 
1803
#else /* RUNTIME */
1840
#else /* RUNTIME */
1804
 
1841
 
Line 1810... Line 1847...
1810
    not enabled.
1847
    not enabled.
1811
*/
1848
*/
1812
 
1849
 
1813
#if c_class_IMPLEMENTATION
1850
#if c_class_IMPLEMENTATION
1814
 
1851
 
1815
void debug
1852
void
1816
   PROTO_N ( ( p ) )
-
 
1817
   PROTO_T ( c_class *p )
1853
debug(c_class *p)
1818
{
1854
{
1819
    error ( ERROR_INTERNAL, "Not compiled with debugging enabled" ) ;
1855
	error(ERROR_INTERNAL, "Not compiled with debugging enabled");
1820
    UNUSED ( p ) ;
1856
	UNUSED(p);
1821
    return ;
1857
	return;
1822
}
1858
}
1823
 
1859
 
1824
#endif /* c_class_IMPLEMENTATION */
1860
#endif /* c_class_IMPLEMENTATION */
1825
 
1861
 
1826
 
1862