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-2006 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
Line 75... Line 105...
75
#include "solve-cycles.h"
105
#include "solve-cycles.h"
76
 
106
 
77
/*--------------------------------------------------------------------------*/
107
/*--------------------------------------------------------------------------*/
78
 
108
 
79
NameEntryP
109
NameEntryP
80
name_entry_create_direct PROTO_N ((key, shape_entry))
110
name_entry_create_direct(NameKeyP    key,				  ShapeEntryP shape_entry)
81
			 PROTO_T (NameKeyP    key X
-
 
82
				  ShapeEntryP shape_entry)
-
 
83
{
111
{
84
    NameEntryP entry = ALLOCATE (NameEntryT);
112
    NameEntryP entry = ALLOCATE(NameEntryT);
85
 
113
 
86
    entry->next                    = NIL (NameEntryP);
114
    entry->next                    = NIL(NameEntryP);
87
    name_key_copy (&(entry->key), key);
115
    name_key_copy(& (entry->key), key);
88
    entry->type                    = NT_DIRECT;
116
    entry->type                    = NT_DIRECT;
89
    entry->u.direct.id             = shape_entry_next_id (shape_entry);
117
    entry->u.direct.id             = shape_entry_next_id(shape_entry);
90
    entry->u.direct.use            = 0;
118
    entry->u.direct.use            = 0;
91
    entry->u.direct.definition     = NIL (CapsuleP);
119
    entry->u.direct.definition     = NIL(CapsuleP);
92
    entry->u.direct.lib_definition = NIL (LibCapsuleP);
120
    entry->u.direct.lib_definition = NIL(LibCapsuleP);
93
    shape_entry_add_to_list (shape_entry, entry);
121
    shape_entry_add_to_list(shape_entry, entry);
94
    return (entry);
122
    return(entry);
95
}
123
}
96
 
124
 
97
NameEntryP
125
NameEntryP
98
name_entry_create_indirect PROTO_N ((key, indirect))
126
name_entry_create_indirect(NameKeyP   key,				    NameEntryP indirect)
99
			   PROTO_T (NameKeyP   key X
-
 
100
				    NameEntryP indirect)
-
 
101
{
127
{
102
    NameEntryP entry = ALLOCATE (NameEntryT);
128
    NameEntryP entry = ALLOCATE(NameEntryT);
103
 
129
 
104
    entry->next       = NIL (NameEntryP);
130
    entry->next       = NIL(NameEntryP);
105
    name_key_copy (&(entry->key), key);
131
    name_key_copy(& (entry->key), key);
106
    entry->type       = NT_INDIRECT;
132
    entry->type       = NT_INDIRECT;
107
    entry->u.indirect = indirect;
133
    entry->u.indirect = indirect;
108
    return (entry);
134
    return(entry);
109
}
135
}
110
 
136
 
111
NameEntryP
137
NameEntryP
112
name_entry_create_place PROTO_N ((key))
138
name_entry_create_place(NameKeyP key)
113
			PROTO_T (NameKeyP key)
-
 
114
{
139
{
115
    NameEntryP entry = ALLOCATE (NameEntryT);
140
    NameEntryP entry = ALLOCATE(NameEntryT);
116
 
141
 
117
    entry->next       = NIL (NameEntryP);
142
    entry->next       = NIL(NameEntryP);
118
    name_key_copy (&(entry->key), key);
143
    name_key_copy(& (entry->key), key);
119
    entry->type       = NT_PLACEHOLDER;
144
    entry->type       = NT_PLACEHOLDER;
120
    return (entry);
145
    return(entry);
121
}
146
}
122
 
147
 
123
void
148
void
124
name_entry_make_direct PROTO_N ((entry, shape_entry))
149
name_entry_make_direct(NameEntryP  entry,				ShapeEntryP shape_entry)
125
		       PROTO_T (NameEntryP  entry X
-
 
126
				ShapeEntryP shape_entry)
-
 
127
{
150
{
128
    ASSERT (name_entry_is_place (entry));
151
    ASSERT(name_entry_is_place(entry));
129
    entry->type                    = NT_DIRECT;
152
    entry->type                    = NT_DIRECT;
130
    entry->u.direct.id             = shape_entry_next_id (shape_entry);
153
    entry->u.direct.id             = shape_entry_next_id(shape_entry);
131
    entry->u.direct.use            = 0;
154
    entry->u.direct.use            = 0;
132
    entry->u.direct.definition     = NIL (CapsuleP);
155
    entry->u.direct.definition     = NIL(CapsuleP);
133
    entry->u.direct.lib_definition = NIL (LibCapsuleP);
156
    entry->u.direct.lib_definition = NIL(LibCapsuleP);
134
    shape_entry_add_to_list (shape_entry, entry);
157
    shape_entry_add_to_list(shape_entry, entry);
135
}
158
}
136
 
159
 
137
void
160
void
138
name_entry_make_indirect PROTO_N ((entry, indirect))
161
name_entry_make_indirect(NameEntryP entry,				  NameEntryP indirect)
139
			 PROTO_T (NameEntryP entry X
-
 
140
				  NameEntryP indirect)
-
 
141
{
162
{
142
    ASSERT (name_entry_is_place (entry));
163
    ASSERT(name_entry_is_place(entry));
143
    entry->type       = NT_INDIRECT;
164
    entry->type       = NT_INDIRECT;
144
    entry->u.indirect = indirect;
165
    entry->u.indirect = indirect;
145
}
166
}
146
 
167
 
147
NameEntryP
168
NameEntryP
148
name_entry_resolve_renames PROTO_N ((entry, shape, report))
169
name_entry_resolve_renames(NameEntryP entry,				    NStringP   shape, 
149
			   PROTO_T (NameEntryP entry X
-
 
150
				    NStringP   shape X
-
 
151
				    BoolT      report)
170
				    BoolT      report)
152
{
171
{
153
    switch (entry->type) EXHAUSTIVE {
172
    switch (entry->type)EXHAUSTIVE {
154
      case NT_PLACEHOLDER:
173
      case NT_PLACEHOLDER:
155
      case NT_DIRECT:
174
      case NT_DIRECT:
156
	return (entry);
175
	return(entry);
157
      case NT_INDIRECT_DONE:
176
      case NT_INDIRECT_DONE:
158
	return (name_entry_get_indirect (entry));
177
	return(name_entry_get_indirect(entry));
159
      case NT_INDIRECT_CYCLING:
178
      case NT_INDIRECT_CYCLING:
160
	if (report) {
179
	if (report) {
161
	    E_rename_cycle (shape, name_entry_key (entry));
180
	    E_rename_cycle(shape, name_entry_key(entry));
162
	}
181
	}
163
	return (NIL (NameEntryP));
182
	return(NIL(NameEntryP));
164
      case NT_INDIRECT:
183
      case NT_INDIRECT:
165
	entry->type = NT_INDIRECT_CYCLING;
184
	entry->type = NT_INDIRECT_CYCLING;
166
	entry->u.indirect = name_entry_resolve_renames (entry->u.indirect,
185
	entry->u.indirect = name_entry_resolve_renames(entry->u.indirect,
167
							shape, report);
186
							shape, report);
168
	entry->type = NT_INDIRECT_DONE;
187
	entry->type = NT_INDIRECT_DONE;
169
	return (name_entry_get_indirect (entry));
188
	return(name_entry_get_indirect(entry));
170
    }
189
    }
171
    UNREACHED;
190
    UNREACHED;
172
}
191
}
173
 
192
 
174
NameKeyP
193
NameKeyP
175
name_entry_key PROTO_N ((entry))
194
name_entry_key(NameEntryP entry)
176
	       PROTO_T (NameEntryP entry)
-
 
177
{
195
{
178
    return (&(entry->key));
196
    return(& (entry->key));
179
}
197
}
180
 
198
 
181
NameEntryP
199
NameEntryP
182
name_entry_next PROTO_N ((entry))
200
name_entry_next(NameEntryP entry)
183
		PROTO_T (NameEntryP entry)
-
 
184
{
201
{
185
    return (entry->next);
202
    return(entry->next);
186
}
203
}
187
 
204
 
188
NameEntryP *
205
NameEntryP *
189
name_entry_next_ref PROTO_N ((entry))
206
name_entry_next_ref(NameEntryP entry)
190
		    PROTO_T (NameEntryP entry)
-
 
191
{
207
{
192
    return (&(entry->next));
208
    return(& (entry->next));
193
}
209
}
194
 
210
 
195
BoolT
211
BoolT
196
name_entry_is_direct PROTO_N ((entry))
212
name_entry_is_direct(NameEntryP entry)
197
		     PROTO_T (NameEntryP entry)
-
 
198
{
213
{
199
    return (entry->type == NT_DIRECT);
214
    return(entry->type == NT_DIRECT);
200
}
215
}
201
 
216
 
202
BoolT
217
BoolT
203
name_entry_is_indirect PROTO_N ((entry))
218
name_entry_is_indirect(NameEntryP entry)
204
		       PROTO_T (NameEntryP entry)
-
 
205
{
219
{
206
    return ((entry->type == NT_INDIRECT) ||
220
    return((entry->type == NT_INDIRECT) ||
207
	    (entry->type == NT_INDIRECT_CYCLING) ||
221
	   (entry->type == NT_INDIRECT_CYCLING) ||
208
	    (entry->type == NT_INDIRECT_DONE));
222
	   (entry->type == NT_INDIRECT_DONE));
209
}
223
}
210
 
224
 
211
BoolT
225
BoolT
212
name_entry_is_place PROTO_N ((entry))
226
name_entry_is_place(NameEntryP entry)
213
		    PROTO_T (NameEntryP entry)
-
 
214
{
227
{
215
    return (entry->type == NT_PLACEHOLDER);
228
    return(entry->type == NT_PLACEHOLDER);
216
}
229
}
217
 
230
 
218
unsigned
231
unsigned
219
name_entry_id PROTO_N ((entry))
232
name_entry_id(NameEntryP entry)
220
	      PROTO_T (NameEntryP entry)
-
 
221
{
233
{
222
    ASSERT (name_entry_is_direct (entry));
234
    ASSERT(name_entry_is_direct(entry));
223
    return (entry->u.direct.id);
235
    return(entry->u.direct.id);
224
}
236
}
225
 
237
 
226
void
238
void
227
name_entry_merge_use PROTO_N ((entry, use))
239
name_entry_merge_use(NameEntryP entry,			      unsigned   use)
228
		     PROTO_T (NameEntryP entry X
-
 
229
			      unsigned   use)
-
 
230
{
240
{
231
    ASSERT (name_entry_is_direct (entry));
241
    ASSERT(name_entry_is_direct(entry));
232
    entry->u.direct.use |= use;
242
    entry->u.direct.use |= use;
233
}
243
}
234
 
244
 
235
unsigned
245
unsigned
236
name_entry_get_use PROTO_N ((entry))
246
name_entry_get_use(NameEntryP entry)
237
		   PROTO_T (NameEntryP entry)
-
 
238
{
247
{
239
    ASSERT (name_entry_is_direct (entry));
248
    ASSERT(name_entry_is_direct(entry));
240
    return (entry->u.direct.use & (U_DEFD | U_DECD | U_MULT | U_USED));
249
    return(entry->u.direct.use & (U_DEFD | U_DECD | U_MULT | U_USED));
241
}
250
}
242
 
251
 
243
void
252
void
244
name_entry_hide PROTO_N ((entry))
253
name_entry_hide(NameEntryP entry)
245
		PROTO_T (NameEntryP entry)
-
 
246
{
254
{
247
    ASSERT (name_entry_is_direct (entry));
255
    ASSERT(name_entry_is_direct(entry));
248
    entry->u.direct.use |= U_HIDE;
256
    entry->u.direct.use |= U_HIDE;
249
}
257
}
250
 
258
 
251
void
259
void
252
name_entry_unhide PROTO_N ((entry))
260
name_entry_unhide(NameEntryP entry)
253
		  PROTO_T (NameEntryP entry)
-
 
254
{
261
{
255
    ASSERT (name_entry_is_direct (entry));
262
    ASSERT(name_entry_is_direct(entry));
256
    entry->u.direct.use &= ~U_HIDE;
263
    entry->u.direct.use &= ~U_HIDE;
257
}
264
}
258
 
265
 
259
BoolT
266
BoolT
260
name_entry_is_hidden PROTO_N ((entry))
267
name_entry_is_hidden(NameEntryP entry)
261
		     PROTO_T (NameEntryP entry)
-
 
262
{
268
{
263
    ASSERT (name_entry_is_direct (entry));
269
    ASSERT(name_entry_is_direct(entry));
264
    return ((entry->u.direct.use & U_HIDE) == U_HIDE);
270
    return((entry->u.direct.use & U_HIDE) == U_HIDE);
265
}
271
}
266
 
272
 
267
void
273
void
268
name_entry_set_definition PROTO_N ((entry, capsule))
274
name_entry_set_definition(NameEntryP entry,				   CapsuleP   capsule)
269
			  PROTO_T (NameEntryP entry X
-
 
270
				   CapsuleP   capsule)
-
 
271
{
275
{
272
    ASSERT (name_entry_is_direct (entry));
276
    ASSERT(name_entry_is_direct(entry));
273
    entry->u.direct.definition = capsule;
277
    entry->u.direct.definition = capsule;
274
}
278
}
275
 
279
 
276
CapsuleP
280
CapsuleP
277
name_entry_get_definition PROTO_N ((entry))
281
name_entry_get_definition(NameEntryP entry)
278
			  PROTO_T (NameEntryP entry)
-
 
279
{
282
{
280
    ASSERT (name_entry_is_direct (entry));
283
    ASSERT(name_entry_is_direct(entry));
281
    return (entry->u.direct.definition);
284
    return(entry->u.direct.definition);
282
}
285
}
283
 
286
 
284
void
287
void
285
name_entry_set_lib_definition PROTO_N ((entry, capsule))
288
name_entry_set_lib_definition(NameEntryP  entry,				       LibCapsuleP capsule)
286
			      PROTO_T (NameEntryP  entry X
-
 
287
				       LibCapsuleP capsule)
-
 
288
{
289
{
289
    ASSERT (name_entry_is_direct (entry));
290
    ASSERT(name_entry_is_direct(entry));
290
    entry->u.direct.lib_definition = capsule;
291
    entry->u.direct.lib_definition = capsule;
291
}
292
}
292
 
293
 
293
LibCapsuleP
294
LibCapsuleP
294
name_entry_get_lib_definition PROTO_N ((entry))
295
name_entry_get_lib_definition(NameEntryP entry)
295
			      PROTO_T (NameEntryP entry)
-
 
296
{
296
{
297
    ASSERT (name_entry_is_direct (entry));
297
    ASSERT(name_entry_is_direct(entry));
298
    return (entry->u.direct.lib_definition);
298
    return(entry->u.direct.lib_definition);
299
}
299
}
300
 
300
 
301
NameEntryP
301
NameEntryP
302
name_entry_list_next PROTO_N ((entry))
302
name_entry_list_next(NameEntryP entry)
303
		     PROTO_T (NameEntryP entry)
-
 
304
{
303
{
305
    ASSERT (name_entry_is_direct (entry));
304
    ASSERT(name_entry_is_direct(entry));
306
    return (entry->u.direct.list_next);
305
    return(entry->u.direct.list_next);
307
}
306
}
308
 
307
 
309
NameEntryP *
308
NameEntryP *
310
name_entry_list_next_ref PROTO_N ((entry))
309
name_entry_list_next_ref(NameEntryP entry)
311
			 PROTO_T (NameEntryP entry)
-
 
312
{
310
{
313
    ASSERT (name_entry_is_direct (entry));
311
    ASSERT(name_entry_is_direct(entry));
314
    return (&(entry->u.direct.list_next));
312
    return(& (entry->u.direct.list_next));
315
}
313
}
316
 
314
 
317
NameEntryP
315
NameEntryP
318
name_entry_get_indirect PROTO_N ((entry))
316
name_entry_get_indirect(NameEntryP entry)
319
			PROTO_T (NameEntryP entry)
-
 
320
{
317
{
321
    ASSERT (name_entry_is_indirect (entry));
318
    ASSERT(name_entry_is_indirect(entry));
322
    return (entry->u.indirect);
319
    return(entry->u.indirect);
323
}
320
}
324
 
321
 
325
NameEntryP
322
NameEntryP
326
name_entry_deallocate PROTO_N ((entry))
323
name_entry_deallocate(NameEntryP entry)
327
		      PROTO_T (NameEntryP entry)
-
 
328
{
324
{
329
    NameEntryP next = name_entry_next (entry);
325
    NameEntryP next = name_entry_next(entry);
330
 
326
 
331
    name_key_destroy (name_entry_key (entry));
327
    name_key_destroy(name_entry_key(entry));
332
    DEALLOCATE (entry);
328
    DEALLOCATE(entry);
333
    return (next);
329
    return(next);
334
}
330
}
335
 
331
 
336
/*--------------------------------------------------------------------------*/
332
/*--------------------------------------------------------------------------*/
337
 
333
 
338
void
334
void
339
name_entry_do_count PROTO_N ((entry, gclosure))
335
name_entry_do_count(NameEntryP entry,			     GenericP   gclosure)
340
		    PROTO_T (NameEntryP entry X
-
 
341
			     GenericP   gclosure)
-
 
342
{
336
{
343
    unsigned *count_ref = (unsigned *) gclosure;
337
    unsigned *count_ref = (unsigned *)gclosure;
344
 
338
 
345
    if (!(name_entry_is_hidden (entry))) {
339
    if (!(name_entry_is_hidden(entry))) {
346
	(*count_ref) ++;
340
	(*count_ref)++;
347
    }
341
    }
348
}
342
}
349
 
343
 
350
void
344
void
351
name_entry_write_name PROTO_N ((entry, gclosure))
345
name_entry_write_name(NameEntryP entry,			       GenericP   gclosure)
352
		      PROTO_T (NameEntryP entry X
-
 
353
			       GenericP   gclosure)
-
 
354
{
346
{
355
    if (!(name_entry_is_hidden (entry))) {
347
    if (!(name_entry_is_hidden(entry))) {
356
	TDFWriterP writer = (TDFWriterP) gclosure;
348
	TDFWriterP writer = (TDFWriterP)gclosure;
357
	NameKeyP   key    = name_entry_key (entry);
349
	NameKeyP   key    = name_entry_key(entry);
358
	unsigned   id     = name_entry_id (entry);
350
	unsigned   id     = name_entry_id(entry);
359
 
351
 
360
	debug_info_w_name (key, id);
352
	debug_info_w_name(key, id);
361
	tdf_write_int (writer, id);
353
	tdf_write_int(writer, id);
362
	tdf_write_name (writer, key);
354
	tdf_write_name(writer, key);
363
    }
355
    }
364
}
356
}
365
 
357
 
366
void
358
void
367
name_entry_compute_tld_size PROTO_N ((entry, gclosure))
359
name_entry_compute_tld_size(NameEntryP entry,				     GenericP   gclosure)
368
			    PROTO_T (NameEntryP entry X
-
 
369
				     GenericP   gclosure)
-
 
370
{
360
{
371
    unsigned *size_ref = (unsigned *) gclosure;
361
    unsigned *size_ref = (unsigned *)gclosure;
372
 
362
 
373
    if (!name_entry_is_hidden (entry)) {
363
    if (!name_entry_is_hidden(entry)) {
374
	unsigned use = name_entry_get_use (entry);
364
	unsigned use = name_entry_get_use(entry);
375
 
365
 
376
	(*size_ref) += tdf_int_size (use);
366
	(*size_ref) += tdf_int_size(use);
377
    }
367
    }
378
}
368
}
379
 
369
 
380
void
370
void
381
name_entry_write_tld PROTO_N ((entry, gclosure))
371
name_entry_write_tld(NameEntryP entry,			      GenericP   gclosure)
382
		     PROTO_T (NameEntryP entry X
-
 
383
			      GenericP   gclosure)
-
 
384
{
372
{
385
    TDFWriterP writer = (TDFWriterP) gclosure;
373
    TDFWriterP writer = (TDFWriterP)gclosure;
386
 
374
 
387
    if (!(name_entry_is_hidden (entry))) {
375
    if (!(name_entry_is_hidden(entry))) {
388
	unsigned use = name_entry_get_use (entry);
376
	unsigned use = name_entry_get_use(entry);
389
 
377
 
390
	debug_info_w_usage (use, name_entry_key (entry));
378
	debug_info_w_usage(use, name_entry_key(entry));
391
	tdf_write_int (writer, use);
379
	tdf_write_int(writer, use);
392
    }
380
    }
393
}
381
}
394
 
382
 
395
void
383
void
396
name_entry_check_multi_defs PROTO_N ((entry, gclosure))
384
name_entry_check_multi_defs(NameEntryP entry,				     GenericP   gclosure)
397
			    PROTO_T (NameEntryP entry X
-
 
398
				     GenericP   gclosure)
-
 
399
{
385
{
400
    NStringP shape_name = (NStringP) gclosure;
386
    NStringP shape_name = (NStringP)gclosure;
401
 
387
 
402
    if ((name_entry_get_use (entry) & U_MULT) &&
388
    if ((name_entry_get_use(entry) & U_MULT) &&
403
	(name_entry_get_definition (entry) == NIL (CapsuleP))) {
389
	(name_entry_get_definition(entry) == NIL(CapsuleP))) {
404
	E_no_single_definition (shape_name, name_entry_key (entry));
390
	E_no_single_definition(shape_name, name_entry_key(entry));
405
    }
391
    }
406
}
392
}
407
 
393
 
408
void
394
void
409
name_entry_do_lib_count PROTO_N ((entry, gclosure))
395
name_entry_do_lib_count(NameEntryP entry,				 GenericP   gclosure)
410
			PROTO_T (NameEntryP entry X
-
 
411
				 GenericP   gclosure)
-
 
412
{
396
{
413
    if (name_entry_get_definition (entry)) {
397
    if (name_entry_get_definition(entry)) {
414
	unsigned *num_names_ref = (unsigned *) gclosure;
398
	unsigned *num_names_ref = (unsigned *)gclosure;
415
 
399
 
416
	(*num_names_ref) ++;
400
	(*num_names_ref)++;
417
    }
401
    }
418
}
402
}
419
 
403
 
420
void
404
void
421
name_entry_do_lib_write PROTO_N ((entry, gclosure))
405
name_entry_do_lib_write(NameEntryP entry,				 GenericP   gclosure)
422
			PROTO_T (NameEntryP entry X
-
 
423
				 GenericP   gclosure)
-
 
424
{
406
{
425
    CapsuleP definition = name_entry_get_definition (entry);
407
    CapsuleP definition = name_entry_get_definition(entry);
426
 
408
 
427
    if (definition) {
409
    if (definition) {
428
	TDFWriterP writer        = (TDFWriterP) gclosure;
410
	TDFWriterP writer        = (TDFWriterP)gclosure;
429
	NameKeyP   key           = name_entry_key (entry);
411
	NameKeyP   key           = name_entry_key(entry);
430
	unsigned   use           = name_entry_get_use (entry);
412
	unsigned   use           = name_entry_get_use(entry);
431
	unsigned   capsule_index = capsule_get_index (definition);
413
	unsigned   capsule_index = capsule_get_index(definition);
432
 
414
 
433
	debug_info_w_index_entry (key, use, capsule_name (definition),
415
	debug_info_w_index_entry(key, use, capsule_name(definition),
434
				  capsule_index);
416
				  capsule_index);
435
	tdf_write_name (writer, key);
417
	tdf_write_name(writer, key);
436
	tdf_write_int (writer, use);
418
	tdf_write_int(writer, use);
437
	tdf_write_int (writer, capsule_index);
419
	tdf_write_int(writer, capsule_index);
438
    }
420
    }
439
}
421
}
440
 
422
 
441
void
423
void
442
name_entry_suppress PROTO_N ((entry, gclosure))
424
name_entry_suppress(NameEntryP entry,			     GenericP   gclosure)
443
		    PROTO_T (NameEntryP entry X
-
 
444
			     GenericP   gclosure)
-
 
445
{
425
{
446
    NStringP shape = (NStringP) gclosure;
426
    NStringP shape = (NStringP)gclosure;
447
 
427
 
448
    debug_info_l_suppress (shape, name_entry_key (entry));
428
    debug_info_l_suppress(shape, name_entry_key(entry));
449
    name_entry_set_lib_definition (entry, NIL (LibCapsuleP));
429
    name_entry_set_lib_definition(entry, NIL(LibCapsuleP));
450
}
430
}
451
 
431
 
452
void
432
void
453
name_entry_builder_suppress PROTO_N ((entry, gclosure))
433
name_entry_builder_suppress(NameEntryP entry,				     GenericP   gclosure)
454
			    PROTO_T (NameEntryP entry X
-
 
455
				     GenericP   gclosure)
-
 
456
{
434
{
457
    NStringP shape = (NStringP) gclosure;
435
    NStringP shape = (NStringP)gclosure;
458
 
436
 
459
    debug_info_l_suppress (shape, name_entry_key (entry));
437
    debug_info_l_suppress(shape, name_entry_key(entry));
460
    name_entry_set_definition (entry, NIL (CapsuleP));
438
    name_entry_set_definition(entry, NIL(CapsuleP));
461
}
439
}
462
 
440
 
463
BoolT
441
BoolT
464
name_entry_resolve_undefined PROTO_N ((entry, table, units, shapes, shape_key))
442
name_entry_resolve_undefined(NameEntryP  entry,				      NameTableP  table, 
465
			     PROTO_T (NameEntryP  entry X
-
 
466
				      NameTableP  table X
-
 
467
				      UnitTableP  units X
443
				      UnitTableP  units, 
468
				      ShapeTableP shapes X
444
				      ShapeTableP shapes, 
469
				      NStringP    shape_key)
445
				      NStringP    shape_key)
470
{
446
{
471
    unsigned use = name_entry_get_use (entry);
447
    unsigned use = name_entry_get_use(entry);
472
    NameKeyP key = name_entry_key (entry);
448
    NameKeyP key = name_entry_key(entry);
473
 
449
 
474
    if ((use & U_DEFD) || (!(use & U_USED))) {
450
    if ((use & U_DEFD) || (!(use & U_USED))) {
475
	debug_info_l_not_needed (key, shape_key, use);
451
	debug_info_l_not_needed(key, shape_key, use);
476
	return (FALSE);
452
	return(FALSE);
477
    } else if (table) {
453
    } else if (table) {
478
	NameEntryP lib_entry = name_table_get (table, key);
454
	NameEntryP lib_entry = name_table_get(table, key);
479
 
455
 
480
	if (lib_entry) {
456
	if (lib_entry) {
481
	    LibCapsuleP lib_def = name_entry_get_lib_definition (lib_entry);
457
	    LibCapsuleP lib_def = name_entry_get_lib_definition(lib_entry);
482
	    unsigned    lib_use = name_entry_get_use (lib_entry);
458
	    unsigned    lib_use = name_entry_get_use(lib_entry);
483
 
459
 
484
	    if (lib_def && (!lib_capsule_is_loaded (lib_def)) &&
460
	    if (lib_def && (!lib_capsule_is_loaded(lib_def)) &&
485
		((!(use & U_MULT)) || (lib_use & U_DEFD))) {
461
		((!(use & U_MULT)) || (lib_use & U_DEFD))) {
486
		CStringP name     = lib_capsule_full_name (lib_def);
462
		CStringP name     = lib_capsule_full_name(lib_def);
487
		NStringP contents = lib_capsule_contents (lib_def);
463
		NStringP contents = lib_capsule_contents(lib_def);
488
		CapsuleP capsule;
464
		CapsuleP capsule;
489
 
465
 
490
		debug_info_l_found (key, shape_key, use, name);
466
		debug_info_l_found(key, shape_key, use, name);
491
		capsule = capsule_create_string_input (name, contents);
467
		capsule = capsule_create_string_input(name, contents);
492
		capsule_read (capsule, units, shapes);
468
		capsule_read(capsule, units, shapes);
493
		capsule_close (capsule);
469
		capsule_close(capsule);
494
		lib_capsule_loaded (lib_def);
470
		lib_capsule_loaded(lib_def);
495
		return (TRUE);
471
		return(TRUE);
496
	    }
472
	    }
497
	}
473
	}
498
    }
474
    }
499
    E_no_definition_found (shape_key, key);
475
    E_no_definition_found(shape_key, key);
500
    debug_info_l_not_found (key, shape_key, use);
476
    debug_info_l_not_found(key, shape_key, use);
501
    return (FALSE);
477
    return(FALSE);
502
}
478
}
503
 
479
 
504
void
480
void
505
name_entry_hide_defd PROTO_N ((entry, gclosure))
481
name_entry_hide_defd(NameEntryP entry,			      GenericP   gclosure)
506
		     PROTO_T (NameEntryP entry X
-
 
507
			      GenericP   gclosure)
-
 
508
{
482
{
509
    if (name_entry_get_use (entry) & U_DEFD) {
483
    if (name_entry_get_use(entry) & U_DEFD) {
510
	NStringP shape = (NStringP) gclosure;
484
	NStringP shape = (NStringP)gclosure;
511
 
485
 
512
	debug_info_l_hide (shape, name_entry_key (entry));
486
	debug_info_l_hide(shape, name_entry_key(entry));
513
	name_entry_hide (entry);
487
	name_entry_hide(entry);
514
    }
488
    }
515
}
489
}
516
 
490
 
517
void
491
void
518
name_entry_keep PROTO_N ((entry, gclosure))
492
name_entry_keep(NameEntryP entry,			 GenericP   gclosure)
519
		PROTO_T (NameEntryP entry X
-
 
520
			 GenericP   gclosure)
-
 
521
{
493
{
522
    NStringP shape = (NStringP) gclosure;
494
    NStringP shape = (NStringP)gclosure;
523
 
495
 
524
    debug_info_l_keep (shape, name_entry_key (entry));
496
    debug_info_l_keep(shape, name_entry_key(entry));
525
    name_entry_unhide (entry);
497
    name_entry_unhide(entry);
526
}
498
}
527
 
499
 
528
void
500
void
529
name_entry_suppress_mult PROTO_N ((entry, gclosure))
501
name_entry_suppress_mult(NameEntryP entry,				  GenericP   gclosure)
530
			 PROTO_T (NameEntryP entry X
-
 
531
				  GenericP   gclosure)
-
 
532
{
502
{
533
    if ((name_entry_get_use (entry) & (U_DEFD | U_MULT)) == U_MULT) {
503
    if ((name_entry_get_use(entry) & (U_DEFD | U_MULT)) == U_MULT) {
534
	NStringP shape = (NStringP) gclosure;
504
	NStringP shape = (NStringP)gclosure;
535
 
505
 
536
	debug_info_l_suppress (shape, name_entry_key (entry));
506
	debug_info_l_suppress(shape, name_entry_key(entry));
537
	name_entry_set_definition (entry, NIL (CapsuleP));
507
	name_entry_set_definition(entry, NIL(CapsuleP));
538
    }
508
    }
539
}
509
}
540
 
510
 
541
void
511
void
542
name_entry_lib_suppress_mult PROTO_N ((entry, gclosure))
512
name_entry_lib_suppress_mult(NameEntryP entry,				      GenericP   gclosure)
543
			     PROTO_T (NameEntryP entry X
-
 
544
				      GenericP   gclosure)
-
 
545
{
513
{
546
    if ((name_entry_get_use (entry) & (U_DEFD | U_MULT)) == U_MULT) {
514
    if ((name_entry_get_use(entry) & (U_DEFD | U_MULT)) == U_MULT) {
547
	NStringP shape = (NStringP) gclosure;
515
	NStringP shape = (NStringP)gclosure;
548
 
516
 
549
	debug_info_l_suppress (shape, name_entry_key (entry));
517
	debug_info_l_suppress(shape, name_entry_key(entry));
550
	name_entry_set_lib_definition (entry, NIL (LibCapsuleP));
518
	name_entry_set_lib_definition(entry, NIL(LibCapsuleP));
551
    }
519
    }
552
}
520
}
553
 
521
 
554
void
522
void
555
name_entry_show_content PROTO_N ((entry, gclosure))
523
name_entry_show_content(NameEntryP entry,				 GenericP   gclosure)
556
			PROTO_T (NameEntryP entry X
-
 
557
				 GenericP   gclosure)
-
 
558
{
524
{
559
    LibCapsuleP capsule = name_entry_get_lib_definition (entry);
525
    LibCapsuleP capsule = name_entry_get_lib_definition(entry);
560
 
526
 
561
    UNUSED (gclosure);
527
    UNUSED(gclosure);
562
    write_cstring (ostream_output, "  ");
528
    write_cstring(ostream_output, "  ");
563
    write_name_key (ostream_output, name_entry_key (entry));
529
    write_name_key(ostream_output, name_entry_key(entry));
564
    write_char (ostream_output, ' ');
530
    write_char(ostream_output, ' ');
565
    write_usage (ostream_output, name_entry_get_use (entry));
531
    write_usage(ostream_output, name_entry_get_use(entry));
566
    write_cstring (ostream_output, " '");
532
    write_cstring(ostream_output, " '");
567
    write_cstring (ostream_output, lib_capsule_name (capsule));
533
    write_cstring(ostream_output, lib_capsule_name(capsule));
568
    write_char (ostream_output, '\'');
534
    write_char(ostream_output, '\'');
569
    write_newline (ostream_output);
535
    write_newline(ostream_output);
570
}
536
}
571

537

572
/*
538
/*
573
 * Local variables(smf):
539
 * Local variables(smf):
574
 * eval: (include::add-path-entry "../os-interface" "../library")
540
 * eval: (include::add-path-entry "../os-interface" "../library")