Subversion Repositories tendra.SVN

Rev

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

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
Line 60... Line 90...
60
#include "entry.h"
90
#include "entry.h"
61
#include "name.h"
91
#include "name.h"
62
#include "output.h"
92
#include "output.h"
63
#include "rstack.h"
93
#include "rstack.h"
64
#include "type.h"
94
#include "type.h"
65
 
95
 
66
/*--------------------------------------------------------------------------*/
96
/*--------------------------------------------------------------------------*/
67
 
97
 
68
static void
98
static void
69
c_output_param_assign PROTO_N ((info, inputs))
99
c_output_param_assign(COutputInfoP info, TypeTupleP inputs)
70
		      PROTO_T (COutputInfoP info X
-
 
71
			       TypeTupleP   inputs)
-
 
72
{
100
{
73
    OStreamP        ostream = c_out_info_ostream (info);
101
    OStreamP        ostream = c_out_info_ostream(info);
74
    TypeTupleEntryP ptr;
102
    TypeTupleEntryP ptr;
75
 
103
 
76
    for (ptr = inputs->head; ptr; ptr = ptr->next) {
104
    for (ptr = inputs->head; ptr; ptr = ptr->next) {
77
	TypeP  type = entry_get_type (ptr->type);
105
	TypeP  type = entry_get_type(ptr->type);
78
	CCodeP code;
106
	CCodeP code;
79
 
107
 
80
	if ((!(ptr->reference)) &&
108
	if ((!(ptr->reference)) &&
81
	    ((code = type_get_param_assign_code (type)) != NIL (CCodeP))) {
109
	    ((code = type_get_param_assign_code(type)) != NIL(CCodeP))) {
82
	    KeyP key = entry_key (ptr->type);
110
	    KeyP key = entry_key(ptr->type);
83
 
111
 
84
	    c_output_key_message (info, "/* BEGINNING OF PARAM ASSIGNMENT: ",
112
	    c_output_key_message(info, "/* BEGINNING OF PARAM ASSIGNMENT: ",
85
				  key, " */", C_INDENT_STEP);
113
				 key, " */", C_INDENT_STEP);
86
	    c_output_open (info, C_INDENT_STEP);
114
	    c_output_open(info, C_INDENT_STEP);
87
	    c_output_location (info, c_code_file (code),
115
	    c_output_location(info, c_code_file(code), c_code_line(code));
88
			       c_code_line (code));
-
 
89
	    c_output_c_code_param_assign (info, code, ptr->type, ptr->name);
116
	    c_output_c_code_param_assign(info, code, ptr->type, ptr->name);
90
	    c_output_location (info, ostream_name (ostream),
117
	    c_output_location(info, ostream_name(ostream),
91
			       ostream_line (ostream) + 1);
118
			      ostream_line(ostream) + 1);
92
	    c_output_close (info, C_INDENT_STEP);
119
	    c_output_close(info, C_INDENT_STEP);
93
	    c_output_key_message (info, "/* END OF PARAM ASSIGNMENT: ",
120
	    c_output_key_message(info, "/* END OF PARAM ASSIGNMENT: ",
94
				  key, " */", C_INDENT_STEP);
121
				 key, " */", C_INDENT_STEP);
95
	}
122
	}
96
    }
123
    }
97
}
124
}
98
 
125
 
99
static void
126
static void
100
c_output_non_ansi_params PROTO_N ((info, inputs, outputs))
127
c_output_non_ansi_params(COutputInfoP info, TypeTupleP inputs,
101
			 PROTO_T (COutputInfoP info X
-
 
102
				  TypeTupleP   inputs X
-
 
103
				  TypeTupleP   outputs)
128
			 TypeTupleP outputs)
104
{
129
{
105
    OStreamP        ostream    = c_out_info_ostream (info);
130
    OStreamP        ostream    = c_out_info_ostream(info);
106
    NStringP        in_prefix  = c_out_info_in_prefix (info);
131
    NStringP        in_prefix  = c_out_info_in_prefix(info);
107
    NStringP        out_prefix = c_out_info_out_prefix (info);
132
    NStringP        out_prefix = c_out_info_out_prefix(info);
108
    CStringP        sep        = "";
133
    CStringP        sep        = "";
109
    TypeTupleEntryP ptr;
134
    TypeTupleEntryP ptr;
110
 
135
 
111
    write_char (ostream, '(');
136
    write_char(ostream, '(');
112
    for (ptr = inputs->head; ptr; ptr = ptr->next) {
137
    for (ptr = inputs->head; ptr; ptr = ptr->next) {
113
	write_cstring (ostream, sep);
138
	write_cstring(ostream, sep);
114
	if ((!(ptr->reference)) &&
139
	if ((!(ptr->reference)) &&
115
	    (type_get_assign_code (entry_get_type (ptr->type)) !=
140
	    (type_get_assign_code(entry_get_type(ptr->type)) !=
116
	     NIL (GenericP))) {
141
	     NIL(GenericP))) {
117
	    c_output_key (info, entry_key (ptr->name), out_prefix);
142
	    c_output_key(info, entry_key(ptr->name), out_prefix);
118
	} else {
143
	} else {
119
	    c_output_key (info, entry_key (ptr->name), in_prefix);
144
	    c_output_key(info, entry_key(ptr->name), in_prefix);
120
	}
145
	}
121
	sep = ", ";
146
	sep = ", ";
122
    }
147
    }
123
    for (ptr = outputs->head; ptr; ptr = ptr->next) {
148
    for (ptr = outputs->head; ptr; ptr = ptr->next) {
124
	write_cstring (ostream, sep);
149
	write_cstring(ostream, sep);
125
	c_output_key (info, entry_key (ptr->name), out_prefix);
150
	c_output_key(info, entry_key(ptr->name), out_prefix);
126
	sep = ", ";
151
	sep = ", ";
127
    }
152
    }
128
    write_char (ostream, ')');
153
    write_char(ostream, ')');
129
}
154
}
130
 
155
 
131
static void
156
static void
132
c_output_non_ansi_type_defn PROTO_N ((info, inputs, outputs))
157
c_output_non_ansi_type_defn(COutputInfoP info, TypeTupleP inputs,
133
			    PROTO_T (COutputInfoP info X
-
 
134
				     TypeTupleP   inputs X
-
 
135
				     TypeTupleP   outputs)
158
			    TypeTupleP outputs)
136
{
159
{
137
    OStreamP        ostream    = c_out_info_ostream (info);
160
    OStreamP        ostream    = c_out_info_ostream(info);
138
    NStringP        in_prefix  = c_out_info_in_prefix (info);
161
    NStringP        in_prefix  = c_out_info_in_prefix(info);
139
    NStringP        out_prefix = c_out_info_out_prefix (info);
162
    NStringP        out_prefix = c_out_info_out_prefix(info);
140
    BoolT           specials   = FALSE;
163
    BoolT           specials   = FALSE;
141
    TypeTupleEntryP ptr;
164
    TypeTupleEntryP ptr;
142
 
165
 
143
    c_output_non_ansi_params (info, inputs, outputs);
166
    c_output_non_ansi_params(info, inputs, outputs);
144
    write_newline (ostream);
167
    write_newline(ostream);
145
    for (ptr = inputs->head; ptr; ptr = ptr->next) {
168
    for (ptr = inputs->head; ptr; ptr = ptr->next) {
146
	output_indent (c_out_info_info (info), C_INDENT_FOR_PARAM);
169
	output_indent(c_out_info_info(info), C_INDENT_FOR_PARAM);
147
	c_output_mapped_key (info, ptr->type);
170
	c_output_mapped_key(info, ptr->type);
148
	write_char (ostream, ' ');
171
	write_char(ostream, ' ');
149
	if (ptr->reference) {
172
	if (ptr->reference) {
150
	    write_char (ostream, '*');
173
	    write_char(ostream, '*');
151
	    c_output_key (info, entry_key (ptr->name), in_prefix);
174
	    c_output_key(info, entry_key(ptr->name), in_prefix);
152
	} else if (type_get_assign_code (entry_get_type (ptr->type)) !=
175
	} else if (type_get_assign_code(entry_get_type(ptr->type)) !=
153
		   NIL (GenericP)) {
176
		   NIL(GenericP)) {
154
	    write_char (ostream, '*');
177
	    write_char(ostream, '*');
155
	    c_output_key (info, entry_key (ptr->name), out_prefix);
178
	    c_output_key(info, entry_key(ptr->name), out_prefix);
156
	    specials = TRUE;
179
	    specials = TRUE;
157
	} else {
180
	} else {
158
	    c_output_key (info, entry_key (ptr->name), in_prefix);
181
	    c_output_key(info, entry_key(ptr->name), in_prefix);
159
	}
182
	}
160
	write_char (ostream, ';');
183
	write_char(ostream, ';');
161
	write_newline (ostream);
184
	write_newline(ostream);
162
    }
185
    }
163
    for (ptr = outputs->head; ptr; ptr = ptr->next) {
186
    for (ptr = outputs->head; ptr; ptr = ptr->next) {
164
	output_indent (c_out_info_info (info), C_INDENT_FOR_PARAM);
187
	output_indent(c_out_info_info(info), C_INDENT_FOR_PARAM);
165
	c_output_mapped_key (info, ptr->type);
188
	c_output_mapped_key(info, ptr->type);
166
	write_cstring (ostream, " *");
189
	write_cstring(ostream, " *");
167
	c_output_key (info, entry_key (ptr->name), out_prefix);
190
	c_output_key(info, entry_key(ptr->name), out_prefix);
168
	write_char (ostream, ';');
191
	write_char(ostream, ';');
169
	write_newline (ostream);
192
	write_newline(ostream);
170
    }
193
    }
171
    write_char (ostream, '{');
194
    write_char(ostream, '{');
172
    write_newline (ostream);
195
    write_newline(ostream);
173
    if (specials) {
196
    if (specials) {
174
	for (ptr = inputs->head; ptr; ptr = ptr->next) {
197
	for (ptr = inputs->head; ptr; ptr = ptr->next) {
175
	    if ((!(ptr->reference)) &&
198
	    if ((!(ptr->reference)) &&
176
		(type_get_assign_code (entry_get_type (ptr->type)) !=
199
		(type_get_assign_code(entry_get_type(ptr->type)) !=
177
		 NIL (GenericP))) {
200
		 NIL(GenericP))) {
178
		output_indent (c_out_info_info (info), C_INDENT_STEP);
201
		output_indent(c_out_info_info(info), C_INDENT_STEP);
179
		c_output_mapped_key (info, ptr->type);
202
		c_output_mapped_key(info, ptr->type);
180
		write_char (ostream, ' ');
203
		write_char(ostream, ' ');
181
		c_output_key (info, entry_key (ptr->name), in_prefix);
204
		c_output_key(info, entry_key(ptr->name), in_prefix);
182
		write_char (ostream, ';');
205
		write_char(ostream, ';');
183
		write_newline (ostream);
206
		write_newline(ostream);
184
	    }
207
	    }
185
	}
208
	}
186
    }
209
    }
187
    if (outputs->head) {
210
    if (outputs->head) {
188
	for (ptr = outputs->head; ptr; ptr = ptr->next) {
211
	for (ptr = outputs->head; ptr; ptr = ptr->next) {
189
	    output_indent (c_out_info_info (info), C_INDENT_STEP);
212
	    output_indent(c_out_info_info(info), C_INDENT_STEP);
190
	    c_output_mapped_key (info, ptr->type);
213
	    c_output_mapped_key(info, ptr->type);
191
	    write_char (ostream, ' ');
214
	    write_char(ostream, ' ');
192
	    c_output_key (info, entry_key (ptr->name), in_prefix);
215
	    c_output_key(info, entry_key(ptr->name), in_prefix);
193
	    write_char (ostream, ';');
216
	    write_char(ostream, ';');
194
	    write_newline (ostream);
217
	    write_newline(ostream);
195
	}
218
	}
196
    }
219
    }
197
    if (specials || (outputs->head != NIL (TypeTupleEntryP))) {
220
    if (specials || (outputs->head != NIL(TypeTupleEntryP))) {
198
	write_newline (ostream);
221
	write_newline(ostream);
199
    }
222
    }
200
    if (specials) {
223
    if (specials) {
201
	c_output_param_assign (info, inputs);
224
	c_output_param_assign(info, inputs);
202
    }
225
    }
203
}
226
}
204
 
227
 
205
static void
228
static void
206
c_output_ansi_type_defn PROTO_N ((info, inputs, outputs))
229
c_output_ansi_type_defn(COutputInfoP info, TypeTupleP inputs,
207
			PROTO_T (COutputInfoP info X
-
 
208
				 TypeTupleP   inputs X
-
 
209
				 TypeTupleP   outputs)
230
			TypeTupleP outputs)
210
{
231
{
211
    OStreamP        ostream    = c_out_info_ostream (info);
232
    OStreamP        ostream    = c_out_info_ostream(info);
212
    NStringP        in_prefix  = c_out_info_in_prefix (info);
233
    NStringP        in_prefix  = c_out_info_in_prefix(info);
213
    NStringP        out_prefix = c_out_info_out_prefix (info);
234
    NStringP        out_prefix = c_out_info_out_prefix(info);
214
    CStringP        sep        = "";
235
    CStringP        sep        = "";
215
    BoolT           specials   = FALSE;
236
    BoolT           specials   = FALSE;
216
    TypeTupleEntryP ptr;
237
    TypeTupleEntryP ptr;
217
    BoolT           ossg       = c_out_info_get_ossg (info);
-
 
218
 
238
 
219
    if ((inputs->head == NIL (TypeTupleEntryP)) &&
239
    if ((inputs->head == NIL(TypeTupleEntryP)) &&
220
	(outputs->head == NIL (TypeTupleEntryP))) {
240
	(outputs->head == NIL(TypeTupleEntryP))) {
221
	if (ossg) {
-
 
222
	    write_cstring (ostream, "PROTO_Z ()");
-
 
223
	} else {
-
 
224
	    write_cstring (ostream, "(void)");
241
	    write_cstring(ostream, "(void)");
225
	}
-
 
226
    } else {
242
    } else {
227
	if (ossg) {
-
 
228
	    write_cstring (ostream, "PROTO_N (");
-
 
229
	    c_output_non_ansi_params (info, inputs, outputs);
-
 
230
	    write_char (ostream, ')');
-
 
231
	    write_newline (ostream);
-
 
232
	    write_cstring (ostream, "  PROTO_T ");
-
 
233
	}
-
 
234
 
-
 
235
	write_char (ostream, '(');
243
	write_char(ostream, '(');
236
	for (ptr = inputs->head; ptr; ptr = ptr->next) {
244
	for (ptr = inputs->head; ptr; ptr = ptr->next) {
237
	    write_cstring (ostream, sep);
245
	    write_cstring(ostream, sep);
238
	    c_output_mapped_key (info, ptr->type);
246
	    c_output_mapped_key(info, ptr->type);
239
	    write_char (ostream, ' ');
247
	    write_char(ostream, ' ');
240
	    if (ptr->reference) {
248
	    if (ptr->reference) {
241
		write_char (ostream, '*');
249
		write_char(ostream, '*');
242
		c_output_key (info, entry_key (ptr->name), in_prefix);
250
		c_output_key(info, entry_key(ptr->name), in_prefix);
243
	    } else if (type_get_assign_code (entry_get_type (ptr->type)) !=
251
	    } else if (type_get_assign_code(entry_get_type(ptr->type)) !=
244
		       NIL (GenericP)) {
252
		       NIL(GenericP)) {
245
		write_char (ostream, '*');
253
		write_char(ostream, '*');
246
		c_output_key (info, entry_key (ptr->name), out_prefix);
254
		c_output_key(info, entry_key(ptr->name), out_prefix);
247
		specials = TRUE;
255
		specials = TRUE;
248
	    } else {
256
	    } else {
249
		c_output_key (info, entry_key (ptr->name), in_prefix);
257
		c_output_key(info, entry_key(ptr->name), in_prefix);
250
	    }
258
	    }
251
	    sep = (ossg ? " X " : ", ");
259
	    sep = ", ";
252
	}
260
	}
253
	for (ptr = outputs->head; ptr; ptr = ptr->next) {
261
	for (ptr = outputs->head; ptr; ptr = ptr->next) {
254
	    write_cstring (ostream, sep);
262
	    write_cstring(ostream, sep);
255
	    c_output_mapped_key (info, ptr->type);
263
	    c_output_mapped_key(info, ptr->type);
256
	    write_cstring (ostream, " *");
264
	    write_cstring(ostream, " *");
257
	    c_output_key (info, entry_key (ptr->name), out_prefix);
265
	    c_output_key(info, entry_key(ptr->name), out_prefix);
258
	    sep = (ossg ? " X " : ", ");
266
	    sep = ", ";
259
	}
267
	}
260
	write_char (ostream, ')');
268
	write_char(ostream, ')');
261
    }
269
    }
262
    write_newline (ostream);
270
    write_newline(ostream);
263
    write_char (ostream, '{');
271
    write_char(ostream, '{');
264
    write_newline (ostream);
272
    write_newline(ostream);
265
    if (specials) {
273
    if (specials) {
266
	for (ptr = inputs->head; ptr; ptr = ptr->next) {
274
	for (ptr = inputs->head; ptr; ptr = ptr->next) {
267
	    if ((!(ptr->reference)) &&
275
	    if ((!(ptr->reference)) &&
268
		(type_get_assign_code (entry_get_type (ptr->type)) !=
276
		(type_get_assign_code(entry_get_type(ptr->type)) !=
269
		 NIL (GenericP))) {
277
		 NIL(GenericP))) {
270
		output_indent (c_out_info_info (info), C_INDENT_STEP);
278
		output_indent(c_out_info_info(info), C_INDENT_STEP);
271
		c_output_mapped_key (info, ptr->type);
279
		c_output_mapped_key(info, ptr->type);
272
		write_char (ostream, ' ');
280
		write_char(ostream, ' ');
273
		c_output_key (info, entry_key (ptr->name), in_prefix);
281
		c_output_key(info, entry_key(ptr->name), in_prefix);
274
		write_char (ostream, ';');
282
		write_char(ostream, ';');
275
		write_newline (ostream);
283
		write_newline(ostream);
276
	    }
284
	    }
277
	}
285
	}
278
    }
286
    }
279
    if (outputs->head) {
287
    if (outputs->head) {
280
	for (ptr = outputs->head; ptr; ptr = ptr->next) {
288
	for (ptr = outputs->head; ptr; ptr = ptr->next) {
281
	    output_indent (c_out_info_info (info), C_INDENT_STEP);
289
	    output_indent(c_out_info_info(info), C_INDENT_STEP);
282
	    c_output_mapped_key (info, ptr->type);
290
	    c_output_mapped_key(info, ptr->type);
283
	    write_char (ostream, ' ');
291
	    write_char(ostream, ' ');
284
	    c_output_key (info, entry_key (ptr->name), in_prefix);
292
	    c_output_key(info, entry_key(ptr->name), in_prefix);
285
	    write_char (ostream, ';');
293
	    write_char(ostream, ';');
286
	    write_newline (ostream);
294
	    write_newline(ostream);
287
	}
295
	}
288
    }
296
    }
289
    if (specials || (outputs->head != NIL (TypeTupleEntryP))) {
297
    if (specials || (outputs->head != NIL(TypeTupleEntryP))) {
290
	write_newline (ostream);
298
	write_newline(ostream);
291
    }
299
    }
292
    if (specials) {
300
    if (specials) {
293
	c_output_param_assign (info, inputs);
301
	c_output_param_assign(info, inputs);
294
    }
302
    }
295
}
303
}
296
 
304
 
297
static EntryP
305
static EntryP
298
types_get_entry PROTO_N ((entry, state, type_ref, reference_ref))
306
types_get_entry(EntryP entry, SaveRStackP state, EntryP *type_ref,
299
		PROTO_T (EntryP      entry X
-
 
300
			 SaveRStackP state X
-
 
301
			 EntryP     *type_ref X
-
 
302
			 BoolT      *reference_ref)
307
		BoolT *reference_ref)
303
{
308
{
304
    EntryP trans_entry;
309
    EntryP trans_entry;
305
 
310
 
306
    trans_entry = rstack_get_translation (state, entry, type_ref,
311
    trans_entry = rstack_get_translation(state, entry, type_ref,
307
					  reference_ref);
312
					 reference_ref);
308
    if ((trans_entry == NIL (EntryP)) && (entry_is_non_local (entry))) {
313
    if ((trans_entry == NIL(EntryP)) && (entry_is_non_local(entry))) {
309
	trans_entry    = entry;
314
	trans_entry    = entry;
310
	*type_ref      = entry_get_non_local (entry);
315
	*type_ref      = entry_get_non_local(entry);
311
	*reference_ref = FALSE;
316
	*reference_ref = FALSE;
312
    }
317
    }
313
    ASSERT (trans_entry);
318
    ASSERT(trans_entry);
314
    return (trans_entry);
319
    return(trans_entry);
315
}
320
}
316
 
321
 
317
static KeyP
322
static KeyP
318
types_get_key PROTO_N ((entry, state, type_ref, reference_ref))
323
types_get_key(EntryP entry, SaveRStackP state, EntryP *type_ref,
319
	      PROTO_T (EntryP      entry X
-
 
320
		       SaveRStackP state X
-
 
321
		       EntryP     *type_ref X
-
 
322
		       BoolT      *reference_ref)
324
	      BoolT *reference_ref)
323
{
325
{
324
    EntryP trans = types_get_entry (entry, state, type_ref, reference_ref);
326
    EntryP trans = types_get_entry(entry, state, type_ref, reference_ref);
325
 
327
 
326
    return (entry_key (trans));
328
    return(entry_key(trans));
327
}
329
}
328
 
330
 
329
/*--------------------------------------------------------------------------*/
331
/*--------------------------------------------------------------------------*/
330
 
332
 
331
void
333
void
332
c_output_assign PROTO_N ((info, in_entry, out_entry, in_state, out_state,
334
c_output_assign(COutputInfoP info, EntryP in_entry, EntryP out_entry,
333
			  indent))
-
 
334
		PROTO_T (COutputInfoP info X
-
 
335
			 EntryP       in_entry X
-
 
336
			 EntryP       out_entry X
-
 
337
			 SaveRStackP  in_state X
-
 
338
			 SaveRStackP  out_state X
335
		SaveRStackP in_state, SaveRStackP out_state, unsigned indent)
339
			 unsigned     indent)
-
 
340
{
336
{
341
    OStreamP ostream  = c_out_info_ostream (info);
337
    OStreamP ostream  = c_out_info_ostream(info);
342
    EntryP   in_type;
338
    EntryP   in_type;
343
    EntryP   out_type;
339
    EntryP   out_type;
344
    BoolT    in_reference;
340
    BoolT    in_reference;
345
    BoolT    out_reference;
341
    BoolT    out_reference;
346
    EntryP   in_name  = types_get_entry (in_entry, in_state, &in_type,
342
    EntryP   in_name  = types_get_entry(in_entry, in_state, &in_type,
347
					 &in_reference);
343
					&in_reference);
348
    EntryP   out_name = types_get_entry (out_entry, out_state, &out_type,
344
    EntryP   out_name = types_get_entry(out_entry, out_state, &out_type,
349
					 &out_reference);
345
					&out_reference);
350
 
346
 
351
    ASSERT (in_type == out_type);
347
    ASSERT(in_type == out_type);
352
    if (in_name != out_name) {
348
    if (in_name != out_name) {
353
	TypeP  type = entry_get_type (in_type);
349
	TypeP  type = entry_get_type(in_type);
354
	CCodeP code;
350
	CCodeP code;
355
 
351
 
356
	if ((code = type_get_assign_code (type)) != NIL (CCodeP)) {
352
	if ((code = type_get_assign_code(type)) != NIL(CCodeP)) {
357
	    KeyP key = entry_key (in_type);
353
	    KeyP key = entry_key(in_type);
358
 
354
 
359
	    c_output_key_message (info, "/* BEGINNING OF ASSIGNMENT: ", key,
355
	    c_output_key_message (info, "/* BEGINNING OF ASSIGNMENT: ", key,
360
				  " */", indent);
356
				  " */", indent);
361
	    c_output_open (info, indent);
357
	    c_output_open(info, indent);
362
	    c_output_location (info, c_code_file (code), c_code_line (code));
358
	    c_output_location(info, c_code_file(code), c_code_line(code));
363
	    c_output_c_code_assign (info, code, in_type, in_name, out_name,
359
	    c_output_c_code_assign(info, code, in_type, in_name, out_name,
364
				    in_reference, out_reference);
360
				   in_reference, out_reference);
365
	    c_output_location (info, ostream_name (ostream),
361
	    c_output_location(info, ostream_name(ostream),
366
			       ostream_line (ostream) + 1);
362
			      ostream_line(ostream) + 1);
367
	    c_output_close (info, indent);
363
	    c_output_close(info, indent);
368
	    c_output_key_message (info, "/* END OF ASSIGNMENT: ", key, " */",
364
	    c_output_key_message (info, "/* END OF ASSIGNMENT: ", key, " */",
369
				  indent);
365
				  indent);
370
	} else {
366
	} else {
371
	    KeyP     in_key    = entry_key (in_name);
367
	    KeyP     in_key    = entry_key(in_name);
372
	    KeyP     out_key   = entry_key (out_name);
368
	    KeyP     out_key   = entry_key(out_name);
373
	    NStringP in_prefix = c_out_info_in_prefix (info);
369
	    NStringP in_prefix = c_out_info_in_prefix(info);
374
 
370
 
375
	    output_indent (c_out_info_info (info), indent);
371
	    output_indent(c_out_info_info(info), indent);
376
	    if (out_reference) {
372
	    if (out_reference) {
377
		write_char (ostream, '*');
373
		write_char(ostream, '*');
378
	    }
374
	    }
379
	    c_output_key (info, out_key, in_prefix);
375
	    c_output_key(info, out_key, in_prefix);
380
	    write_cstring (ostream, " = ");
376
	    write_cstring(ostream, " = ");
381
	    if (in_reference) {
377
	    if (in_reference) {
382
		write_char (ostream, '*');
378
		write_char(ostream, '*');
383
	    }
379
	    }
384
	    c_output_key (info, in_key, in_prefix);
380
	    c_output_key(info, in_key, in_prefix);
385
	    write_char (ostream, ';');
381
	    write_char(ostream, ';');
386
	    write_newline (ostream);
382
	    write_newline(ostream);
387
	}
383
	}
388
    }
384
    }
389
}
385
}
390
 
386
 
391
void
387
void
392
c_output_type_decl PROTO_N ((info, inputs, outputs))
388
c_output_type_decl(COutputInfoP info, TypeTupleP inputs, TypeTupleP outputs)
393
		   PROTO_T (COutputInfoP info X
-
 
394
			    TypeTupleP   inputs X
-
 
395
			    TypeTupleP   outputs)
-
 
396
{
389
{
397
    OStreamP ostream = c_out_info_ostream (info);
390
    OStreamP ostream = c_out_info_ostream(info);
398
 
391
 
399
    if (c_out_info_get_prototypes (info)) {
392
    if (c_out_info_get_prototypes(info)) {
400
	CStringP        sep  = "";
393
	CStringP        sep  = "";
401
	TypeTupleEntryP ptr;
394
	TypeTupleEntryP ptr;
402
	BoolT           ossg = c_out_info_get_ossg (info);
-
 
403
 
395
 
404
	if (ossg) {
-
 
405
	    write_cstring (ostream, "PROTO_S (") ;
-
 
406
	}
-
 
407
	write_char (ostream, '(');
396
	write_char(ostream, '(');
408
	for (ptr = inputs->head; ptr; ptr = ptr->next) {
397
	for (ptr = inputs->head; ptr; ptr = ptr->next) {
409
	    write_cstring (ostream, sep);
398
	    write_cstring(ostream, sep);
410
	    c_output_mapped_key (info, ptr->type);
399
	    c_output_mapped_key(info, ptr->type);
411
	    if ((ptr->reference) ||
400
	    if ((ptr->reference) ||
412
		(type_get_assign_code (entry_get_type (ptr->type)) !=
401
		(type_get_assign_code(entry_get_type(ptr->type)) !=
413
		 NIL (GenericP))) {
402
		 NIL(GenericP))) {
414
		write_cstring (ostream, " *");
403
		write_cstring(ostream, " *");
415
	    }
404
	    }
416
	    sep = ", ";
405
	    sep = ", ";
417
	}
406
	}
418
	for (ptr = outputs->head; ptr; ptr = ptr->next) {
407
	for (ptr = outputs->head; ptr; ptr = ptr->next) {
419
	    write_cstring (ostream, sep);
408
	    write_cstring(ostream, sep);
420
	    c_output_mapped_key (info, ptr->type);
409
	    c_output_mapped_key(info, ptr->type);
421
	    write_cstring (ostream, " *");
410
	    write_cstring(ostream, " *");
422
	    sep = ", ";
411
	    sep = ", ";
423
	}
412
	}
424
	if ((inputs->head == NIL (TypeTupleEntryP)) &&
413
	if ((inputs->head == NIL(TypeTupleEntryP)) &&
425
	    (outputs->head == NIL (TypeTupleEntryP))) {
414
	   (outputs->head == NIL(TypeTupleEntryP))) {
426
	    write_cstring (ostream, "void");
415
	    write_cstring(ostream, "void");
427
	}
-
 
428
	write_char (ostream, ')');
-
 
429
	if (ossg) {
-
 
430
	    write_char (ostream, ')');
-
 
431
	}
416
	}
-
 
417
	write_char(ostream, ')');
432
    } else {
418
    } else {
433
	write_cstring (ostream, " ()");
419
	write_cstring(ostream, " ()");
434
    }
420
    }
435
}
421
}
436
 
422
 
437
void
423
void
438
c_output_type_defn PROTO_N ((info, inputs, outputs))
424
c_output_type_defn(COutputInfoP info, TypeTupleP inputs, TypeTupleP outputs)
439
		   PROTO_T (COutputInfoP info X
-
 
440
			    TypeTupleP   inputs X
-
 
441
			    TypeTupleP   outputs)
-
 
442
{
425
{
443
    if (c_out_info_get_prototypes (info)) {
426
    if (c_out_info_get_prototypes(info)) {
444
	c_output_ansi_type_defn (info, inputs, outputs);
427
	c_output_ansi_type_defn(info, inputs, outputs);
445
    } else {
428
    } else {
446
	c_output_non_ansi_type_defn (info, inputs, outputs);
429
	c_output_non_ansi_type_defn(info, inputs, outputs);
447
    }
430
    }
448
}
431
}
449
 
432
 
450
void
433
void
451
c_output_result_assign PROTO_N ((info, outputs, indent))
434
c_output_result_assign(COutputInfoP info, TypeTupleP outputs, unsigned indent)
452
		       PROTO_T (COutputInfoP info X
-
 
453
				TypeTupleP   outputs X
-
 
454
				unsigned     indent)
-
 
455
{
435
{
456
    OStreamP        ostream    = c_out_info_ostream (info);
436
    OStreamP        ostream    = c_out_info_ostream(info);
457
    NStringP        in_prefix  = c_out_info_in_prefix (info);
437
    NStringP        in_prefix  = c_out_info_in_prefix(info);
458
    NStringP        out_prefix = c_out_info_out_prefix (info);
438
    NStringP        out_prefix = c_out_info_out_prefix(info);
459
    TypeTupleEntryP ptr;
439
    TypeTupleEntryP ptr;
460
 
440
 
461
    for (ptr = outputs->head; ptr; ptr = ptr->next) {
441
    for (ptr = outputs->head; ptr; ptr = ptr->next) {
462
	TypeP  type = entry_get_type (ptr->type);
442
	TypeP  type = entry_get_type(ptr->type);
463
	CCodeP code;
443
	CCodeP code;
464
 
444
 
465
	if ((code = type_get_result_assign_code (type)) != NIL (CCodeP)) {
445
	if ((code = type_get_result_assign_code(type)) != NIL(CCodeP)) {
466
	    KeyP key = entry_key (ptr->type);
446
	    KeyP key = entry_key(ptr->type);
467
 
447
 
468
	    c_output_key_message (info, "/* BEGINNING OF RESULT ASSIGNMENT: ",
448
	    c_output_key_message (info, "/* BEGINNING OF RESULT ASSIGNMENT: ",
469
				  key, " */", indent);
449
				  key, " */", indent);
470
	    c_output_open (info, indent);
450
	    c_output_open(info, indent);
471
	    c_output_location (info, c_code_file (code), c_code_line (code));
451
	    c_output_location(info, c_code_file(code), c_code_line(code));
472
	    c_output_c_code_result_assign (info, code, ptr->type, ptr->name);
452
	    c_output_c_code_result_assign(info, code, ptr->type, ptr->name);
473
	    c_output_location (info, ostream_name (ostream),
453
	    c_output_location(info, ostream_name(ostream),
474
			       ostream_line (ostream) + 1);
454
			      ostream_line(ostream) + 1);
475
	    c_output_close (info, indent);
455
	    c_output_close(info, indent);
476
	    c_output_key_message (info, "/* END OF RESULT ASSIGNMENT: ", key,
456
	    c_output_key_message (info, "/* END OF RESULT ASSIGNMENT: ", key,
477
				  " */", indent);
457
				  " */", indent);
478
	} else {
458
	} else {
479
	    output_indent (c_out_info_info (info), indent);
459
	    output_indent(c_out_info_info(info), indent);
480
	    write_char (ostream, '*');
460
	    write_char(ostream, '*');
481
	    c_output_key (info, entry_key (ptr->name), out_prefix);
461
	    c_output_key(info, entry_key(ptr->name), out_prefix);
482
	    write_cstring (ostream, " = ");
462
	    write_cstring(ostream, " = ");
483
	    c_output_key (info, entry_key (ptr->name), in_prefix);
463
	    c_output_key(info, entry_key(ptr->name), in_prefix);
484
	    write_char (ostream, ';');
464
	    write_char(ostream, ';');
485
	    write_newline (ostream);
465
	    write_newline(ostream);
486
	}
466
	}
487
    }
467
    }
488
}
468
}
489
 
469
 
490
void
470
void
491
c_output_alt_names PROTO_N ((info, names, exclude, state, indent))
471
c_output_alt_names(COutputInfoP info, TypeTupleP names, TypeTupleP exclude,
492
		   PROTO_T (COutputInfoP info X
-
 
493
			    TypeTupleP   names X
-
 
494
			    TypeTupleP   exclude X
-
 
495
			    SaveRStackP  state X
472
		   SaveRStackP state, unsigned indent)
496
			    unsigned     indent)
-
 
497
{
473
{
498
    OStreamP        ostream   = c_out_info_ostream (info);
474
    OStreamP        ostream   = c_out_info_ostream(info);
499
    NStringP        in_prefix = c_out_info_in_prefix (info);
475
    NStringP        in_prefix = c_out_info_in_prefix(info);
500
    BoolT           want_nl   = FALSE;
476
    BoolT           want_nl   = FALSE;
501
    TypeTupleEntryP ptr;
477
    TypeTupleEntryP ptr;
502
 
478
 
503
    for (ptr = names->head; ptr; ptr = ptr->next) {
479
    for (ptr = names->head; ptr; ptr = ptr->next) {
504
	if (!types_contains (exclude, ptr->name)) {
480
	if (!types_contains(exclude, ptr->name)) {
505
	    EntryP type;
481
	    EntryP type;
506
	    BoolT  reference;
482
	    BoolT  reference;
507
 
483
 
508
	    output_indent (c_out_info_info (info), indent);
484
	    output_indent(c_out_info_info(info), indent);
509
	    c_output_mapped_key (info, ptr->type);
485
	    c_output_mapped_key(info, ptr->type);
510
	    write_char (ostream, ' ');
486
	    write_char(ostream, ' ');
511
	    c_output_key (info, types_get_key (ptr->name, state, &type,
487
	    c_output_key(info, types_get_key(ptr->name, state, &type,
512
					       &reference), in_prefix);
488
					     &reference), in_prefix);
513
	    ASSERT ((type == ptr->type) && (!reference));
489
	    ASSERT((type == ptr->type) && (!reference));
514
	    write_char (ostream, ';');
490
	    write_char(ostream, ';');
515
	    write_newline (ostream);
491
	    write_newline(ostream);
516
	    want_nl = TRUE;
492
	    want_nl = TRUE;
517
	}
493
	}
518
    }
494
    }
519
    if (want_nl) {
495
    if (want_nl) {
520
	write_newline (ostream);
496
	write_newline(ostream);
521
    }
497
    }
522
}
498
}
523
 
499
 
524
void
500
void
525
c_output_rule_params PROTO_N ((info, inputs, outputs, state))
501
c_output_rule_params(COutputInfoP info, TypeTupleP inputs,
526
		     PROTO_T (COutputInfoP info X
-
 
527
			      TypeTupleP   inputs X
-
 
528
			      TypeTupleP   outputs X
-
 
529
			      SaveRStackP  state)
502
		     TypeTupleP outputs, SaveRStackP state)
530
{
503
{
531
    OStreamP        ostream   = c_out_info_ostream (info);
504
    OStreamP        ostream   = c_out_info_ostream(info);
532
    NStringP        in_prefix = c_out_info_in_prefix (info);
505
    NStringP        in_prefix = c_out_info_in_prefix(info);
533
    CStringP        sep       = "";
506
    CStringP        sep       = "";
534
    TypeTupleEntryP ptr;
507
    TypeTupleEntryP ptr;
535
 
508
 
536
    for (ptr = inputs->head; ptr; ptr = ptr->next) {
509
    for (ptr = inputs->head; ptr; ptr = ptr->next) {
537
	TypeP  type = entry_get_type (ptr->type);
510
	TypeP  type = entry_get_type(ptr->type);
538
	CCodeP code = type_get_param_assign_code (type);
511
	CCodeP code = type_get_param_assign_code(type);
539
	EntryP type_entry;
512
	EntryP type_entry;
540
	BoolT  reference;
513
	BoolT  reference;
541
	KeyP   key  = types_get_key (ptr->name, state, &type_entry,
514
	KeyP   key  = types_get_key(ptr->name, state, &type_entry,
542
				     &reference);
515
				     &reference);
543
 
516
 
544
	write_cstring (ostream, sep);
517
	write_cstring(ostream, sep);
545
	if ((ptr->reference && (!reference)) ||
518
	if ((ptr->reference && (!reference)) ||
546
	    ((!ptr->reference) && (!reference) && (code != NIL (CCodeP)))) {
519
	    ((!ptr->reference) && (!reference) && (code != NIL(CCodeP)))) {
547
	    write_char (ostream, '&');
520
	    write_char(ostream, '&');
548
	} else if ((!ptr->reference) && reference && (code == NIL (CCodeP))) {
521
	} else if ((!ptr->reference) && reference && (code == NIL(CCodeP))) {
549
	    write_char (ostream, '*');
522
	    write_char(ostream, '*');
550
	}
523
	}
551
	c_output_key (info, key, in_prefix);
524
	c_output_key(info, key, in_prefix);
552
	sep = ", ";
525
	sep = ", ";
553
    }
526
    }
554
    for (ptr = outputs->head; ptr; ptr = ptr->next) {
527
    for (ptr = outputs->head; ptr; ptr = ptr->next) {
555
	EntryP type_entry;
528
	EntryP type_entry;
556
	BoolT  reference;
529
	BoolT  reference;
557
 
530
 
558
	write_cstring (ostream, sep);
531
	write_cstring(ostream, sep);
559
	write_char (ostream, '&');
532
	write_char(ostream, '&');
560
	c_output_key (info, types_get_key (ptr->name, state, &type_entry,
533
	c_output_key(info, types_get_key(ptr->name, state, &type_entry,
561
					   &reference), in_prefix);
534
					 &reference), in_prefix);
562
	ASSERT ((type_entry == ptr->type) && (!reference));
535
	ASSERT((type_entry == ptr->type) && (!reference));
563
	sep = ", ";
536
	sep = ", ";
564
    }
537
    }
565
}
538
}
566
 
539
 
567
void
540
void
568
c_output_rename PROTO_N ((info, inputs, outputs, state, indent))
541
c_output_rename(COutputInfoP info, TypeTupleP inputs, TypeTupleP outputs,
569
		PROTO_T (COutputInfoP info X
-
 
570
			 TypeTupleP   inputs X
-
 
571
			 TypeTupleP   outputs X
-
 
572
			 SaveRStackP  state X
542
		SaveRStackP state, unsigned indent)
573
			 unsigned     indent)
-
 
574
{
543
{
575
    TypeTupleEntryP in_ptr  = inputs->head;
544
    TypeTupleEntryP in_ptr  = inputs->head;
576
    TypeTupleEntryP out_ptr = outputs->head;
545
    TypeTupleEntryP out_ptr = outputs->head;
577
 
546
 
578
    while (in_ptr) {
547
    while (in_ptr) {
579
	ASSERT (out_ptr);
548
	ASSERT(out_ptr);
580
	c_output_assign (info, in_ptr->name, out_ptr->name, state, state,
549
	c_output_assign(info, in_ptr->name, out_ptr->name, state, state,
581
			 indent);
550
			indent);
582
	in_ptr  = in_ptr->next;
551
	in_ptr  = in_ptr->next;
583
	out_ptr = out_ptr->next;
552
	out_ptr = out_ptr->next;
584
    }
553
    }
585
    ASSERT (out_ptr == NIL (TypeTupleEntryP));
554
    ASSERT(out_ptr == NIL(TypeTupleEntryP));
586
}
555
}
587
 
556
 
588
void
557
void
589
c_output_tail_decls PROTO_N ((info, inputs, in_state, outputs, out_state,
558
c_output_tail_decls(COutputInfoP info, TypeTupleP inputs, SaveRStackP in_state,
590
			      indent))
-
 
591
		    PROTO_T (COutputInfoP info X
-
 
592
			     TypeTupleP   inputs X
-
 
593
			     SaveRStackP  in_state X
-
 
594
			     TypeTupleP   outputs X
-
 
595
			     SaveRStackP  out_state X
559
		    TypeTupleP outputs, SaveRStackP out_state, unsigned indent)
596
			     unsigned     indent)
-
 
597
{
560
{
598
    TypeTupleEntryP in_ptr  = inputs->head;
561
    TypeTupleEntryP in_ptr  = inputs->head;
599
    TypeTupleEntryP out_ptr = outputs->head;
562
    TypeTupleEntryP out_ptr = outputs->head;
600
 
563
 
601
    while (in_ptr) {
564
    while (in_ptr) {
602
	ASSERT (out_ptr);
565
	ASSERT(out_ptr);
603
	c_output_assign (info, in_ptr->name, out_ptr->name, in_state,
566
	c_output_assign(info, in_ptr->name, out_ptr->name, in_state,
604
			 out_state, indent);
567
			out_state, indent);
605
	in_ptr  = in_ptr->next;
568
	in_ptr  = in_ptr->next;
606
	out_ptr = out_ptr->next;
569
	out_ptr = out_ptr->next;
607
    }
570
    }
608
    ASSERT (out_ptr == NIL (TypeTupleEntryP));
571
    ASSERT(out_ptr == NIL(TypeTupleEntryP));
609
}
572
}
610
 
573
 
611
BoolT
574
BoolT
612
c_output_required_copies PROTO_N ((info, param, args, rstack, astate, indent,
575
c_output_required_copies(COutputInfoP info, TypeTupleP param, TypeTupleP args,
613
				   table))
-
 
614
			 PROTO_T (COutputInfoP info X
-
 
615
				  TypeTupleP   param X
-
 
616
				  TypeTupleP   args X
-
 
617
				  RStackP      rstack X
-
 
618
				  SaveRStackP  astate X
576
			 RStackP rstack, SaveRStackP astate, unsigned indent,
619
				  unsigned     indent X
-
 
620
				  TableP       table)
577
			 TableP table)
621
{
578
{
622
    OStreamP        ostream   = c_out_info_ostream (info);
579
    OStreamP        ostream   = c_out_info_ostream(info);
623
    NStringP        in_prefix = c_out_info_in_prefix (info);
580
    NStringP        in_prefix = c_out_info_in_prefix(info);
624
    TypeTupleEntryP ptr       = param->head;
581
    TypeTupleEntryP ptr       = param->head;
625
    TypeTupleEntryP aptr      = args->head;
582
    TypeTupleEntryP aptr      = args->head;
626
    BoolT           copies    = FALSE;
583
    BoolT           copies    = FALSE;
627
    SaveRStackT     state;
584
    SaveRStackT     state;
628
 
585
 
629
    rstack_save_state (rstack, &state);
586
    rstack_save_state(rstack, &state);
630
    while (ptr) {
587
    while (ptr) {
631
	ASSERT (aptr);
588
	ASSERT(aptr);
632
	if (ptr->mutated && (!ptr->reference)) {
589
	if (ptr->mutated && (!ptr->reference)) {
633
	    EntryP entry = table_add_generated_name (table);
590
	    EntryP entry = table_add_generated_name(table);
634
 
591
 
635
	    output_indent (c_out_info_info (info), indent);
592
	    output_indent(c_out_info_info(info), indent);
636
	    c_output_mapped_key (info, ptr->type);
593
	    c_output_mapped_key(info, ptr->type);
637
	    write_char (ostream, ' ');
594
	    write_char(ostream, ' ');
638
	    c_output_key (info, entry_key (entry), in_prefix);
595
	    c_output_key(info, entry_key(entry), in_prefix);
639
	    write_char (ostream, ';');
596
	    write_char(ostream, ';');
640
	    write_newline (ostream);
597
	    write_newline(ostream);
641
	    copies = TRUE;
598
	    copies = TRUE;
642
	    rstack_add_translation (rstack, aptr->name, entry, aptr->type,
599
	    rstack_add_translation(rstack, aptr->name, entry, aptr->type,
643
				    FALSE);
600
				   FALSE);
644
	    rstack_add_translation (rstack, entry, entry, aptr->type, FALSE);
601
	    rstack_add_translation(rstack, entry, entry, aptr->type, FALSE);
645
	}
602
	}
646
	ptr  = ptr->next;
603
	ptr  = ptr->next;
647
	aptr = aptr->next;
604
	aptr = aptr->next;
648
    }
605
    }
649
    ASSERT (aptr == NIL (TypeTupleEntryP));
606
    ASSERT(aptr == NIL(TypeTupleEntryP));
650
    if (copies) {
607
    if (copies) {
651
	write_newline (ostream);
608
	write_newline(ostream);
652
	for (aptr = args->head, ptr = param->head; ptr;
609
	for (aptr = args->head, ptr = param->head; ptr;
653
	     ptr = ptr->next, aptr = aptr->next) {
610
	     ptr = ptr->next, aptr = aptr->next) {
654
	    ASSERT (aptr);
611
	    ASSERT(aptr);
655
	    if (ptr->mutated && (!ptr->reference)) {
612
	    if (ptr->mutated && (!ptr->reference)) {
656
		EntryP type;
613
		EntryP type;
657
		BoolT  reference;
614
		BoolT  reference;
658
		EntryP entry = rstack_get_translation (&state, aptr->name,
615
		EntryP entry = rstack_get_translation(&state, aptr->name,
659
						       &type, &reference);
616
						      &type, &reference);
660
 
617
 
661
		ASSERT (entry);
618
		ASSERT(entry);
662
		c_output_assign (info, aptr->name, entry, astate, &state,
619
		c_output_assign(info, aptr->name, entry, astate, &state,
663
				 indent);
620
				indent);
664
	    }
621
	    }
665
	}
622
	}
666
	ASSERT (aptr == NIL (TypeTupleEntryP));
623
	ASSERT(aptr == NIL(TypeTupleEntryP));
667
    }
624
    }
668
    return (copies);
625
    return(copies);
669
}
626
}
670

627

671
/*
628
/*
672
 * Local variables(smf):
629
 * Local variables(smf):
673
 * eval: (include::add-path-entry "../os-interface" "../library")
630
 * eval: (include::add-path-entry "../os-interface" "../library")