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

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/output/exp.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, 1998
32
    		 Crown Copyright (c) 1997, 1998
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
29
 
59
 
30
 
60
 
31
#include "config.h"
61
#include "config.h"
32
#include "version.h"
62
#include "version.h"
33
#include "c_types.h"
63
#include "c_types.h"
34
#include "ctype_ops.h"
64
#include "ctype_ops.h"
35
#include "exp_ops.h"
65
#include "exp_ops.h"
Line 71... Line 101...
71
#include "tok.h"
101
#include "tok.h"
72
#include "throw.h"
102
#include "throw.h"
73
#include "ustring.h"
103
#include "ustring.h"
74
#include "virtual.h"
104
#include "virtual.h"
75
#if TDF_OUTPUT
105
#if TDF_OUTPUT
76
 
106
 
77
 
107
 
78
/*
108
/*
79
    ENCODE A SMALL TDF INTEGER CONSTANT
109
    ENCODE A SMALL TDF INTEGER CONSTANT
80
 
110
 
81
    This routine adds the small integer n to the bitstream bs as a TDF
111
    This routine adds the small integer n to the bitstream bs as a TDF
82
    SIGNED_NAT.
112
    SIGNED_NAT.
83
*/
113
*/
84
 
114
 
85
BITSTREAM *enc_make_snat
115
BITSTREAM *
86
    PROTO_N ( ( bs, n ) )
-
 
87
    PROTO_T ( BITSTREAM *bs X int n )
116
enc_make_snat(BITSTREAM *bs, int n)
88
{
117
{
89
    ENC_make_signed_nat ( bs ) ;
118
	ENC_make_signed_nat(bs);
90
    if ( n >= 0 ) {
119
	if (n >= 0) {
91
	ENC_OFF ( bs ) ;
120
		ENC_OFF(bs);
92
    } else {
121
	} else {
93
	ENC_ON ( bs ) ;
122
		ENC_ON(bs);
94
	n = -n ;
123
		n = -n;
95
    }
124
	}
96
    ENC_INT ( bs, n ) ;
125
	ENC_INT(bs, n);
97
    return ( bs ) ;
126
	return (bs);
98
}
127
}
99
 
128
 
100
 
129
 
101
/*
130
/*
102
    ENCODE A SMALL TDF INTEGER
131
    ENCODE A SMALL TDF INTEGER
103
 
132
 
104
    This routine adds the small integer n of type t to the bitstream bs
133
    This routine adds the small integer n of type t to the bitstream bs
105
    as a TDF EXP.
134
    as a TDF EXP.
106
*/
135
*/
107
 
136
 
108
BITSTREAM *enc_make_int
137
BITSTREAM *
109
    PROTO_N ( ( bs, t, n ) )
-
 
110
    PROTO_T ( BITSTREAM *bs X TYPE t X int n )
138
enc_make_int(BITSTREAM *bs, TYPE t, int n)
111
{
139
{
112
    ENC_make_int ( bs ) ;
140
	ENC_make_int(bs);
113
    bs = enc_variety ( bs, t ) ;
141
	bs = enc_variety(bs, t);
114
    bs = enc_make_snat ( bs, n ) ;
142
	bs = enc_make_snat(bs, n);
115
    return ( bs ) ;
143
	return (bs);
116
}
144
}
117
 
145
 
118
 
146
 
119
/*
147
/*
120
    ENCODE A NULL TDF EXPRESSION
148
    ENCODE A NULL TDF EXPRESSION
121
 
149
 
122
    This routine adds a null TDF EXP with shape corresponding to the type
150
    This routine adds a null TDF EXP with shape corresponding to the type
123
    t to the bitstream bs.
151
    t to the bitstream bs.
124
*/
152
*/
125
 
153
 
126
BITSTREAM *enc_null_exp
154
BITSTREAM *
127
    PROTO_N ( ( bs, t ) )
-
 
128
    PROTO_T ( BITSTREAM *bs X TYPE t )
155
enc_null_exp(BITSTREAM *bs, TYPE t)
129
{
156
{
130
    if ( IS_NULL_type ( t ) ) {
157
	if (IS_NULL_type(t)) {
131
	/* This shouldn't happen */
158
		/* This shouldn't happen */
132
	t = type_sint ;
159
		t = type_sint;
133
    }
160
	}
134
    switch ( TAG_type ( t ) ) {
161
	switch (TAG_type(t)) {
135
	case type_integer_tag :
162
	case type_integer_tag:
136
	case type_enumerate_tag : {
163
	case type_enumerate_tag: {
137
	    /* Integral types */
164
		/* Integral types */
138
	    bs = enc_make_int ( bs, t, 0 ) ;
165
		bs = enc_make_int(bs, t, 0);
139
	    break ;
166
		break;
140
	}
167
	}
141
	case type_floating_tag : {
168
	case type_floating_tag: {
142
	    /* Floating types */
169
		/* Floating types */
143
	    bs = enc_float_int ( bs, 0, t ) ;
170
		bs = enc_float_int(bs, 0, t);
144
	    break ;
171
		break;
145
	}
172
	}
146
	case type_top_tag :
173
	case type_top_tag:
147
	case type_bottom_tag : {
174
	case type_bottom_tag: {
148
	    /* Top type */
175
		/* Top type */
149
	    ENC_make_top ( bs ) ;
176
		ENC_make_top(bs);
150
	    break ;
177
		break;
151
	}
178
	}
152
	case type_ptr_tag :
179
	case type_ptr_tag:
153
	case type_ref_tag : {
180
	case type_ref_tag: {
154
	    /* Pointer types */
181
		/* Pointer types */
155
	    TYPE s = DEREF_type ( type_ptr_etc_sub ( t ) ) ;
182
		TYPE s = DEREF_type(type_ptr_etc_sub(t));
156
	    switch ( TAG_type ( s ) ) {
183
		switch (TAG_type(s)) {
157
		case type_top_tag :
184
		case type_top_tag:
158
		case type_bottom_tag : {
185
		case type_bottom_tag: {
159
		    /* Generic pointer */
186
			/* Generic pointer */
160
		    bs = enc_special ( bs, TOK_null_pv ) ;
187
			bs = enc_special(bs, TOK_null_pv);
161
		    break ;
188
			break;
162
		}
189
		}
163
		case type_func_tag : {
190
		case type_func_tag: {
164
		    /* Function pointer */
191
			/* Function pointer */
165
		    ENC_make_null_proc ( bs ) ;
192
			ENC_make_null_proc(bs);
166
		    break ;
193
			break;
167
		}
194
		}
168
		default : {
195
		default: {
169
		    /* Normal pointer */
196
			/* Normal pointer */
170
		    ENC_make_null_ptr ( bs ) ;
197
			ENC_make_null_ptr(bs);
171
		    bs = enc_alignment ( bs, s ) ;
198
			bs = enc_alignment(bs, s);
172
		    break ;
199
			break;
173
		}
200
		}
174
	    }
201
		}
175
	    break ;
202
		break;
176
	}
203
	}
177
	case type_ptr_mem_tag : {
204
	case type_ptr_mem_tag: {
178
	    /* Pointer to member types */
205
		/* Pointer to member types */
179
	    TYPE s = DEREF_type ( type_ptr_mem_sub ( t ) ) ;
206
		TYPE s = DEREF_type(type_ptr_mem_sub(t));
180
	    if ( IS_type_func ( s ) ) {
207
		if (IS_type_func(s)) {
181
		if ( in_static_init ) {
208
			if (in_static_init) {
-
 
209
				bs = enc_special(bs, TOK_pmf_null);
-
 
210
			} else {
182
		    bs = enc_special ( bs, TOK_pmf_null ) ;
211
				bs = enc_special(bs, TOK_pmf_null2);
-
 
212
			}
-
 
213
		} else {
-
 
214
			bs = enc_special(bs, TOK_pm_null);
-
 
215
		}
-
 
216
		break;
-
 
217
	}
-
 
218
	case type_array_tag: {
-
 
219
		/* Array types */
-
 
220
		NAT n = DEREF_nat(type_array_size(t));
-
 
221
		TYPE s = DEREF_type(type_array_sub(t));
-
 
222
		ENC_n_copies(bs);
-
 
223
		bs = enc_nat(bs, n, 1);
-
 
224
		bs = enc_null_exp(bs, s);
-
 
225
		break;
-
 
226
	}
-
 
227
	case type_bitfield_tag: {
-
 
228
		/* Bitfield types */
-
 
229
		TYPE s = find_bitfield_type(t);
-
 
230
		ENC_change_int_to_bitfield(bs);
-
 
231
		bs = enc_bfvar(bs, t);
-
 
232
		bs = enc_null_exp(bs, s);
-
 
233
		break;
-
 
234
	}
-
 
235
	case type_compound_tag: {
-
 
236
		/* Compound types */
-
 
237
		CLASS_TYPE ct = DEREF_ctype(type_compound_defn(t));
-
 
238
		TYPE s = DEREF_type(ctype_form(ct));
-
 
239
		if (is_tokenised_class(s)) {
-
 
240
			ENC_make_value(bs);
-
 
241
			bs = enc_shape(bs, s);
183
		} else {
242
		} else {
184
		    bs = enc_special ( bs, TOK_pmf_null2 ) ;
243
			bs = enc_null_class(bs, ct);
185
		}
244
		}
186
	    } else {
-
 
187
		bs = enc_special ( bs, TOK_pm_null ) ;
-
 
188
	    }
-
 
189
	    break ;
245
		break;
190
	}
-
 
191
	case type_array_tag : {
-
 
192
	    /* Array types */
-
 
193
	    NAT n = DEREF_nat ( type_array_size ( t ) ) ;
-
 
194
	    TYPE s = DEREF_type ( type_array_sub ( t ) ) ;
-
 
195
	    ENC_n_copies ( bs ) ;
-
 
196
	    bs = enc_nat ( bs, n, 1 ) ;
-
 
197
	    bs = enc_null_exp ( bs, s ) ;
-
 
198
	    break ;
-
 
199
	}
-
 
200
	case type_bitfield_tag : {
-
 
201
	    /* Bitfield types */
-
 
202
	    TYPE s = find_bitfield_type ( t ) ;
-
 
203
	    ENC_change_int_to_bitfield ( bs ) ;
-
 
204
	    bs = enc_bfvar ( bs, t ) ;
-
 
205
	    bs = enc_null_exp ( bs, s ) ;
-
 
206
	    break ;
-
 
207
	}
246
	}
208
	case type_compound_tag : {
247
	default: {
209
	    /* Compound types */
248
		/* Other types */
210
	    CLASS_TYPE ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
-
 
211
	    TYPE s = DEREF_type ( ctype_form ( ct ) ) ;
-
 
212
	    if ( is_tokenised_class ( s ) ) {
-
 
213
		ENC_make_value ( bs ) ;
249
		ENC_make_value(bs);
214
		bs = enc_shape ( bs, s ) ;
250
		bs = enc_shape(bs, t);
215
	    } else {
-
 
216
		bs = enc_null_class ( bs, ct ) ;
-
 
217
	    }
-
 
218
	    break ;
251
		break;
219
	}
252
	}
220
	default : {
-
 
221
	    /* Other types */
-
 
222
	    ENC_make_value ( bs ) ;
-
 
223
	    bs = enc_shape ( bs, t ) ;
-
 
224
	    break ;
-
 
225
	}
253
	}
226
    }
-
 
227
    return ( bs ) ;
254
	return (bs);
228
}
255
}
229
 
256
 
230
 
257
 
231
/*
258
/*
232
    CHECK ANONYMOUS UNION MEMBER EXPRESSION
259
    CHECK ANONYMOUS UNION MEMBER EXPRESSION
Line 234... Line 261...
234
    This routine checks whether the identifier expression a arises from a
261
    This routine checks whether the identifier expression a arises from a
235
    member of an anonymous union.  The routine also marks any external
262
    member of an anonymous union.  The routine also marks any external
236
    variables.
263
    variables.
237
*/
264
*/
238
 
265
 
239
static int is_anon_exp
266
static int
240
    PROTO_N ( ( a ) )
-
 
241
    PROTO_T ( EXP a )
267
is_anon_exp(EXP a)
242
{
268
{
243
    IDENTIFIER id = DEREF_id ( exp_identifier_id ( a ) ) ;
269
	IDENTIFIER id = DEREF_id(exp_identifier_id(a));
244
    DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
270
	DECL_SPEC ds = DEREF_dspec(id_storage(id));
245
    if ( !( ds & dspec_auto ) ) {
271
	if (!(ds & dspec_auto)) {
246
	/* Mark external variables */
272
		/* Mark external variables */
247
	IGNORE capsule_id ( id, VAR_tag ) ;
273
		IGNORE capsule_id(id, VAR_tag);
248
    }
274
	}
249
    if ( ds & dspec_reserve ) {
275
	if (ds & dspec_reserve) {
250
	/* Check for anonymous union members */
276
		/* Check for anonymous union members */
251
	return ( is_anon_member ( id ) ) ;
277
		return (is_anon_member(id));
252
    }
278
	}
253
    return ( 0 ) ;
279
	return (0);
254
}
280
}
255
 
281
 
256
 
282
 
257
/*
283
/*
258
    CREATE AN IDENTITY DECLARATION
284
    CREATE AN IDENTITY DECLARATION
259
 
285
 
260
    This routine adds the start of an identity declaration for the
286
    This routine adds the start of an identity declaration for the
261
    expression a to the bitstream bs.  The identity body will consist
287
    expression a to the bitstream bs.  The identity body will consist
262
    of a sequence of seq + 1 expressions.  The identity tag number is
288
    of a sequence of seq + 1 expressions.  The identity tag number is
263
    returned via pn.
289
    returned via pn.
264
*/
290
*/
265
 
291
 
266
static BITSTREAM *make_identity
292
static BITSTREAM *
267
    PROTO_N ( ( bs, a, pn, cnt, seq ) )
-
 
268
    PROTO_T ( BITSTREAM *bs X EXP a X ulong *pn X int cnt X int seq )
293
make_identity(BITSTREAM *bs, EXP a, ulong *pn, int cnt, int seq)
269
{
294
{
270
    ulong n ;
295
	ulong n;
271
    if ( IS_exp_identifier ( a ) ) {
296
	if (IS_exp_identifier(a)) {
272
	/* No identity required in this case */
297
		/* No identity required in this case */
273
	IDENTIFIER id = DEREF_id ( exp_identifier_id ( a ) ) ;
298
		IDENTIFIER id = DEREF_id(exp_identifier_id(a));
274
	DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
299
		DECL_SPEC ds = DEREF_dspec(id_storage(id));
275
	if ( ( ds & dspec_auto ) && !is_anon_exp ( a ) ) {
300
		if ((ds & dspec_auto) && !is_anon_exp(a)) {
276
	    n = unit_no ( bs, id, VAR_tag, 0 ) ;
301
			n = unit_no(bs, id, VAR_tag, 0);
-
 
302
			if (seq) {
277
	    if ( seq ) ENC_SEQUENCE ( bs, seq ) ;
303
				ENC_SEQUENCE(bs, seq);
-
 
304
			}
278
	    *pn = n ;
305
			*pn = n;
279
	    return ( bs ) ;
306
			return (bs);
280
	}
307
		}
281
    }
308
	}
282
    /* Declare new identity */
309
	/* Declare new identity */
283
    n = unit_no ( bs, NULL_id, VAR_tag, 1 ) ;
310
	n = unit_no(bs, NULL_id, VAR_tag, 1);
284
    ENC_identify ( bs ) ;
311
	ENC_identify(bs);
285
    bs = enc_access ( bs, crt_func_access ) ;
312
	bs = enc_access(bs, crt_func_access);
286
    ENC_make_tag ( bs, n ) ;
313
	ENC_make_tag(bs, n);
287
    if ( cnt ) {
314
	if (cnt) {
288
	bs = enc_exp ( bs, a ) ;
315
		bs = enc_exp(bs, a);
289
    } else {
316
	} else {
290
	TYPE t = DEREF_type ( exp_type ( a ) ) ;
317
		TYPE t = DEREF_type(exp_type(a));
291
	bs = enc_addr_exp ( bs, t, a ) ;
318
		bs = enc_addr_exp(bs, t, a);
292
    }
319
	}
-
 
320
	if (seq) {
293
    if ( seq ) ENC_SEQUENCE ( bs, seq ) ;
321
		ENC_SEQUENCE(bs, seq);
-
 
322
	}
294
    *pn = n ;
323
	*pn = n;
295
    return ( bs ) ;
324
	return (bs);
296
}
325
}
297
 
326
 
298
 
327
 
299
/*
328
/*
300
    CREATE A POINTER TO MEMBER FUNCTION TAG
329
    CREATE A POINTER TO MEMBER FUNCTION TAG
301
 
330
 
302
    This routine adds the start of an identity or variable declaration
331
    This routine adds the start of an identity or variable declaration
303
    for the pointer to member function or similar expression a to the
332
    for the pointer to member function or similar expression a to the
304
    bitstream bs.  If var is true then a variable declaration is forced.
333
    bitstream bs.  If var is true then a variable declaration is forced.
305
    The tag number is returned via pn.
334
    The tag number is returned via pn.
306
*/
335
*/
307
 
336
 
308
static BITSTREAM *make_ptr_mem_func
337
static BITSTREAM *
309
    PROTO_N ( ( bs, a, pn, var ) )
-
 
310
    PROTO_T ( BITSTREAM *bs X EXP a X ulong *pn X int var )
338
make_ptr_mem_func(BITSTREAM *bs, EXP a, ulong *pn, int var)
311
{
339
{
312
    if ( IS_exp_contents ( a ) && !var ) {
340
	if (IS_exp_contents(a) && !var) {
313
	EXP b = DEREF_exp ( exp_contents_ptr ( a ) ) ;
341
		EXP b = DEREF_exp(exp_contents_ptr(a));
314
	bs = make_identity ( bs, b, pn, 0, 0 ) ;
342
		bs = make_identity(bs, b, pn, 0, 0);
315
    } else {
343
	} else {
316
	ulong n = unit_no ( bs, NULL_id, VAR_tag, 1 ) ;
344
		ulong n = unit_no(bs, NULL_id, VAR_tag, 1);
317
	ENC_variable ( bs ) ;
345
		ENC_variable(bs);
318
	bs = enc_access ( bs, crt_func_access ) ;
346
		bs = enc_access(bs, crt_func_access);
319
	ENC_make_tag ( bs, n ) ;
347
		ENC_make_tag(bs, n);
320
	bs = enc_exp ( bs, a ) ;
348
		bs = enc_exp(bs, a);
321
	*pn = n ;
349
		*pn = n;
322
    }
350
	}
323
    return ( bs ) ;
351
	return (bs);
324
}
352
}
325
 
353
 
326
 
354
 
327
/*
355
/*
328
    ENCODE AN ASSIGNMENT OPERATOR
356
    ENCODE AN ASSIGNMENT OPERATOR
329
 
357
 
330
    This routine encodes an assignment operator for an expression of
358
    This routine encodes an assignment operator for an expression of
331
    type t.  bf is set to true for bitfields.
359
    type t.  bf is set to true for bitfields.
332
*/
360
*/
333
 
361
 
334
BITSTREAM *enc_assign_op
362
BITSTREAM *
335
    PROTO_N ( ( bs, t, bf ) )
-
 
336
    PROTO_T ( BITSTREAM *bs X TYPE t X int *bf )
363
enc_assign_op(BITSTREAM *bs, TYPE t, int *bf)
337
{
364
{
338
    CV_SPEC cv = DEREF_cv ( type_qual ( t ) ) ;
365
	CV_SPEC cv = DEREF_cv(type_qual(t));
339
    if ( IS_type_bitfield ( t ) ) {
366
	if (IS_type_bitfield(t)) {
340
	if ( cv & cv_volatile ) {
367
		if (cv & cv_volatile) {
341
	    ENC_bitfield_assign_with_mode ( bs ) ;
368
			ENC_bitfield_assign_with_mode(bs);
342
	    ENC_volatile ( bs ) ;
369
			ENC_volatile(bs);
-
 
370
		} else {
-
 
371
			ENC_bitfield_assign(bs);
-
 
372
		}
-
 
373
		*bf = 1;
343
	} else {
374
	} else {
-
 
375
		if (cv & cv_volatile) {
-
 
376
			ENC_assign_with_mode(bs);
-
 
377
			ENC_volatile(bs);
-
 
378
		} else {
344
	    ENC_bitfield_assign ( bs ) ;
379
			ENC_assign(bs);
-
 
380
		}
345
	}
381
	}
346
	*bf = 1 ;
-
 
347
    } else {
-
 
348
	if ( cv & cv_volatile ) {
-
 
349
	    ENC_assign_with_mode ( bs ) ;
-
 
350
	    ENC_volatile ( bs ) ;
-
 
351
	} else {
-
 
352
	    ENC_assign ( bs ) ;
-
 
353
	}
-
 
354
    }
-
 
355
    return ( bs ) ;
382
	return (bs);
356
}
383
}
357
 
384
 
358
 
385
 
359
/*
386
/*
360
    ENCODE THE ADDRESS OF A TDF EXPRESSION
387
    ENCODE THE ADDRESS OF A TDF EXPRESSION
361
 
388
 
362
    This routine adds the address of the expression e to the bitstream
389
    This routine adds the address of the expression e to the bitstream
363
    bs as a TDF EXP.
390
    bs as a TDF EXP.
549
    ENCODE A CONTENTS OPERATOR
575
    ENCODE A CONTENTS OPERATOR
550
 
576
 
551
    This routine encodes a contents operator for an expression of type t.
577
    This routine encodes a contents operator for an expression of type t.
552
    bf is set to true for bitfields.
578
    bf is set to true for bitfields.
553
*/
579
*/
554
 
580
 
555
BITSTREAM *enc_cont_op
581
BITSTREAM *
556
    PROTO_N ( ( bs, t, bf ) )
-
 
557
    PROTO_T ( BITSTREAM *bs X TYPE t X int *bf )
582
enc_cont_op(BITSTREAM *bs, TYPE t, int *bf)
558
{
583
{
559
    CV_SPEC cv = DEREF_cv ( type_qual ( t ) ) ;
584
	CV_SPEC cv = DEREF_cv(type_qual(t));
560
    if ( IS_type_bitfield ( t ) ) {
585
	if (IS_type_bitfield(t)) {
561
	if ( cv & cv_volatile ) {
586
		if (cv & cv_volatile) {
562
	    ENC_bitfield_contents_with_mode ( bs ) ;
587
			ENC_bitfield_contents_with_mode(bs);
563
	    ENC_volatile ( bs ) ;
588
			ENC_volatile(bs);
564
	} else {
589
		} else {
565
	    ENC_bitfield_contents ( bs ) ;
590
			ENC_bitfield_contents(bs);
566
	}
591
		}
567
	*bf = 1 ;
592
		*bf = 1;
568
    } else {
593
	} else {
569
	if ( cv & cv_volatile ) {
594
		if (cv & cv_volatile) {
570
	    ENC_contents_with_mode ( bs ) ;
595
			ENC_contents_with_mode(bs);
571
	    ENC_volatile ( bs ) ;
596
			ENC_volatile(bs);
572
	} else {
597
		} else {
573
	    ENC_contents ( bs ) ;
598
			ENC_contents(bs);
-
 
599
		}
574
	}
600
	}
575
    }
-
 
576
    return ( bs ) ;
601
	return (bs);
577
}
602
}
578
 
603
 
579
 
604
 
580
/*
605
/*
581
    ENCODE THE CONTENTS OF A TDF EXPRESSION
606
    ENCODE THE CONTENTS OF A TDF EXPRESSION
582
 
607
 
583
    This routine adds the contents of the expression e of type t to the
608
    This routine adds the contents of the expression e of type t to the
584
    bitstream bs as a TDF EXP.
609
    bitstream bs as a TDF EXP.
747
	}
765
	}
-
 
766
 
-
 
767
	/* Encode a contents expression */
-
 
768
	bs = enc_cont_op(bs, s, &bf);
-
 
769
	if (bf) {
-
 
770
		if (IS_NULL_off(off)) {
-
 
771
			/* Find bitfield offset */
-
 
772
			off = decons_bitf_exp(&e);
-
 
773
		}
748
	bs = enc_bfvar ( bs, t ) ;
774
		bs = enc_bfvar(bs, t);
749
	if ( n == LINK_NONE ) {
775
		if (n == LINK_NONE) {
750
	    bs = enc_addr_exp ( bs, t, e ) ;
776
			bs = enc_addr_exp(bs, t, e);
-
 
777
		} else {
-
 
778
			ENC_obtain_tag(bs);
-
 
779
			ENC_make_tag(bs, n);
-
 
780
		}
-
 
781
		bs = enc_offset(bs, off);
751
	} else {
782
	} else {
-
 
783
		bs = enc_shape(bs, t);
-
 
784
		if (n == LINK_NONE) {
-
 
785
			bs = enc_exp(bs, e);
-
 
786
		} else {
752
	    ENC_obtain_tag ( bs ) ;
787
			ENC_obtain_tag(bs);
753
	    ENC_make_tag ( bs, n ) ;
788
			ENC_make_tag(bs, n);
-
 
789
		}
754
	}
790
	}
755
	bs = enc_offset ( bs, off ) ;
-
 
756
    } else {
-
 
757
	bs = enc_shape ( bs, t ) ;
-
 
758
	if ( n == LINK_NONE ) {
-
 
759
	    bs = enc_exp ( bs, e ) ;
-
 
760
	} else {
-
 
761
	    ENC_obtain_tag ( bs ) ;
-
 
762
	    ENC_make_tag ( bs, n ) ;
-
 
763
	}
-
 
764
    }
-
 
765
    return ( bs ) ;
791
	return (bs);
766
}
792
}
767
 
793
 
768
 
794
 
769
/*
795
/*
770
    ENCODE A LIST OF TDF EXPS
796
    ENCODE A LIST OF TDF EXPS
771
 
797
 
772
    This routines adds the expressions p to the bitstream bs as a list
798
    This routines adds the expressions p to the bitstream bs as a list
773
    of TDF EXPs.
799
    of TDF EXPs.
774
*/
800
*/
775
 
801
 
776
BITSTREAM *enc_exp_list
802
BITSTREAM *
777
    PROTO_N ( ( bs, p ) )
-
 
778
    PROTO_T ( BITSTREAM *bs X LIST ( EXP ) p )
803
enc_exp_list(BITSTREAM *bs, LIST(EXP)p)
779
{
804
{
780
    unsigned n = LENGTH_list ( p ) ;
805
	unsigned n = LENGTH_list(p);
781
    ENC_LIST ( bs, n ) ;
806
	ENC_LIST(bs, n);
782
    while ( !IS_NULL_list ( p ) ) {
807
	while (!IS_NULL_list(p)) {
783
	EXP e = DEREF_exp ( HEAD_list ( p ) ) ;
808
		EXP e = DEREF_exp(HEAD_list(p));
784
	bs = enc_exp ( bs, e ) ;
809
		bs = enc_exp(bs, e);
785
	p = TAIL_list ( p ) ;
810
		p = TAIL_list(p);
786
    }
811
	}
787
    return ( bs ) ;
812
	return (bs);
788
}
813
}
789
 
814
 
790
 
815
 
791
/*
816
/*
792
    ENCODE A TDF NTEST
817
    ENCODE A TDF NTEST
Line 794... Line 819...
794
    This routine adds the comparison operator tst to the bitstream bs as
819
    This routine adds the comparison operator tst to the bitstream bs as
795
    a TDF NTEST.  The macro ENC_NTEST exploits the correlation between
820
    a TDF NTEST.  The macro ENC_NTEST exploits the correlation between
796
    the internal representation of NTESTs and the TDF encoding.
821
    the internal representation of NTESTs and the TDF encoding.
797
*/
822
*/
798
 
823
 
799
BITSTREAM *enc_ntest
824
BITSTREAM *
800
    PROTO_N ( ( bs, tst ) )
-
 
801
    PROTO_T ( BITSTREAM *bs X NTEST tst )
825
enc_ntest(BITSTREAM *bs, NTEST tst)
802
{
826
{
803
    ENC_NTEST ( bs, tst ) ;
827
	ENC_NTEST(bs, tst);
804
    return ( bs ) ;
828
	return (bs);
805
}
829
}
806
 
830
 
807
 
831
 
808
/*
832
/*
809
    ENCODE A COMPARISON
833
    ENCODE A COMPARISON
Line 811... Line 835...
811
    This routine adds a comparison expression to the bitstream bs for
835
    This routine adds a comparison expression to the bitstream bs for
812
    comparing a with b using test tst.  lab gives the destination label
836
    comparing a with b using test tst.  lab gives the destination label
813
    number.
837
    number.
814
*/
838
*/
815
 
839
 
816
BITSTREAM *enc_compare
840
BITSTREAM *
817
    PROTO_N ( ( bs, a, b, tst, lab, nlab ) )
-
 
818
    PROTO_T ( BITSTREAM *bs X EXP a X EXP b X NTEST tst X
841
enc_compare(BITSTREAM *bs, EXP a, EXP b, NTEST tst, ulong lab, ulong nlab)
819
	      ulong lab X ulong nlab )
-
 
820
{
842
{
950
    SIMPLIFY A CONDITION
976
    SIMPLIFY A CONDITION
951
 
977
 
952
    This routine simplifies the condition e by removing any double
978
    This routine simplifies the condition e by removing any double
953
    negations.  sw is set to 1 if the result has the form 'a || b' or
979
    negations.  sw is set to 1 if the result has the form 'a || b' or
954
    '!( a && b )'.
980
    '!( a && b )'.
955
*/
981
*/
956
 
982
 
957
EXP simplify_cond
983
EXP
958
    PROTO_N ( ( e, sw ) )
-
 
959
    PROTO_T ( EXP e X int *sw )
984
simplify_cond(EXP e, int *sw)
960
{
985
{
961
    EXP a = e ;
986
	EXP a = e;
962
    unsigned tag = TAG_exp ( a ) ;
987
	unsigned tag = TAG_exp(a);
963
    if ( tag == exp_location_tag ) {
988
	if (tag == exp_location_tag) {
964
	/* Can have location markers */
989
		/* Can have location markers */
965
	EXP b ;
990
		EXP b;
966
	a = DEREF_exp ( exp_location_arg ( e ) ) ;
991
		a = DEREF_exp(exp_location_arg(e));
967
	b = simplify_cond ( a, sw ) ;
992
		b = simplify_cond(a, sw);
968
	if ( !EQ_exp ( b, a ) ) {
993
		if (!EQ_exp(b, a)) {
969
	    LOCATION loc ;
994
			LOCATION loc;
970
	    TYPE t = DEREF_type ( exp_type ( e ) ) ;
995
			TYPE t = DEREF_type(exp_type(e));
971
	    DEREF_loc ( exp_location_end ( e ), loc ) ;
996
			DEREF_loc(exp_location_end(e), loc);
972
	    MAKE_exp_location ( t, loc, b, e ) ;
997
			MAKE_exp_location(t, loc, b, e);
973
	}
998
		}
974
	return ( e ) ;
999
		return (e);
975
    }
1000
	}
976
    while ( tag == exp_not_tag ) {
1001
	while (tag == exp_not_tag) {
977
	EXP b = DEREF_exp ( exp_not_arg ( a ) ) ;
1002
		EXP b = DEREF_exp(exp_not_arg(a));
978
	tag = TAG_exp ( b ) ;
1003
		tag = TAG_exp(b);
979
	if ( tag != exp_not_tag ) {
1004
		if (tag != exp_not_tag) {
980
	    if ( tag == exp_log_and_tag ) *sw = 1 ;
1005
			if (tag == exp_log_and_tag) {
-
 
1006
				*sw = 1;
-
 
1007
			}
981
	    return ( a ) ;
1008
			return (a);
982
	}
1009
		}
983
	a = DEREF_exp ( exp_not_arg ( b ) ) ;
1010
		a = DEREF_exp(exp_not_arg(b));
984
	tag = TAG_exp ( a ) ;
1011
		tag = TAG_exp(a);
985
    }
1012
	}
986
    if ( tag == exp_log_or_tag ) *sw = 1 ;
1013
	if (tag == exp_log_or_tag) {
-
 
1014
		*sw = 1;
-
 
1015
	}
987
    return ( a ) ;
1016
	return (a);
988
}
1017
}
989
 
1018
 
990
 
1019
 
991
/*
1020
/*
992
    ENCODE A CONDITION
1021
    ENCODE A CONDITION
993
 
1022
 
994
    This routine adds the expression e as a conditional jump to the label
1023
    This routine adds the expression e as a conditional jump to the label
995
    lab if true or label nlab if false to the bitstream bs.  Either label
1024
    lab if true or label nlab if false to the bitstream bs.  Either label
996
    may be LINK_NONE.
1025
    may be LINK_NONE.
997
*/
1026
*/
998
 
1027
 
999
BITSTREAM *enc_condition
1028
BITSTREAM *
1000
    PROTO_N ( ( bs, e, lab, nlab ) )
-
 
1001
    PROTO_T ( BITSTREAM *bs X EXP e X ulong lab X ulong nlab )
1029
enc_condition(BITSTREAM *bs, EXP e, ulong lab, ulong nlab)
1002
{
1030
{
1003
    switch ( TAG_exp ( e ) ) {
1031
	switch (TAG_exp(e)) {
1004
 
1032
 
1005
	case exp_int_lit_tag : {
1033
	case exp_int_lit_tag: {
1006
	    /* Constant conditions */
1034
		/* Constant conditions */
1007
	    NAT n = DEREF_nat ( exp_int_lit_nat ( e ) ) ;
1035
		NAT n = DEREF_nat(exp_int_lit_nat(e));
1008
	    if ( IS_nat_small ( n ) ) {
1036
		if (IS_nat_small(n)) {
1009
		unsigned v = DEREF_unsigned ( nat_small_value ( n ) ) ;
1037
			unsigned v = DEREF_unsigned(nat_small_value(n));
1010
		if ( v == BOOL_FALSE ) nlab = lab ;
1038
			if (v == BOOL_FALSE) {
-
 
1039
				nlab = lab;
-
 
1040
			}
1011
		if ( nlab == LINK_NONE ) {
1041
			if (nlab == LINK_NONE) {
1012
		    ENC_make_top ( bs ) ;
1042
				ENC_make_top(bs);
1013
		} else {
1043
			} else {
1014
		    ENC_goto ( bs ) ;
1044
				ENC_goto(bs);
1015
		    ENC_make_label ( bs, nlab ) ;
1045
				ENC_make_label(bs, nlab);
1016
		}
1046
			}
1017
		break ;
1047
			break;
1018
	    }
1048
		}
1019
	    if ( IS_nat_calc ( n ) ) {
1049
		if (IS_nat_calc(n)) {
1020
		EXP a = DEREF_exp ( nat_calc_value ( n ) ) ;
1050
			EXP a = DEREF_exp(nat_calc_value(n));
1021
		bs = enc_condition ( bs, a, lab, nlab ) ;
1051
			bs = enc_condition(bs, a, lab, nlab);
1022
		break ;
1052
			break;
1023
	    }
1053
		}
1024
	    goto default_lab ;
1054
		goto default_lab;
1025
	}
1055
	}
1026
 
1056
 
1027
	case exp_not_tag : {
1057
	case exp_not_tag: {
1028
	    /* Negated conditions */
1058
		/* Negated conditions */
1029
	    EXP a = DEREF_exp ( exp_not_arg ( e ) ) ;
1059
		EXP a = DEREF_exp(exp_not_arg(e));
1030
	    bs = enc_condition ( bs, a, nlab, lab ) ;
1060
		bs = enc_condition(bs, a, nlab, lab);
1031
	    break ;
1061
		break;
1032
	}
1062
	}
1033
 
1063
 
1034
	case exp_log_and_tag : {
1064
	case exp_log_and_tag: {
1035
	    /* Logical and conditions */
1065
		/* Logical and conditions */
1036
	    EXP a = DEREF_exp ( exp_log_and_arg1 ( e ) ) ;
1066
		EXP a = DEREF_exp(exp_log_and_arg1(e));
1037
	    EXP b = DEREF_exp ( exp_log_and_arg2 ( e ) ) ;
1067
		EXP b = DEREF_exp(exp_log_and_arg2(e));
1038
	    if ( lab == LINK_NONE ) {
1068
		if (lab == LINK_NONE) {
1039
		/* '!( a && b )' equals '!a || !b' */
1069
			/* '!( a && b )' equals '!a || !b' */
1040
		ulong mlab = unit_no ( bs, NULL_id, VAR_label, 1 ) ;
1070
			ulong mlab = unit_no(bs, NULL_id, VAR_label, 1);
1041
		ENC_conditional ( bs ) ;
1071
			ENC_conditional(bs);
1042
		ENC_make_label ( bs, mlab ) ;
1072
			ENC_make_label(bs, mlab);
1043
		ENC_SEQ_SMALL ( bs, 1 ) ;
1073
			ENC_SEQ_SMALL(bs, 1);
1044
		bs = enc_condition ( bs, a, mlab, LINK_NONE ) ;
1074
			bs = enc_condition(bs, a, mlab, LINK_NONE);
1045
		bs = enc_condition ( bs, b, LINK_NONE, nlab ) ;
1075
			bs = enc_condition(bs, b, LINK_NONE, nlab);
1046
		ENC_make_top ( bs ) ;
1076
			ENC_make_top(bs);
1047
	    } else {
1077
		} else {
1048
		/* Encode 'a && b' */
1078
			/* Encode 'a && b' */
1049
		ENC_SEQ_SMALL ( bs, 1 ) ;
1079
			ENC_SEQ_SMALL(bs, 1);
1050
		bs = enc_condition ( bs, a, lab, nlab ) ;
1080
			bs = enc_condition(bs, a, lab, nlab);
1051
		bs = enc_condition ( bs, b, lab, nlab ) ;
1081
			bs = enc_condition(bs, b, lab, nlab);
1052
	    }
1082
		}
1053
	    break ;
1083
		break;
1054
	}
1084
	}
1055
 
1085
 
1056
	case exp_log_or_tag : {
1086
	case exp_log_or_tag: {
1057
	    /* Logical or conditions */
1087
		/* Logical or conditions */
1058
	    EXP a = DEREF_exp ( exp_log_or_arg1 ( e ) ) ;
1088
		EXP a = DEREF_exp(exp_log_or_arg1(e));
1059
	    EXP b = DEREF_exp ( exp_log_or_arg2 ( e ) ) ;
1089
		EXP b = DEREF_exp(exp_log_or_arg2(e));
1060
	    if ( nlab == LINK_NONE ) {
1090
		if (nlab == LINK_NONE) {
1061
		/* Encode 'a || b' */
1091
			/* Encode 'a || b' */
1062
		ulong mlab = unit_no ( bs, NULL_id, VAR_label, 1 ) ;
1092
			ulong mlab = unit_no(bs, NULL_id, VAR_label, 1);
1063
		ENC_conditional ( bs ) ;
1093
			ENC_conditional(bs);
1064
		ENC_make_label ( bs, mlab ) ;
1094
			ENC_make_label(bs, mlab);
1065
		ENC_SEQ_SMALL ( bs, 1 ) ;
1095
			ENC_SEQ_SMALL(bs, 1);
1066
		bs = enc_condition ( bs, a, LINK_NONE, mlab ) ;
1096
			bs = enc_condition(bs, a, LINK_NONE, mlab);
1067
		bs = enc_condition ( bs, b, lab, LINK_NONE ) ;
1097
			bs = enc_condition(bs, b, lab, LINK_NONE);
1068
		ENC_make_top ( bs ) ;
1098
			ENC_make_top(bs);
1069
	    } else {
1099
		} else {
1070
		/* '!( a || b )' equals '!a && !b' */
1100
			/* '!( a || b )' equals '!a && !b' */
1071
		ENC_SEQ_SMALL ( bs, 1 ) ;
1101
			ENC_SEQ_SMALL(bs, 1);
1072
		bs = enc_condition ( bs, a, lab, nlab ) ;
1102
			bs = enc_condition(bs, a, lab, nlab);
1073
		bs = enc_condition ( bs, b, lab, nlab ) ;
1103
			bs = enc_condition(bs, b, lab, nlab);
1074
	    }
1104
		}
1075
	    break ;
1105
		break;
1076
	}
1106
	}
1077
 
1107
 
1078
	case exp_test_tag : {
1108
	case exp_test_tag: {
1079
	    /* Test conditions */
1109
		/* Test conditions */
1080
	    NTEST tst = DEREF_ntest ( exp_test_tst ( e ) ) ;
1110
		NTEST tst = DEREF_ntest(exp_test_tst(e));
1081
	    EXP a = DEREF_exp ( exp_test_arg ( e ) ) ;
1111
		EXP a = DEREF_exp(exp_test_arg(e));
1082
	    bs = enc_compare ( bs, a, NULL_exp, tst, lab, nlab ) ;
1112
		bs = enc_compare(bs, a, NULL_exp, tst, lab, nlab);
1083
	    break ;
1113
		break;
1084
	}
1114
	}
1085
 
1115
 
1086
	case exp_compare_tag : {
1116
	case exp_compare_tag: {
1087
	    /* Comparison conditions */
1117
		/* Comparison conditions */
1088
	    NTEST tst = DEREF_ntest ( exp_compare_tst ( e ) ) ;
1118
		NTEST tst = DEREF_ntest(exp_compare_tst(e));
1089
	    EXP a = DEREF_exp ( exp_compare_arg1 ( e ) ) ;
1119
		EXP a = DEREF_exp(exp_compare_arg1(e));
1090
	    EXP b = DEREF_exp ( exp_compare_arg2 ( e ) ) ;
1120
		EXP b = DEREF_exp(exp_compare_arg2(e));
1091
	    bs = enc_compare ( bs, a, b, tst, lab, nlab ) ;
1121
		bs = enc_compare(bs, a, b, tst, lab, nlab);
1092
	    break ;
1122
		break;
1093
	}
1123
	}
1094
 
1124
 
1095
	case exp_comma_tag : {
1125
	case exp_comma_tag: {
1096
	    /* Comma conditions */
1126
		/* Comma conditions */
1097
	    EXP a ;
1127
		EXP a;
1098
	    LIST ( EXP ) p = DEREF_list ( exp_comma_args ( e ) ) ;
1128
		LIST(EXP)p = DEREF_list(exp_comma_args(e));
1099
	    bs = enc_stmt_exp ( bs, e, type_void, -1 ) ;
1129
		bs = enc_stmt_exp(bs, e, type_void, -1);
1100
	    p = END_list ( p ) ;
1130
		p = END_list(p);
1101
	    a = DEREF_exp ( HEAD_list ( p ) ) ;
1131
		a = DEREF_exp(HEAD_list(p));
1102
	    bs = enc_condition ( bs, a, lab, nlab ) ;
1132
		bs = enc_condition(bs, a, lab, nlab);
1103
	    break ;
1133
		break;
1104
	}
1134
	}
1105
 
1135
 
1106
	case exp_location_tag : {
1136
	case exp_location_tag: {
1107
	    /* Location marker */
1137
		/* Location marker */
1108
	    PTR ( LOCATION ) loc = crt_enc_loc ;
1138
		PTR(LOCATION)loc = crt_enc_loc;
1109
	    EXP a = DEREF_exp ( exp_location_arg ( e ) ) ;
1139
		EXP a = DEREF_exp(exp_location_arg(e));
1110
            BITSTREAM *ts = enc_diag_begin ( &bs ) ;
1140
		BITSTREAM *ts = enc_diag_begin(&bs);
1111
	    ts = enc_condition ( ts, a, lab, nlab ) ;
1141
		ts = enc_condition(ts, a, lab, nlab);
1112
            crt_enc_loc = exp_location_end ( e ) ;
1142
		crt_enc_loc = exp_location_end(e);
1113
            bs = enc_diag_end ( bs, ts, a, 2 ) ;
1143
		bs = enc_diag_end(bs, ts, a, 2);
1114
            crt_enc_loc = loc ;
1144
		crt_enc_loc = loc;
1115
	    break ;
1145
		break;
1116
	}
1146
	}
1117
 
1147
 
1118
	default :
1148
	default:
1119
	default_lab : {
1149
default_lab: {
1120
	    /* Other conditions */
1150
		     /* Other conditions */
1121
	    NTEST tst = ntest_not_eq ;
1151
		     NTEST tst = ntest_not_eq;
1122
	    bs = enc_compare ( bs, e, NULL_exp, tst, lab, nlab ) ;
1152
		     bs = enc_compare(bs, e, NULL_exp, tst, lab, nlab);
1123
	    break ;
1153
		     break;
1124
	}
1154
	     }
1125
    }
1155
	}
1126
    return ( bs ) ;
1156
	return (bs);
1127
}
1157
}
1128
 
1158
 
1129
 
1159
 
1130
/*
1160
/*
1131
    ENCODE A LOGICAL EXPRESSION
1161
    ENCODE A LOGICAL EXPRESSION
1132
 
1162
 
1133
    This routine adds the logical expression e of type t to the bitstream
1163
    This routine adds the logical expression e of type t to the bitstream
1134
    bs.  The code added is equivalent to '( e ? 1 : 0 )'.
1164
    bs.  The code added is equivalent to '( e ? 1 : 0 )'.
1135
*/
1165
*/
1136
 
1166
 
1137
static BITSTREAM *enc_logical
1167
static BITSTREAM *
1138
    PROTO_N ( ( bs, e, t ) )
-
 
1139
    PROTO_T ( BITSTREAM *bs X EXP e X TYPE t )
1168
enc_logical(BITSTREAM *bs, EXP e, TYPE t)
1140
{
1169
{
1141
    int sw = 0 ;
1170
	int sw = 0;
1142
    ulong nlab = LINK_NONE ;
1171
	ulong nlab = LINK_NONE;
1143
    ulong n = unit_no ( bs, NULL_id, VAR_tag, 1 ) ;
1172
	ulong n = unit_no(bs, NULL_id, VAR_tag, 1);
1144
    ulong lab = unit_no ( bs, NULL_id, VAR_label, 1 ) ;
1173
	ulong lab = unit_no(bs, NULL_id, VAR_label, 1);
1145
    e = simplify_cond ( e, &sw ) ;
1174
	e = simplify_cond(e, &sw);
1146
 
-
 
1147
    /* Introduce variable for boolean value */
-
 
1148
    ENC_variable ( bs ) ;
-
 
1149
    bs = enc_access ( bs, dspec_none ) ;
-
 
1150
    ENC_make_tag ( bs, n ) ;
-
 
1151
    bs = enc_make_int ( bs, t, sw ) ;
-
 
1152
    ENC_SEQ_SMALL ( bs, 1 ) ;
-
 
1153
    ENC_conditional ( bs ) ;
-
 
1154
    ENC_make_label ( bs, lab ) ;
-
 
1155
    ENC_SEQ_SMALL ( bs, 1 ) ;
-
 
1156
 
-
 
1157
    /* Conditionally assign to boolean variable */
-
 
1158
    if ( sw ) {
-
 
1159
	nlab = lab ;
-
 
1160
	lab = LINK_NONE ;
-
 
1161
    }
-
 
1162
    bs = enc_condition ( bs, e, lab, nlab ) ;
-
 
1163
    ENC_assign ( bs ) ;
-
 
1164
    ENC_obtain_tag ( bs ) ;
-
 
1165
    ENC_make_tag ( bs, n ) ;
-
 
1166
    bs = enc_make_int ( bs, t, !sw ) ;
-
 
1167
    ENC_make_top ( bs ) ;
-
 
1168
 
1175
 
-
 
1176
	/* Introduce variable for boolean value */
-
 
1177
	ENC_variable(bs);
-
 
1178
	bs = enc_access(bs, dspec_none);
-
 
1179
	ENC_make_tag(bs, n);
-
 
1180
	bs = enc_make_int(bs, t, sw);
-
 
1181
	ENC_SEQ_SMALL(bs, 1);
-
 
1182
	ENC_conditional(bs);
-
 
1183
	ENC_make_label(bs, lab);
-
 
1184
	ENC_SEQ_SMALL(bs, 1);
-
 
1185
 
-
 
1186
	/* Conditionally assign to boolean variable */
-
 
1187
	if (sw) {
-
 
1188
		nlab = lab;
-
 
1189
		lab = LINK_NONE;
-
 
1190
	}
-
 
1191
	bs = enc_condition(bs, e, lab, nlab);
-
 
1192
	ENC_assign(bs);
-
 
1193
	ENC_obtain_tag(bs);
-
 
1194
	ENC_make_tag(bs, n);
-
 
1195
	bs = enc_make_int(bs, t, !sw);
-
 
1196
	ENC_make_top(bs);
-
 
1197
 
1169
    /* Return the contents of the boolean */
1198
	/* Return the contents of the boolean */
1170
    ENC_contents ( bs ) ;
1199
	ENC_contents(bs);
1171
    bs = enc_shape ( bs, t ) ;
1200
	bs = enc_shape(bs, t);
1172
    ENC_obtain_tag ( bs ) ;
1201
	ENC_obtain_tag(bs);
1173
    ENC_make_tag ( bs, n ) ;
1202
	ENC_make_tag(bs, n);
1174
    return ( bs ) ;
1203
	return (bs);
1175
}
1204
}
1176
 
1205
 
1177
 
1206
 
1178
/*
1207
/*
1179
    CHECK FOR CONSTANT POINTER TO MEMBERS
1208
    CHECK FOR CONSTANT POINTER TO MEMBERS
1180
 
1209
 
1181
    This routine checks whether the expression e consists of a cast of the
1210
    This routine checks whether the expression e consists of a cast of the
1182
    address of a member of some class.  If so it returns the corresponding
1211
    address of a member of some class.  If so it returns the corresponding
1183
    member identifier.
1212
    member identifier.
1184
*/
1213
*/
1185
 
1214
 
1186
static IDENTIFIER is_const_ptr_mem
1215
static IDENTIFIER
1187
    PROTO_N ( ( e, rev ) )
-
 
1188
    PROTO_T ( EXP e X int rev )
1216
is_const_ptr_mem(EXP e, int rev)
1189
{
1217
{
1190
    if ( !IS_NULL_exp ( e ) ) {
1218
	if (!IS_NULL_exp(e)) {
1191
	unsigned tag = TAG_exp ( e ) ;
1219
		unsigned tag = TAG_exp(e);
1192
	if ( tag == exp_address_mem_tag ) {
1220
		if (tag == exp_address_mem_tag) {
1193
	    /* Allow for addresses of members */
1221
			/* Allow for addresses of members */
1194
	    EXP a = DEREF_exp ( exp_address_mem_arg ( e ) ) ;
1222
			EXP a = DEREF_exp(exp_address_mem_arg(e));
1195
	    IDENTIFIER id = DEREF_id ( exp_member_id ( a ) ) ;
1223
			IDENTIFIER id = DEREF_id(exp_member_id(a));
1196
	    return ( id ) ;
1224
			return (id);
1197
	} else if ( tag == exp_base_cast_tag ) {
1225
		} else if (tag == exp_base_cast_tag) {
1198
	    /* Allow for base casts */
1226
			/* Allow for base casts */
1199
	    EXP a = DEREF_exp ( exp_base_cast_arg ( e ) ) ;
1227
			EXP a = DEREF_exp(exp_base_cast_arg(e));
1200
	    unsigned conv = DEREF_unsigned ( exp_base_cast_conv ( e ) ) ;
1228
			unsigned conv = DEREF_unsigned(exp_base_cast_conv(e));
1201
	    if ( rev || !( conv & CONV_REVERSE ) ) {
1229
			if (rev || !(conv & CONV_REVERSE)) {
1202
		IDENTIFIER id = is_const_ptr_mem ( a, rev ) ;
1230
				IDENTIFIER id = is_const_ptr_mem(a, rev);
1203
		return ( id ) ;
1231
				return (id);
1204
	    }
1232
			}
1205
	} else if ( tag == exp_dummy_tag ) {
1233
		} else if (tag == exp_dummy_tag) {
1206
	    /* Allow for dummy expressions */
1234
			/* Allow for dummy expressions */
1207
	    EXP a = DEREF_exp ( exp_dummy_value ( e ) ) ;
1235
			EXP a = DEREF_exp(exp_dummy_value(e));
1208
	    IDENTIFIER id = is_const_ptr_mem ( a, rev ) ;
1236
			IDENTIFIER id = is_const_ptr_mem(a, rev);
1209
	    return ( id ) ;
1237
			return (id);
1210
	}
1238
		}
1211
    }
1239
	}
1212
    return ( NULL_id ) ;
1240
	return (NULL_id);
1213
}
1241
}
1214
 
1242
 
1215
 
1243
 
1216
/*
1244
/*
1217
    ENCODE A POINTER TO MEMBER
1245
    ENCODE A POINTER TO MEMBER
1218
 
1246
 
1219
    This routine adds the address of the member id plus the base class
1247
    This routine adds the address of the member id plus the base class
1220
    offset gr, converted to type t, to the bitstream bs.
1248
    offset gr, converted to type t, to the bitstream bs.
1221
*/
1249
*/
1222
 
1250
 
1223
static BITSTREAM *enc_ptr_mem
1251
static BITSTREAM *
1224
    PROTO_N ( ( bs, t, id, gr ) )
-
 
1225
    PROTO_T ( BITSTREAM *bs X TYPE t X IDENTIFIER id X GRAPH gr )
1252
enc_ptr_mem(BITSTREAM *bs, TYPE t, IDENTIFIER id, GRAPH gr)
1226
{
1253
{
1227
    BITSTREAM *ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
1254
	BITSTREAM *ts = start_bitstream(NIL(FILE), bs->link);
1228
    if ( IS_id_mem_func ( id ) ) {
1255
	if (IS_id_mem_func(id)) {
1229
	DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
1256
		DECL_SPEC ds = DEREF_dspec(id_storage(id));
1230
	CLASS_TYPE ct = DEREF_ctype ( type_ptr_mem_of ( t ) ) ;
1257
		CLASS_TYPE ct = DEREF_ctype(type_ptr_mem_of(t));
1231
	ASSERT ( !( ds & dspec_inherit ) ) ;
1258
		ASSERT(!(ds & dspec_inherit));
1232
	if ( ds & dspec_virtual ) {
1259
		if (ds & dspec_virtual) {
1233
	    /* Virtual member function */
1260
			/* Virtual member function */
1234
	    ulong m ;
1261
			ulong m;
1235
	    ulong tok ;
1262
			ulong tok;
1236
	    VIRTUAL vt ;
1263
			VIRTUAL vt;
1237
	    OFFSET off ;
1264
			OFFSET off;
1238
	    IGNORE compile_class ( ct ) ;
1265
			IGNORE compile_class(ct);
1239
	    vt = DEREF_virt ( ctype_virt ( ct ) ) ;
1266
			vt = DEREF_virt(ctype_virt(ct));
1240
	    off = DEREF_off ( virt_table_off ( vt ) ) ;
1267
			off = DEREF_off(virt_table_off(vt));
1241
	    tok = DEREF_ulong ( virt_table_tok ( vt ) ) ;
1268
			tok = DEREF_ulong(virt_table_tok(vt));
1242
	    if ( !IS_NULL_graph ( gr ) ) {
1269
			if (!IS_NULL_graph(gr)) {
1243
		/* Allow for overriding virtual functions */
1270
				/* Allow for overriding virtual functions */
1244
		GRAPH gs = NULL_graph ;
1271
				GRAPH gs = NULL_graph;
1245
		VIRTUAL at = find_overrider ( ct, id, gr, &gs ) ;
1272
				VIRTUAL at = find_overrider(ct, id, gr, &gs);
1246
		if ( !IS_NULL_virt ( at ) ) {
1273
				if (!IS_NULL_virt(at)) {
1247
		    id = DEREF_id ( virt_func ( at ) ) ;
1274
					id = DEREF_id(virt_func(at));
1248
		}
1275
				}
1249
	    }
1276
			}
1250
	    m = virtual_no ( id, vt ) ;
1277
			m = virtual_no(id, vt);
1251
	    bs = enc_special ( bs, TOK_pmf_vmake ) ;
1278
			bs = enc_special(bs, TOK_pmf_vmake);
1252
	    ts = enc_make_snat ( ts, ( int ) m ) ;
1279
			ts = enc_make_snat(ts,(int)m);
1253
	    if ( !is_zero_offset ( off ) ) {
1280
			if (!is_zero_offset(off)) {
1254
		ENC_offset_add ( ts ) ;
1281
				ENC_offset_add(ts);
1255
		ts = enc_offset ( ts, off ) ;
1282
				ts = enc_offset(ts, off);
1256
	    }
1283
			}
1257
	    tok = link_no ( ts, tok, VAR_token ) ;
1284
			tok = link_no(ts, tok, VAR_token);
1258
	    ENC_exp_apply_token ( ts ) ;
1285
			ENC_exp_apply_token(ts);
1259
	    ENC_make_tok ( ts, tok ) ;
1286
			ENC_make_tok(ts, tok);
1260
	    ENC_LEN_SMALL ( ts, 0 ) ;
1287
			ENC_LEN_SMALL(ts, 0);
-
 
1288
			ENC_offset_zero(ts);
-
 
1289
			ts = enc_al_ctype(ts, ct);
-
 
1290
			ENC_offset_zero(ts);
-
 
1291
			ts = enc_al_ctype(ts, ct);
-
 
1292
		} else {
-
 
1293
			/* Member function */
-
 
1294
			bs = enc_special(bs, TOK_pmf_make);
-
 
1295
			ts = enc_member(ts, id);
-
 
1296
			if (IS_NULL_graph(gr)) {
1261
	    ENC_offset_zero ( ts ) ;
1297
				ENC_offset_zero(ts);
1262
	    ts = enc_al_ctype ( ts, ct ) ;
1298
				ts = enc_al_ctype(ts, ct);
-
 
1299
			} else {
-
 
1300
				ts = enc_base(ts, gr, 0);
-
 
1301
			}
1263
	    ENC_offset_zero ( ts ) ;
1302
			ENC_offset_zero(ts);
1264
	    ts = enc_al_ctype ( ts, ct ) ;
1303
			ts = enc_al_ctype(ts, ct);
-
 
1304
		}
1265
	} else {
1305
	} else {
1266
	    /* Member function */
1306
		/* Data member */
1267
	    bs = enc_special ( bs, TOK_pmf_make ) ;
1307
		bs = enc_special(bs, TOK_pm_make);
1268
	    ts = enc_member ( ts, id ) ;
-
 
1269
	    if ( IS_NULL_graph ( gr ) ) {
1308
		if (!IS_NULL_graph(gr)) {
1270
		ENC_offset_zero ( ts ) ;
1309
			DECL_SPEC acc = DEREF_dspec(graph_access(gr));
1271
		ts = enc_al_ctype ( ts, ct ) ;
1310
			if (!(acc & dspec_ignore)) {
1272
	    } else {
1311
				ENC_offset_add(ts);
1273
		ts = enc_base ( ts, gr, 0 ) ;
1312
				ts = enc_base(ts, gr, 0);
1274
	    }
1313
			}
1275
	    ENC_offset_zero ( ts ) ;
1314
		}
1276
	    ts = enc_al_ctype ( ts, ct ) ;
1315
		ts = enc_member(ts, id);
1277
	}
1316
	}
1278
    } else {
-
 
1279
	/* Data member */
-
 
1280
	bs = enc_special ( bs, TOK_pm_make ) ;
-
 
1281
	if ( !IS_NULL_graph ( gr ) ) {
-
 
1282
	    DECL_SPEC acc = DEREF_dspec ( graph_access ( gr ) ) ;
-
 
1283
	    if ( !( acc & dspec_ignore ) ) {
-
 
1284
		ENC_offset_add ( ts ) ;
-
 
1285
		ts = enc_base ( ts, gr, 0 ) ;
-
 
1286
	    }
-
 
1287
	}
-
 
1288
	ts = enc_member ( ts, id ) ;
-
 
1289
    }
-
 
1290
    bs = enc_bitstream ( bs, ts ) ;
1317
	bs = enc_bitstream(bs, ts);
1291
    return ( bs ) ;
1318
	return (bs);
1292
}
1319
}
1293
 
1320
 
1294
 
1321
 
1295
/*
1322
/*
1296
    ENCODE A CAST EXPRESSION
1323
    ENCODE A CAST EXPRESSION
1297
 
1324
 
1298
    This routine adds a TDF EXP to the bitstream bs representing a cast
1325
    This routine adds a TDF EXP to the bitstream bs representing a cast
1299
    of the expression e to the type t.  conv represents the conversion
1326
    of the expression e to the type t.  conv represents the conversion
1300
    type (see cast.c).
1327
    type (see cast.c).
1301
*/
1328
*/
1302
 
1329
 
1303
static BITSTREAM *enc_cast_exp
1330
static BITSTREAM *
1304
    PROTO_N ( ( bs, t, e, conv ) )
-
 
1305
    PROTO_T ( BITSTREAM *bs X TYPE t X EXP e X unsigned conv )
1331
enc_cast_exp(BITSTREAM *bs, TYPE t, EXP e, unsigned conv)
1306
{
1332
{
1307
    BITSTREAM *ts ;
1333
	BITSTREAM *ts;
1308
    switch ( conv ) {
1334
	switch (conv) {
1309
 
1335
 
1310
	case CONV_EXACT :
1336
	case CONV_EXACT:
1311
	case CONV_FUNC :
1337
	case CONV_FUNC:
1312
	case CONV_STRING :
1338
	case CONV_STRING:
1313
	case CONV_PTR_PTR_ALIGN :
1339
	case CONV_PTR_PTR_ALIGN:
1314
	case CONV_PTR_MEM_PTR_MEM : {
1340
	case CONV_PTR_MEM_PTR_MEM: {
1315
	    /* Trivial conversions */
1341
		/* Trivial conversions */
1316
	    bs = enc_exp ( bs, e ) ;
1342
		bs = enc_exp(bs, e);
1317
	    break ;
1343
		break;
1318
	}
1344
	}
1319
 
1345
 
1320
	case CONV_QUAL : {
1346
	case CONV_QUAL: {
1321
	    /* Qualification conversions */
1347
		/* Qualification conversions */
1322
	    if ( IS_exp_address ( e ) ) {
1348
		if (IS_exp_address(e)) {
1323
		EXP a = DEREF_exp ( exp_address_arg ( e ) ) ;
1349
			EXP a = DEREF_exp(exp_address_arg(e));
1324
		bs = enc_addr_exp ( bs, t, a ) ;
1350
			bs = enc_addr_exp(bs, t, a);
1325
	    } else {
1351
		} else {
1326
		bs = enc_exp ( bs, e ) ;
1352
			bs = enc_exp(bs, e);
1327
	    }
1353
		}
1328
	    break ;
1354
		break;
1329
	}
1355
	}
1330
 
1356
 
1331
	case CONV_ELLIPSIS : {
1357
	case CONV_ELLIPSIS: {
1332
	    /* Discarded expression */
1358
		/* Discarded expression */
1333
	    if ( overflow_exp ( e ) ) {
1359
		if (overflow_exp(e)) {
1334
		bs = enc_stmt_exp ( bs, e, t, 0 ) ;
1360
			bs = enc_stmt_exp(bs, e, t, 0);
1335
	    } else {
1361
		} else {
1336
		bs = enc_null_exp ( bs, t ) ;
1362
			bs = enc_null_exp(bs, t);
1337
	    }
-
 
1338
	    break ;
-
 
1339
	}
-
 
1340
 
-
 
1341
	case CONV_INT_INT :
-
 
1342
	case CONV_ENUM : {
-
 
1343
	    /* Integer to integer conversion */
-
 
1344
	    TYPE u = DEREF_type ( exp_type ( e ) ) ;
-
 
1345
	    switch ( TAG_exp ( e ) ) {
-
 
1346
		case exp_char_lit_tag : {
-
 
1347
		    STRING s = DEREF_str ( exp_char_lit_str ( e ) ) ;
-
 
1348
		    bs = enc_char ( bs, s, t, u ) ;
-
 
1349
		    break ;
-
 
1350
		}
1363
		}
1351
		case exp_cast_tag : {
-
 
1352
		    conv = DEREF_unsigned ( exp_cast_conv ( e ) ) ;
-
 
1353
		    if ( conv == CONV_BITFIELD ) {
-
 
1354
			/* Elide following bitfield conversion */
-
 
1355
			e = DEREF_exp ( exp_cast_arg ( e ) ) ;
-
 
1356
			ENC_change_bitfield_to_int ( bs ) ;
-
 
1357
			bs = enc_variety ( bs, t ) ;
-
 
1358
			bs = enc_exp ( bs, e ) ;
-
 
1359
			break ;
1364
		break;
1360
		    }
-
 
1361
		    goto int_int_label ;
-
 
1362
		}
-
 
1363
		case exp_not_tag :
-
 
1364
		case exp_log_and_tag :
-
 
1365
		case exp_log_or_tag :
-
 
1366
		case exp_test_tag :
-
 
1367
		case exp_compare_tag : {
-
 
1368
		    /* Logical expressions */
-
 
1369
		    bs = enc_logical ( bs, e, t ) ;
-
 
1370
		    break ;
-
 
1371
		}
-
 
1372
		default :
-
 
1373
		int_int_label : {
-
 
1374
		    if ( !eq_type_rep ( u, t, 0 ) ) {
-
 
1375
			ENC_change_variety ( bs ) ;
-
 
1376
			bs = enc_error_treatment ( bs, t ) ;
-
 
1377
			bs = enc_variety ( bs, t ) ;
-
 
1378
		    }
-
 
1379
		    bs = enc_exp ( bs, e ) ;
-
 
1380
		    break ;
-
 
1381
		}
-
 
1382
	    }
-
 
1383
	    break ;
-
 
1384
	}
-
 
1385
 
-
 
1386
	case CONV_BITFIELD : {
-
 
1387
	    /* Bitfield to integer conversion */
-
 
1388
	    ENC_change_bitfield_to_int ( bs ) ;
-
 
1389
	    bs = enc_variety ( bs, t ) ;
-
 
1390
	    bs = enc_exp ( bs, e ) ;
-
 
1391
	    break ;
-
 
1392
	}
-
 
1393
 
-
 
1394
	case CONV_BITFIELD | CONV_REVERSE : {
-
 
1395
	    /* Integer to bitfield conversion */
-
 
1396
	    if ( IS_exp_cast ( e ) ) {
-
 
1397
		conv = DEREF_unsigned ( exp_cast_conv ( e ) ) ;
-
 
1398
		if ( conv == CONV_INT_INT ) {
-
 
1399
		    /* Elide following integer conversion */
-
 
1400
		    e = DEREF_exp ( exp_cast_arg ( e ) ) ;
-
 
1401
		}
-
 
1402
	    }
-
 
1403
	    ENC_change_int_to_bitfield ( bs ) ;
-
 
1404
	    bs = enc_bfvar ( bs, t ) ;
-
 
1405
	    bs = enc_exp ( bs, e ) ;
-
 
1406
	    break ;
-
 
1407
	}
-
 
1408
 
-
 
1409
	case CONV_INT_FLT : {
-
 
1410
	    /* Integer to float conversion */
-
 
1411
	    if ( IS_exp_int_lit ( e ) ) {
-
 
1412
		NAT n = DEREF_nat ( exp_int_lit_nat ( e ) ) ;
-
 
1413
		unsigned long v = get_nat_value ( n ) ;
-
 
1414
		if ( v < SMALL_FLOAT_CONST ) {
-
 
1415
		    /* Small floating point constants */
-
 
1416
		    bs = enc_float_int ( bs, ( int ) v, t ) ;
-
 
1417
		    break ;
-
 
1418
		}
-
 
1419
	    }
-
 
1420
	    ENC_float_int ( bs ) ;
-
 
1421
	    ENC_impossible ( bs ) ;
-
 
1422
	    bs = enc_flvar ( bs, t ) ;
-
 
1423
	    bs = enc_exp ( bs, e ) ;
-
 
1424
	    break ;
-
 
1425
	}
-
 
1426
 
-
 
1427
	case CONV_FLT_INT : {
-
 
1428
	    /* Float to integer conversion */
-
 
1429
	    ENC_round_with_mode ( bs ) ;
-
 
1430
	    ENC_impossible ( bs ) ;
-
 
1431
	    ENC_RMODE ( bs, crt_round_mode ) ;
-
 
1432
	    bs = enc_variety ( bs, t ) ;
-
 
1433
	    bs = enc_exp ( bs, e ) ;
-
 
1434
	    break ;
-
 
1435
	}
-
 
1436
 
-
 
1437
	case CONV_FLT_FLT : {
-
 
1438
	    /* Float to float conversion */
-
 
1439
	    ENC_change_floating_variety ( bs ) ;
-
 
1440
	    ENC_impossible ( bs ) ;
-
 
1441
	    bs = enc_flvar ( bs, t ) ;
-
 
1442
	    bs = enc_exp ( bs, e ) ;
-
 
1443
	    break ;
-
 
1444
	}
-
 
1445
 
-
 
1446
	case CONV_PTR_VOID :
-
 
1447
	case CONV_PTR_VOID | CONV_REVERSE :
-
 
1448
	pointer_void_label : {
-
 
1449
	    /* Object pointer and 'void *' conversions */
-
 
1450
	    if ( conv & CONV_REVERSE ) {
-
 
1451
		bs = enc_special ( bs, TOK_from_ptr_void ) ;
-
 
1452
	    } else {
-
 
1453
		bs = enc_special ( bs, TOK_to_ptr_void ) ;
-
 
1454
		t = DEREF_type ( exp_type ( e ) ) ;
-
 
1455
	    }
-
 
1456
	    ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
-
 
1457
	    t = DEREF_type ( type_ptr_etc_sub ( t ) ) ;
-
 
1458
	    ts = enc_alignment ( ts, t ) ;
-
 
1459
	    ts = enc_exp ( ts, e ) ;
-
 
1460
	    bs = enc_bitstream ( bs, ts ) ;
-
 
1461
	    break ;
-
 
1462
	}
-
 
1463
 
-
 
1464
	case CONV_PTR_PTR :
-
 
1465
	case CONV_PTR_BASE :
-
 
1466
	case CONV_PTR_PTR | CONV_REVERSE :
-
 
1467
	case CONV_PTR_BASE | CONV_REVERSE : {
-
 
1468
	    /* Pointer to pointer conversion */
-
 
1469
	    TYPE s = DEREF_type ( exp_type ( e ) ) ;
-
 
1470
	    TYPE ps = DEREF_type ( type_ptr_etc_sub ( s ) ) ;
-
 
1471
	    TYPE pt = DEREF_type ( type_ptr_etc_sub ( t ) ) ;
-
 
1472
	    switch ( TAG_type ( pt ) ) {
-
 
1473
		case type_top_tag :
-
 
1474
		case type_bottom_tag : {
-
 
1475
		    switch ( TAG_type ( ps ) ) {
-
 
1476
			case type_top_tag :
-
 
1477
			case type_bottom_tag : {
-
 
1478
			    /* 'void *' to 'void *' */
-
 
1479
			    bs = enc_exp ( bs, e ) ;
-
 
1480
			    break ;
-
 
1481
			}
-
 
1482
			case type_func_tag : {
-
 
1483
			    /* Function to 'void *' */
-
 
1484
			    bs = enc_special ( bs, TOK_f_to_pv ) ;
-
 
1485
			    ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
-
 
1486
			    ts = enc_exp ( ts, e ) ;
-
 
1487
			    bs = enc_bitstream ( bs, ts ) ;
-
 
1488
			    break ;
-
 
1489
			}
-
 
1490
			default : {
-
 
1491
			    /* Object pointer to 'void *' */
-
 
1492
			    conv = CONV_PTR_VOID ;
-
 
1493
			    goto pointer_void_label ;
-
 
1494
			}
-
 
1495
		    }
-
 
1496
		    break ;
-
 
1497
		}
-
 
1498
		case type_func_tag : {
-
 
1499
		    switch ( TAG_type ( ps ) ) {
-
 
1500
			case type_top_tag :
-
 
1501
			case type_bottom_tag : {
-
 
1502
			    /* 'void *' to function */
-
 
1503
			    bs = enc_special ( bs, TOK_pv_to_f ) ;
-
 
1504
			    ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
-
 
1505
			    ts = enc_exp ( ts, e ) ;
-
 
1506
			    bs = enc_bitstream ( bs, ts ) ;
-
 
1507
			    break ;
-
 
1508
			}
-
 
1509
			case type_func_tag : {
-
 
1510
			    /* Function to function */
-
 
1511
			    bs = enc_exp ( bs, e ) ;
-
 
1512
			    break ;
-
 
1513
			}
-
 
1514
			default : {
-
 
1515
			    /* Object pointer to function */
-
 
1516
			    BITSTREAM *us ;
-
 
1517
			    bs = enc_special ( bs, TOK_pv_to_f ) ;
-
 
1518
			    ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
-
 
1519
			    ts = enc_special ( ts, TOK_to_ptr_void ) ;
-
 
1520
			    us = start_bitstream ( NIL ( FILE ), ts->link ) ;
-
 
1521
			    us = enc_alignment ( us, ps ) ;
-
 
1522
			    us = enc_exp ( us, e ) ;
-
 
1523
			    ts = enc_bitstream ( ts, us ) ;
-
 
1524
			    bs = enc_bitstream ( bs, ts ) ;
-
 
1525
			    break ;
-
 
1526
			}
-
 
1527
		    }
-
 
1528
		    break ;
-
 
1529
		}
-
 
1530
		default : {
-
 
1531
		    switch ( TAG_type ( ps ) ) {
-
 
1532
			case type_top_tag :
-
 
1533
			case type_bottom_tag : {
-
 
1534
			    /* 'void *' to object pointer */
-
 
1535
			    conv = ( CONV_PTR_VOID | CONV_REVERSE ) ;
-
 
1536
			    goto pointer_void_label ;
-
 
1537
			}
-
 
1538
			case type_func_tag : {
-
 
1539
			    /* Function to object pointer */
-
 
1540
			    BITSTREAM *us ;
-
 
1541
			    bs = enc_special ( bs, TOK_from_ptr_void ) ;
-
 
1542
			    ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
-
 
1543
			    ts = enc_alignment ( ts, pt ) ;
-
 
1544
			    ts = enc_special ( ts, TOK_f_to_pv ) ;
-
 
1545
			    us = start_bitstream ( NIL ( FILE ), ts->link ) ;
-
 
1546
			    us = enc_exp ( us, e ) ;
-
 
1547
			    ts = enc_bitstream ( ts, us ) ;
-
 
1548
			    bs = enc_bitstream ( bs, ts ) ;
-
 
1549
			    break ;
-
 
1550
			}
-
 
1551
			default : {
-
 
1552
			    /* Object pointer to object pointer */
-
 
1553
			    if ( conv & CONV_REVERSE ) {
-
 
1554
				/* Force conversion in these cases */
-
 
1555
				/* EMPTY */
-
 
1556
			    } else {
-
 
1557
				if ( eq_type_rep ( ps, pt, 1 ) ) {
-
 
1558
				    bs = enc_exp ( bs, e ) ;
-
 
1559
				    break ;
-
 
1560
				}
-
 
1561
			    }
-
 
1562
			    bs = enc_special ( bs, TOK_ptr_to_ptr ) ;
-
 
1563
			    ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
-
 
1564
			    ts = enc_alignment ( ts, ps ) ;
-
 
1565
			    ts = enc_alignment ( ts, pt ) ;
-
 
1566
			    ts = enc_exp ( ts, e ) ;
-
 
1567
			    bs = enc_bitstream ( bs, ts ) ;
-
 
1568
			    break ;
-
 
1569
			}
-
 
1570
		    }
-
 
1571
		    break ;
-
 
1572
		}
-
 
1573
	    }
-
 
1574
	    break ;
-
 
1575
	}
-
 
1576
 
-
 
1577
	case CONV_INT_PTR : {
-
 
1578
	    /* Integer to pointer conversion */
-
 
1579
	    TYPE s = DEREF_type ( exp_type ( e ) ) ;
-
 
1580
	    TYPE pt = DEREF_type ( type_ptr_etc_sub ( t ) ) ;
-
 
1581
	    switch ( TAG_type ( pt ) ) {
-
 
1582
		case type_top_tag :
-
 
1583
		case type_bottom_tag : {
-
 
1584
		    /* Integer to 'void *' */
-
 
1585
		    bs = enc_special ( bs, TOK_i_to_pv ) ;
-
 
1586
		    ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
-
 
1587
		    ts = enc_variety ( ts, s ) ;
-
 
1588
		    ts = enc_exp ( ts, e ) ;
-
 
1589
		    bs = enc_bitstream ( bs, ts ) ;
-
 
1590
		    break ;
-
 
1591
		}
-
 
1592
		case type_func_tag : {
-
 
1593
		    /* Integer to function */
-
 
1594
		    BITSTREAM *us ;
-
 
1595
		    bs = enc_special ( bs, TOK_pv_to_f ) ;
-
 
1596
		    ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
-
 
1597
		    ts = enc_special ( ts, TOK_i_to_pv ) ;
-
 
1598
		    us = start_bitstream ( NIL ( FILE ), ts->link ) ;
-
 
1599
		    us = enc_variety ( us, s ) ;
-
 
1600
		    us = enc_exp ( us, e ) ;
-
 
1601
		    ts = enc_bitstream ( ts, us ) ;
-
 
1602
		    bs = enc_bitstream ( bs, ts ) ;
-
 
1603
		    break ;
-
 
1604
		}
-
 
1605
		default : {
-
 
1606
		    /* Integer to object pointer */
-
 
1607
		    bs = enc_special ( bs, TOK_i_to_p ) ;
-
 
1608
		    ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
-
 
1609
		    ts = enc_variety ( ts, s ) ;
-
 
1610
		    ts = enc_alignment ( ts, pt ) ;
-
 
1611
		    ts = enc_exp ( ts, e ) ;
-
 
1612
		    bs = enc_bitstream ( bs, ts ) ;
-
 
1613
		    break ;
-
 
1614
		}
-
 
1615
	    }
-
 
1616
	    break ;
-
 
1617
	}
1365
	}
1618
 
1366
 
1619
	case CONV_PTR_INT : {
1367
	case CONV_INT_INT:
-
 
1368
	case CONV_ENUM: {
1620
	    /* Pointer to integer conversion */
1369
		/* Integer to integer conversion */
1621
	    TYPE s = DEREF_type ( exp_type ( e ) ) ;
1370
		TYPE u = DEREF_type(exp_type(e));
-
 
1371
		switch (TAG_exp(e)) {
-
 
1372
		case exp_char_lit_tag: {
1622
	    TYPE ps = DEREF_type ( type_ptr_etc_sub ( s ) ) ;
1373
			STRING s = DEREF_str(exp_char_lit_str(e));
1623
	    switch ( TAG_type ( ps ) ) {
1374
			bs = enc_char(bs, s, t, u);
1624
		case type_top_tag :
1375
			break;
-
 
1376
		}
1625
		case type_bottom_tag : {
1377
		case exp_cast_tag: {
-
 
1378
			conv = DEREF_unsigned(exp_cast_conv(e));
1626
		    /* 'void *' to integer */
1379
			if (conv == CONV_BITFIELD) {
1627
		    bs = enc_special ( bs, TOK_pv_to_i ) ;
1380
				/* Elide following bitfield conversion */
1628
		    ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
1381
				e = DEREF_exp(exp_cast_arg(e));
1629
		    ts = enc_variety ( ts, t ) ;
1382
				ENC_change_bitfield_to_int(bs);
1630
		    ts = enc_exp ( ts, e ) ;
1383
				bs = enc_variety(bs, t);
1631
		    bs = enc_bitstream ( bs, ts ) ;
1384
				bs = enc_exp(bs, e);
1632
		    break ;
1385
				break;
-
 
1386
			}
-
 
1387
			goto int_int_label;
1633
		}
1388
		}
1634
		case type_func_tag : {
1389
		case exp_not_tag:
1635
		    /* Function to integer */
1390
		case exp_log_and_tag:
1636
		    BITSTREAM *us ;
1391
		case exp_log_or_tag:
1637
		    bs = enc_special ( bs, TOK_pv_to_i ) ;
-
 
1638
		    ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
-
 
1639
		    ts = enc_variety ( ts, t ) ;
1392
		case exp_test_tag:
1640
		    ts = enc_special ( ts, TOK_f_to_pv ) ;
-
 
1641
		    us = start_bitstream ( NIL ( FILE ), ts->link ) ;
-
 
1642
		    us = enc_exp ( us, e ) ;
1393
		case exp_compare_tag: {
1643
		    ts = enc_bitstream ( ts, us ) ;
1394
			/* Logical expressions */
1644
		    bs = enc_bitstream ( bs, ts ) ;
1395
			bs = enc_logical(bs, e, t);
1645
		    break ;
1396
			break;
1646
		}
1397
		}
1647
		default : {
1398
		default :
1648
		    /* Object pointer to integer */
1399
int_int_label: {
1649
		    bs = enc_special ( bs, TOK_p_to_i ) ;
1400
		       if (!eq_type_rep(u, t, 0)) {
1650
		    ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
1401
			       ENC_change_variety(bs);
1651
		    ts = enc_alignment ( ts, ps ) ;
1402
			       bs = enc_error_treatment(bs, t);
1652
		    ts = enc_variety ( ts, t ) ;
1403
			       bs = enc_variety(bs, t);
-
 
1404
		       }
1653
		    ts = enc_exp ( ts, e ) ;
1405
		       bs = enc_exp(bs, e);
1654
		    bs = enc_bitstream ( bs, ts ) ;
1406
		       break;
1655
		    break ;
1407
	       }
1656
		}
1408
		}
1657
	    }
-
 
1658
	    break ;
1409
		break;
1659
	}
1410
	}
1660
 
1411
 
1661
	case CONV_NULL : {
1412
	case CONV_BITFIELD: {
1662
	    /* Null pointer conversion */
1413
		/* Bitfield to integer conversion */
-
 
1414
		ENC_change_bitfield_to_int(bs);
-
 
1415
		bs = enc_variety(bs, t);
-
 
1416
		bs = enc_exp(bs, e);
-
 
1417
		break;
-
 
1418
	}
-
 
1419
 
-
 
1420
	case CONV_BITFIELD | CONV_REVERSE: {
-
 
1421
		/* Integer to bitfield conversion */
-
 
1422
		if (IS_exp_cast(e)) {
-
 
1423
			conv = DEREF_unsigned(exp_cast_conv(e));
-
 
1424
			if (conv == CONV_INT_INT) {
-
 
1425
				/* Elide following integer conversion */
-
 
1426
				e = DEREF_exp(exp_cast_arg(e));
-
 
1427
			}
-
 
1428
		}
-
 
1429
		ENC_change_int_to_bitfield(bs);
-
 
1430
		bs = enc_bfvar(bs, t);
1663
	    bs = enc_null_exp ( bs, t ) ;
1431
		bs = enc_exp(bs, e);
-
 
1432
		break;
-
 
1433
	}
-
 
1434
 
-
 
1435
	case CONV_INT_FLT: {
-
 
1436
		/* Integer to float conversion */
-
 
1437
		if (IS_exp_int_lit(e)) {
-
 
1438
			NAT n = DEREF_nat(exp_int_lit_nat(e));
-
 
1439
			unsigned long v = get_nat_value(n);
-
 
1440
			if (v < SMALL_FLOAT_CONST) {
-
 
1441
				/* Small floating point constants */
-
 
1442
				bs = enc_float_int(bs,(int)v, t);
1664
	    break ;
1443
				break;
-
 
1444
			}
-
 
1445
		}
-
 
1446
		ENC_float_int(bs);
-
 
1447
		ENC_impossible(bs);
-
 
1448
		bs = enc_flvar(bs, t);
-
 
1449
		bs = enc_exp(bs, e);
-
 
1450
		break;
1665
	}
1451
	}
1666
 
1452
 
1667
	case CONV_PTR_MEM_FUNC : {
1453
	case CONV_FLT_INT: {
1668
	    /* Pointer to member function to function conversion */
1454
		/* Float to integer conversion */
1669
	    IDENTIFIER fn = is_const_ptr_mem ( e, 1 ) ;
-
 
1670
	    if ( !IS_NULL_id ( fn ) ) {
1455
		ENC_round_with_mode(bs);
1671
		/* Constant function */
1456
		ENC_impossible(bs);
1672
		ulong n = unit_no ( bs, fn, VAR_tag, 0 ) ;
1457
		ENC_RMODE(bs, crt_round_mode);
1673
		ENC_obtain_tag ( bs ) ;
1458
		bs = enc_variety(bs, t);
1674
		ENC_make_tag ( bs, n ) ;
1459
		bs = enc_exp(bs, e);
1675
	    } else {
1460
		break;
1676
		/* Non-constant function */
1461
	}
-
 
1462
 
1677
		ulong n = LINK_NONE ;
1463
	case CONV_FLT_FLT: {
1678
		bs = make_ptr_mem_func ( bs, e, &n, 0 ) ;
1464
		/* Float to float conversion */
1679
		bs = enc_special ( bs, TOK_pmf_func ) ;
1465
		ENC_change_floating_variety(bs);
1680
		ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
-
 
1681
		ENC_obtain_tag ( ts ) ;
1466
		ENC_impossible(bs);
1682
		ENC_make_tag ( ts, n ) ;
1467
		bs = enc_flvar(bs, t);
1683
		bs = enc_bitstream ( bs, ts ) ;
1468
		bs = enc_exp(bs, e);
1684
	    }
-
 
1685
	    break ;
1469
		break;
1686
	}
1470
	}
1687
 
1471
 
-
 
1472
	case CONV_PTR_VOID:
-
 
1473
	case CONV_PTR_VOID | CONV_REVERSE :
-
 
1474
pointer_void_label: {
-
 
1475
			    /* Object pointer and 'void *' conversions */
-
 
1476
			    if (conv & CONV_REVERSE) {
-
 
1477
				    bs = enc_special(bs, TOK_from_ptr_void);
-
 
1478
			    } else {
-
 
1479
				    bs = enc_special(bs, TOK_to_ptr_void);
-
 
1480
				    t = DEREF_type(exp_type(e));
-
 
1481
			    }
-
 
1482
			    ts = start_bitstream(NIL(FILE), bs->link);
-
 
1483
			    t = DEREF_type(type_ptr_etc_sub(t));
-
 
1484
			    ts = enc_alignment(ts, t);
-
 
1485
			    ts = enc_exp(ts, e);
-
 
1486
			    bs = enc_bitstream(bs, ts);
-
 
1487
			    break;
-
 
1488
		    }
-
 
1489
 
-
 
1490
	case CONV_PTR_PTR:
-
 
1491
	case CONV_PTR_BASE:
-
 
1492
	case CONV_PTR_PTR | CONV_REVERSE :
-
 
1493
	case CONV_PTR_BASE | CONV_REVERSE: {
-
 
1494
		/* Pointer to pointer conversion */
-
 
1495
		TYPE s = DEREF_type(exp_type(e));
-
 
1496
		TYPE ps = DEREF_type(type_ptr_etc_sub(s));
-
 
1497
		TYPE pt = DEREF_type(type_ptr_etc_sub(t));
-
 
1498
		switch (TAG_type(pt)) {
-
 
1499
		case type_top_tag:
-
 
1500
		case type_bottom_tag: {
-
 
1501
			switch (TAG_type(ps)) {
-
 
1502
			case type_top_tag:
-
 
1503
			case type_bottom_tag: {
-
 
1504
				/* 'void *' to 'void *' */
-
 
1505
				bs = enc_exp(bs, e);
-
 
1506
				break;
-
 
1507
			}
-
 
1508
			case type_func_tag: {
-
 
1509
				/* Function to 'void *' */
-
 
1510
				bs = enc_special(bs, TOK_f_to_pv);
-
 
1511
				ts = start_bitstream(NIL(FILE), bs->link);
-
 
1512
				ts = enc_exp(ts, e);
-
 
1513
				bs = enc_bitstream(bs, ts);
-
 
1514
				break;
-
 
1515
			}
-
 
1516
			default: {
-
 
1517
				/* Object pointer to 'void *' */
-
 
1518
				conv = CONV_PTR_VOID;
-
 
1519
				goto pointer_void_label;
-
 
1520
			}
-
 
1521
			}
-
 
1522
			break;
-
 
1523
		}
-
 
1524
		case type_func_tag: {
-
 
1525
			switch (TAG_type(ps)) {
-
 
1526
			case type_top_tag:
-
 
1527
			case type_bottom_tag: {
-
 
1528
				/* 'void *' to function */
-
 
1529
				bs = enc_special(bs, TOK_pv_to_f);
-
 
1530
				ts = start_bitstream(NIL(FILE), bs->link);
-
 
1531
				ts = enc_exp(ts, e);
-
 
1532
				bs = enc_bitstream(bs, ts);
-
 
1533
				break;
-
 
1534
			}
-
 
1535
			case type_func_tag: {
-
 
1536
				/* Function to function */
-
 
1537
				bs = enc_exp(bs, e);
-
 
1538
				break;
-
 
1539
			}
-
 
1540
			default: {
-
 
1541
				/* Object pointer to function */
-
 
1542
				BITSTREAM *us;
-
 
1543
				bs = enc_special(bs, TOK_pv_to_f);
-
 
1544
				ts = start_bitstream(NIL(FILE), bs->link);
-
 
1545
				ts = enc_special(ts, TOK_to_ptr_void);
-
 
1546
				us = start_bitstream(NIL(FILE), ts->link);
-
 
1547
				us = enc_alignment(us, ps);
-
 
1548
				us = enc_exp(us, e);
-
 
1549
				ts = enc_bitstream(ts, us);
-
 
1550
				bs = enc_bitstream(bs, ts);
-
 
1551
				break;
-
 
1552
			}
-
 
1553
			}
-
 
1554
			break;
-
 
1555
		}
-
 
1556
		default: {
-
 
1557
			switch (TAG_type(ps)) {
-
 
1558
			case type_top_tag:
-
 
1559
			case type_bottom_tag: {
-
 
1560
				/* 'void *' to object pointer */
-
 
1561
				conv = (CONV_PTR_VOID | CONV_REVERSE);
-
 
1562
				goto pointer_void_label;
-
 
1563
			}
-
 
1564
			case type_func_tag: {
-
 
1565
				/* Function to object pointer */
-
 
1566
				BITSTREAM *us;
-
 
1567
				bs = enc_special(bs, TOK_from_ptr_void);
-
 
1568
				ts = start_bitstream(NIL(FILE), bs->link);
-
 
1569
				ts = enc_alignment(ts, pt);
-
 
1570
				ts = enc_special(ts, TOK_f_to_pv);
-
 
1571
				us = start_bitstream(NIL(FILE), ts->link);
-
 
1572
				us = enc_exp(us, e);
-
 
1573
				ts = enc_bitstream(ts, us);
-
 
1574
				bs = enc_bitstream(bs, ts);
-
 
1575
				break;
-
 
1576
			}
-
 
1577
			default: {
-
 
1578
				/* Object pointer to object pointer */
-
 
1579
				if (conv & CONV_REVERSE) {
-
 
1580
					/* Force conversion in these cases */
-
 
1581
					/* EMPTY */
-
 
1582
				} else {
-
 
1583
					if (eq_type_rep(ps, pt, 1)) {
-
 
1584
						bs = enc_exp(bs, e);
-
 
1585
						break;
-
 
1586
					}
-
 
1587
				}
-
 
1588
				bs = enc_special(bs, TOK_ptr_to_ptr);
-
 
1589
				ts = start_bitstream(NIL(FILE), bs->link);
-
 
1590
				ts = enc_alignment(ts, ps);
-
 
1591
				ts = enc_alignment(ts, pt);
-
 
1592
				ts = enc_exp(ts, e);
-
 
1593
				bs = enc_bitstream(bs, ts);
-
 
1594
				break;
-
 
1595
			}
-
 
1596
			}
-
 
1597
			break;
-
 
1598
		}
-
 
1599
		}
-
 
1600
		break;
-
 
1601
	}
-
 
1602
 
-
 
1603
	case CONV_INT_PTR: {
-
 
1604
		/* Integer to pointer conversion */
-
 
1605
		TYPE s = DEREF_type(exp_type(e));
-
 
1606
		TYPE pt = DEREF_type(type_ptr_etc_sub(t));
-
 
1607
		switch (TAG_type(pt)) {
-
 
1608
		case type_top_tag:
-
 
1609
		case type_bottom_tag: {
-
 
1610
			/* Integer to 'void *' */
-
 
1611
			bs = enc_special(bs, TOK_i_to_pv);
-
 
1612
			ts = start_bitstream(NIL(FILE), bs->link);
-
 
1613
			ts = enc_variety(ts, s);
-
 
1614
			ts = enc_exp(ts, e);
-
 
1615
			bs = enc_bitstream(bs, ts);
-
 
1616
			break;
-
 
1617
		}
-
 
1618
		case type_func_tag: {
-
 
1619
			/* Integer to function */
-
 
1620
			BITSTREAM *us;
-
 
1621
			bs = enc_special(bs, TOK_pv_to_f);
-
 
1622
			ts = start_bitstream(NIL(FILE), bs->link);
-
 
1623
			ts = enc_special(ts, TOK_i_to_pv);
-
 
1624
			us = start_bitstream(NIL(FILE), ts->link);
-
 
1625
			us = enc_variety(us, s);
-
 
1626
			us = enc_exp(us, e);
-
 
1627
			ts = enc_bitstream(ts, us);
-
 
1628
			bs = enc_bitstream(bs, ts);
-
 
1629
			break;
-
 
1630
		}
-
 
1631
		default: {
-
 
1632
			/* Integer to object pointer */
-
 
1633
			bs = enc_special(bs, TOK_i_to_p);
-
 
1634
			ts = start_bitstream(NIL(FILE), bs->link);
-
 
1635
			ts = enc_variety(ts, s);
-
 
1636
			ts = enc_alignment(ts, pt);
-
 
1637
			ts = enc_exp(ts, e);
-
 
1638
			bs = enc_bitstream(bs, ts);
-
 
1639
			break;
-
 
1640
		}
-
 
1641
		}
-
 
1642
		break;
-
 
1643
	}
-
 
1644
 
-
 
1645
	case CONV_PTR_INT: {
-
 
1646
		/* Pointer to integer conversion */
-
 
1647
		TYPE s = DEREF_type(exp_type(e));
-
 
1648
		TYPE ps = DEREF_type(type_ptr_etc_sub(s));
-
 
1649
		switch (TAG_type(ps)) {
-
 
1650
		case type_top_tag:
-
 
1651
		case type_bottom_tag: {
-
 
1652
			/* 'void *' to integer */
-
 
1653
			bs = enc_special(bs, TOK_pv_to_i);
-
 
1654
			ts = start_bitstream(NIL(FILE), bs->link);
-
 
1655
			ts = enc_variety(ts, t);
-
 
1656
			ts = enc_exp(ts, e);
-
 
1657
			bs = enc_bitstream(bs, ts);
-
 
1658
			break;
-
 
1659
		}
-
 
1660
		case type_func_tag: {
-
 
1661
			/* Function to integer */
-
 
1662
			BITSTREAM *us;
-
 
1663
			bs = enc_special(bs, TOK_pv_to_i);
-
 
1664
			ts = start_bitstream(NIL(FILE), bs->link);
-
 
1665
			ts = enc_variety(ts, t);
-
 
1666
			ts = enc_special(ts, TOK_f_to_pv);
-
 
1667
			us = start_bitstream(NIL(FILE), ts->link);
-
 
1668
			us = enc_exp(us, e);
-
 
1669
			ts = enc_bitstream(ts, us);
-
 
1670
			bs = enc_bitstream(bs, ts);
-
 
1671
			break;
-
 
1672
		}
-
 
1673
		default: {
-
 
1674
			/* Object pointer to integer */
-
 
1675
			bs = enc_special(bs, TOK_p_to_i);
-
 
1676
			ts = start_bitstream(NIL(FILE), bs->link);
-
 
1677
			ts = enc_alignment(ts, ps);
-
 
1678
			ts = enc_variety(ts, t);
-
 
1679
			ts = enc_exp(ts, e);
-
 
1680
			bs = enc_bitstream(bs, ts);
-
 
1681
			break;
-
 
1682
		}
-
 
1683
		}
-
 
1684
		break;
-
 
1685
	}
-
 
1686
 
-
 
1687
	case CONV_NULL: {
-
 
1688
		/* Null pointer conversion */
-
 
1689
		bs = enc_null_exp(bs, t);
-
 
1690
		break;
-
 
1691
	}
-
 
1692
 
-
 
1693
	case CONV_PTR_MEM_FUNC: {
-
 
1694
		/* Pointer to member function to function conversion */
-
 
1695
		IDENTIFIER fn = is_const_ptr_mem(e, 1);
-
 
1696
		if (!IS_NULL_id(fn)) {
-
 
1697
			/* Constant function */
-
 
1698
			ulong n = unit_no(bs, fn, VAR_tag, 0);
-
 
1699
			ENC_obtain_tag(bs);
-
 
1700
			ENC_make_tag(bs, n);
-
 
1701
		} else {
-
 
1702
			/* Non-constant function */
-
 
1703
			ulong n = LINK_NONE;
-
 
1704
			bs = make_ptr_mem_func(bs, e, &n, 0);
-
 
1705
			bs = enc_special(bs, TOK_pmf_func);
-
 
1706
			ts = start_bitstream(NIL(FILE), bs->link);
-
 
1707
			ENC_obtain_tag(ts);
-
 
1708
			ENC_make_tag(ts, n);
-
 
1709
			bs = enc_bitstream(bs, ts);
-
 
1710
		}
-
 
1711
		break;
-
 
1712
	}
-
 
1713
 
1688
	default : {
1714
	default: {
1689
	    /* Other conversions */
1715
		/* Other conversions */
1690
	    TYPE s = DEREF_type ( exp_type ( e ) ) ;
1716
		TYPE s = DEREF_type(exp_type(e));
1691
	    if ( eq_type_rep ( s, t, 0 ) ) {
1717
		if (eq_type_rep(s, t, 0)) {
1692
		bs = enc_exp ( bs, e ) ;
1718
			bs = enc_exp(bs, e);
1693
	    } else {
1719
		} else {
1694
		ENC_component ( bs ) ;
1720
			ENC_component(bs);
1695
		bs = enc_shape ( bs, t ) ;
1721
			bs = enc_shape(bs, t);
1696
		ENC_make_compound ( bs ) ;
1722
			ENC_make_compound(bs);
1697
		ENC_offset_max ( bs ) ;
1723
			ENC_offset_max(bs);
1698
		ENC_shape_offset ( bs ) ;
1724
			ENC_shape_offset(bs);
1699
		bs = enc_shape ( bs, s ) ;
1725
			bs = enc_shape(bs, s);
1700
		ENC_shape_offset ( bs ) ;
1726
			ENC_shape_offset(bs);
1701
		bs = enc_shape ( bs, t ) ;
1727
			bs = enc_shape(bs, t);
1702
		ENC_LIST_SMALL ( bs, 2 ) ;
1728
			ENC_LIST_SMALL(bs, 2);
1703
		ENC_offset_zero ( bs ) ;
1729
			ENC_offset_zero(bs);
1704
		bs = enc_alignment ( bs, s ) ;
1730
			bs = enc_alignment(bs, s);
1705
		bs = enc_exp ( bs, e ) ;
1731
			bs = enc_exp(bs, e);
1706
		ENC_offset_zero ( bs ) ;
1732
			ENC_offset_zero(bs);
1707
		bs = enc_alignment ( bs, t ) ;
1733
			bs = enc_alignment(bs, t);
1708
	    }
1734
		}
1709
	    break ;
1735
		break;
-
 
1736
	}
1710
	}
1737
	}
1711
    }
-
 
1712
    return ( bs ) ;
1738
	return (bs);
1713
}
1739
}
1714
 
1740
 
1715
 
1741
 
1716
/*
1742
/*
1717
    ENCODE A BASE CLASS CONVERSION
1743
    ENCODE A BASE CLASS CONVERSION
1718
 
1744
 
1719
    This routine adds the base class conversion of e using the base
1745
    This routine adds the base class conversion of e using the base
1720
    offset off to the bitstream bs.  conv represents the conversion type.
1746
    offset off to the bitstream bs.  conv represents the conversion type.
1878
    ENCODE A TDF ERROR TREATMENT
1906
    ENCODE A TDF ERROR TREATMENT
1879
 
1907
 
1880
    This routine adds an error treatment corresponding to arithmetic
1908
    This routine adds an error treatment corresponding to arithmetic
1881
    operations on the arithmetic type t to the bitstream bs.
1909
    operations on the arithmetic type t to the bitstream bs.
1882
*/
1910
*/
1883
 
1911
 
1884
BITSTREAM *enc_error_treatment
1912
BITSTREAM *
1885
    PROTO_N ( ( bs, t ) )
-
 
1886
    PROTO_T ( BITSTREAM *bs X TYPE t )
1913
enc_error_treatment(BITSTREAM *bs, TYPE t)
1887
{
1914
{
1888
    if ( IS_type_floating ( t ) || check_int_type ( t, btype_signed ) ) {
1915
	if (IS_type_floating(t) || check_int_type(t, btype_signed)) {
1889
	ENC_impossible ( bs ) ;
1916
		ENC_impossible(bs);
1890
    } else {
1917
	} else {
1891
	ENC_wrap ( bs ) ;
1918
		ENC_wrap(bs);
1892
    }
1919
	}
1893
    return ( bs ) ;
1920
	return (bs);
1894
}
1921
}
1895
 
1922
 
1896
 
1923
 
1897
/*
1924
/*
1898
    ENCODE A LIST OF VIRTUAL FUNCTION ARGUMENTS
1925
    ENCODE A LIST OF VIRTUAL FUNCTION ARGUMENTS
1899
 
1926
 
1900
    This routine adds the list of virtual function arguments p to the
1927
    This routine adds the list of virtual function arguments p to the
1901
    bitstream bs.  m is a tag number giving a pointer into the virtual
1928
    bitstream bs.  m is a tag number giving a pointer into the virtual
1902
    function table and j gives the number of the argument corresponding
1929
    function table and j gives the number of the argument corresponding
1903
    to the object pointer.
1930
    to the object pointer.
1904
*/
1931
*/
1905
 
1932
 
1906
static BITSTREAM *enc_virt_args
1933
static BITSTREAM *
1907
    PROTO_N ( ( bs, p, m, j ) )
-
 
1908
    PROTO_T ( BITSTREAM *bs X LIST ( EXP ) p X ulong m X unsigned j )
1934
enc_virt_args(BITSTREAM *bs, LIST(EXP)p, ulong m, unsigned j)
1909
{
1935
{
1910
    unsigned i ;
1936
	unsigned i;
1911
    unsigned n = LENGTH_list ( p ) ;
1937
	unsigned n = LENGTH_list(p);
1912
    ENC_LIST ( bs, n ) ;
1938
	ENC_LIST(bs, n);
1913
    for ( i = 0 ; i < n ; i++ ) {
1939
	for (i = 0; i < n; i++) {
1914
	EXP e = DEREF_exp ( HEAD_list ( p ) ) ;
1940
		EXP e = DEREF_exp(HEAD_list(p));
1915
	if ( i == j ) {
1941
		if (i == j) {
1916
	    TYPE t ;
1942
			TYPE t;
1917
	    BITSTREAM *ts ;
1943
			BITSTREAM *ts;
1918
	    ENC_add_to_ptr ( bs ) ;
1944
			ENC_add_to_ptr(bs);
1919
	    bs = enc_exp ( bs, e ) ;
1945
			bs = enc_exp(bs, e);
1920
	    bs = enc_special ( bs, TOK_pmf_delta ) ;
1946
			bs = enc_special(bs, TOK_pmf_delta);
1921
	    ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
1947
			ts = start_bitstream(NIL(FILE), bs->link);
1922
	    t = DEREF_type ( exp_type ( e ) ) ;
1948
			t = DEREF_type(exp_type(e));
1923
	    if ( IS_type_ptr_etc ( t ) ) {
1949
			if (IS_type_ptr_etc(t)) {
1924
		t = DEREF_type ( type_ptr_etc_sub ( t ) ) ;
1950
				t = DEREF_type(type_ptr_etc_sub(t));
1925
	    }
1951
			}
1926
	    ts = enc_alignment ( ts, t ) ;
1952
			ts = enc_alignment(ts, t);
1927
	    ENC_obtain_tag ( ts ) ;
1953
			ENC_obtain_tag(ts);
1928
	    ENC_make_tag ( ts, m ) ;
1954
			ENC_make_tag(ts, m);
1929
	    bs = enc_bitstream ( bs, ts ) ;
1955
			bs = enc_bitstream(bs, ts);
1930
	} else {
1956
		} else {
1931
	    bs = enc_exp ( bs, e ) ;
1957
			bs = enc_exp(bs, e);
1932
	}
1958
		}
1933
	p = TAIL_list ( p ) ;
1959
		p = TAIL_list(p);
1934
    }
1960
	}
1935
    return ( bs ) ;
1961
	return (bs);
1936
}
1962
}
1937
 
1963
 
1938
 
1964
 
1939
/*
1965
/*
1940
    ENCODE A NAMED FUNCTION CALL
1966
    ENCODE A NAMED FUNCTION CALL
1941
 
1967
 
1942
    This routine outputs an apply_proc construct for the identifier
1968
    This routine outputs an apply_proc construct for the identifier
1943
    function call given by e to the bitstream bs.  t gives the return
1969
    function call given by e to the bitstream bs.  t gives the return
1944
    type.
1970
    type.
1945
*/
1971
*/
1946
 
1972
 
1947
static BITSTREAM *enc_func_id_call
1973
static BITSTREAM *
1948
    PROTO_N ( ( bs, t, e ) )
-
 
1949
    PROTO_T ( BITSTREAM *bs X TYPE t X EXP e )
1974
enc_func_id_call(BITSTREAM *bs, TYPE t, EXP e)
1950
{
1975
{
1951
    IDENTIFIER id = DEREF_id ( exp_func_id_id ( e ) ) ;
1976
	IDENTIFIER id = DEREF_id(exp_func_id_id(e));
1952
    LIST ( EXP ) args = DEREF_list ( exp_func_id_args ( e ) ) ;
1977
	LIST(EXP)args = DEREF_list(exp_func_id_args(e));
1953
    EXP virt = DEREF_exp ( exp_func_id_virt ( e ) ) ;
1978
	EXP virt = DEREF_exp(exp_func_id_virt(e));
1954
 
-
 
1955
    /* Check for static member functions */
-
 
1956
    unsigned tag = TAG_id ( id ) ;
-
 
1957
    if ( tag == id_stat_mem_func_tag ) {
-
 
1958
	EXP a = DEREF_exp ( HEAD_list ( args ) ) ;
-
 
1959
	if ( !IS_NULL_exp ( a ) ) {
-
 
1960
	    ENC_SEQ_SMALL ( bs, 1 ) ;
-
 
1961
	    bs = enc_exp ( bs, a ) ;
-
 
1962
	}
-
 
1963
	args = TAIL_list ( args ) ;
-
 
1964
    }
-
 
1965
 
1979
 
1966
    /* Output the procedure application */
1980
	/* Check for static member functions */
1967
    if ( tag == id_token_tag ) {
1981
	unsigned tag = TAG_id(id);
1968
	/* Function token */
-
 
1969
	ulong n ;
-
 
1970
	IGNORE enc_tokdef ( id, 0 ) ;
1982
	if (tag == id_stat_mem_func_tag) {
1971
	ENC_exp_apply_token ( bs ) ;
-
 
1972
	n = unit_no ( bs, id, VAR_token, 0 ) ;
1983
		EXP a = DEREF_exp(HEAD_list(args));
1973
	ENC_make_tok ( bs, n ) ;
-
 
1974
	if ( IS_NULL_list ( args ) ) {
1984
		if (!IS_NULL_exp(a)) {
1975
	    ENC_LEN_SMALL ( bs, 0 ) ;
1985
			ENC_SEQ_SMALL(bs, 1);
1976
	} else {
-
 
1977
	    BITSTREAM *ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
-
 
1978
	    while ( !IS_NULL_list ( args ) ) {
-
 
1979
		EXP a = DEREF_exp ( HEAD_list ( args ) ) ;
-
 
1980
		ts = enc_exp ( ts, a ) ;
1986
			bs = enc_exp(bs, a);
1981
		args = TAIL_list ( args ) ;
-
 
1982
	    }
1987
		}
1983
	    bs = enc_bitstream ( bs, ts ) ;
1988
		args = TAIL_list(args);
1984
	}
1989
	}
1985
 
1990
 
-
 
1991
	/* Output the procedure application */
-
 
1992
	if (tag == id_token_tag) {
-
 
1993
		/* Function token */
-
 
1994
		ulong n;
-
 
1995
		IGNORE enc_tokdef(id, 0);
-
 
1996
		ENC_exp_apply_token(bs);
-
 
1997
		n = unit_no(bs, id, VAR_token, 0);
-
 
1998
		ENC_make_tok(bs, n);
-
 
1999
		if (IS_NULL_list(args)) {
-
 
2000
			ENC_LEN_SMALL(bs, 0);
-
 
2001
		} else {
-
 
2002
			BITSTREAM *ts = start_bitstream(NIL(FILE), bs->link);
-
 
2003
			while (!IS_NULL_list(args)) {
-
 
2004
				EXP a = DEREF_exp(HEAD_list(args));
-
 
2005
				ts = enc_exp(ts, a);
-
 
2006
				args = TAIL_list(args);
-
 
2007
			}
-
 
2008
			bs = enc_bitstream(bs, ts);
-
 
2009
		}
-
 
2010
 
1986
    } else if ( !IS_NULL_exp ( virt ) ) {
2011
	} else if (!IS_NULL_exp(virt)) {
1987
	/* Virtual function */
2012
		/* Virtual function */
1988
	EXP a ;
2013
		EXP a;
1989
	ulong tok ;
2014
		ulong tok;
1990
	VIRTUAL vt ;
2015
		VIRTUAL vt;
1991
	unsigned i ;
2016
		unsigned i;
1992
	OFFSET off ;
2017
		OFFSET off;
1993
	BITSTREAM *ts ;
2018
		BITSTREAM *ts;
1994
	ulong n, m, p ;
2019
		ulong n, m, p;
1995
 
2020
 
1996
	/* Find class information */
2021
		/* Find class information */
1997
	CLASS_TYPE ct = parent_class ( id ) ;
2022
		CLASS_TYPE ct = parent_class(id);
1998
	IGNORE compile_class ( ct ) ;
2023
		IGNORE compile_class(ct);
1999
	vt = DEREF_virt ( ctype_virt ( ct ) ) ;
2024
		vt = DEREF_virt(ctype_virt(ct));
2000
	off = DEREF_off ( virt_table_off ( vt ) ) ;
2025
		off = DEREF_off(virt_table_off(vt));
2001
	tok = DEREF_ulong ( virt_table_tok ( vt ) ) ;
2026
		tok = DEREF_ulong(virt_table_tok(vt));
2002
	m = virtual_no ( id, vt ) ;
2027
		m = virtual_no(id, vt);
2003
 
2028
 
2004
	/* Introduce variable for argument */
2029
		/* Introduce variable for argument */
2005
	a = DEREF_exp ( exp_dummy_value ( virt ) ) ;
2030
		a = DEREF_exp(exp_dummy_value(virt));
2006
	bs = make_ptr_mem_func ( bs, a, &n, 0 ) ;
2031
		bs = make_ptr_mem_func(bs, a, &n, 0);
2007
	COPY_exp ( exp_dummy_value ( virt ), NULL_exp ) ;
2032
		COPY_exp(exp_dummy_value(virt), NULL_exp);
2008
	COPY_ulong ( exp_dummy_no ( virt ), n ) ;
2033
		COPY_ulong(exp_dummy_no(virt), n);
2009
 
2034
 
2010
	/* Find pointer to member function */
2035
		/* Find pointer to member function */
2011
	p = unit_no ( bs, NULL_id, VAR_tag, 1 ) ;
2036
		p = unit_no(bs, NULL_id, VAR_tag, 1);
2012
	ENC_identify ( bs ) ;
2037
		ENC_identify(bs);
2013
	bs = enc_access ( bs, dspec_none ) ;
2038
		bs = enc_access(bs, dspec_none);
2014
	ENC_make_tag ( bs, p ) ;
2039
		ENC_make_tag(bs, p);
2015
	bs = enc_special ( bs, TOK_vtab_func ) ;
2040
		bs = enc_special(bs, TOK_vtab_func);
2016
	ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
2041
		ts = start_bitstream(NIL(FILE), bs->link);
2017
	ENC_add_to_ptr ( ts ) ;
2042
		ENC_add_to_ptr(ts);
2018
	ts = enc_add_ptr ( ts, virt, LINK_NONE, off, 0 ) ;
2043
		ts = enc_add_ptr(ts, virt, LINK_NONE, off, 0);
2019
	tok = link_no ( ts, tok, VAR_token ) ;
2044
		tok = link_no(ts, tok, VAR_token);
2020
	ENC_exp_apply_token ( ts ) ;
2045
		ENC_exp_apply_token(ts);
2021
	ENC_make_tok ( ts, tok ) ;
2046
		ENC_make_tok(ts, tok);
2022
	ENC_LEN_SMALL ( ts, 0 ) ;
2047
		ENC_LEN_SMALL(ts, 0);
2023
	ts = enc_make_snat ( ts, ( int ) m ) ;
2048
		ts = enc_make_snat(ts,(int)m);
2024
	bs = enc_bitstream ( bs, ts ) ;
2049
		bs = enc_bitstream(bs, ts);
2025
 
2050
 
2026
	/* Encode function call */
2051
		/* Encode function call */
2027
	ENC_apply_proc ( bs ) ;
2052
		ENC_apply_proc(bs);
2028
	bs = enc_shape ( bs, t ) ;
2053
		bs = enc_shape(bs, t);
2029
	bs = enc_special ( bs, TOK_pmf_func ) ;
2054
		bs = enc_special(bs, TOK_pmf_func);
2030
	ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
2055
		ts = start_bitstream(NIL(FILE), bs->link);
2031
	ENC_obtain_tag ( ts ) ;
2056
		ENC_obtain_tag(ts);
2032
	ENC_make_tag ( ts, p ) ;
2057
		ENC_make_tag(ts, p);
2033
	bs = enc_bitstream ( bs, ts ) ;
2058
		bs = enc_bitstream(bs, ts);
2034
	i = DEREF_unsigned ( exp_func_id_extra ( e ) ) ;
2059
		i = DEREF_unsigned(exp_func_id_extra(e));
2035
	bs = enc_virt_args ( bs, args, p, i ) ;
2060
		bs = enc_virt_args(bs, args, p, i);
2036
	ENC_OFF ( bs ) ;
2061
		ENC_OFF(bs);
2037
	COPY_exp ( exp_dummy_value ( virt ), a ) ;
2062
		COPY_exp(exp_dummy_value(virt), a);
2038
 
2063
 
2039
    } else {
2064
	} else {
2040
	/* Simple function */
2065
		/* Simple function */
2041
	ulong n ;
2066
		ulong n;
2042
	DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
2067
		DECL_SPEC ds = DEREF_dspec(id_storage(id));
2043
	if ( ( ds & dspec_inline ) && !( ds & dspec_temp ) ) {
2068
		if ((ds & dspec_inline) && !(ds & dspec_temp)) {
2044
	    /* Check for function inlining */
2069
			/* Check for function inlining */
2045
	    if ( output_inline ) {
2070
			if (output_inline) {
2046
		EXP a = check_inline ( id, args, t ) ;
2071
				EXP a = check_inline(id, args, t);
2047
		if ( !IS_NULL_exp ( a ) ) {
2072
				if (!IS_NULL_exp(a)) {
2048
		    COPY_dspec ( id_storage ( id ), ( ds | dspec_temp ) ) ;
2073
					COPY_dspec(id_storage(id),
-
 
2074
						   (ds | dspec_temp));
2049
		    bs = enc_exp ( bs, a ) ;
2075
					bs = enc_exp(bs, a);
2050
		    free_exp ( a, 1 ) ;
2076
					free_exp(a, 1);
2051
		    COPY_dspec ( id_storage ( id ), ds ) ;
2077
					COPY_dspec(id_storage(id), ds);
2052
		    return ( bs ) ;
2078
					return (bs);
-
 
2079
				}
-
 
2080
			}
2053
		}
2081
		}
-
 
2082
		ENC_apply_proc(bs);
-
 
2083
		bs = enc_shape(bs, t);
-
 
2084
		IGNORE capsule_id(id, VAR_tag);
-
 
2085
		n = unit_no(bs, id, VAR_tag, 0);
-
 
2086
		ENC_obtain_tag(bs);
-
 
2087
		ENC_make_tag(bs, n);
-
 
2088
		bs = enc_exp_list(bs, args);
2054
	    }
2089
		ENC_OFF(bs);
2055
	}
2090
	}
2056
	ENC_apply_proc ( bs ) ;
-
 
2057
	bs = enc_shape ( bs, t ) ;
-
 
2058
	IGNORE capsule_id ( id, VAR_tag ) ;
-
 
2059
	n = unit_no ( bs, id, VAR_tag, 0 ) ;
-
 
2060
	ENC_obtain_tag ( bs ) ;
-
 
2061
	ENC_make_tag ( bs, n ) ;
-
 
2062
	bs = enc_exp_list ( bs, args ) ;
-
 
2063
	ENC_OFF ( bs ) ;
-
 
2064
    }
-
 
2065
    return ( bs ) ;
2091
	return (bs);
2066
}
2092
}
2067
 
2093
 
2068
 
2094
 
2069
/*
2095
/*
2070
    ENCODE A FUNCTION CALL
2096
    ENCODE A FUNCTION CALL
2071
 
2097
 
2072
    This routine outputs an apply_proc construct for the expression
2098
    This routine outputs an apply_proc construct for the expression
2073
    function call given by e to the bitstream bs.  t gives the return
2099
    function call given by e to the bitstream bs.  t gives the return
2074
    type.
2100
    type.
2075
*/
2101
*/
2076
 
2102
 
2077
static BITSTREAM *enc_func_call
2103
static BITSTREAM *
2078
    PROTO_N ( ( bs, t, e ) )
-
 
2079
    PROTO_T ( BITSTREAM *bs X TYPE t X EXP e )
2104
enc_func_call(BITSTREAM *bs, TYPE t, EXP e)
2080
{
2105
{
2081
    EXP a = DEREF_exp ( exp_func_fn ( e ) ) ;
2106
	EXP a = DEREF_exp(exp_func_fn(e));
2082
    LIST ( EXP ) args = DEREF_list ( exp_func_args ( e ) ) ;
2107
	LIST(EXP)args = DEREF_list(exp_func_args(e));
2083
    if ( IS_exp_call ( a ) ) {
2108
	if (IS_exp_call(a)) {
2084
	/* Pointer to member function call */
2109
		/* Pointer to member function call */
2085
	EXP b ;
2110
		EXP b;
2086
	EXP b1 ;
2111
		EXP b1;
2087
	TYPE s ;
2112
		TYPE s;
2088
	ulong n ;
2113
		ulong n;
2089
	unsigned i ;
2114
		unsigned i;
2090
	BITSTREAM *ts ;
2115
		BITSTREAM *ts;
2091
	CLASS_TYPE ct ;
2116
		CLASS_TYPE ct;
2092
	ulong m = LINK_NONE ;
2117
		ulong m = LINK_NONE;
2093
 
2118
 
2094
	/* Decompose pointer to member */
2119
		/* Decompose pointer to member */
2095
	b = DEREF_exp ( exp_call_arg ( a ) ) ;
2120
		b = DEREF_exp(exp_call_arg(a));
2096
	b1 = DEREF_exp ( exp_dummy_value ( b ) ) ;
2121
		b1 = DEREF_exp(exp_dummy_value(b));
2097
	a = DEREF_exp ( exp_call_ptr ( a ) ) ;
2122
		a = DEREF_exp(exp_call_ptr(a));
2098
	s = DEREF_type ( exp_type ( a ) ) ;
2123
		s = DEREF_type(exp_type(a));
2099
	ct = DEREF_ctype ( type_ptr_mem_of ( s ) ) ;
2124
		ct = DEREF_ctype(type_ptr_mem_of(s));
2100
 
2125
 
2101
	/* Introduce variable for argument */
2126
		/* Introduce variable for argument */
2102
	bs = make_ptr_mem_func ( bs, b1, &m, 0 ) ;
2127
		bs = make_ptr_mem_func(bs, b1, &m, 0);
2103
	COPY_exp ( exp_dummy_value ( b ), NULL_exp ) ;
2128
		COPY_exp(exp_dummy_value(b), NULL_exp);
2104
	COPY_ulong ( exp_dummy_no ( b ), m ) ;
2129
		COPY_ulong(exp_dummy_no(b), m);
2105
	IGNORE compile_class ( ct ) ;
2130
		IGNORE compile_class(ct);
2106
 
2131
 
2107
	/* Allow for virtual functions */
2132
		/* Allow for virtual functions */
2108
	bs = make_ptr_mem_func ( bs, a, &n, 1 ) ;
2133
		bs = make_ptr_mem_func(bs, a, &n, 1);
2109
	ENC_SEQ_SMALL ( bs, 1 ) ;
2134
		ENC_SEQ_SMALL(bs, 1);
2110
	bs = enc_special ( bs, TOK_pmf_virt ) ;
2135
		bs = enc_special(bs, TOK_pmf_virt);
2111
	ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
2136
		ts = start_bitstream(NIL(FILE), bs->link);
2112
	ENC_obtain_tag ( ts ) ;
2137
		ENC_obtain_tag(ts);
2113
	ENC_make_tag ( ts, n ) ;
2138
		ENC_make_tag(ts, n);
2114
	ts = enc_exp ( ts, b ) ;
2139
		ts = enc_exp(ts, b);
2115
	ts = enc_al_ctype ( ts, ct ) ;
2140
		ts = enc_al_ctype(ts, ct);
2116
	bs = enc_bitstream ( bs, ts ) ;
2141
		bs = enc_bitstream(bs, ts);
2117
 
2142
 
2118
	/* Encode call */
2143
		/* Encode call */
2119
	ENC_apply_proc ( bs ) ;
2144
		ENC_apply_proc(bs);
2120
	bs = enc_shape ( bs, t ) ;
2145
		bs = enc_shape(bs, t);
2121
	bs = enc_special ( bs, TOK_pmf_func ) ;
2146
		bs = enc_special(bs, TOK_pmf_func);
2122
	ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
2147
		ts = start_bitstream(NIL(FILE), bs->link);
2123
	ENC_obtain_tag ( ts ) ;
2148
		ENC_obtain_tag(ts);
2124
	ENC_make_tag ( ts, n ) ;
2149
		ENC_make_tag(ts, n);
2125
	bs = enc_bitstream ( bs, ts ) ;
2150
		bs = enc_bitstream(bs, ts);
2126
	i = DEREF_unsigned ( exp_func_extra ( e ) ) ;
2151
		i = DEREF_unsigned(exp_func_extra(e));
2127
	bs = enc_virt_args ( bs, args, n, i ) ;
2152
		bs = enc_virt_args(bs, args, n, i);
2128
	ENC_OFF ( bs ) ;
2153
		ENC_OFF(bs);
2129
	COPY_exp ( exp_dummy_value ( b ), b1 ) ;
2154
		COPY_exp(exp_dummy_value(b), b1);
2130
 
-
 
2131
    } else {
2155
	} else {
2132
	/* Simple function call */
2156
		/* Simple function call */
2133
	ENC_apply_proc ( bs ) ;
2157
		ENC_apply_proc(bs);
2134
	bs = enc_shape ( bs, t ) ;
2158
		bs = enc_shape(bs, t);
2135
	bs = enc_exp ( bs, a ) ;
2159
		bs = enc_exp(bs, a);
2136
	bs = enc_exp_list ( bs, args ) ;
2160
		bs = enc_exp_list(bs, args);
2137
	ENC_OFF ( bs ) ;
2161
		ENC_OFF(bs);
2138
    }
2162
	}
2139
    return ( bs ) ;
2163
	return (bs);
2140
}
2164
}
2141
 
2165
 
2142
 
2166
 
2143
/*
2167
/*
2144
    ENCODE A DUMMY EXPRESSION
2168
    ENCODE A DUMMY EXPRESSION
2145
 
2169
 
2146
    This routine adds the dummy expression given by the tag n plus the
2170
    This routine adds the dummy expression given by the tag n plus the
2147
    offset off to the bitstream bs.  cnt gives the expression type.
2171
    offset off to the bitstream bs.  cnt gives the expression type.
2148
*/
2172
*/
2149
 
2173
 
2150
BITSTREAM *enc_dummy_exp
2174
BITSTREAM *
2151
    PROTO_N ( ( bs, t, n, off, cnt, virt ) )
-
 
2152
    PROTO_T ( BITSTREAM *bs X TYPE t X ulong n X OFFSET off X
2175
enc_dummy_exp(BITSTREAM *bs, TYPE t, ulong n, OFFSET off, int cnt, int virt)
2153
	      int cnt X int virt )
-
 
2154
{
2176
{
2155
    int bf = 0 ;
2177
	int bf = 0;
2156
    OFFSET off1 = NULL_off ;
2178
	OFFSET off1 = NULL_off;
2157
    if ( cnt > 2 ) {
2179
	if (cnt > 2) {
2158
	/* Special tag */
2180
		/* Special tag */
2159
	n = last_params [ cnt ] ;
2181
		n = last_params[cnt];
2160
	cnt = last_conts [ cnt ] ;
2182
		cnt = last_conts[cnt];
2161
    }
2183
	}
2162
    if ( n == LINK_NONE ) {
2184
	if (n == LINK_NONE) {
2163
	/* This shouldn't happen */
2185
		/* This shouldn't happen */
2164
	n = capsule_no ( NULL_string, VAR_tag ) ;
2186
		n = capsule_no(NULL_string, VAR_tag);
2165
    }
2187
	}
2166
    if ( n & LINK_EXTERN ) {
2188
	if (n & LINK_EXTERN) {
2167
	/* Allow for global tags */
2189
		/* Allow for global tags */
2168
	n = link_no ( bs, n, VAR_tag ) ;
2190
		n = link_no(bs, n, VAR_tag);
2169
    }
-
 
2170
    if ( cnt == 1 ) {
-
 
2171
	/* Contents */
-
 
2172
	bs = enc_cont_op ( bs, t, &bf ) ;
-
 
2173
	if ( bf ) {
-
 
2174
	    off1 = decons_bitf_off ( &off ) ;
-
 
2175
	    bs = enc_bfvar ( bs, t ) ;
-
 
2176
	} else {
-
 
2177
	    bs = enc_shape ( bs, t ) ;
-
 
2178
	}
2191
	}
2179
    } else if ( cnt == 2 ) {
2192
	if (cnt == 1) {
2180
	/* Contents of pointer */
2193
		/* Contents */
2181
	ENC_contents ( bs ) ;
-
 
2182
	ENC_pointer ( bs ) ;
-
 
2183
	bs = enc_alignment ( bs, t ) ;
2194
		bs = enc_cont_op(bs, t, &bf);
2184
    }
2195
		if (bf) {
2185
    if ( is_zero_offset ( off ) ) {
2196
			off1 = decons_bitf_off(&off);
2186
	/* Zero offset */
-
 
2187
	ENC_obtain_tag ( bs ) ;
-
 
2188
	ENC_make_tag ( bs, n ) ;
2197
			bs = enc_bfvar(bs, t);
2189
    } else if ( virt ) {
-
 
2190
	/* Virtual base offset */
-
 
2191
	EXP e ;
-
 
2192
	MAKE_exp_dummy ( t, NULL_exp, n, NULL_off, 0, e ) ;
-
 
2193
	bs = enc_add_ptr ( bs, e, LINK_NONE, off, 1 ) ;
-
 
2194
	free_exp ( e, 1 ) ;
-
 
2195
    } else {
2198
		} else {
2196
	/* Non-virtual base offset */
-
 
2197
	ENC_add_to_ptr ( bs ) ;
-
 
2198
	ENC_obtain_tag ( bs ) ;
-
 
2199
	ENC_make_tag ( bs, n ) ;
-
 
2200
	bs = enc_offset ( bs, off ) ;
2199
			bs = enc_shape(bs, t);
2201
    }
2200
		}
2202
    if ( bf ) {
2201
	} else if (cnt == 2) {
2203
	/* End of bitfield contents */
2202
		/* Contents of pointer */
2204
	bs = enc_offset ( bs, off1 ) ;
2203
		ENC_contents(bs);
2205
    }
-
 
2206
    return ( bs ) ;
2204
		ENC_pointer(bs);
2207
}
-
 
2208
 
-
 
2209
 
-
 
2210
/*
-
 
2211
    ENCODE AN ASSIGNMENT EXPRESSION
-
 
2212
 
-
 
2213
    This routine adds the assignment or initialisation expression 'a = b'
-
 
2214
    to the bitstream bs.
-
 
2215
*/
-
 
2216
 
-
 
2217
static BITSTREAM *enc_assign_exp
-
 
2218
    PROTO_N ( ( bs, a, b ) )
-
 
2219
    PROTO_T ( BITSTREAM *bs X EXP a X EXP b )
-
 
2220
{
-
 
2221
    TYPE s = DEREF_type ( exp_type ( a ) ) ;
-
 
2222
    if ( IS_exp_dummy ( a ) ) {
-
 
2223
	/* Check for dummy expressions */
-
 
2224
	EXP c = DEREF_exp ( exp_dummy_value ( a ) ) ;
-
 
2225
	if ( IS_NULL_exp ( c ) ) {
-
 
2226
	    ulong n = DEREF_ulong ( exp_dummy_no ( a ) ) ;
-
 
2227
	    OFFSET off = DEREF_off ( exp_dummy_off ( a ) ) ;
-
 
2228
	    int cnt = DEREF_int ( exp_dummy_cont ( a ) ) ;
-
 
2229
	    bs = enc_init_tag ( bs, n, off, cnt, s, b, NULL_exp, 0 ) ;
-
 
2230
	    return ( bs ) ;
2205
		bs = enc_alignment(bs, t);
2231
	}
2206
	}
2232
    }
-
 
2233
    if ( is_init_complex ( b ) ) {
2207
	if (is_zero_offset(off)) {
2234
	/* Introduce identity for complex assignment */
2208
		/* Zero offset */
2235
	ulong n ;
2209
		ENC_obtain_tag(bs);
2236
	bs = make_identity ( bs, a, &n, 0, 0 ) ;
2210
		ENC_make_tag(bs, n);
2237
	bs = enc_init_tag ( bs, n, NULL_off, 0, s, b, NULL_exp, 0 ) ;
-
 
2238
    } else {
2211
	} else if (virt) {
2239
	/* Simple assignment */
2212
		/* Virtual base offset */
2240
	int bf = 0 ;
2213
		EXP e;
2241
	bs = enc_assign_op ( bs, s, &bf ) ;
2214
		MAKE_exp_dummy(t, NULL_exp, n, NULL_off, 0, e);
2242
	if ( bf ) {
-
 
2243
	    /* Bitfield assignment */
-
 
2244
	    OFFSET off = decons_bitf_exp ( &a ) ;
-
 
2245
	    bs = enc_addr_exp ( bs, s, a ) ;
2215
		bs = enc_add_ptr(bs, e, LINK_NONE, off, 1);
2246
	    bs = enc_offset ( bs, off ) ;
2216
		free_exp(e, 1);
2247
	} else {
2217
	} else {
-
 
2218
		/* Non-virtual base offset */
-
 
2219
		ENC_add_to_ptr(bs);
-
 
2220
		ENC_obtain_tag(bs);
-
 
2221
		ENC_make_tag(bs, n);
-
 
2222
		bs = enc_offset(bs, off);
-
 
2223
	}
-
 
2224
	if (bf) {
2248
	    /* Non-bitfield assignment */
2225
		/* End of bitfield contents */
2249
	    bs = enc_addr_exp ( bs, s, a ) ;
2226
		bs = enc_offset(bs, off1);
2250
	}
2227
	}
2251
	bs = enc_exp ( bs, b ) ;
-
 
2252
    }
-
 
2253
    return ( bs ) ;
2228
	return (bs);
2254
}
2229
}
2255
 
2230
 
2256
 
2231
 
2257
/*
2232
/*
2258
    ENCODE A TDF EXP
2233
    ENCODE AN ASSIGNMENT EXPRESSION
2259
 
2234
 
2260
    This routine adds the expression e to the bitstream bs as a TDF EXP.
2235
    This routine adds the assignment or initialisation expression 'a = b'
-
 
2236
    to the bitstream bs.
2261
*/
2237
*/
2262
 
2238
 
2263
BITSTREAM *enc_exp
2239
static BITSTREAM *
2264
    PROTO_N ( ( bs, e ) )
-
 
2265
    PROTO_T ( BITSTREAM *bs X EXP e )
2240
enc_assign_exp(BITSTREAM *bs, EXP a, EXP b)
2266
{
2241
{
2267
    TYPE t ;
-
 
2268
    if ( IS_NULL_exp ( e ) ) {
-
 
2269
	/* Deal with null expressions */
-
 
2270
	ENC_make_top ( bs ) ;
-
 
2271
	return ( bs ) ;
-
 
2272
    }
-
 
2273
 
-
 
2274
    /* Examine expression cases */
-
 
2275
    t = DEREF_type ( exp_type ( e ) ) ;
2242
	TYPE s = DEREF_type(exp_type(a));
2276
    ASSERT ( ORDER_exp == 88 ) ;
-
 
2277
    switch ( TAG_exp ( e ) ) {
-
 
2278
 
-
 
2279
	case exp_identifier_tag : {
-
 
2280
	    /* Identifier lvalue expressions */
-
 
2281
	    bs = enc_addr_exp ( bs, t, e ) ;
-
 
2282
	    break ;
-
 
2283
	}
-
 
2284
 
-
 
2285
	case exp_int_lit_tag : {
-
 
2286
	    /* Integer literals */
-
 
2287
	    NAT n = DEREF_nat ( exp_int_lit_nat ( e ) ) ;
-
 
2288
	    unsigned etag = DEREF_unsigned ( exp_int_lit_etag ( e ) ) ;
-
 
2289
	    bs = enc_int_lit ( bs, n, t, etag ) ;
-
 
2290
	    break ;
-
 
2291
	}
-
 
2292
 
-
 
2293
	case exp_float_lit_tag : {
-
 
2294
	    /* Floating literals */
-
 
2295
	    FLOAT f = DEREF_flt ( exp_float_lit_flt ( e ) ) ;
-
 
2296
	    bs = enc_float ( bs, f, t ) ;
-
 
2297
	    break ;
-
 
2298
	}
-
 
2299
 
-
 
2300
	case exp_char_lit_tag : {
-
 
2301
	    /* Character literals */
-
 
2302
	    STRING s = DEREF_str ( exp_char_lit_str ( e ) ) ;
-
 
2303
	    bs = enc_char ( bs, s, t, t ) ;
-
 
2304
	    break ;
-
 
2305
	}
-
 
2306
 
-
 
2307
	case exp_string_lit_tag : {
-
 
2308
	    /* String literals */
-
 
2309
	    STRING s = DEREF_str ( exp_string_lit_str ( e ) ) ;
-
 
2310
	    bs = enc_string ( bs, s, t ) ;
-
 
2311
	    break ;
-
 
2312
	}
-
 
2313
 
-
 
2314
	case exp_value_tag : {
-
 
2315
	    /* Undefined values */
-
 
2316
	    if ( IS_type_top ( t ) ) {
-
 
2317
		ENC_make_top ( bs ) ;
-
 
2318
	    } else {
-
 
2319
		ENC_make_value ( bs ) ;
-
 
2320
		bs = enc_shape ( bs, t ) ;
-
 
2321
	    }
-
 
2322
	    break ;
-
 
2323
	}
-
 
2324
 
-
 
2325
	case exp_null_tag :
-
 
2326
	case exp_zero_tag : {
-
 
2327
	    /* Null expressions */
-
 
2328
	    bs = enc_null_exp ( bs, t ) ;
-
 
2329
	    break ;
-
 
2330
	}
-
 
2331
 
-
 
2332
	case exp_paren_tag :
-
 
2333
	case exp_copy_tag : {
-
 
2334
	    /* Parenthesised expressions */
-
 
2335
	    EXP a = DEREF_exp ( exp_paren_etc_arg ( e ) ) ;
-
 
2336
	    bs = enc_exp ( bs, a ) ;
-
 
2337
	    break ;
-
 
2338
	}
-
 
2339
 
-
 
2340
	case exp_assign_tag : {
-
 
2341
	    /* Assignment expressions */
-
 
2342
	    EXP a = DEREF_exp ( exp_assign_ref ( e ) ) ;
-
 
2343
	    EXP b = DEREF_exp ( exp_assign_arg ( e ) ) ;
-
 
2344
	    bs = enc_assign_exp ( bs, a, b ) ;
-
 
2345
	    break ;
-
 
2346
	}
-
 
2347
 
-
 
2348
	case exp_init_tag : {
-
 
2349
	    /* Initialisation expressions */
-
 
2350
	    ulong n ;
-
 
2351
	    int context = 1 ;
-
 
2352
	    IDENTIFIER id = DEREF_id ( exp_init_id ( e ) ) ;
-
 
2353
	    DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
-
 
2354
	    EXP a = DEREF_exp ( exp_init_arg ( e ) ) ;
-
 
2355
	    EXP d = DEREF_exp ( id_variable_etc_term ( id ) ) ;
-
 
2356
	    if ( !IS_NULL_exp ( d ) ) {
-
 
2357
		while ( IS_exp_nof ( d ) ) {
2243
	if (IS_exp_dummy(a)) {
2358
		    d = DEREF_exp ( exp_nof_pad ( d ) ) ;
-
 
2359
		}
-
 
2360
		ENC_SEQ_SMALL ( bs, 1 ) ;
-
 
2361
	    }
-
 
2362
	    if ( !( ds & dspec_auto ) ) {
-
 
2363
		/* Allow for external variables */
-
 
2364
		if ( capsule_id ( id, VAR_tag ) ) {
-
 
2365
		    make_term_global ( t, &d ) ;
-
 
2366
		}
-
 
2367
		context = 2 ;
-
 
2368
	    }
-
 
2369
	    n = unit_no ( bs, id, VAR_tag, 0 ) ;
-
 
2370
	    bs = enc_init_tag ( bs, n, NULL_off, 0, t, a, d, context ) ;
-
 
2371
	    break ;
-
 
2372
	}
-
 
2373
 
-
 
2374
	case exp_preinc_tag : {
-
 
2375
	    /* Pre-increment expressions */
2244
		/* Check for dummy expressions */
2376
	    int bf = 0 ;
-
 
2377
	    ulong n = LINK_NONE ;
-
 
2378
	    EXP a = DEREF_exp ( exp_preinc_ref ( e ) ) ;
-
 
2379
	    EXP b = DEREF_exp ( exp_preinc_op ( e ) ) ;
-
 
2380
	    EXP a1 = DEREF_exp ( exp_dummy_value ( a ) ) ;
2245
		EXP c = DEREF_exp(exp_dummy_value(a));
2381
	    TYPE s = DEREF_type ( exp_type ( a ) ) ;
-
 
2382
	    int op = DEREF_int ( exp_preinc_becomes ( e ) ) ;
-
 
2383
 
-
 
2384
	    /* Declare identity for complex operations */
-
 
2385
	    if ( op != lex_assign ) {
-
 
2386
		COPY_exp ( exp_dummy_value ( a ), NULL_exp ) ;
-
 
2387
		bs = make_identity ( bs, a1, &n, 0, 0 ) ;
-
 
2388
		COPY_ulong ( exp_dummy_no ( a ), n ) ;
-
 
2389
	    }
-
 
2390
 
-
 
2391
	    /* Encode the result */
-
 
2392
	    bs = enc_assign_op ( bs, s, &bf ) ;
-
 
2393
	    if ( n == LINK_NONE ) {
-
 
2394
		bs = enc_exp ( bs, a1 ) ;
-
 
2395
	    } else {
-
 
2396
		ENC_obtain_tag ( bs ) ;
-
 
2397
		ENC_make_tag ( bs, n ) ;
-
 
2398
	    }
-
 
2399
	    if ( bf ) {
-
 
2400
		OFFSET off = DEREF_off ( exp_dummy_off ( a ) ) ;
-
 
2401
		bs = enc_offset ( bs, off ) ;
-
 
2402
	    }
-
 
2403
	    bs = enc_exp ( bs, b ) ;
-
 
2404
	    COPY_exp ( exp_dummy_value ( a ), a1 ) ;
-
 
2405
	    break ;
-
 
2406
	}
-
 
2407
 
-
 
2408
	case exp_postinc_tag : {
-
 
2409
	    /* Post-increment expressions */
-
 
2410
	    ulong n ;
-
 
2411
	    int bf = 0 ;
-
 
2412
	    EXP a = DEREF_exp ( exp_postinc_ref ( e ) ) ;
-
 
2413
	    EXP b = DEREF_exp ( exp_postinc_value ( e ) ) ;
-
 
2414
	    EXP c = DEREF_exp ( exp_postinc_op ( e ) ) ;
-
 
2415
	    EXP a1 = DEREF_exp ( exp_dummy_value ( a ) ) ;
-
 
2416
	    EXP b1 = NULL_exp ;
-
 
2417
	    TYPE s = DEREF_type ( exp_type ( a ) ) ;
-
 
2418
 
-
 
2419
	    /* Declare outer identity */
-
 
2420
	    COPY_exp ( exp_dummy_value ( a ), NULL_exp ) ;
-
 
2421
	    bs = make_identity ( bs, a1, &n, 0, 0 ) ;
-
 
2422
	    COPY_ulong ( exp_dummy_no ( a ), n ) ;
-
 
2423
 
-
 
2424
	    /* Declare inner identity if necessary */
-
 
2425
	    if ( !IS_NULL_exp ( b ) ) {
2246
		if (IS_NULL_exp(c)) {
2426
		ulong m ;
-
 
2427
		b1 = DEREF_exp ( exp_dummy_value ( b ) ) ;
2247
			ulong n = DEREF_ulong(exp_dummy_no(a));
2428
		COPY_exp ( exp_dummy_value ( b ), NULL_exp ) ;
-
 
2429
		bs = make_identity ( bs, b1, &m, 1, 1 ) ;
-
 
2430
		COPY_ulong ( exp_dummy_no ( b ), m ) ;
-
 
2431
	    }
-
 
2432
 
-
 
2433
	    /* Encode the result */
-
 
2434
	    bs = enc_assign_op ( bs, s, &bf ) ;
-
 
2435
	    ENC_obtain_tag ( bs ) ;
-
 
2436
	    ENC_make_tag ( bs, n ) ;
-
 
2437
	    if ( bf ) {
-
 
2438
		OFFSET off = DEREF_off ( exp_dummy_off ( a ) ) ;
2248
			OFFSET off = DEREF_off(exp_dummy_off(a));
2439
		bs = enc_offset ( bs, off ) ;
-
 
2440
	    }
-
 
2441
	    bs = enc_exp ( bs, c ) ;
-
 
2442
	    if ( !IS_NULL_exp ( b ) ) {
-
 
2443
		bs = enc_exp ( bs, b ) ;
-
 
2444
		COPY_exp ( exp_dummy_value ( b ), b1 ) ;
-
 
2445
	    }
-
 
2446
	    COPY_exp ( exp_dummy_value ( a ), a1 ) ;
-
 
2447
	    break ;
-
 
2448
	}
-
 
2449
 
-
 
2450
	case exp_indir_tag : {
-
 
2451
	    /* Indirection expressions */
-
 
2452
	    EXP a = DEREF_exp ( exp_indir_ptr ( e ) ) ;
2249
			int cnt = DEREF_int(exp_dummy_cont(a));
2453
	    bs = enc_exp ( bs, a ) ;
-
 
2454
	    break ;
-
 
2455
	}
-
 
2456
 
-
 
2457
	case exp_contents_tag : {
-
 
2458
	    /* Contents expressions */
-
 
2459
	    EXP a = DEREF_exp ( exp_contents_ptr ( e ) ) ;
-
 
2460
	    bs = enc_cont_exp ( bs, t, a ) ;
-
 
2461
	    break ;
-
 
2462
	}
-
 
2463
 
-
 
2464
	case exp_address_tag : {
-
 
2465
	    /* Address expressions */
-
 
2466
	    EXP a = DEREF_exp ( exp_address_arg ( e ) ) ;
-
 
2467
	    bs = enc_addr_exp ( bs, t, a ) ;
-
 
2468
	    break ;
-
 
2469
	}
-
 
2470
 
-
 
2471
	case exp_address_mem_tag : {
-
 
2472
	    /* Member address expressions */
-
 
2473
	    EXP a = DEREF_exp ( exp_address_mem_arg ( e ) ) ;
-
 
2474
	    IDENTIFIER id = DEREF_id ( exp_member_id ( a ) ) ;
-
 
2475
	    bs = enc_ptr_mem ( bs, t, id, NULL_graph ) ;
2250
			bs = enc_init_tag(bs, n, off, cnt, s, b, NULL_exp, 0);
2476
	    break ;
-
 
2477
	}
-
 
2478
 
-
 
2479
	case exp_func_tag : {
-
 
2480
	    /* Function applications */
-
 
2481
	    bs = enc_func_call ( bs, t, e ) ;
-
 
2482
	    break ;
-
 
2483
	}
-
 
2484
 
-
 
2485
	case exp_func_id_tag : {
-
 
2486
	    /* Function identifier applications */
-
 
2487
	    bs = enc_func_id_call ( bs, t, e ) ;
-
 
2488
	    break ;
-
 
2489
	}
-
 
2490
 
-
 
2491
	case exp_negate_tag : {
-
 
2492
	    /* Negation expressions */
-
 
2493
	    if ( IS_type_floating ( t ) ) {
-
 
2494
		ENC_floating_negate ( bs ) ;
-
 
2495
	    } else {
-
 
2496
		ENC_negate ( bs ) ;
-
 
2497
	    }
-
 
2498
	    goto unary_err_label ;
-
 
2499
	}
-
 
2500
 
-
 
2501
	case exp_compl_tag : {
-
 
2502
	    /* Complement expressions */
-
 
2503
	    ENC_not ( bs ) ;
-
 
2504
	    goto unary_label ;
-
 
2505
	}
-
 
2506
 
-
 
2507
	case exp_abs_tag : {
-
 
2508
	    /* Absolute expressions */
-
 
2509
	    if ( IS_type_floating ( t ) ) {
-
 
2510
		ENC_floating_abs ( bs ) ;
-
 
2511
	    } else {
-
 
2512
		ENC_abs ( bs ) ;
2251
			return (bs);
2513
	    }
-
 
2514
	    goto unary_err_label ;
-
 
2515
	}
2252
		}
2516
 
-
 
2517
	unary_err_label : {
-
 
2518
	    /* Unary operands with error treatment */
-
 
2519
	    bs = enc_error_treatment ( bs, t ) ;
-
 
2520
	    goto unary_label ;
-
 
2521
	}
2253
	}
-
 
2254
	if (is_init_complex(b)) {
-
 
2255
		/* Introduce identity for complex assignment */
-
 
2256
		ulong n;
-
 
2257
		bs = make_identity(bs, a, &n, 0, 0);
-
 
2258
		bs = enc_init_tag(bs, n, NULL_off, 0, s, b, NULL_exp, 0);
-
 
2259
	} else {
-
 
2260
		/* Simple assignment */
-
 
2261
		int bf = 0;
-
 
2262
		bs = enc_assign_op(bs, s, &bf);
-
 
2263
		if (bf) {
-
 
2264
			/* Bitfield assignment */
-
 
2265
			OFFSET off = decons_bitf_exp(&a);
-
 
2266
			bs = enc_addr_exp(bs, s, a);
-
 
2267
			bs = enc_offset(bs, off);
-
 
2268
		} else {
-
 
2269
			/* Non-bitfield assignment */
-
 
2270
			bs = enc_addr_exp(bs, s, a);
-
 
2271
		}
-
 
2272
		bs = enc_exp(bs, b);
-
 
2273
	}
-
 
2274
	return (bs);
-
 
2275
}
-
 
2276
 
-
 
2277
 
-
 
2278
/*
-
 
2279
    ENCODE A TDF EXP
-
 
2280
 
-
 
2281
    This routine adds the expression e to the bitstream bs as a TDF EXP.
-
 
2282
*/
2522
 
2283
 
2523
	unary_label : {
-
 
2524
	    /* Unary operands */
-
 
2525
	    EXP a = DEREF_exp ( exp_negate_etc_arg ( e ) ) ;
-
 
2526
	    bs = enc_exp ( bs, a ) ;
-
 
2527
	    break ;
2284
BITSTREAM *
2528
	}
-
 
2529
 
-
 
2530
	case exp_plus_tag : {
-
 
2531
	    /* Addition expressions */
-
 
2532
	    unsigned tag = TAG_type ( t ) ;
-
 
2533
	    if ( tag == type_floating_tag ) {
-
 
2534
		ENC_floating_plus ( bs ) ;
-
 
2535
		ENC_impossible ( bs ) ;
-
 
2536
		ENC_LIST_SMALL ( bs, 2 ) ;
2285
enc_exp(BITSTREAM *bs, EXP e)
2537
	    } else {
-
 
2538
		if ( tag == type_enumerate_tag ) {
-
 
2539
		    /* Special case for enumerators */
-
 
2540
		    t = promote_type ( t ) ;
-
 
2541
		}
-
 
2542
		ENC_plus ( bs ) ;
-
 
2543
		bs = enc_error_treatment ( bs, t ) ;
-
 
2544
	    }
-
 
2545
	    goto binary_label ;
-
 
2546
	}
-
 
2547
 
-
 
2548
	case exp_minus_tag : {
-
 
2549
	    /* Subtraction expressions */
-
 
2550
	    if ( IS_type_floating ( t ) ) {
-
 
2551
		ENC_floating_minus ( bs ) ;
-
 
2552
	    } else {
-
 
2553
		ENC_minus ( bs ) ;
-
 
2554
	    }
-
 
2555
	    goto binary_err_label ;
-
 
2556
	}
-
 
2557
 
2286
{
2558
	case exp_mult_tag : {
-
 
2559
	    /* Multiplication expressions */
-
 
2560
	    if ( IS_type_floating ( t ) ) {
-
 
2561
		ENC_floating_mult ( bs ) ;
-
 
2562
		ENC_impossible ( bs ) ;
-
 
2563
		ENC_LIST_SMALL ( bs, 2 ) ;
-
 
2564
	    } else {
-
 
2565
		ENC_mult ( bs ) ;
-
 
2566
		bs = enc_error_treatment ( bs, t ) ;
-
 
2567
	    }
2287
	TYPE t;
2568
	    goto binary_label ;
-
 
2569
	}
-
 
2570
 
-
 
2571
	case exp_div_tag : {
-
 
2572
	    /* Division expressions */
-
 
2573
	    if ( IS_type_floating ( t ) ) {
-
 
2574
		ENC_floating_div ( bs ) ;
-
 
2575
	    } else {
-
 
2576
		int div_mode = division_mode ;
-
 
2577
		if ( div_mode == 3 ) {
2288
	if (IS_NULL_exp(e)) {
2578
		    /* Tokenised division */
-
 
2579
		    bs = enc_special ( bs, TOK_div ) ;
-
 
2580
		    goto division_label ;
-
 
2581
		}
-
 
2582
		switch ( div_mode ) {
-
 
2583
		    case 0 : ENC_div0 ( bs ) ; break ;
-
 
2584
		    case 1 : ENC_div1 ( bs ) ; break ;
-
 
2585
		    case 2 : ENC_div2 ( bs ) ; break ;
-
 
2586
		}
-
 
2587
		ENC_impossible ( bs ) ;
-
 
2588
	    }
-
 
2589
	    goto binary_err_label ;
-
 
2590
	}
-
 
2591
 
-
 
2592
	case exp_rem_tag : {
-
 
2593
	    /* Remainder expressions */
-
 
2594
	    int div_mode = division_mode ;
-
 
2595
	    if ( div_mode == 3 ) {
-
 
2596
		/* Tokenised division */
-
 
2597
		bs = enc_special ( bs, TOK_rem ) ;
-
 
2598
		goto division_label ;
-
 
2599
	    }
-
 
2600
	    switch ( div_mode ) {
-
 
2601
		case 0 : ENC_rem0 ( bs ) ; break ;
-
 
2602
		case 1 : ENC_rem1 ( bs ) ; break ;
-
 
2603
		case 2 : ENC_rem2 ( bs ) ; break ;
-
 
2604
	    }
-
 
2605
	    ENC_impossible ( bs ) ;
-
 
2606
	    goto binary_err_label ;
-
 
2607
	}
-
 
2608
 
-
 
2609
	division_label : {
-
 
2610
	    /* Division operands */
-
 
2611
	    EXP a = DEREF_exp ( exp_plus_etc_arg1 ( e ) ) ;
-
 
2612
	    EXP b = DEREF_exp ( exp_plus_etc_arg2 ( e ) ) ;
-
 
2613
	    BITSTREAM *ts = start_bitstream ( NIL ( FILE ), bs->link ) ;
-
 
2614
	    ts = enc_exp ( ts, a ) ;
-
 
2615
	    ts = enc_exp ( ts, b ) ;
-
 
2616
	    bs = enc_bitstream ( bs, ts ) ;
-
 
2617
	    break ;
-
 
2618
	}
-
 
2619
 
-
 
2620
	case exp_and_tag : {
-
 
2621
	    /* Bitwise and expressions */
-
 
2622
	    ENC_and ( bs ) ;
-
 
2623
	    goto binary_label ; ;
-
 
2624
	}
-
 
2625
 
-
 
2626
	case exp_or_tag : {
-
 
2627
	    /* Bitwise or expressions */
-
 
2628
	    ENC_or ( bs ) ;
-
 
2629
	    goto binary_label ; ;
-
 
2630
	}
-
 
2631
 
-
 
2632
	case exp_xor_tag : {
-
 
2633
	    /* Bitwise xor expressions */
-
 
2634
	    ENC_xor ( bs ) ;
-
 
2635
	    goto binary_label ; ;
-
 
2636
	}
-
 
2637
 
-
 
2638
	case exp_lshift_tag : {
-
 
2639
	    /* Left shift expressions */
-
 
2640
	    ENC_shift_left ( bs ) ;
-
 
2641
	    goto binary_err_label ; ;
-
 
2642
	}
-
 
2643
 
-
 
2644
	case exp_rshift_tag : {
-
 
2645
	    /* Right shift expressions */
2289
		/* Deal with null expressions */
2646
	    ENC_shift_right ( bs ) ;
-
 
2647
	    goto binary_label ;
-
 
2648
	}
-
 
2649
 
-
 
2650
	case exp_max_tag : {
-
 
2651
	    /* Maximum expressions */
-
 
2652
	    if ( IS_type_floating ( t ) ) {
-
 
2653
		ENC_floating_maximum ( bs ) ;
-
 
2654
#if ( TDF_major >= 4 )
-
 
2655
		ENC_impossible ( bs ) ;
-
 
2656
#endif
-
 
2657
	    } else {
-
 
2658
		ENC_maximum ( bs ) ;
2290
		ENC_make_top(bs);
2659
	    }
-
 
2660
	    goto binary_label ;
-
 
2661
	}
-
 
2662
 
-
 
2663
	case exp_min_tag : {
-
 
2664
	    /* Minimum expressions */
-
 
2665
	    if ( IS_type_floating ( t ) ) {
-
 
2666
		ENC_floating_minimum ( bs ) ;
-
 
2667
#if ( TDF_major >= 4 )
-
 
2668
		ENC_impossible ( bs ) ;
-
 
2669
#endif
-
 
2670
	    } else {
-
 
2671
		ENC_minimum ( bs ) ;
2291
		return (bs);
2672
	    }
-
 
2673
	    goto binary_label ;
-
 
2674
	}
-
 
2675
 
-
 
2676
	binary_err_label : {
-
 
2677
	    /* Binary operands with error treatment */
-
 
2678
	    bs = enc_error_treatment ( bs, t ) ;
-
 
2679
	    goto binary_label ;
-
 
2680
	}
-
 
2681
 
-
 
2682
	binary_label : {
-
 
2683
	    /* Binary operands */
-
 
2684
	    EXP a = DEREF_exp ( exp_plus_etc_arg1 ( e ) ) ;
-
 
2685
	    EXP b = DEREF_exp ( exp_plus_etc_arg2 ( e ) ) ;
-
 
2686
	    bs = enc_exp ( bs, a ) ;
-
 
2687
	    bs = enc_exp ( bs, b ) ;
-
 
2688
	    break ;
-
 
2689
	}
-
 
2690
 
-
 
2691
	case exp_cast_tag : {
-
 
2692
	    /* Cast expressions */
-
 
2693
	    EXP a = DEREF_exp ( exp_cast_arg ( e ) ) ;
-
 
2694
	    unsigned conv = DEREF_unsigned ( exp_cast_conv ( e ) ) ;
-
 
2695
	    bs = enc_cast_exp ( bs, t, a, conv ) ;
-
 
2696
	    break ;
-
 
2697
	}
-
 
2698
 
-
 
2699
	case exp_base_cast_tag : {
-
 
2700
	    /* Base class cast expressions */
-
 
2701
	    EXP a = DEREF_exp ( exp_base_cast_arg ( e ) ) ;
-
 
2702
	    OFFSET off = DEREF_off ( exp_base_cast_off ( e ) ) ;
-
 
2703
	    unsigned conv = DEREF_unsigned ( exp_base_cast_conv ( e ) ) ;
-
 
2704
	    if ( conv == CONV_PTR_MEM_BASE ) {
-
 
2705
		/* Check for constant pointer to members */
-
 
2706
		IDENTIFIER fn = is_const_ptr_mem ( a, 0 ) ;
-
 
2707
		if ( !IS_NULL_id ( fn ) ) {
-
 
2708
		    CLASS_TYPE cs = parent_class ( fn ) ;
-
 
2709
		    CLASS_TYPE ct = DEREF_ctype ( type_ptr_mem_of ( t ) ) ;
-
 
2710
		    GRAPH gr = find_base_class ( ct, cs, 0 ) ;
-
 
2711
		    bs = enc_ptr_mem ( bs, t, fn, gr ) ;
-
 
2712
		    break ;
-
 
2713
		}
-
 
2714
	    }
-
 
2715
	    bs = enc_base_cast_exp ( bs, a, off, conv ) ;
-
 
2716
	    break ;
-
 
2717
	}
-
 
2718
 
-
 
2719
	case exp_add_ptr_tag : {
-
 
2720
	    /* Pointer additions */
-
 
2721
	    EXP a = DEREF_exp ( exp_add_ptr_ptr ( e ) ) ;
-
 
2722
	    OFFSET off = DEREF_off ( exp_add_ptr_off ( e ) ) ;
-
 
2723
	    int virt = DEREF_int ( exp_add_ptr_virt ( e ) ) ;
-
 
2724
	    bs = enc_add_ptr ( bs, a, LINK_NONE, off, virt ) ;
-
 
2725
	    break ;
-
 
2726
	}
-
 
2727
 
-
 
2728
	case exp_offset_size_tag : {
-
 
2729
	    /* Size of offset */
-
 
2730
	    OFFSET off = DEREF_off ( exp_offset_size_off ( e ) ) ;
-
 
2731
	    TYPE s = DEREF_type ( exp_offset_size_step ( e ) ) ;
-
 
2732
	    ENC_offset_div ( bs ) ;
-
 
2733
	    bs = enc_variety ( bs, t ) ;
-
 
2734
	    bs = enc_offset ( bs, off ) ;
-
 
2735
	    bs = enc_shape_offset ( bs, s ) ;
-
 
2736
	    break ;
-
 
2737
	}
-
 
2738
 
-
 
2739
	case exp_constr_tag : {
-
 
2740
	    /* Constructor calls */
-
 
2741
	    EXP a = DEREF_exp ( exp_constr_call ( e ) ) ;
-
 
2742
	    bs = enc_exp ( bs, a ) ;
-
 
2743
	    break ;
-
 
2744
	}
-
 
2745
 
-
 
2746
	case exp_destr_tag : {
-
 
2747
	    /* Destructor calls */
-
 
2748
	    EXP a = DEREF_exp ( exp_destr_call ( e ) ) ;
-
 
2749
	    bs = enc_exp ( bs, a ) ;
-
 
2750
	    break ;
-
 
2751
	}
-
 
2752
 
-
 
2753
	case exp_rtti_no_tag : {
-
 
2754
	    /* Link-time type information */
-
 
2755
	    TYPE s = DEREF_type ( exp_rtti_no_arg ( e ) ) ;
-
 
2756
	    ENC_make_int ( bs ) ;
-
 
2757
	    bs = enc_variety ( bs, t ) ;
-
 
2758
	    bs = enc_arith ( bs, s, 0 ) ;
-
 
2759
	    break ;
-
 
2760
	}
2292
	}
2761
 
2293
 
-
 
2294
	/* Examine expression cases */
-
 
2295
	t = DEREF_type(exp_type(e));
-
 
2296
	ASSERT(ORDER_exp == 88);
-
 
2297
	switch (TAG_exp(e)) {
-
 
2298
 
-
 
2299
	case exp_identifier_tag: {
-
 
2300
		/* Identifier lvalue expressions */
-
 
2301
		bs = enc_addr_exp(bs, t, e);
-
 
2302
		break;
-
 
2303
	}
-
 
2304
 
-
 
2305
	case exp_int_lit_tag: {
-
 
2306
		/* Integer literals */
-
 
2307
		NAT n = DEREF_nat(exp_int_lit_nat(e));
-
 
2308
		unsigned etag = DEREF_unsigned(exp_int_lit_etag(e));
-
 
2309
		bs = enc_int_lit(bs, n, t, etag);
-
 
2310
		break;
-
 
2311
	}
-
 
2312
 
-
 
2313
	case exp_float_lit_tag: {
-
 
2314
		/* Floating literals */
-
 
2315
		FLOAT f = DEREF_flt(exp_float_lit_flt(e));
-
 
2316
		bs = enc_float(bs, f, t);
-
 
2317
		break;
-
 
2318
	}
-
 
2319
 
-
 
2320
	case exp_char_lit_tag: {
-
 
2321
		/* Character literals */
-
 
2322
		STRING s = DEREF_str(exp_char_lit_str(e));
-
 
2323
		bs = enc_char(bs, s, t, t);
-
 
2324
		break;
-
 
2325
	}
-
 
2326
 
-
 
2327
	case exp_string_lit_tag: {
-
 
2328
		/* String literals */
-
 
2329
		STRING s = DEREF_str(exp_string_lit_str(e));
-
 
2330
		bs = enc_string(bs, s, t);
-
 
2331
		break;
-
 
2332
	}
-
 
2333
 
-
 
2334
	case exp_value_tag: {
-
 
2335
		/* Undefined values */
-
 
2336
		if (IS_type_top(t)) {
-
 
2337
			ENC_make_top(bs);
-
 
2338
		} else {
-
 
2339
			ENC_make_value(bs);
-
 
2340
			bs = enc_shape(bs, t);
-
 
2341
		}
-
 
2342
		break;
-
 
2343
	}
-
 
2344
 
-
 
2345
	case exp_null_tag:
-
 
2346
	case exp_zero_tag: {
-
 
2347
		/* Null expressions */
-
 
2348
		bs = enc_null_exp(bs, t);
-
 
2349
		break;
-
 
2350
	}
-
 
2351
 
-
 
2352
	case exp_paren_tag:
-
 
2353
	case exp_copy_tag: {
-
 
2354
		/* Parenthesised expressions */
-
 
2355
		EXP a = DEREF_exp(exp_paren_etc_arg(e));
-
 
2356
		bs = enc_exp(bs, a);
-
 
2357
		break;
-
 
2358
	}
-
 
2359
 
-
 
2360
	case exp_assign_tag: {
-
 
2361
		/* Assignment expressions */
-
 
2362
		EXP a = DEREF_exp(exp_assign_ref(e));
-
 
2363
		EXP b = DEREF_exp(exp_assign_arg(e));
-
 
2364
		bs = enc_assign_exp(bs, a, b);
-
 
2365
		break;
-
 
2366
	}
-
 
2367
 
-
 
2368
	case exp_init_tag: {
-
 
2369
		/* Initialisation expressions */
-
 
2370
		ulong n;
-
 
2371
		int context = 1;
-
 
2372
		IDENTIFIER id = DEREF_id(exp_init_id(e));
-
 
2373
		DECL_SPEC ds = DEREF_dspec(id_storage(id));
-
 
2374
		EXP a = DEREF_exp(exp_init_arg(e));
-
 
2375
		EXP d = DEREF_exp(id_variable_etc_term(id));
-
 
2376
		if (!IS_NULL_exp(d)) {
-
 
2377
			while (IS_exp_nof(d)) {
-
 
2378
				d = DEREF_exp(exp_nof_pad(d));
-
 
2379
			}
-
 
2380
			ENC_SEQ_SMALL(bs, 1);
-
 
2381
		}
-
 
2382
		if (!(ds & dspec_auto)) {
-
 
2383
			/* Allow for external variables */
-
 
2384
			if (capsule_id(id, VAR_tag)) {
-
 
2385
				make_term_global(t, &d);
-
 
2386
			}
-
 
2387
			context = 2;
-
 
2388
		}
-
 
2389
		n = unit_no(bs, id, VAR_tag, 0);
-
 
2390
		bs = enc_init_tag(bs, n, NULL_off, 0, t, a, d, context);
-
 
2391
		break;
-
 
2392
	}
-
 
2393
 
-
 
2394
	case exp_preinc_tag: {
-
 
2395
		/* Pre-increment expressions */
-
 
2396
		int bf = 0;
-
 
2397
		ulong n = LINK_NONE;
-
 
2398
		EXP a = DEREF_exp(exp_preinc_ref(e));
-
 
2399
		EXP b = DEREF_exp(exp_preinc_op(e));
-
 
2400
		EXP a1 = DEREF_exp(exp_dummy_value(a));
-
 
2401
		TYPE s = DEREF_type(exp_type(a));
-
 
2402
		int op = DEREF_int(exp_preinc_becomes(e));
-
 
2403
 
-
 
2404
		/* Declare identity for complex operations */
-
 
2405
		if (op != lex_assign) {
-
 
2406
			COPY_exp(exp_dummy_value(a), NULL_exp);
-
 
2407
			bs = make_identity(bs, a1, &n, 0, 0);
-
 
2408
			COPY_ulong(exp_dummy_no(a), n);
-
 
2409
		}
-
 
2410
 
-
 
2411
		/* Encode the result */
-
 
2412
		bs = enc_assign_op(bs, s, &bf);
-
 
2413
		if (n == LINK_NONE) {
-
 
2414
			bs = enc_exp(bs, a1);
-
 
2415
		} else {
-
 
2416
			ENC_obtain_tag(bs);
-
 
2417
			ENC_make_tag(bs, n);
-
 
2418
		}
-
 
2419
		if (bf) {
-
 
2420
			OFFSET off = DEREF_off(exp_dummy_off(a));
-
 
2421
			bs = enc_offset(bs, off);
-
 
2422
		}
-
 
2423
		bs = enc_exp(bs, b);
-
 
2424
		COPY_exp(exp_dummy_value(a), a1);
-
 
2425
		break;
-
 
2426
	}
-
 
2427
 
-
 
2428
	case exp_postinc_tag: {
-
 
2429
		/* Post-increment expressions */
-
 
2430
		ulong n;
-
 
2431
		int bf = 0;
-
 
2432
		EXP a = DEREF_exp(exp_postinc_ref(e));
-
 
2433
		EXP b = DEREF_exp(exp_postinc_value(e));
-
 
2434
		EXP c = DEREF_exp(exp_postinc_op(e));
-
 
2435
		EXP a1 = DEREF_exp(exp_dummy_value(a));
-
 
2436
		EXP b1 = NULL_exp;
-
 
2437
		TYPE s = DEREF_type(exp_type(a));
-
 
2438
 
-
 
2439
		/* Declare outer identity */
-
 
2440
		COPY_exp(exp_dummy_value(a), NULL_exp);
-
 
2441
		bs = make_identity(bs, a1, &n, 0, 0);
-
 
2442
		COPY_ulong(exp_dummy_no(a), n);
-
 
2443
 
-
 
2444
		/* Declare inner identity if necessary */
-
 
2445
		if (!IS_NULL_exp(b)) {
-
 
2446
			ulong m;
-
 
2447
			b1 = DEREF_exp(exp_dummy_value(b));
-
 
2448
			COPY_exp(exp_dummy_value(b), NULL_exp);
-
 
2449
			bs = make_identity(bs, b1, &m, 1, 1);
-
 
2450
			COPY_ulong(exp_dummy_no(b), m);
-
 
2451
		}
-
 
2452
 
-
 
2453
		/* Encode the result */
-
 
2454
		bs = enc_assign_op(bs, s, &bf);
-
 
2455
		ENC_obtain_tag(bs);
-
 
2456
		ENC_make_tag(bs, n);
-
 
2457
		if (bf) {
-
 
2458
			OFFSET off = DEREF_off(exp_dummy_off(a));
-
 
2459
			bs = enc_offset(bs, off);
-
 
2460
		}
-
 
2461
		bs = enc_exp(bs, c);
-
 
2462
		if (!IS_NULL_exp(b)) {
-
 
2463
			bs = enc_exp(bs, b);
-
 
2464
			COPY_exp(exp_dummy_value(b), b1);
-
 
2465
		}
-
 
2466
		COPY_exp(exp_dummy_value(a), a1);
-
 
2467
		break;
-
 
2468
	}
-
 
2469
 
-
 
2470
	case exp_indir_tag: {
-
 
2471
		/* Indirection expressions */
-
 
2472
		EXP a = DEREF_exp(exp_indir_ptr(e));
-
 
2473
		bs = enc_exp(bs, a);
-
 
2474
		break;
-
 
2475
	}
-
 
2476
 
-
 
2477
	case exp_contents_tag: {
-
 
2478
		/* Contents expressions */
-
 
2479
		EXP a = DEREF_exp(exp_contents_ptr(e));
-
 
2480
		bs = enc_cont_exp(bs, t, a);
-
 
2481
		break;
-
 
2482
	}
-
 
2483
 
-
 
2484
	case exp_address_tag: {
-
 
2485
		/* Address expressions */
-
 
2486
		EXP a = DEREF_exp(exp_address_arg(e));
-
 
2487
		bs = enc_addr_exp(bs, t, a);
-
 
2488
		break;
-
 
2489
	}
-
 
2490
 
-
 
2491
	case exp_address_mem_tag: {
-
 
2492
		/* Member address expressions */
-
 
2493
		EXP a = DEREF_exp(exp_address_mem_arg(e));
-
 
2494
		IDENTIFIER id = DEREF_id(exp_member_id(a));
-
 
2495
		bs = enc_ptr_mem(bs, t, id, NULL_graph);
-
 
2496
		break;
-
 
2497
	}
-
 
2498
 
-
 
2499
	case exp_func_tag: {
-
 
2500
		/* Function applications */
-
 
2501
		bs = enc_func_call(bs, t, e);
-
 
2502
		break;
-
 
2503
	}
-
 
2504
 
-
 
2505
	case exp_func_id_tag: {
-
 
2506
		/* Function identifier applications */
-
 
2507
		bs = enc_func_id_call(bs, t, e);
-
 
2508
		break;
-
 
2509
	}
-
 
2510
 
-
 
2511
	case exp_negate_tag: {
-
 
2512
		/* Negation expressions */
-
 
2513
		if (IS_type_floating(t)) {
-
 
2514
			ENC_floating_negate(bs);
-
 
2515
		} else {
-
 
2516
			ENC_negate(bs);
-
 
2517
		}
-
 
2518
		goto unary_err_label;
-
 
2519
	}
-
 
2520
 
-
 
2521
	case exp_compl_tag: {
-
 
2522
		/* Complement expressions */
-
 
2523
		ENC_not(bs);
-
 
2524
		goto unary_label;
-
 
2525
	}
-
 
2526
 
-
 
2527
	case exp_abs_tag: {
-
 
2528
		/* Absolute expressions */
-
 
2529
		if (IS_type_floating(t)) {
-
 
2530
			ENC_floating_abs(bs);
-
 
2531
		} else {
-
 
2532
			ENC_abs(bs);
-
 
2533
		}
-
 
2534
		goto unary_err_label;
-
 
2535
	}
-
 
2536
 
-
 
2537
unary_err_label: {
-
 
2538
			 /* Unary operands with error treatment */
-
 
2539
			 bs = enc_error_treatment(bs, t);
-
 
2540
			 goto unary_label;
-
 
2541
		 }
-
 
2542
 
-
 
2543
unary_label: {
-
 
2544
		     /* Unary operands */
-
 
2545
		     EXP a = DEREF_exp(exp_negate_etc_arg(e));
-
 
2546
		     bs = enc_exp(bs, a);
-
 
2547
		     break;
-
 
2548
	     }
-
 
2549
 
-
 
2550
	case exp_plus_tag: {
-
 
2551
		/* Addition expressions */
-
 
2552
		unsigned tag = TAG_type(t);
-
 
2553
		if (tag == type_floating_tag) {
-
 
2554
			ENC_floating_plus(bs);
-
 
2555
			ENC_impossible(bs);
-
 
2556
			ENC_LIST_SMALL(bs, 2);
-
 
2557
		} else {
-
 
2558
			if (tag == type_enumerate_tag) {
-
 
2559
				/* Special case for enumerators */
-
 
2560
				t = promote_type(t);
-
 
2561
			}
-
 
2562
			ENC_plus(bs);
-
 
2563
			bs = enc_error_treatment(bs, t);
-
 
2564
		}
-
 
2565
		goto binary_label;
-
 
2566
	}
-
 
2567
 
-
 
2568
	case exp_minus_tag: {
-
 
2569
		/* Subtraction expressions */
-
 
2570
		if (IS_type_floating(t)) {
-
 
2571
			ENC_floating_minus(bs);
-
 
2572
		} else {
-
 
2573
			ENC_minus(bs);
-
 
2574
		}
-
 
2575
		goto binary_err_label;
-
 
2576
	}
-
 
2577
 
-
 
2578
	case exp_mult_tag: {
-
 
2579
		/* Multiplication expressions */
-
 
2580
		if (IS_type_floating(t)) {
-
 
2581
			ENC_floating_mult(bs);
-
 
2582
			ENC_impossible(bs);
-
 
2583
			ENC_LIST_SMALL(bs, 2);
-
 
2584
		} else {
-
 
2585
			ENC_mult(bs);
-
 
2586
			bs = enc_error_treatment(bs, t);
-
 
2587
		}
-
 
2588
		goto binary_label;
-
 
2589
	}
-
 
2590
 
-
 
2591
	case exp_div_tag: {
-
 
2592
		/* Division expressions */
-
 
2593
		if (IS_type_floating(t)) {
-
 
2594
			ENC_floating_div(bs);
-
 
2595
		} else {
-
 
2596
			int div_mode = division_mode;
-
 
2597
			if (div_mode == 3) {
-
 
2598
				/* Tokenised division */
-
 
2599
				bs = enc_special(bs, TOK_div);
-
 
2600
				goto division_label;
-
 
2601
			}
-
 
2602
			switch (div_mode) {
-
 
2603
			case 0:
-
 
2604
				ENC_div0(bs);
-
 
2605
				break;
-
 
2606
			case 1:
-
 
2607
				ENC_div1(bs);
-
 
2608
				break;
-
 
2609
			case 2:
-
 
2610
				ENC_div2(bs);
-
 
2611
				break;
-
 
2612
			}
-
 
2613
			ENC_impossible(bs);
-
 
2614
		}
-
 
2615
		goto binary_err_label;
-
 
2616
	}
-
 
2617
 
-
 
2618
	case exp_rem_tag: {
-
 
2619
		/* Remainder expressions */
-
 
2620
		int div_mode = division_mode;
-
 
2621
		if (div_mode == 3) {
-
 
2622
			/* Tokenised division */
-
 
2623
			bs = enc_special(bs, TOK_rem);
-
 
2624
			goto division_label;
-
 
2625
		}
-
 
2626
		switch (div_mode) {
-
 
2627
		case 0:
-
 
2628
			ENC_rem0(bs);
-
 
2629
			break;
-
 
2630
		case 1:
-
 
2631
			ENC_rem1(bs);
-
 
2632
			break;
-
 
2633
		case 2:
-
 
2634
			ENC_rem2(bs);
-
 
2635
			break;
-
 
2636
		}
-
 
2637
		ENC_impossible(bs);
-
 
2638
		goto binary_err_label;
-
 
2639
	}
-
 
2640
 
-
 
2641
division_label: {
-
 
2642
			/* Division operands */
-
 
2643
			EXP a = DEREF_exp(exp_plus_etc_arg1(e));
-
 
2644
			EXP b = DEREF_exp(exp_plus_etc_arg2(e));
-
 
2645
			BITSTREAM *ts = start_bitstream(NIL(FILE), bs->link);
-
 
2646
			ts = enc_exp(ts, a);
-
 
2647
			ts = enc_exp(ts, b);
-
 
2648
			bs = enc_bitstream(bs, ts);
-
 
2649
			break;
-
 
2650
		}
-
 
2651
 
-
 
2652
	case exp_and_tag: {
-
 
2653
		/* Bitwise and expressions */
-
 
2654
		ENC_and(bs);
-
 
2655
		goto binary_label;
-
 
2656
	}
-
 
2657
 
-
 
2658
	case exp_or_tag: {
-
 
2659
		/* Bitwise or expressions */
-
 
2660
		ENC_or(bs);
-
 
2661
		goto binary_label;
-
 
2662
	}
-
 
2663
 
-
 
2664
	case exp_xor_tag: {
-
 
2665
		/* Bitwise xor expressions */
-
 
2666
		ENC_xor(bs);
-
 
2667
		goto binary_label;
-
 
2668
	}
-
 
2669
 
-
 
2670
	case exp_lshift_tag: {
-
 
2671
		/* Left shift expressions */
-
 
2672
		ENC_shift_left(bs);
-
 
2673
		goto binary_err_label;
-
 
2674
	}
-
 
2675
 
-
 
2676
	case exp_rshift_tag: {
-
 
2677
		/* Right shift expressions */
-
 
2678
		ENC_shift_right(bs);
-
 
2679
		goto binary_label;
-
 
2680
	}
-
 
2681
 
-
 
2682
	case exp_max_tag: {
-
 
2683
		/* Maximum expressions */
-
 
2684
		if (IS_type_floating(t)) {
-
 
2685
			ENC_floating_maximum(bs);
-
 
2686
#if (TDF_major >= 4)
-
 
2687
			ENC_impossible(bs);
-
 
2688
#endif
-
 
2689
		} else {
-
 
2690
			ENC_maximum(bs);
-
 
2691
		}
-
 
2692
		goto binary_label;
-
 
2693
	}
-
 
2694
 
-
 
2695
	case exp_min_tag: {
-
 
2696
		/* Minimum expressions */
-
 
2697
		if (IS_type_floating(t)) {
-
 
2698
			ENC_floating_minimum(bs);
-
 
2699
#if (TDF_major >= 4)
-
 
2700
			ENC_impossible(bs);
-
 
2701
#endif
-
 
2702
		} else {
-
 
2703
			ENC_minimum(bs);
-
 
2704
		}
-
 
2705
		goto binary_label;
-
 
2706
	}
-
 
2707
 
-
 
2708
binary_err_label: {
-
 
2709
			  /* Binary operands with error treatment */
-
 
2710
			  bs = enc_error_treatment(bs, t);
-
 
2711
			  goto binary_label;
-
 
2712
		  }
-
 
2713
 
-
 
2714
binary_label: {
-
 
2715
		      /* Binary operands */
-
 
2716
		      EXP a = DEREF_exp(exp_plus_etc_arg1(e));
-
 
2717
		      EXP b = DEREF_exp(exp_plus_etc_arg2(e));
-
 
2718
		      bs = enc_exp(bs, a);
-
 
2719
		      bs = enc_exp(bs, b);
-
 
2720
		      break;
-
 
2721
	      }
-
 
2722
 
-
 
2723
	case exp_cast_tag: {
-
 
2724
		/* Cast expressions */
-
 
2725
		EXP a = DEREF_exp(exp_cast_arg(e));
-
 
2726
		unsigned conv = DEREF_unsigned(exp_cast_conv(e));
-
 
2727
		bs = enc_cast_exp(bs, t, a, conv);
-
 
2728
		break;
-
 
2729
	}
-
 
2730
 
-
 
2731
	case exp_base_cast_tag: {
-
 
2732
		/* Base class cast expressions */
-
 
2733
		EXP a = DEREF_exp(exp_base_cast_arg(e));
-
 
2734
		OFFSET off = DEREF_off(exp_base_cast_off(e));
-
 
2735
		unsigned conv = DEREF_unsigned(exp_base_cast_conv(e));
-
 
2736
		if (conv == CONV_PTR_MEM_BASE) {
-
 
2737
			/* Check for constant pointer to members */
-
 
2738
			IDENTIFIER fn = is_const_ptr_mem(a, 0);
-
 
2739
			if (!IS_NULL_id(fn)) {
-
 
2740
				CLASS_TYPE cs = parent_class(fn);
-
 
2741
				CLASS_TYPE ct = DEREF_ctype(type_ptr_mem_of(t));
-
 
2742
				GRAPH gr = find_base_class(ct, cs, 0);
-
 
2743
				bs = enc_ptr_mem(bs, t, fn, gr);
-
 
2744
				break;
-
 
2745
			}
-
 
2746
		}
-
 
2747
		bs = enc_base_cast_exp(bs, a, off, conv);
-
 
2748
		break;
-
 
2749
	}
-
 
2750
 
-
 
2751
	case exp_add_ptr_tag: {
-
 
2752
		/* Pointer additions */
-
 
2753
		EXP a = DEREF_exp(exp_add_ptr_ptr(e));
-
 
2754
		OFFSET off = DEREF_off(exp_add_ptr_off(e));
-
 
2755
		int virt = DEREF_int(exp_add_ptr_virt(e));
-
 
2756
		bs = enc_add_ptr(bs, a, LINK_NONE, off, virt);
-
 
2757
		break;
-
 
2758
	}
-
 
2759
 
-
 
2760
	case exp_offset_size_tag: {
-
 
2761
		/* Size of offset */
-
 
2762
		OFFSET off = DEREF_off(exp_offset_size_off(e));
-
 
2763
		TYPE s = DEREF_type(exp_offset_size_step(e));
-
 
2764
		ENC_offset_div(bs);
-
 
2765
		bs = enc_variety(bs, t);
-
 
2766
		bs = enc_offset(bs, off);
-
 
2767
		bs = enc_shape_offset(bs, s);
-
 
2768
		break;
-
 
2769
	}
-
 
2770
 
-
 
2771
	case exp_constr_tag: {
-
 
2772
		/* Constructor calls */
-
 
2773
		EXP a = DEREF_exp(exp_constr_call(e));
-
 
2774
		bs = enc_exp(bs, a);
-
 
2775
		break;
-
 
2776
	}
-
 
2777
 
-
 
2778
	case exp_destr_tag: {
-
 
2779
		/* Destructor calls */
-
 
2780
		EXP a = DEREF_exp(exp_destr_call(e));
-
 
2781
		bs = enc_exp(bs, a);
-
 
2782
		break;
-
 
2783
	}
-
 
2784
 
-
 
2785
	case exp_rtti_no_tag: {
-
 
2786
		/* Link-time type information */
-
 
2787
		TYPE s = DEREF_type(exp_rtti_no_arg(e));
-
 
2788
		ENC_make_int(bs);
-
 
2789
		bs = enc_variety(bs, t);
-
 
2790
		bs = enc_arith(bs, s, 0);
-
 
2791
		break;
-
 
2792
	}
-
 
2793
 
2762
	case exp_dynamic_tag : {
2794
	case exp_dynamic_tag: {
2763
	    /* Dynamic initialisers */
2795
		/* Dynamic initialisers */
2764
	    EXP a = DEREF_exp ( exp_dynamic_arg ( e ) ) ;
2796
		EXP a = DEREF_exp(exp_dynamic_arg(e));
2765
	    bs = enc_exp ( bs, a ) ;
2797
		bs = enc_exp(bs, a);
-
 
2798
		break;
-
 
2799
	}
-
 
2800
 
-
 
2801
	case exp_aggregate_tag: {
-
 
2802
		/* Aggregate initialisers */
-
 
2803
		unsigned tt = TAG_type(t);
-
 
2804
		if (tt == type_array_tag) {
-
 
2805
			bs = enc_init_array(bs, e, NULL_nat, t);
-
 
2806
		} else if (tt == type_compound_tag) {
-
 
2807
			CLASS_TYPE ct = DEREF_ctype(type_compound_defn(t));
-
 
2808
			bs = enc_init_class(bs, e, ct);
-
 
2809
		}
-
 
2810
		break;
-
 
2811
	}
-
 
2812
 
-
 
2813
	case exp_nof_tag: {
-
 
2814
		/* Array initialisers */
-
 
2815
		int pad = 1;
-
 
2816
		EXP a = DEREF_exp(exp_nof_start(e));
-
 
2817
		NAT n = DEREF_nat(exp_nof_size(e));
-
 
2818
		EXP b = DEREF_exp(exp_nof_pad(e));
-
 
2819
		EXP c = DEREF_exp(exp_nof_end(e));
-
 
2820
		if (!IS_NULL_exp(c))ENC_concat_nof(bs);
-
 
2821
		if (!IS_NULL_exp(a)) {
-
 
2822
			/* Encode initial component */
-
 
2823
			if (IS_exp_aggregate(a) && is_zero_exp(b)) {
-
 
2824
				/* Deal with integral arrays */
-
 
2825
				bs = enc_init_array(bs, a, n, t);
2766
	    break ;
2826
				break;
-
 
2827
			}
-
 
2828
			if (is_zero_nat(n)) {
-
 
2829
				pad = 0;
-
 
2830
			} else {
-
 
2831
				ENC_concat_nof(bs);
-
 
2832
			}
-
 
2833
			bs = enc_exp(bs, a);
-
 
2834
		}
-
 
2835
		if (pad) {
-
 
2836
			ENC_n_copies(bs);
-
 
2837
			bs = enc_nat(bs, n, 1);
-
 
2838
			if (IS_NULL_exp(b)) {
-
 
2839
				TYPE s = DEREF_type(type_array_sub(t));
-
 
2840
				bs = enc_null_exp(bs, s);
-
 
2841
			} else {
-
 
2842
				bs = enc_exp(bs, b);
-
 
2843
			}
-
 
2844
		}
-
 
2845
		if (!IS_NULL_exp(c)) {
-
 
2846
			bs = enc_exp(bs, c);
-
 
2847
		}
-
 
2848
		break;
-
 
2849
	}
-
 
2850
 
-
 
2851
	case exp_call_tag: {
-
 
2852
		/* Shouldn't happen */
-
 
2853
		EXP a = DEREF_exp(exp_call_ptr(e));
-
 
2854
		EXP b = DEREF_exp(exp_call_arg(e));
-
 
2855
		ENC_SEQ_SMALL(bs, 1);
-
 
2856
		bs = enc_exp(bs, a);
-
 
2857
		bs = enc_exp(bs, b);
-
 
2858
		break;
-
 
2859
	}
-
 
2860
 
-
 
2861
	case exp_not_tag:
-
 
2862
	case exp_log_and_tag:
-
 
2863
	case exp_log_or_tag:
-
 
2864
	case exp_test_tag:
-
 
2865
	case exp_compare_tag: {
-
 
2866
		/* Logical expressions */
-
 
2867
		bs = enc_logical(bs, e, t);
-
 
2868
		break;
-
 
2869
	}
-
 
2870
 
-
 
2871
	case exp_assembler_tag: {
-
 
2872
		/* Assembler expression */
-
 
2873
		bs = enc_asm(bs, e);
-
 
2874
		break;
-
 
2875
	}
-
 
2876
 
-
 
2877
	case exp_fail_tag: {
-
 
2878
		/* Install-time failure expression */
-
 
2879
		string s = DEREF_string(exp_fail_msg(e));
-
 
2880
		ENC_fail_installer(bs);
-
 
2881
		ENC_make_string(bs);
-
 
2882
		bs = enc_ustring(bs, s);
-
 
2883
		break;
-
 
2884
	}
-
 
2885
 
-
 
2886
	case exp_token_tag: {
-
 
2887
		/* Token applications */
-
 
2888
		IDENTIFIER tok = DEREF_id(exp_token_tok(e));
-
 
2889
		LIST(TOKEN)args = DEREF_list(exp_token_args(e));
-
 
2890
		bs = enc_token(bs, tok, args);
-
 
2891
		break;
-
 
2892
	}
-
 
2893
 
-
 
2894
	case exp_dummy_tag: {
-
 
2895
		/* Dummy identifier tag */
-
 
2896
		EXP a = DEREF_exp(exp_dummy_value(e));
-
 
2897
		if (IS_NULL_exp(a)) {
-
 
2898
			ulong n = DEREF_ulong(exp_dummy_no(e));
-
 
2899
			OFFSET off = DEREF_off(exp_dummy_off(e));
-
 
2900
			int cnt = DEREF_int(exp_dummy_cont(e));
-
 
2901
			int virt = DEREF_int(exp_dummy_virt(e));
-
 
2902
			bs = enc_dummy_exp(bs, t, n, off, cnt, virt);
-
 
2903
		} else {
-
 
2904
			bs = enc_exp(bs, a);
-
 
2905
		}
-
 
2906
		break;
-
 
2907
	}
-
 
2908
 
-
 
2909
#if LANGUAGE_CPP
-
 
2910
	case exp_alloc_tag: {
-
 
2911
		/* Allocator calls */
-
 
2912
		bs = enc_alloc(bs, e);
-
 
2913
		break;
-
 
2914
	}
-
 
2915
 
-
 
2916
	case exp_dealloc_tag: {
-
 
2917
		/* Deallocator calls */
-
 
2918
		bs = enc_dealloc(bs, e, LINK_NONE);
-
 
2919
		break;
-
 
2920
	}
-
 
2921
 
-
 
2922
	case exp_rtti_tag: {
-
 
2923
		/* Run-time type information */
-
 
2924
		if (IS_type_compound(t)) {
-
 
2925
			/* Make sure that 'type_info' is completed */
-
 
2926
			CLASS_TYPE ct = DEREF_ctype(type_compound_defn(t));
-
 
2927
			IGNORE compile_class(ct);
-
 
2928
		}
-
 
2929
		bs = enc_rtti_exp(bs, e);
-
 
2930
		break;
-
 
2931
	}
-
 
2932
 
-
 
2933
	case exp_rtti_type_tag: {
-
 
2934
		/* Run-time type information */
-
 
2935
		TYPE s = DEREF_type(exp_rtti_type_arg(e));
-
 
2936
		int op = DEREF_int(exp_rtti_type_op(e));
-
 
2937
		if (IS_type_compound(t)) {
-
 
2938
			/* Make sure that 'type_info' is completed */
-
 
2939
			CLASS_TYPE ct = DEREF_ctype(type_compound_defn(t));
-
 
2940
			IGNORE compile_class(ct);
-
 
2941
		}
-
 
2942
		bs = enc_rtti_type(bs, s, op);
-
 
2943
		break;
-
 
2944
	}
-
 
2945
 
-
 
2946
	case exp_dyn_cast_tag: {
-
 
2947
		/* Dynamic cast expressions */
-
 
2948
		bs = enc_dyn_cast(bs, e);
-
 
2949
		break;
-
 
2950
	}
-
 
2951
 
-
 
2952
	case exp_initialiser_tag: {
-
 
2953
		/* Constructor initialisers */
-
 
2954
		bs = enc_ctor_init(bs, e);
-
 
2955
		break;
-
 
2956
	}
-
 
2957
 
-
 
2958
	case exp_exception_tag: {
-
 
2959
		/* Throw expression */
-
 
2960
		EXP a = DEREF_exp(exp_exception_arg(e));
-
 
2961
		EXP b = DEREF_exp(exp_exception_size(e));
-
 
2962
		EXP d = DEREF_exp(exp_exception_destr(e));
-
 
2963
		bs = enc_throw(bs, a, b, d);
-
 
2964
		break;
2767
	}
2965
	}
2768
 
2966
 
2769
	case exp_aggregate_tag : {
-
 
2770
	    /* Aggregate initialisers */
-
 
2771
	    unsigned tt = TAG_type ( t ) ;
-
 
2772
	    if ( tt == type_array_tag ) {
-
 
2773
		bs = enc_init_array ( bs, e, NULL_nat, t ) ;
-
 
2774
	    } else if ( tt == type_compound_tag ) {
-
 
2775
		CLASS_TYPE ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
-
 
2776
		bs = enc_init_class ( bs, e, ct ) ;
-
 
2777
	    }
-
 
2778
	    break ;
-
 
2779
	}
-
 
2780
 
-
 
2781
	case exp_nof_tag : {
2967
	case exp_thrown_tag: {
2782
	    /* Array initialisers */
2968
		/* Thrown expression */
2783
	    int pad = 1 ;
-
 
2784
	    EXP a = DEREF_exp ( exp_nof_start ( e ) ) ;
-
 
2785
	    NAT n = DEREF_nat ( exp_nof_size ( e ) ) ;
2969
		int done = DEREF_int(exp_thrown_done(e));
2786
	    EXP b = DEREF_exp ( exp_nof_pad ( e ) ) ;
-
 
2787
	    EXP c = DEREF_exp ( exp_nof_end ( e ) ) ;
-
 
2788
	    if ( !IS_NULL_exp ( c ) ) ENC_concat_nof ( bs ) ;
-
 
2789
	    if ( !IS_NULL_exp ( a ) ) {
-
 
2790
		/* Encode initial component */
-
 
2791
		if ( IS_exp_aggregate ( a ) && is_zero_exp ( b ) ) {
-
 
2792
		    /* Deal with integral arrays */
-
 
2793
		    bs = enc_init_array ( bs, a, n, t ) ;
-
 
2794
		    break ;
2970
		if (done) {
2795
		}
-
 
2796
		if ( is_zero_nat ( n ) ) {
2971
			bs = enc_special(bs, TOK_except_caught);
2797
		    pad = 0 ;
-
 
2798
		} else {
2972
		} else {
2799
		    ENC_concat_nof ( bs ) ;
2973
			bs = enc_thrown(bs, t);
2800
		}
2974
		}
2801
		bs = enc_exp ( bs, a ) ;
-
 
2802
	    }
-
 
2803
	    if ( pad ) {
-
 
2804
		ENC_n_copies ( bs ) ;
-
 
2805
		bs = enc_nat ( bs, n, 1 ) ;
-
 
2806
		if ( IS_NULL_exp ( b ) ) {
-
 
2807
		    TYPE s = DEREF_type ( type_array_sub ( t ) ) ;
-
 
2808
		    bs = enc_null_exp ( bs, s ) ;
-
 
2809
		} else {
-
 
2810
		    bs = enc_exp ( bs, b ) ;
-
 
2811
		}
-
 
2812
	    }
-
 
2813
	    if ( !IS_NULL_exp ( c ) ) bs = enc_exp ( bs, c ) ;
-
 
2814
	    break ;
-
 
2815
	}
-
 
2816
 
-
 
2817
	case exp_call_tag : {
-
 
2818
	    /* Shouldn't happen */
-
 
2819
	    EXP a = DEREF_exp ( exp_call_ptr ( e ) ) ;
-
 
2820
	    EXP b = DEREF_exp ( exp_call_arg ( e ) ) ;
-
 
2821
	    ENC_SEQ_SMALL ( bs, 1 ) ;
-
 
2822
	    bs = enc_exp ( bs, a ) ;
-
 
2823
	    bs = enc_exp ( bs, b ) ;
-
 
2824
	    break ;
-
 
2825
	}
-
 
2826
 
-
 
2827
	case exp_not_tag :
-
 
2828
	case exp_log_and_tag :
-
 
2829
	case exp_log_or_tag :
-
 
2830
	case exp_test_tag :
-
 
2831
	case exp_compare_tag : {
-
 
2832
	    /* Logical expressions */
-
 
2833
	    bs = enc_logical ( bs, e, t ) ;
-
 
2834
	    break ;
-
 
2835
	}
-
 
2836
 
-
 
2837
	case exp_assembler_tag : {
-
 
2838
	    /* Assembler expression */
-
 
2839
	    bs = enc_asm ( bs, e ) ;
-
 
2840
	    break ;
-
 
2841
	}
-
 
2842
 
-
 
2843
	case exp_fail_tag : {
-
 
2844
	    /* Install-time failure expression */
-
 
2845
	    string s = DEREF_string ( exp_fail_msg ( e ) ) ;
-
 
2846
	    ENC_fail_installer ( bs ) ;
-
 
2847
	    ENC_make_string ( bs ) ;
-
 
2848
	    bs = enc_ustring ( bs, s ) ;
-
 
2849
	    break ;
-
 
2850
	}
-
 
2851
 
-
 
2852
	case exp_token_tag : {
-
 
2853
	    /* Token applications */
-
 
2854
	    IDENTIFIER tok = DEREF_id ( exp_token_tok ( e ) ) ;
-
 
2855
	    LIST ( TOKEN ) args = DEREF_list ( exp_token_args ( e ) ) ;
-
 
2856
	    bs = enc_token ( bs, tok, args ) ;
-
 
2857
	    break ;
-
 
2858
	}
-
 
2859
 
-
 
2860
	case exp_dummy_tag : {
-
 
2861
	    /* Dummy identifier tag */
-
 
2862
	    EXP a = DEREF_exp ( exp_dummy_value ( e ) ) ;
-
 
2863
	    if ( IS_NULL_exp ( a ) ) {
-
 
2864
		ulong n = DEREF_ulong ( exp_dummy_no ( e ) ) ;
-
 
2865
		OFFSET off = DEREF_off ( exp_dummy_off ( e ) ) ;
-
 
2866
		int cnt = DEREF_int ( exp_dummy_cont ( e ) ) ;
-
 
2867
		int virt = DEREF_int ( exp_dummy_virt ( e ) ) ;
-
 
2868
		bs = enc_dummy_exp ( bs, t, n, off, cnt, virt ) ;
-
 
2869
	    } else {
-
 
2870
		bs = enc_exp ( bs, a ) ;
-
 
2871
	    }
-
 
2872
	    break ;
-
 
2873
	}
-
 
2874
 
-
 
2875
#if LANGUAGE_CPP
-
 
2876
	case exp_alloc_tag : {
-
 
2877
	    /* Allocator calls */
-
 
2878
	    bs = enc_alloc ( bs, e ) ;
-
 
2879
	    break ;
-
 
2880
	}
-
 
2881
 
-
 
2882
	case exp_dealloc_tag : {
-
 
2883
	    /* Deallocator calls */
-
 
2884
	    bs = enc_dealloc ( bs, e, LINK_NONE ) ;
-
 
2885
	    break ;
-
 
2886
	}
-
 
2887
 
-
 
2888
	case exp_rtti_tag : {
-
 
2889
	    /* Run-time type information */
-
 
2890
	    if ( IS_type_compound ( t ) ) {
-
 
2891
		/* Make sure that 'type_info' is completed */
-
 
2892
		CLASS_TYPE ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
-
 
2893
		IGNORE compile_class ( ct ) ;
-
 
2894
	    }
-
 
2895
	    bs = enc_rtti_exp ( bs, e ) ;
-
 
2896
	    break ;
-
 
2897
	}
-
 
2898
 
-
 
2899
	case exp_rtti_type_tag : {
-
 
2900
	    /* Run-time type information */
-
 
2901
	    TYPE s = DEREF_type ( exp_rtti_type_arg ( e ) ) ;
-
 
2902
	    int op = DEREF_int ( exp_rtti_type_op ( e ) ) ;
-
 
2903
	    if ( IS_type_compound ( t ) ) {
-
 
2904
		/* Make sure that 'type_info' is completed */
-
 
2905
		CLASS_TYPE ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
-
 
2906
		IGNORE compile_class ( ct ) ;
-
 
2907
	    }
-
 
2908
	    bs = enc_rtti_type ( bs, s, op ) ;
-
 
2909
	    break ;
2975
		break;
2910
	}
2976
	}
-
 
2977
#endif
2911
 
2978
 
-
 
2979
	case exp_comma_tag:
-
 
2980
	case exp_if_stmt_tag:
-
 
2981
	case exp_hash_if_tag:
2912
	case exp_dyn_cast_tag : {
2982
	case exp_location_tag: {
2913
	    /* Dynamic cast expressions */
2983
		/* Statement-like expressions */
2914
	    bs = enc_dyn_cast ( bs, e ) ;
2984
		bs = enc_stmt_exp(bs, e, t, 1);
2915
	    break ;
2985
		break;
2916
	}
2986
	}
2917
 
2987
 
-
 
2988
	case exp_reach_tag:
-
 
2989
	case exp_unreach_tag:
-
 
2990
	case exp_sequence_tag:
-
 
2991
	case exp_solve_stmt_tag:
-
 
2992
	case exp_decl_stmt_tag:
-
 
2993
	case exp_while_stmt_tag:
-
 
2994
	case exp_do_stmt_tag:
-
 
2995
	case exp_switch_stmt_tag:
-
 
2996
	case exp_return_stmt_tag:
-
 
2997
	case exp_goto_stmt_tag:
-
 
2998
	case exp_label_stmt_tag:
-
 
2999
	case exp_try_block_tag:
2918
	case exp_initialiser_tag : {
3000
	case exp_handler_tag: {
2919
	    /* Constructor initialisers */
3001
		/* Statements */
2920
	    bs = enc_ctor_init ( bs, e ) ;
3002
		bs = enc_stmt(bs, e);
2921
	    break ;
3003
		break;
2922
	}
3004
	}
2923
 
3005
 
2924
	case exp_exception_tag : {
3006
	case exp_member_tag:
2925
	    /* Throw expression */
3007
	case exp_ambiguous_tag:
2926
	    EXP a = DEREF_exp ( exp_exception_arg ( e ) ) ;
3008
	case exp_undeclared_tag:
-
 
3009
	case exp_set_tag:
-
 
3010
	case exp_unused_tag:
-
 
3011
	case exp_op_tag:
-
 
3012
	case exp_opn_tag:
2927
	    EXP b = DEREF_exp ( exp_exception_size ( e ) ) ;
3013
	case exp_uncompiled_tag:
-
 
3014
	default: {
2928
	    EXP d = DEREF_exp ( exp_exception_destr ( e ) ) ;
3015
		/* Illegal expressions */
2929
	    bs = enc_throw ( bs, a, b, d ) ;
3016
		ENC_make_top(bs);
2930
	    break ;
3017
		break;
2931
	}
3018
	}
2932
 
-
 
2933
	case exp_thrown_tag : {
-
 
2934
	    /* Thrown expression */
-
 
2935
	    int done = DEREF_int ( exp_thrown_done ( e ) ) ;
-
 
2936
	    if ( done ) {
-
 
2937
		bs = enc_special ( bs, TOK_except_caught ) ;
-
 
2938
	    } else {
-
 
2939
		bs = enc_thrown ( bs, t ) ;
-
 
2940
	    }
-
 
2941
	    break ;
-
 
2942
	}
-
 
2943
#endif
-
 
2944
 
-
 
2945
	case exp_comma_tag :
-
 
2946
	case exp_if_stmt_tag :
-
 
2947
	case exp_hash_if_tag :
-
 
2948
	case exp_location_tag : {
-
 
2949
	    /* Statement-like expressions */
-
 
2950
	    bs = enc_stmt_exp ( bs, e, t, 1 ) ;
-
 
2951
	    break ;
-
 
2952
	}
-
 
2953
 
-
 
2954
	case exp_reach_tag :
-
 
2955
	case exp_unreach_tag :
-
 
2956
	case exp_sequence_tag :
-
 
2957
	case exp_solve_stmt_tag :
-
 
2958
	case exp_decl_stmt_tag :
-
 
2959
	case exp_while_stmt_tag :
-
 
2960
	case exp_do_stmt_tag :
-
 
2961
	case exp_switch_stmt_tag :
-
 
2962
	case exp_return_stmt_tag :
-
 
2963
	case exp_goto_stmt_tag :
-
 
2964
	case exp_label_stmt_tag :
-
 
2965
	case exp_try_block_tag :
-
 
2966
	case exp_handler_tag : {
-
 
2967
	    /* Statements */
-
 
2968
	    bs = enc_stmt ( bs, e ) ;
-
 
2969
	    break ;
-
 
2970
	}
-
 
2971
 
-
 
2972
	case exp_member_tag :
-
 
2973
	case exp_ambiguous_tag :
-
 
2974
	case exp_undeclared_tag :
-
 
2975
	case exp_set_tag :
-
 
2976
	case exp_unused_tag :
-
 
2977
	case exp_op_tag :
-
 
2978
	case exp_opn_tag :
-
 
2979
	case exp_uncompiled_tag :
-
 
2980
	default : {
-
 
2981
	    /* Illegal expressions */
-
 
2982
	    ENC_make_top ( bs ) ;
-
 
2983
	    break ;
-
 
2984
	}
3019
	}
2985
    }
-
 
2986
    return ( bs ) ;
3020
	return (bs);
2987
}
3021
}
2988
 
3022
 
2989
 
3023
 
2990
#endif /* TDF_OUTPUT */
3024
#endif /* TDF_OUTPUT */