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-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 "type.h"
90
#include "type.h"
61
 
91
 
62
/*--------------------------------------------------------------------------*/
92
/*--------------------------------------------------------------------------*/
63
 
93
 
64
ItemP
94
ItemP
65
item_create PROTO_N ((entry))
95
item_create(EntryP entry)
66
	    PROTO_T (EntryP entry)
-
 
67
{
96
{
68
    ItemP item = ALLOCATE (ItemT);
97
    ItemP item = ALLOCATE(ItemT);
69
 
98
 
70
    item->next         = NIL (ItemP);
99
    item->next         = NIL(ItemP);
71
    types_init (item_param (item));
100
    types_init(item_param(item));
72
    types_init (item_result (item));
101
    types_init(item_result(item));
73
    item->type         = entry_type (entry);
102
    item->type         = entry_type(entry);
74
    item->entry        = entry;
103
    item->entry        = entry;
75
    item->inlinable    = FALSE;
104
    item->inlinable    = FALSE;
76
    item->tail_call    = FALSE;
105
    item->tail_call    = FALSE;
77
    return (item);
106
    return(item);
78
}
107
}
79
 
108
 
80
ItemP
109
ItemP
81
item_duplicate PROTO_N ((item))
110
item_duplicate(ItemP item)
82
	       PROTO_T (ItemP item)
-
 
83
{
111
{
84
    ItemP new_item = ALLOCATE (ItemT);
112
    ItemP new_item = ALLOCATE(ItemT);
85
 
113
 
86
    new_item->next         = NIL (ItemP);
114
    new_item->next         = NIL(ItemP);
87
    types_copy (item_param (new_item), item_param (item));
115
    types_copy(item_param(new_item), item_param(item));
88
    types_copy (item_result (new_item), item_result (item));
116
    types_copy(item_result(new_item), item_result(item));
89
    new_item->type         = item->type;
117
    new_item->type         = item->type;
90
    new_item->entry        = item->entry;
118
    new_item->entry        = item->entry;
91
    new_item->inlinable    = item->inlinable;
119
    new_item->inlinable    = item->inlinable;
92
    new_item->tail_call    = item->tail_call;
120
    new_item->tail_call    = item->tail_call;
93
    return (new_item);
121
    return(new_item);
94
}
122
}
95
 
123
 
96
ItemP
124
ItemP
97
item_duplicate_and_translate PROTO_N ((item, translator, table))
125
item_duplicate_and_translate(ItemP item, TypeTransP translator, TableP table)
98
			     PROTO_T (ItemP      item X
-
 
99
				      TypeTransP translator X
-
 
100
				      TableP     table)
-
 
101
{
126
{
102
    ItemP new_item = ALLOCATE (ItemT);
127
    ItemP new_item = ALLOCATE(ItemT);
103
 
128
 
104
    new_item->next         = NIL (ItemP);
129
    new_item->next         = NIL(ItemP);
105
    types_copy_and_translate (item_param (new_item), item_param (item),
130
    types_copy_and_translate(item_param(new_item), item_param(item),
106
			      translator, table);
131
			      translator, table);
107
    types_copy_and_translate (item_result (new_item), item_result (item),
132
    types_copy_and_translate(item_result(new_item), item_result(item),
108
			      translator, table);
133
			      translator, table);
109
    new_item->type         = item->type;
134
    new_item->type         = item->type;
110
    new_item->entry        = item->entry;
135
    new_item->entry        = item->entry;
111
    new_item->inlinable    = item->inlinable;
136
    new_item->inlinable    = item->inlinable;
112
    new_item->tail_call    = item->tail_call;
137
    new_item->tail_call    = item->tail_call;
113
    return (new_item);
138
    return(new_item);
114
}
139
}
115
 
140
 
116
void
141
void
117
item_translate_list PROTO_N ((item, translator))
142
item_translate_list(ItemP item, TypeBTransP translator)
118
		    PROTO_T (ItemP       item X
-
 
119
			     TypeBTransP translator)
-
 
120
{
143
{
121
    for (; item; item = item_next (item)) {
144
    for (; item; item = item_next(item)) {
122
	types_translate (item_param (item), translator);
145
	types_translate(item_param(item), translator);
123
	types_translate (item_result (item), translator);
146
	types_translate(item_result(item), translator);
124
    }
147
    }
125
}
148
}
126
 
149
 
127
void
150
void
128
item_to_predicate PROTO_N ((item))
151
item_to_predicate(ItemP item)
129
		  PROTO_T (ItemP item)
-
 
130
{
152
{
131
    ASSERT (item_is_action (item));
153
    ASSERT(item_is_action(item));
132
    item->type = ET_PREDICATE;
154
    item->type = ET_PREDICATE;
133
}
155
}
134
 
156
 
135
#ifdef FS_FAST
157
#ifdef FS_FAST
136
#undef item_next
158
#undef item_next
137
#endif /* defined (FS_FAST) */
159
#endif /* defined (FS_FAST) */
138
ItemP
160
ItemP
139
item_next PROTO_N ((item))
161
item_next(ItemP item)
140
	  PROTO_T (ItemP item)
-
 
141
{
162
{
142
    return (item->next);
163
    return(item->next);
143
}
164
}
144
#ifdef FS_FAST
165
#ifdef FS_FAST
145
#define item_next(i) ((i)->next)
166
#define item_next(i)	((i)->next)
146
#endif /* defined (FS_FAST) */
167
#endif /* defined (FS_FAST) */
147
 
168
 
148
#ifdef FS_FAST
169
#ifdef FS_FAST
149
#undef item_next_ref
170
#undef item_next_ref
150
#endif /* defined (FS_FAST) */
171
#endif /* defined (FS_FAST) */
151
ItemP *
172
ItemP *
152
item_next_ref PROTO_N ((item))
173
item_next_ref(ItemP item)
153
	      PROTO_T (ItemP item)
-
 
154
{
174
{
155
    return (&(item->next));
175
    return(&(item->next));
156
}
176
}
157
#ifdef FS_FAST
177
#ifdef FS_FAST
158
#define item_next_ref(i) (&((i)->next))
178
#define item_next_ref(i)	(&((i)->next))
159
#endif /* defined (FS_FAST) */
179
#endif /* defined (FS_FAST) */
160
 
180
 
161
#ifdef FS_FAST
181
#ifdef FS_FAST
162
#undef item_set_next
182
#undef item_set_next
163
#endif /* defined (FS_FAST) */
183
#endif /* defined (FS_FAST) */
164
void
184
void
165
item_set_next PROTO_N ((item1, item2))
185
item_set_next(ItemP item1, ItemP item2)
166
	      PROTO_T (ItemP item1 X
-
 
167
		       ItemP item2)
-
 
168
{
186
{
169
    item1->next = item2;
187
    item1->next = item2;
170
}
188
}
171
#ifdef FS_FAST
189
#ifdef FS_FAST
172
#define item_set_next(i1, i2) ((i1)->next = (i2))
190
#define item_set_next(i1, i2)	((i1)->next = (i2))
173
#endif /* defined (FS_FAST) */
191
#endif /* defined (FS_FAST) */
174
 
192
 
175
#ifdef FS_FAST
193
#ifdef FS_FAST
176
#undef item_entry
194
#undef item_entry
177
#endif /* defined (FS_FAST) */
195
#endif /* defined (FS_FAST) */
178
EntryP
196
EntryP
179
item_entry PROTO_N ((item))
197
item_entry(ItemP item)
180
	   PROTO_T (ItemP item)
-
 
181
{
198
{
182
    return (item->entry);
199
    return(item->entry);
183
}
200
}
184
#ifdef FS_FAST
201
#ifdef FS_FAST
185
#define item_entry(i) ((i)->entry)
202
#define item_entry(i)	((i)->entry)
186
#endif /* defined (FS_FAST) */
203
#endif /* defined (FS_FAST) */
187
 
204
 
188
#ifdef FS_FAST
205
#ifdef FS_FAST
189
#undef item_set_entry
206
#undef item_set_entry
190
#endif /* defined (FS_FAST) */
207
#endif /* defined (FS_FAST) */
191
void
208
void
192
item_set_entry PROTO_N ((item, entry))
209
item_set_entry(ItemP item, EntryP entry)
193
	       PROTO_T (ItemP  item X
-
 
194
			EntryP entry)
-
 
195
{
210
{
196
    item->entry = entry;
211
    item->entry = entry;
197
}
212
}
198
#ifdef FS_FAST
213
#ifdef FS_FAST
199
#define item_set_entry(i, e) ((i)->entry = (e))
214
#define item_set_entry(i, e)	((i)->entry = (e))
200
#endif /* defined (FS_FAST) */
215
#endif /* defined (FS_FAST) */
201
 
216
 
202
#ifdef FS_FAST
217
#ifdef FS_FAST
203
#undef item_type
218
#undef item_type
204
#endif /* defined (FS_FAST) */
219
#endif /* defined (FS_FAST) */
205
EntryTypeT
220
EntryTypeT
206
item_type PROTO_N ((item))
221
item_type(ItemP item)
207
	  PROTO_T (ItemP item)
-
 
208
{
222
{
209
    return (item->type);
223
    return(item->type);
210
}
224
}
211
#ifdef FS_FAST
225
#ifdef FS_FAST
212
#define item_type(i) ((i)->type)
226
#define item_type(i)	((i)->type)
213
#endif /* defined (FS_FAST) */
227
#endif /* defined (FS_FAST) */
214
 
228
 
215
#ifdef FS_FAST
229
#ifdef FS_FAST
216
#undef item_is_rule
230
#undef item_is_rule
217
#endif /* defined (FS_FAST) */
231
#endif /* defined (FS_FAST) */
218
BoolT
232
BoolT
219
item_is_rule PROTO_N ((item))
233
item_is_rule(ItemP item)
220
	     PROTO_T (ItemP item)
-
 
221
{
234
{
222
    return (item->type == ET_RULE);
235
    return(item->type == ET_RULE);
223
}
236
}
224
#ifdef FS_FAST
237
#ifdef FS_FAST
225
#define item_is_rule(i) ((i)->type == ET_RULE)
238
#define item_is_rule(i)	((i)->type == ET_RULE)
226
#endif /* defined (FS_FAST) */
239
#endif /* defined (FS_FAST) */
227
 
240
 
228
#ifdef FS_FAST
241
#ifdef FS_FAST
229
#undef item_is_action
242
#undef item_is_action
230
#endif /* defined (FS_FAST) */
243
#endif /* defined (FS_FAST) */
231
BoolT
244
BoolT
232
item_is_action PROTO_N ((item))
245
item_is_action(ItemP item)
233
	       PROTO_T (ItemP item)
-
 
234
{
246
{
235
    return (item->type == ET_ACTION);
247
    return(item->type == ET_ACTION);
236
}
248
}
237
#ifdef FS_FAST
249
#ifdef FS_FAST
238
#define item_is_action(i) ((i)->type == ET_ACTION)
250
#define item_is_action(i)	((i)->type == ET_ACTION)
239
#endif /* defined (FS_FAST) */
251
#endif /* defined (FS_FAST) */
240
 
252
 
241
#ifdef FS_FAST
253
#ifdef FS_FAST
242
#undef item_is_predicate
254
#undef item_is_predicate
243
#endif /* defined (FS_FAST) */
255
#endif /* defined (FS_FAST) */
244
BoolT
256
BoolT
245
item_is_predicate PROTO_N ((item))
257
item_is_predicate(ItemP item)
246
		  PROTO_T (ItemP item)
-
 
247
{
258
{
248
    return (item->type == ET_PREDICATE);
259
    return(item->type == ET_PREDICATE);
249
}
260
}
250
#ifdef FS_FAST
261
#ifdef FS_FAST
251
#define item_is_predicate(i) ((i)->type == ET_PREDICATE)
262
#define item_is_predicate(i)	((i)->type == ET_PREDICATE)
252
#endif /* defined (FS_FAST) */
263
#endif /* defined (FS_FAST) */
253
 
264
 
254
#ifdef FS_FAST
265
#ifdef FS_FAST
255
#undef item_is_basic
266
#undef item_is_basic
256
#endif /* defined (FS_FAST) */
267
#endif /* defined (FS_FAST) */
257
BoolT
268
BoolT
258
item_is_basic PROTO_N ((item))
269
item_is_basic(ItemP item)
259
	      PROTO_T (ItemP item)
-
 
260
{
270
{
261
    return (item->type == ET_BASIC);
271
    return(item->type == ET_BASIC);
262
}
272
}
263
#ifdef FS_FAST
273
#ifdef FS_FAST
264
#define item_is_basic(i) ((i)->type == ET_BASIC)
274
#define item_is_basic(i)	((i)->type == ET_BASIC)
265
#endif /* defined (FS_FAST) */
275
#endif /* defined (FS_FAST) */
266
 
276
 
267
#ifdef FS_FAST
277
#ifdef FS_FAST
268
#undef item_is_rename
278
#undef item_is_rename
269
#endif /* defined (FS_FAST) */
279
#endif /* defined (FS_FAST) */
270
BoolT
280
BoolT
271
item_is_rename PROTO_N ((item))
281
item_is_rename(ItemP item)
272
	       PROTO_T (ItemP item)
-
 
273
{
282
{
274
    return (item->type == ET_RENAME);
283
    return(item->type == ET_RENAME);
275
}
284
}
276
#ifdef FS_FAST
285
#ifdef FS_FAST
277
#define item_is_rename(i) ((i)->type == ET_RENAME)
286
#define item_is_rename(i)	((i)->type == ET_RENAME)
278
#endif /* defined (FS_FAST) */
287
#endif /* defined (FS_FAST) */
279
 
288
 
280
#ifdef FS_FAST
289
#ifdef FS_FAST
281
#undef item_param
290
#undef item_param
282
#endif /* defined (FS_FAST) */
291
#endif /* defined (FS_FAST) */
283
TypeTupleP
292
TypeTupleP
284
item_param PROTO_N ((item))
293
item_param(ItemP item)
285
	   PROTO_T (ItemP item)
-
 
286
{
294
{
287
    return (&(item->param));
295
    return(&(item->param));
288
}
296
}
289
#ifdef FS_FAST
297
#ifdef FS_FAST
290
#define item_param(i) (&((i)->param))
298
#define item_param(i)	(&((i)->param))
291
#endif /* defined (FS_FAST) */
299
#endif /* defined (FS_FAST) */
292
 
300
 
293
#ifdef FS_FAST
301
#ifdef FS_FAST
294
#undef item_add_param
302
#undef item_add_param
295
#endif /* defined (FS_FAST) */
303
#endif /* defined (FS_FAST) */
296
void
304
void
297
item_add_param PROTO_N ((item, param))
305
item_add_param(ItemP item, TypeTupleP param)
298
	       PROTO_T (ItemP      item X
-
 
299
			TypeTupleP param)
-
 
300
{
306
{
301
    types_assign (item_param (item), param);
307
    types_assign(item_param(item), param);
302
}
308
}
303
#ifdef FS_FAST
309
#ifdef FS_FAST
304
#define item_add_param(i, t) (types_assign (&((i)->param), (t)))
310
#define item_add_param(i, t)	(types_assign(&((i)->param), (t)))
305
#endif /* defined (FS_FAST) */
311
#endif /* defined (FS_FAST) */
306
 
312
 
307
#ifdef FS_FAST
313
#ifdef FS_FAST
308
#undef item_result
314
#undef item_result
309
#endif /* defined (FS_FAST) */
315
#endif /* defined (FS_FAST) */
310
TypeTupleP
316
TypeTupleP
311
item_result PROTO_N ((item))
317
item_result(ItemP item)
312
	    PROTO_T (ItemP item)
-
 
313
{
318
{
314
    return (&(item->result));
319
    return(&(item->result));
315
}
320
}
316
#ifdef FS_FAST
321
#ifdef FS_FAST
317
#define item_result(i) (&((i)->result))
322
#define item_result(i)	(&((i)->result))
318
#endif /* defined (FS_FAST) */
323
#endif /* defined (FS_FAST) */
319
 
324
 
320
#ifdef FS_FAST
325
#ifdef FS_FAST
321
#undef item_add_result
326
#undef item_add_result
322
#endif /* defined (FS_FAST) */
327
#endif /* defined (FS_FAST) */
323
void
328
void
324
item_add_result PROTO_N ((item, result))
329
item_add_result(ItemP item, TypeTupleP result)
325
		PROTO_T (ItemP      item X
-
 
326
			 TypeTupleP result)
-
 
327
{
330
{
328
    types_assign (item_result (item), result);
331
    types_assign(item_result(item), result);
329
}
332
}
330
#ifdef FS_FAST
333
#ifdef FS_FAST
331
#define item_add_result(i, t) (types_assign (&((i)->result), (t)))
334
#define item_add_result(i, t)	(types_assign(&((i)->result), (t)))
332
#endif /* defined (FS_FAST) */
335
#endif /* defined (FS_FAST) */
333
 
336
 
334
#ifdef FS_FAST
337
#ifdef FS_FAST
335
#undef item_is_inlinable
338
#undef item_is_inlinable
336
#endif /* defined (FS_FAST) */
339
#endif /* defined (FS_FAST) */
337
BoolT
340
BoolT
338
item_is_inlinable PROTO_N ((item))
341
item_is_inlinable(ItemP item)
339
		  PROTO_T (ItemP item)
-
 
340
{
342
{
341
    return (item->inlinable);
343
    return(item->inlinable);
342
}
344
}
343
#ifdef FS_FAST
345
#ifdef FS_FAST
344
#define item_is_inlinable(i) ((i)->inlinable)
346
#define item_is_inlinable(i)	((i)->inlinable)
345
#endif /* defined (FS_FAST) */
347
#endif /* defined (FS_FAST) */
346
 
348
 
347
#ifdef FS_FAST
349
#ifdef FS_FAST
348
#undef item_inlinable
350
#undef item_inlinable
349
#endif /* defined (FS_FAST) */
351
#endif /* defined (FS_FAST) */
350
void
352
void
351
item_inlinable PROTO_N ((item))
353
item_inlinable(ItemP item)
352
	       PROTO_T (ItemP item)
-
 
353
{
354
{
354
    item->inlinable = TRUE;
355
    item->inlinable = TRUE;
355
}
356
}
356
#ifdef FS_FAST
357
#ifdef FS_FAST
357
#define item_inlinable(i) ((i)->inlinable = TRUE)
358
#define item_inlinable(i)	((i)->inlinable = TRUE)
358
#endif /* defined (FS_FAST) */
359
#endif /* defined (FS_FAST) */
359
 
360
 
360
#ifdef FS_FAST
361
#ifdef FS_FAST
361
#undef item_is_tail_call
362
#undef item_is_tail_call
362
#endif /* defined (FS_FAST) */
363
#endif /* defined (FS_FAST) */
363
BoolT
364
BoolT
364
item_is_tail_call PROTO_N ((item))
365
item_is_tail_call(ItemP item)
365
		  PROTO_T (ItemP item)
-
 
366
{
366
{
367
    return (item->tail_call);
367
    return(item->tail_call);
368
}
368
}
369
#ifdef FS_FAST
369
#ifdef FS_FAST
370
#define item_is_tail_call(i) ((i)->tail_call)
370
#define item_is_tail_call(i)	((i)->tail_call)
371
#endif /* defined (FS_FAST) */
371
#endif /* defined (FS_FAST) */
372
 
372
 
373
#ifdef FS_FAST
373
#ifdef FS_FAST
374
#undef item_tail_call
374
#undef item_tail_call
375
#endif /* defined (FS_FAST) */
375
#endif /* defined (FS_FAST) */
376
void
376
void
377
item_tail_call PROTO_N ((item))
377
item_tail_call(ItemP item)
378
	       PROTO_T (ItemP item)
-
 
379
{
378
{
380
    item->tail_call = TRUE;
379
    item->tail_call = TRUE;
381
}
380
}
382
#ifdef FS_FAST
381
#ifdef FS_FAST
383
#define item_tail_call(i) ((i)->tail_call = TRUE)
382
#define item_tail_call(i)	((i)->tail_call = TRUE)
384
#endif /* defined (FS_FAST) */
383
#endif /* defined (FS_FAST) */
385
 
384
 
386
BoolT
385
BoolT
387
item_names_used_in_list PROTO_N ((item, names))
386
item_names_used_in_list(ItemP item, TypeTupleP names)
388
			PROTO_T (ItemP      item X
-
 
389
				 TypeTupleP names)
-
 
390
{
387
{
391
    while (item) {
388
    while (item) {
392
	if ((types_intersect (item_param (item), names)) ||
389
	if ((types_intersect(item_param(item), names)) ||
393
	    (types_intersect (item_result (item), names))) {
390
	    (types_intersect(item_result(item), names))) {
394
	    return (TRUE);
391
	    return(TRUE);
395
	}
392
	}
396
	item = item_next (item);
393
	item = item_next(item);
397
    }
394
    }
398
    return (FALSE);
395
    return(FALSE);
399
}
396
}
400
 
397
 
401
void
398
void
402
item_compute_minimal_dataflow PROTO_N ((item, used))
399
item_compute_minimal_dataflow(ItemP item, TypeTupleP used)
403
			      PROTO_T (ItemP      item X
-
 
404
				       TypeTupleP used)
-
 
405
{
400
{
406
    if (item) {
401
    if (item) {
407
	ItemP next = item_next (item);
402
	ItemP next = item_next(item);
408
 
403
 
409
	if (next) {
404
	if (next) {
410
	    item_compute_minimal_dataflow (next, used);
405
	    item_compute_minimal_dataflow(next, used);
411
	}
406
	}
412
	if (item_is_inlinable (item)) {
407
	if (item_is_inlinable(item)) {
413
	    RuleP rule = entry_get_rule (item_entry (item));
408
	    RuleP rule = entry_get_rule(item_entry(item));
414
 
409
 
415
	    types_inplace_intersection (item_result (item), used);
410
	    types_inplace_intersection(item_result(item), used);
416
	    types_inplace_intersection (rule_result (rule), used);
411
	    types_inplace_intersection(rule_result(rule), used);
417
	    rule_compute_minimal_dataflow (rule, item_param (item));
412
	    rule_compute_minimal_dataflow(rule, item_param(item));
418
	}
413
	}
419
	types_add_new_names (used, item_param (item), NIL (EntryP));
414
	types_add_new_names(used, item_param(item), NIL(EntryP));
420
    }
415
    }
421
}
416
}
422
 
417
 
423
ItemP
418
ItemP
424
item_deallocate PROTO_N ((item))
419
item_deallocate(ItemP item)
425
		PROTO_T (ItemP item)
-
 
426
{
420
{
427
    ItemP next = item_next (item);
421
    ItemP next = item_next(item);
428
 
422
 
429
    types_destroy (item_param (item));
423
    types_destroy(item_param(item));
430
    types_destroy (item_result (item));
424
    types_destroy(item_result(item));
431
    DEALLOCATE (item);
425
    DEALLOCATE(item);
432
    return (next);
426
    return(next);
433
}
427
}
434
 
428
 
435
void
429
void
436
write_item PROTO_N ((ostream, item))
430
write_item(OStreamP ostream, ItemP item)
437
	   PROTO_T (OStreamP ostream X
-
 
438
		    ItemP    item)
-
 
439
{
431
{
440
    EntryP entry = item_entry (item);
432
    EntryP entry = item_entry(item);
441
 
433
 
442
    write_type_names (ostream, item_result (item), TRUE);
434
    write_type_names(ostream, item_result(item), TRUE);
443
    if (item_is_predicate (item)) {
435
    if (item_is_predicate(item)) {
444
	write_cstring (ostream, " ?");
436
	write_cstring(ostream, " ?");
445
    }
437
    }
446
    write_cstring (ostream, " = ");
438
    write_cstring(ostream, " = ");
447
    switch (item_type (item)) EXHAUSTIVE {
439
    switch (item_type(item))EXHAUSTIVE {
448
      case ET_ACTION:
440
      case ET_ACTION:
449
      case ET_PREDICATE:
441
      case ET_PREDICATE:
450
	write_char (ostream, '<');
442
	write_char(ostream, '<');
451
	write_key (ostream, entry_key (entry));
443
	write_key(ostream, entry_key(entry));
452
	write_cstring (ostream, "> ");
444
	write_cstring(ostream, "> ");
453
	break;
445
	break;
454
      case ET_RULE:
446
      case ET_RULE:
455
	if (item_is_inlinable (item)) {
447
	if (item_is_inlinable(item)) {
456
	    if (item_is_tail_call (item)) {
448
	    if (item_is_tail_call(item)) {
457
		write_char (ostream, '*');
449
		write_char(ostream, '*');
458
	    } else {
450
	    } else {
459
		write_char (ostream, '+');
451
		write_char(ostream, '+');
460
	    }
452
	    }
461
	}
453
	}
462
	FALL_THROUGH;
454
	FALL_THROUGH;
463
      case ET_BASIC:
455
      case ET_BASIC:
464
	write_key (ostream, entry_key (item_entry (item)));
456
	write_key(ostream, entry_key(item_entry(item)));
465
	write_char (ostream, ' ');
457
	write_char(ostream, ' ');
466
	break;
458
	break;
467
      case ET_RENAME:
459
      case ET_RENAME:
468
	break;
460
	break;
469
      case ET_NON_LOCAL:
461
      case ET_NON_LOCAL:
470
      case ET_NAME:
462
      case ET_NAME:
471
      case ET_TYPE:
463
      case ET_TYPE:
472
	UNREACHED;
464
	UNREACHED;
473
    }
465
    }
474
    write_type_names (ostream, item_param (item), TRUE);
466
    write_type_names(ostream, item_param(item), TRUE);
475
    write_char (ostream, ';');
467
    write_char(ostream, ';');
476
}
468
}
477

469

478
/*
470
/*
479
 * Local variables(smf):
471
 * Local variables(smf):
480
 * eval: (include::add-path-entry "../os-interface" "../library")
472
 * eval: (include::add-path-entry "../os-interface" "../library")