Subversion Repositories tendra.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
7 7u83 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
 */
31
/*
2 7u83 32
    		 Crown Copyright (c) 1997
7 7u83 33
 
2 7u83 34
    This TenDRA(r) Computer Program is subject to Copyright
35
    owned by the United Kingdom Secretary of State for Defence
36
    acting through the Defence Evaluation and Research Agency
37
    (DERA).  It is made available to Recipients with a
38
    royalty-free licence for its use, reproduction, transfer
39
    to other parties and amendment for any purpose not excluding
40
    product development provided that any such use et cetera
41
    shall be deemed to be acceptance of the following conditions:-
7 7u83 42
 
2 7u83 43
        (1) Its Recipients shall ensure that this Notice is
44
        reproduced upon any copies or amended versions of it;
7 7u83 45
 
2 7u83 46
        (2) Any amended version of it shall be clearly marked to
47
        show both the nature of and the organisation responsible
48
        for the relevant amendment or amendments;
7 7u83 49
 
2 7u83 50
        (3) Its onward transfer from a recipient to another
51
        party shall be deemed to be that party's acceptance of
52
        these conditions;
7 7u83 53
 
2 7u83 54
        (4) DERA gives no warranty or assurance as to its
55
        quality or suitability for any purpose and DERA accepts
56
        no liability whatsoever in relation to any use to which
57
        it may be put.
58
*/
59
 
60
 
61
#include "config.h"
62
#include "c_types.h"
63
#include "exp_ops.h"
64
#include "id_ops.h"
65
#include "member_ops.h"
66
#include "nspace_ops.h"
67
#include "off_ops.h"
68
#include "type_ops.h"
69
#include "error.h"
70
#include "destroy.h"
71
#include "exception.h"
72
#include "macro.h"
73
 
74
 
75
/*
76
    FREE A LOCAL IDENTIFIER
77
 
78
    This routine frees the local identifier id.
79
*/
80
 
7 7u83 81
static void
82
free_id(IDENTIFIER id, int force)
2 7u83 83
{
7 7u83 84
	if (IS_NULL_id(id)) {
85
		return;
2 7u83 86
	}
7 7u83 87
	switch (TAG_id(id)) {
88
	case id_variable_tag: {
89
		DECL_SPEC ds = DEREF_dspec(id_storage(id));
90
		if (ds & dspec_auto) {
91
			EXP e = DEREF_exp(id_variable_init(id));
92
			EXP d = DEREF_exp(id_variable_term(id));
93
			if (!IS_NULL_exp(e)) {
94
				free_exp(e, force);
95
			}
96
			if (!IS_NULL_exp(d)) {
97
				free_exp(d, force);
98
			}
99
			COPY_exp(id_variable_init(id), NULL_exp);
100
			COPY_exp(id_variable_term(id), NULL_exp);
101
		}
102
		break;
2 7u83 103
	}
7 7u83 104
	case id_label_tag: {
105
		LIST(VARIABLE)v = DEREF_list(id_label_vars(id));
106
		DESTROY_list(v, SIZE_var);
107
		COPY_list(id_label_vars(id), NULL_list(VARIABLE));
108
		COPY_exp(id_label_stmt(id), NULL_exp);
109
		COPY_exp(id_label_gotos(id), NULL_exp);
110
		break;
111
	}
112
	}
113
	return;
2 7u83 114
}
115
 
116
 
117
/*
118
    FREE A NAMESPACE
119
 
120
    This routine frees the block namespace ns.
121
*/
122
 
7 7u83 123
void
124
free_nspace(NAMESPACE ns)
2 7u83 125
{
7 7u83 126
	if (!IS_NULL_nspace(ns)) {
127
		MEMBER mem = DEREF_member(nspace_last(ns));
128
		while (!IS_NULL_member(mem)) {
129
			IDENTIFIER id;
130
			IDENTIFIER alt;
131
			DESTROY_member_small(destroy, id, alt, mem, mem);
132
			UNUSED(id);
133
			UNUSED(alt);
134
		}
135
		COPY_member(nspace_last(ns), NULL_member);
136
		COPY_member(nspace_prev(ns), NULL_member);
2 7u83 137
	}
7 7u83 138
	return;
2 7u83 139
}
140
 
141
 
142
/*
143
    FREE AN OFFSET
144
 
145
    This routine frees the offset off.  Note that member and base offsets
146
    are linked directly to the classes they represent and so are not
147
    destroyed here.
148
*/
149
 
7 7u83 150
void
151
free_offset(OFFSET off, int force)
2 7u83 152
{
7 7u83 153
	if (IS_NULL_off(off)) {
154
		return;
2 7u83 155
	}
7 7u83 156
	ASSERT(ORDER_off == 13);
157
	switch (TAG_off(off)) {
158
	case off_zero_tag: {
159
		TYPE t;
160
		DESTROY_off_zero(destroy, t, off);
161
		UNUSED(t);
162
		break;
2 7u83 163
	}
7 7u83 164
	case off_type_tag: {
165
		TYPE t;
166
		DESTROY_off_type(destroy, t, off);
167
		UNUSED(t);
168
		break;
2 7u83 169
	}
7 7u83 170
	case off_extra_tag: {
171
		int n;
172
		TYPE t;
173
		DESTROY_off_extra(destroy, t, n, off);
174
		UNUSED(n);
175
		UNUSED(t);
176
		break;
2 7u83 177
	}
7 7u83 178
	case off_array_tag: {
179
		TYPE t;
180
		unsigned n;
181
		DESTROY_off_array(destroy, t, n, off);
182
		UNUSED(n);
183
		UNUSED(t);
184
		break;
2 7u83 185
	}
7 7u83 186
	case off_ptr_mem_tag: {
187
		EXP a;
188
		DESTROY_off_ptr_mem(destroy, a, off);
189
		free_exp(a, force);
190
		break;
2 7u83 191
	}
7 7u83 192
	case off_negate_tag: {
193
		OFFSET a;
194
		DESTROY_off_negate(destroy, a, off);
195
		free_offset(a, force);
196
		break;
2 7u83 197
	}
7 7u83 198
	case off_mult_tag: {
199
		EXP b;
200
		OFFSET a;
201
		DESTROY_off_mult(destroy, a, b, off);
202
		free_offset(a, force);
203
		free_exp(b, force);
204
		break;
2 7u83 205
	}
7 7u83 206
	case off_ptr_diff_tag: {
207
		EXP a, b;
208
		DESTROY_off_ptr_diff(destroy, a, b, off);
209
		free_exp(a, force);
210
		free_exp(b, force);
211
		break;
2 7u83 212
	}
7 7u83 213
	case off_base_tag:
214
	case off_deriv_tag:
215
	case off_member_tag:
216
	case off_plus_tag:
217
	case off_token_tag: {
218
		/* Don't free these cases */
219
		break;
220
	}
221
	}
222
	return;
2 7u83 223
}
224
 
225
 
226
/*
227
    DESTROY A LIST OF EXPRESSIONS
228
 
229
    This routine frees the list of expressions p.
230
*/
231
 
7 7u83 232
void
233
free_exp_list(LIST(EXP)p, int force)
2 7u83 234
{
7 7u83 235
	while (!IS_NULL_list(p)) {
236
		EXP e;
237
		DESTROY_CONS_exp(destroy, e, p, p);
238
		free_exp(e, force);
239
	}
240
	return;
2 7u83 241
}
242
 
243
 
244
/*
245
    FREE AN EXPRESSION
246
 
247
    This routine frees the expression e.  It is possible for the same
248
    sub-expression to be reused twice in an expression, so freed expressions
249
    are marked by having their type set to the rule type.  This exploits
250
    some knowledge about about how destroy_c_class works.
251
*/
252
 
7 7u83 253
void
254
free_exp(EXP e, int force)
2 7u83 255
{
7 7u83 256
	TYPE t;
257
	EXP a, b;
258
	int force1 = force;
259
	if (force1 == 0) {
260
		force1 = 1;
261
	}
2 7u83 262
 
7 7u83 263
	/* Check expression type */
264
	if (IS_NULL_exp(e)) {
265
		return;
266
	}
267
	t = DEREF_type(exp_type(e));
268
	if (IS_NULL_type(t) || IS_type_error(t)) {
269
		return;
270
	}
271
	COPY_type(exp_type(e), NULL_type);
2 7u83 272
 
7 7u83 273
	/* Deal with the various cases */
274
	ASSERT(ORDER_exp == 88);
275
	switch (TAG_exp(e)) {
276
	case exp_identifier_tag:
277
	case exp_member_tag:
278
	case exp_ambiguous_tag:
279
	case exp_undeclared_tag: {
280
		IDENTIFIER id;
281
		QUALIFIER qual;
282
		DESTROY_exp_identifier_etc(destroy, t, id, qual, e);
283
		UNUSED(qual);
284
		UNUSED(id);
285
		break;
2 7u83 286
	}
7 7u83 287
	case exp_int_lit_tag: {
288
		NAT n;
289
		unsigned etag;
290
		DESTROY_exp_int_lit(destroy, t, n, etag, e);
291
		UNUSED(etag);
292
		UNUSED(n);
293
		break;
2 7u83 294
	}
7 7u83 295
	case exp_float_lit_tag: {
296
		FLOAT f;
297
		DESTROY_exp_float_lit(destroy, t, f, e);
298
		UNUSED(f);
299
		break;
2 7u83 300
	}
7 7u83 301
	case exp_char_lit_tag: {
302
		int r;
303
		STRING s;
304
		DESTROY_exp_char_lit(destroy, t, s, r, e);
305
		UNUSED(s);
306
		UNUSED(r);
307
		break;
2 7u83 308
	}
7 7u83 309
	case exp_string_lit_tag: {
310
		STRING s;
311
		DESTROY_exp_string_lit(destroy, t, s, e);
312
		UNUSED(s);
313
		break;
2 7u83 314
	}
7 7u83 315
	case exp_value_tag: {
316
		DESTROY_exp_value(destroy, t, e);
317
		break;
2 7u83 318
	}
7 7u83 319
	case exp_null_tag: {
320
		DESTROY_exp_null(destroy, t, e);
321
		break;
2 7u83 322
	}
7 7u83 323
	case exp_zero_tag: {
324
		DESTROY_exp_zero(destroy, t, e);
325
		break;
2 7u83 326
	}
7 7u83 327
	case exp_paren_tag: {
328
		DESTROY_exp_paren(destroy, t, a, e);
329
		free_exp(a, force1);
330
		break;
2 7u83 331
	}
7 7u83 332
	case exp_copy_tag: {
333
		DESTROY_exp_copy(destroy, t, a, e);
334
		UNUSED(a);
335
		break;
2 7u83 336
	}
7 7u83 337
	case exp_assign_tag: {
338
		DESTROY_exp_assign(destroy, t, a, b, e);
339
		free_exp(a, force1);
340
		free_exp(b, force1);
341
		break;
2 7u83 342
	}
7 7u83 343
	case exp_init_tag: {
344
		IDENTIFIER id;
345
		DESTROY_exp_init(destroy, t, id, a, e);
346
		if (force == 2) {
347
			DECL_SPEC ds = DEREF_dspec(id_storage(id));
348
			if (ds & dspec_temp) {
349
				/* Remove temporary variable */
350
				ds |= dspec_ignore;
351
				COPY_dspec(id_storage(id), ds);
352
			}
2 7u83 353
		}
7 7u83 354
		free_exp(a, force1);
355
		break;
2 7u83 356
	}
7 7u83 357
	case exp_preinc_tag: {
358
		int bc;
359
		DESTROY_exp_preinc(destroy, t, a, b, bc, e);
360
		free_exp(b, force1);
361
		UNUSED(bc);
362
		UNUSED(a);
363
		break;
2 7u83 364
	}
7 7u83 365
	case exp_postinc_tag: {
366
		EXP c;
367
		DESTROY_exp_postinc(destroy, t, a, b, c, e);
368
		free_exp(c, force1);
369
		UNUSED(a);
370
		UNUSED(b);
371
		break;
2 7u83 372
	}
7 7u83 373
	case exp_indir_tag: {
374
		int i;
375
		DESTROY_exp_indir(destroy, t, a, i, e);
376
		free_exp(a, force1);
377
		UNUSED(i);
378
		break;
2 7u83 379
	}
7 7u83 380
	case exp_contents_tag: {
381
		DESTROY_exp_contents(destroy, t, a, e);
382
		free_exp(a, force1);
383
		break;
2 7u83 384
	}
7 7u83 385
	case exp_address_tag: {
386
		DESTROY_exp_address(destroy, t, a, e);
387
		free_exp(a, force1);
388
		break;
2 7u83 389
	}
7 7u83 390
	case exp_address_mem_tag: {
391
		int paren;
392
		DESTROY_exp_address_mem(destroy, t, a, paren, e);
393
		UNUSED(paren);
394
		free_exp(a, force1);
395
		break;
2 7u83 396
	}
7 7u83 397
	case exp_func_tag: {
398
		unsigned n;
399
		LIST(EXP)p;
400
		DESTROY_exp_func(destroy, t, a, p, n, e);
401
		free_exp_list(p, force1);
402
		free_exp(a, force1);
403
		UNUSED(n);
404
		break;
2 7u83 405
	}
7 7u83 406
	case exp_func_id_tag: {
407
		unsigned n;
408
		IDENTIFIER id;
409
		LIST(EXP)p;
410
		DESTROY_exp_func_id(destroy, t, id, p, b, n, e);
411
		free_exp_list(p, force1);
412
		UNUSED(id);
413
		UNUSED(b);
414
		UNUSED(n);
415
		break;
2 7u83 416
	}
7 7u83 417
	case exp_call_tag: {
418
		GRAPH gr;
419
		DESTROY_exp_call(destroy, t, a, b, gr, e);
420
		free_exp(a, force1);
421
		free_exp(b, force1);
422
		UNUSED(gr);
423
		break;
2 7u83 424
	}
7 7u83 425
	case exp_negate_tag:
426
	case exp_compl_tag:
427
	case exp_not_tag:
428
	case exp_abs_tag: {
429
		DESTROY_exp_negate_etc(destroy, t, a, e);
430
		free_exp(a, force1);
431
		break;
2 7u83 432
	}
7 7u83 433
	case exp_plus_tag:
434
	case exp_minus_tag:
435
	case exp_mult_tag:
436
	case exp_div_tag:
437
	case exp_rem_tag:
438
	case exp_and_tag:
439
	case exp_or_tag:
440
	case exp_xor_tag:
441
	case exp_log_and_tag:
442
	case exp_log_or_tag:
443
	case exp_lshift_tag:
444
	case exp_rshift_tag:
445
	case exp_max_tag:
446
	case exp_min_tag: {
447
		DESTROY_exp_plus_etc(destroy, t, a, b, e);
448
		free_exp(a, force1);
449
		free_exp(b, force1);
450
		break;
2 7u83 451
	}
7 7u83 452
	case exp_test_tag: {
453
		NTEST tst;
454
		DESTROY_exp_test(destroy, t, tst, a, e);
455
		free_exp(a, force1);
456
		UNUSED(tst);
457
		break;
2 7u83 458
	}
7 7u83 459
	case exp_compare_tag: {
460
		NTEST tst;
461
		DESTROY_exp_compare(destroy, t, tst, a, b, e);
462
		free_exp(a, force1);
463
		free_exp(b, force1);
464
		UNUSED(tst);
465
		break;
2 7u83 466
	}
7 7u83 467
	case exp_cast_tag: {
468
		unsigned conv;
469
		DESTROY_exp_cast(destroy, t, conv, a, e);
470
		free_exp(a, force1);
471
		UNUSED(conv);
472
		break;
2 7u83 473
	}
7 7u83 474
	case exp_base_cast_tag: {
475
		OFFSET off;
476
		unsigned conv;
477
		DESTROY_exp_base_cast(destroy, t, conv, a, off, e);
478
		free_exp(a, force1);
479
		free_offset(off, force1);
480
		UNUSED(conv);
481
		break;
2 7u83 482
	}
7 7u83 483
	case exp_dyn_cast_tag: {
484
		DESTROY_exp_dyn_cast(destroy, t, a, b, e);
485
		free_exp(a, force1);
486
		free_exp(b, force1);
487
		break;
2 7u83 488
	}
7 7u83 489
	case exp_add_ptr_tag: {
490
		int v;
491
		OFFSET off;
492
		DESTROY_exp_add_ptr(destroy, t, a, off, v, e);
493
		free_exp(a, force1);
494
		free_offset(off, force1);
495
		UNUSED(v);
496
		break;
2 7u83 497
	}
7 7u83 498
	case exp_offset_size_tag: {
499
		TYPE s;
500
		int pad;
501
		OFFSET off;
502
		DESTROY_exp_offset_size(destroy, t, off, s, pad, e);
503
		free_offset(off, force1);
504
		UNUSED(pad);
505
		UNUSED(s);
506
		break;
2 7u83 507
	}
7 7u83 508
	case exp_constr_tag: {
509
		int i;
510
		EXP c;
511
		DESTROY_exp_constr(destroy, t, a, b, c, i, e);
512
		free_exp(a, force1);
513
		UNUSED(b);
514
		UNUSED(c);
515
		UNUSED(i);
516
		break;
2 7u83 517
	}
7 7u83 518
	case exp_destr_tag: {
519
		EXP c;
520
		DESTROY_exp_destr(destroy, t, a, b, c, e);
521
		free_exp(a, force1);
522
		free_exp(c, force1);
523
		UNUSED(b);
524
		break;
2 7u83 525
	}
7 7u83 526
	case exp_alloc_tag: {
527
		EXP c, d;
528
		DESTROY_exp_alloc(destroy, t, a, b, c, d, e);
529
		free_exp(a, force1);
530
		free_exp(b, force1);
531
		free_exp(c, force1);
532
		UNUSED(d);
533
		break;
2 7u83 534
	}
7 7u83 535
	case exp_dealloc_tag: {
536
		EXP c, d;
537
		DESTROY_exp_dealloc(destroy, t, a, b, c, d, e);
538
		free_exp(a, force1);
539
		free_exp(b, force1);
540
		free_exp(d, force1);
541
		UNUSED(c);
542
		break;
2 7u83 543
	}
7 7u83 544
	case exp_rtti_tag: {
545
		int op;
546
		DESTROY_exp_rtti(destroy, t, a, b, op, e);
547
		free_exp(a, force1);
548
		free_exp(b, force1);
549
		UNUSED(op);
550
		break;
2 7u83 551
	}
7 7u83 552
	case exp_rtti_type_tag: {
553
		int op;
554
		TYPE s;
555
		DESTROY_exp_rtti_type(destroy, t, s, op, e);
556
		UNUSED(s);
557
		UNUSED(op);
558
		break;
2 7u83 559
	}
7 7u83 560
	case exp_rtti_no_tag: {
561
		TYPE s;
562
		DESTROY_exp_rtti_no(destroy, t, s, e);
563
		UNUSED(s);
564
		break;
2 7u83 565
	}
7 7u83 566
	case exp_dynamic_tag: {
567
		DESTROY_exp_dynamic(destroy, t, a, e);
568
		free_exp(a, force1);
569
		break;
2 7u83 570
	}
7 7u83 571
	case exp_aggregate_tag: {
572
		LIST(EXP)p;
573
		LIST(OFFSET)q;
574
		DESTROY_exp_aggregate(destroy, t, p, q, e);
575
		DESTROY_list(q, SIZE_off);
576
		free_exp_list(p, force1);
577
		break;
2 7u83 578
	}
7 7u83 579
	case exp_initialiser_tag: {
580
		int n;
581
		LIST(EXP)p;
582
		unsigned nv, nb;
583
		LIST(OFFSET)q;
584
		DESTROY_exp_initialiser(destroy, t, p, q, n, nv, nb, e);
585
		DESTROY_list(q, SIZE_off);
586
		free_exp_list(p, force1);
587
		UNUSED(nv);
588
		UNUSED(nb);
589
		UNUSED(n);
590
		break;
2 7u83 591
	}
7 7u83 592
	case exp_nof_tag: {
593
		NAT n;
594
		EXP c;
595
		DESTROY_exp_nof(destroy, t, a, n, b, c, e);
596
		free_exp(a, force1);
597
		free_exp(b, force1);
598
		free_exp(c, force1);
599
		UNUSED(n);
600
		break;
2 7u83 601
	}
7 7u83 602
	case exp_comma_tag: {
603
		LIST(EXP)p;
604
		DESTROY_exp_comma(destroy, t, p, e);
605
		free_exp_list(p, force1);
606
		break;
2 7u83 607
	}
7 7u83 608
	case exp_set_tag:
609
	case exp_unused_tag: {
610
		DESTROY_exp_set_etc(destroy, t, a, e);
611
		free_exp(a, force1);
612
		break;
2 7u83 613
	}
7 7u83 614
	case exp_reach_tag:
615
	case exp_unreach_tag: {
616
		DESTROY_exp_reach_etc(destroy, t, a, b, e);
617
		free_exp(b, force1);
618
		UNUSED(a);
619
		break;
2 7u83 620
	}
7 7u83 621
	case exp_sequence_tag: {
622
		int bl;
623
		NAMESPACE ns;
624
		LIST(EXP)p, q;
625
		DESTROY_exp_sequence(destroy, t, a, p, q, ns, bl, e);
626
		if (force)free_nspace(ns);
627
		free_exp_list(p, force1);
628
		UNUSED(bl);
629
		UNUSED(q);
630
		UNUSED(a);
631
		break;
2 7u83 632
	}
7 7u83 633
	case exp_solve_stmt_tag: {
634
		LIST(IDENTIFIER)lb;
635
		LIST(IDENTIFIER)vr;
636
		DESTROY_exp_solve_stmt(destroy, t, a, b, lb, vr, e);
637
		DESTROY_list(lb, SIZE_id);
638
		DESTROY_list(vr, SIZE_id);
639
		free_exp(b, force);
640
		UNUSED(a);
641
		break;
2 7u83 642
	}
7 7u83 643
	case exp_decl_stmt_tag: {
644
		IDENTIFIER id;
645
		DESTROY_exp_decl_stmt(destroy, t, a, id, b, e);
646
		free_exp(b, force);
647
		free_id(id, force);
648
		UNUSED(a);
649
		break;
2 7u83 650
	}
7 7u83 651
	case exp_if_stmt_tag: {
652
		EXP c, d;
653
		IDENTIFIER lb;
654
		DESTROY_exp_if_stmt(destroy, t, a, b, c, d, lb, e);
655
		free_exp(b, force1);
656
		free_exp(c, force1);
657
		free_exp(d, force1);
658
		free_id(lb, force1);
659
		UNUSED(a);
660
		break;
2 7u83 661
	}
7 7u83 662
	case exp_while_stmt_tag: {
663
		EXP c;
664
		IDENTIFIER bk, ct, lp;
665
		LIST(IDENTIFIER) cn;
666
		DESTROY_exp_while_stmt(destroy, t, a, b, c, bk, ct, lp, cn, e);
667
		DESTROY_list(cn, SIZE_id);
668
		free_exp(b, force1);
669
		free_exp(c, force1);
670
		free_id(bk, force1);
671
		free_id(ct, force1);
672
		free_id(lp, force1);
673
		UNUSED(a);
674
		break;
2 7u83 675
	}
7 7u83 676
	case exp_do_stmt_tag: {
677
		EXP c;
678
		IDENTIFIER bk, ct, lp;
679
		DESTROY_exp_do_stmt(destroy, t, a, b, c, bk, ct, lp, e);
680
		free_exp(b, force1);
681
		free_exp(c, force1);
682
		free_id(bk, force1);
683
		free_id(ct, force1);
684
		free_id(lp, force1);
685
		UNUSED(a);
686
		break;
2 7u83 687
	}
7 7u83 688
	case exp_switch_stmt_tag: {
689
		EXP c;
690
		int ex;
691
		LIST(NAT)p;
692
		IDENTIFIER df, bk;
693
		LIST(IDENTIFIER)q;
694
		DESTROY_exp_switch_stmt(destroy, t, a, b, c, p, q,
695
					df, ex, bk, e);
696
		free_exp(b, force1);
697
		free_exp(c, force1);
698
		free_id(df, force1);
699
		free_id(bk, force1);
700
		DESTROY_list(p, SIZE_nat);
701
		DESTROY_list(q, SIZE_id);
702
		UNUSED(ex);
703
		UNUSED(a);
704
		break;
2 7u83 705
	}
7 7u83 706
	case exp_hash_if_tag: {
707
		EXP c, d, f;
708
		DESTROY_exp_hash_if (destroy, t, a, b, c, d, f, e);
709
		free_exp(c, force1);
710
		free_exp(d, force1);
711
		UNUSED(f);
712
		UNUSED(a);
713
		UNUSED(b);
714
		break;
2 7u83 715
	}
7 7u83 716
	case exp_return_stmt_tag: {
717
		DESTROY_exp_return_stmt(destroy, t, a, b, e);
718
		free_exp(b, force1);
719
		UNUSED(a);
720
		break;
2 7u83 721
	}
7 7u83 722
	case exp_goto_stmt_tag: {
723
		EXP c;
724
		IDENTIFIER lb;
725
		DESTROY_exp_goto_stmt(destroy, t, a, lb, b, c, e);
726
		free_id(lb, force1);
727
		UNUSED(c);
728
		UNUSED(b);
729
		UNUSED(a);
730
		break;
2 7u83 731
	}
7 7u83 732
	case exp_label_stmt_tag: {
733
		IDENTIFIER lb;
734
		IDENTIFIER nt;
735
		DESTROY_exp_label_stmt(destroy, t, a, lb, b, nt, e);
736
		free_id(lb, force1);
737
		free_exp(b, force1);
738
		UNUSED(nt);
739
		UNUSED(a);
740
		break;
2 7u83 741
	}
7 7u83 742
	case exp_try_block_tag: {
743
		int f;
744
		EXP c;
745
		ulong n;
746
		LIST(EXP)p;
747
		LIST(TYPE)q, r;
748
		LIST(LOCATION)s;
749
		LIST(TYPE)u = univ_type_set;
750
		LIST(TYPE)v = empty_type_set;
751
		DESTROY_exp_try_block(destroy, t, a, b, f, p, q, c, r, s, n, e);
752
		if (!EQ_list(q, r)) {
753
			if (!EQ_list(q, u) && !EQ_list(q, v)) {
754
				DESTROY_list(q, SIZE_type);
755
			}
2 7u83 756
		}
7 7u83 757
		if (!EQ_list(r, u) && !EQ_list(r, v)) {
758
			DESTROY_list(r, SIZE_type);
759
		}
760
		DESTROY_list(s, SIZE_loc);
761
		free_exp_list(p, force1);
762
		free_exp(b, force);
763
		free_exp(c, force1);
764
		UNUSED(f);
765
		UNUSED(n);
766
		UNUSED(a);
767
		break;
2 7u83 768
	}
7 7u83 769
	case exp_handler_tag: {
770
		ulong n;
771
		IDENTIFIER id;
772
		DESTROY_exp_handler(destroy, t, a, id, b, n, e);
773
		free_exp(b, force1);
774
		free_id(id, force1);
775
		UNUSED(n);
776
		UNUSED(a);
777
		break;
2 7u83 778
	}
7 7u83 779
	case exp_exception_tag: {
780
		int d;
781
		EXP c;
782
		DESTROY_exp_exception(destroy, t, a, b, c, d, e);
783
		free_exp(a, force1);
784
		free_exp(b, force1);
785
		free_exp(c, force1);
786
		UNUSED(d);
787
		break;
2 7u83 788
	}
7 7u83 789
	case exp_thrown_tag: {
790
		int d;
791
		DESTROY_exp_thrown(destroy, t, d, e);
792
		UNUSED(d);
793
		break;
2 7u83 794
	}
7 7u83 795
	case exp_op_tag: {
796
		int op;
797
		DESTROY_exp_op(destroy, t, op, a, b, e);
798
		free_exp(a, force1);
799
		free_exp(b, force1);
800
		UNUSED(op);
801
		break;
2 7u83 802
	}
7 7u83 803
	case exp_opn_tag: {
804
		int op;
805
		LIST(EXP)p;
806
		DESTROY_exp_opn(destroy, t, op, p, e);
807
		free_exp_list(p, force1);
808
		UNUSED(op);
809
		break;
2 7u83 810
	}
7 7u83 811
	case exp_assembler_tag: {
812
		STRING s;
813
		LIST(EXP)p;
814
		DESTROY_exp_assembler(destroy, t, s, p, e);
815
		free_exp_list(p, force1);
816
		UNUSED(s);
817
		break;
2 7u83 818
	}
7 7u83 819
	case exp_uncompiled_tag: {
820
		PPTOKEN *p;
821
		LOCATION loc;
822
		DESTROY_exp_uncompiled(destroy, t, loc, p, e);
823
		free_tok_list(p);
824
		UNUSED(loc);
825
		break;
2 7u83 826
	}
7 7u83 827
	case exp_location_tag: {
828
		LOCATION loc;
829
		DESTROY_exp_location(destroy, t, loc, a, e);
830
		free_exp(a, force1);
831
		UNUSED(loc);
832
		break;
2 7u83 833
	}
7 7u83 834
	case exp_fail_tag: {
835
		string s;
836
		DESTROY_exp_fail(destroy, t, s, e);
837
		UNUSED(s);
838
		break;
2 7u83 839
	}
7 7u83 840
	case exp_token_tag: {
841
		IDENTIFIER id;
842
		LIST(TOKEN)p;
843
		DESTROY_exp_token(destroy, t, a, id, p, e);
844
		UNUSED(id);
845
		UNUSED(p);
846
		UNUSED(a);
847
		break;
2 7u83 848
	}
7 7u83 849
	case exp_dummy_tag: {
850
		int v;
851
		ulong n;
852
		int cnt;
853
		OFFSET off;
854
		DESTROY_exp_dummy(destroy, t, a, n, off, v, cnt, e);
855
		free_exp(a, force1);
856
		free_offset(off, force1);
857
		UNUSED(cnt);
858
		UNUSED(n);
859
		UNUSED(v);
860
		break;
2 7u83 861
	}
7 7u83 862
	}
863
	UNUSED(t);
864
	return;
2 7u83 865
}
866
 
867
 
868
/*
869
    FREE A FUNCTION DEFINITION
870
 
871
    This routine frees the definition of the function id, replacing it
872
    by a dummy definition.
873
*/
874
 
7 7u83 875
void
876
free_function(IDENTIFIER id)
2 7u83 877
{
7 7u83 878
	EXP e = DEREF_exp(id_function_etc_defn(id));
879
	if (!IS_NULL_exp(e)) {
880
		TYPE t = DEREF_type(id_function_etc_type(id));
881
		free_exp(e, 0);
882
		MAKE_exp_value(t, e);
883
		COPY_exp(id_function_etc_defn(id), e);
884
	}
885
	return;
2 7u83 886
}