Subversion Repositories tendra.SVN

Rev

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

Rev Author Line No. Line
2 7u83 1
/*
6 7u83 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
 */
31
/*
2 7u83 32
    		 Crown Copyright (c) 1997
6 7u83 33
 
2 7u83 34
    This TenDRA(r) Computer Program is subject to Copyright
35
    owned by the United Kingdom Secretary of State for Defence
36
    acting through the Defence Evaluation and Research Agency
37
    (DERA).  It is made available to Recipients with a
38
    royalty-free licence for its use, reproduction, transfer
39
    to other parties and amendment for any purpose not excluding
40
    product development provided that any such use et cetera
41
    shall be deemed to be acceptance of the following conditions:-
6 7u83 42
 
2 7u83 43
        (1) Its Recipients shall ensure that this Notice is
44
        reproduced upon any copies or amended versions of it;
6 7u83 45
 
2 7u83 46
        (2) Any amended version of it shall be clearly marked to
47
        show both the nature of and the organisation responsible
48
        for the relevant amendment or amendments;
6 7u83 49
 
2 7u83 50
        (3) Its onward transfer from a recipient to another
51
        party shall be deemed to be that party's acceptance of
52
        these conditions;
6 7u83 53
 
2 7u83 54
        (4) DERA gives no warranty or assurance as to its
55
        quality or suitability for any purpose and DERA accepts
56
        no liability whatsoever in relation to any use to which
57
        it may be put.
58
*/
59
 
60
 
61
/*** c-out-info.c --- Output control ADT.
62
 *
63
 ** Author: Steve Folkes <smf@hermes.mod.uk>
64
 *
65
 *** Commentary:
66
 *
67
 * This file implements the SID output information routines.
68
 *
69
 *** Change Log:
70
 * $Log: c-out-info.c,v $
71
 * Revision 1.1.1.1  1998/01/17  15:57:43  release
72
 * First version to be checked into rolling release.
73
 *
74
 * Revision 1.3  1996/03/01  09:53:14  smf
75
 * c-code.c, c-out-info.c, c-out-info.h, c-output.c:
76
 * 	- improved unreachable code analysis;
77
 * 	- improved some output formatting;
78
 * 	- added support for comment or macro to mark unreachable code.
79
 *
80
 * Revision 1.2  1994/12/15  09:56:27  smf
81
 * Brought into line with OSSG C Coding Standards Document, as per
82
 * "CR94_178.sid+tld-update".
83
 *
84
 * Revision 1.1.1.1  1994/07/25  16:04:18  smf
85
 * Initial import of SID 1.8 non shared files.
86
 *
87
**/
88
 
89
/****************************************************************************/
90
 
91
#include "c-out-info.h"
92
#include "c-code.h"
93
 
94
/*--------------------------------------------------------------------------*/
95
 
96
void
6 7u83 97
c_out_info_init(COutputInfoP info, OutputInfoP out_info)
2 7u83 98
{
99
    info->info        = out_info;
6 7u83 100
    info->header1     = NIL(CCodeP);
101
    info->header2     = NIL(CCodeP);
102
    info->trailer1    = NIL(CCodeP);
103
    info->trailer2    = NIL(CCodeP);
104
    nstring_copy_cstring(c_out_info_type_prefix(info), "ZT");
105
    nstring_copy_cstring(c_out_info_fn_prefix(info), "ZR");
106
    nstring_copy_cstring(c_out_info_in_prefix(info), "ZI");
107
    nstring_copy_cstring(c_out_info_out_prefix(info), "ZO");
108
    nstring_copy_cstring(c_out_info_label_prefix(info), "ZL");
109
    nstring_copy_cstring(c_out_info_terminal_prefix(info), "ZB");
2 7u83 110
    info->prototypes  = FALSE;
111
    info->numeric_ids = FALSE;
112
    info->casts       = FALSE;
113
    info->unreachable = FALSE;
114
    info->lines       = TRUE;
115
    info->split       = 0;
116
}
117
 
118
#ifdef FS_FAST
119
#undef c_out_info_info
120
#endif /* defined (FS_FAST) */
121
OutputInfoP
6 7u83 122
c_out_info_info(COutputInfoP info)
2 7u83 123
{
6 7u83 124
    return(info->info);
2 7u83 125
}
126
#ifdef FS_FAST
6 7u83 127
#define c_out_info_info(o)	((o)->info)
2 7u83 128
#endif /* defined (FS_FAST) */
129
 
130
#ifdef FS_FAST
131
#undef c_out_info_ostream
132
#endif /* defined (FS_FAST) */
133
OStreamP
6 7u83 134
c_out_info_ostream(COutputInfoP info)
2 7u83 135
{
6 7u83 136
    return(out_info_get_current_ostream(info->info));
2 7u83 137
}
138
#ifdef FS_FAST
6 7u83 139
#define c_out_info_ostream(o)	(out_info_get_current_ostream((o)->info))
2 7u83 140
#endif /* defined (FS_FAST) */
141
 
142
#ifdef FS_FAST
143
#undef c_out_info_program_name
144
#endif /* defined (FS_FAST) */
145
CStringP
6 7u83 146
c_out_info_program_name(COutputInfoP info)
2 7u83 147
{
6 7u83 148
    return(out_info_get_prog_name(info->info));
2 7u83 149
}
150
#ifdef FS_FAST
6 7u83 151
#define c_out_info_program_name(o)	(out_info_get_prog_name((o)->info))
2 7u83 152
#endif /* defined (FS_FAST) */
153
 
154
#ifdef FS_FAST
155
#undef c_out_info_source_name
156
#endif /* defined (FS_FAST) */
157
CStringP
6 7u83 158
c_out_info_source_name(COutputInfoP info)
2 7u83 159
{
6 7u83 160
    return(out_info_get_infile_name(info->info, (unsigned)0));
2 7u83 161
}
162
#ifdef FS_FAST
6 7u83 163
#define c_out_info_source_name(o)\
164
(out_info_get_infile_name((o)->info, (unsigned)0))
2 7u83 165
#endif /* defined (FS_FAST) */
166
 
167
#ifdef FS_FAST
168
#undef c_out_info_c_source_name
169
#endif /* defined (FS_FAST) */
170
CStringP
6 7u83 171
c_out_info_c_source_name(COutputInfoP info)
2 7u83 172
{
6 7u83 173
    return(out_info_get_infile_name(info->info, (unsigned)1));
2 7u83 174
}
175
#ifdef FS_FAST
6 7u83 176
#define c_out_info_c_source_name(o)\
177
(out_info_get_infile_name((o)->info, (unsigned)1))
2 7u83 178
#endif /* defined (FS_FAST) */
179
 
180
#ifdef FS_FAST
181
#undef c_out_info_get_header1
182
#endif /* defined (FS_FAST) */
183
CCodeP
6 7u83 184
c_out_info_get_header1(COutputInfoP info)
2 7u83 185
{
6 7u83 186
    return(info->header1);
2 7u83 187
}
188
#ifdef FS_FAST
6 7u83 189
#define c_out_info_get_header1(o)	((o)->header1)
2 7u83 190
#endif /* defined (FS_FAST) */
191
 
192
#ifdef FS_FAST
193
#undef c_out_info_set_header1
194
#endif /* defined (FS_FAST) */
195
void
6 7u83 196
c_out_info_set_header1(COutputInfoP info, CCodeP code)
2 7u83 197
{
198
    info->header1 = code;
199
}
200
#ifdef FS_FAST
201
#define c_out_info_set_header1(o, c) ((o)->header1 = (c))
202
#endif /* defined (FS_FAST) */
203
 
204
#ifdef FS_FAST
205
#undef c_out_info_get_header2
206
#endif /* defined (FS_FAST) */
207
CCodeP
6 7u83 208
c_out_info_get_header2(COutputInfoP info)
2 7u83 209
{
6 7u83 210
    return(info->header2);
2 7u83 211
}
212
#ifdef FS_FAST
213
#define c_out_info_get_header2(o) ((o)->header2)
214
#endif /* defined (FS_FAST) */
215
 
216
#ifdef FS_FAST
217
#undef c_out_info_set_header2
218
#endif /* defined (FS_FAST) */
219
void
6 7u83 220
c_out_info_set_header2(COutputInfoP info, CCodeP code)
2 7u83 221
{
222
    info->header2 = code;
223
}
224
#ifdef FS_FAST
6 7u83 225
#define c_out_info_set_header2(o, c)	((o)->header2 = (c))
2 7u83 226
#endif /* defined (FS_FAST) */
227
 
228
#ifdef FS_FAST
229
#undef c_out_info_get_trailer1
230
#endif /* defined (FS_FAST) */
231
CCodeP
6 7u83 232
c_out_info_get_trailer1(COutputInfoP info)
2 7u83 233
{
6 7u83 234
    return(info->trailer1);
2 7u83 235
}
236
#ifdef FS_FAST
6 7u83 237
#define c_out_info_get_trailer1(o)	((o)->trailer1)
2 7u83 238
#endif /* defined (FS_FAST) */
239
 
240
#ifdef FS_FAST
241
#undef c_out_info_set_trailer1
242
#endif /* defined (FS_FAST) */
243
void
6 7u83 244
c_out_info_set_trailer1(COutputInfoP info, CCodeP code)
2 7u83 245
{
246
    info->trailer1 = code;
247
}
248
#ifdef FS_FAST
6 7u83 249
#define c_out_info_set_trailer1(o, c)	((o)->trailer1 = (c))
2 7u83 250
#endif /* defined (FS_FAST) */
251
 
252
#ifdef FS_FAST
253
#undef c_out_info_get_trailer2
254
#endif /* defined (FS_FAST) */
255
CCodeP
6 7u83 256
c_out_info_get_trailer2(COutputInfoP info)
2 7u83 257
{
6 7u83 258
    return(info->trailer2);
2 7u83 259
}
260
#ifdef FS_FAST
6 7u83 261
#define c_out_info_get_trailer2(o)	((o)->trailer2)
2 7u83 262
#endif /* defined (FS_FAST) */
263
 
264
#ifdef FS_FAST
265
#undef c_out_info_set_trailer2
266
#endif /* defined (FS_FAST) */
267
void
6 7u83 268
c_out_info_set_trailer2(COutputInfoP info, CCodeP code)
2 7u83 269
{
270
    info->trailer2 = code;
271
}
272
#ifdef FS_FAST
6 7u83 273
#define c_out_info_set_trailer2(o, c)	((o)->trailer2 = (c))
2 7u83 274
#endif /* defined (FS_FAST) */
275
 
276
#ifdef FS_FAST
277
#undef c_out_info_type_prefix
278
#endif /* defined (FS_FAST) */
279
NStringP
6 7u83 280
c_out_info_type_prefix(COutputInfoP info)
2 7u83 281
{
6 7u83 282
    return(&(info->prefixes[CPFX_TYPE]));
2 7u83 283
}
284
#ifdef FS_FAST
6 7u83 285
#define c_out_info_type_prefix(o)	(&((o)->prefixes[CPFX_TYPE]))
2 7u83 286
#endif /* defined (FS_FAST) */
287
 
288
#ifdef FS_FAST
289
#undef c_out_info_fn_prefix
290
#endif /* defined (FS_FAST) */
291
NStringP
6 7u83 292
c_out_info_fn_prefix(COutputInfoP info)
2 7u83 293
{
6 7u83 294
    return(&(info->prefixes[CPFX_FN]));
2 7u83 295
}
296
#ifdef FS_FAST
6 7u83 297
#define c_out_info_fn_prefix(o)	(&((o)->prefixes[CPFX_FN]))
2 7u83 298
#endif /* defined (FS_FAST) */
299
 
300
#ifdef FS_FAST
301
#undef c_out_info_in_prefix
302
#endif /* defined (FS_FAST) */
303
NStringP
6 7u83 304
c_out_info_in_prefix(COutputInfoP info)
2 7u83 305
{
6 7u83 306
    return(&(info->prefixes[CPFX_IN]));
2 7u83 307
}
308
#ifdef FS_FAST
6 7u83 309
#define c_out_info_in_prefix(o)	(&((o)->prefixes[CPFX_IN]))
2 7u83 310
#endif /* defined (FS_FAST) */
311
 
312
#ifdef FS_FAST
313
#undef c_out_info_out_prefix
314
#endif /* defined (FS_FAST) */
315
NStringP
6 7u83 316
c_out_info_out_prefix(COutputInfoP info)
2 7u83 317
{
6 7u83 318
    return(&(info->prefixes[CPFX_OUT]));
2 7u83 319
}
320
#ifdef FS_FAST
6 7u83 321
#define c_out_info_out_prefix(o)	(&((o)->prefixes[CPFX_OUT]))
2 7u83 322
#endif /* defined (FS_FAST) */
323
 
324
#ifdef FS_FAST
325
#undef c_out_info_label_prefix
326
#endif /* defined (FS_FAST) */
327
NStringP
6 7u83 328
c_out_info_label_prefix(COutputInfoP info)
2 7u83 329
{
6 7u83 330
    return(&(info->prefixes[CPFX_LABEL]));
2 7u83 331
}
332
#ifdef FS_FAST
6 7u83 333
#define c_out_info_label_prefix(o)	(&((o)->prefixes[CPFX_LABEL]))
2 7u83 334
#endif /* defined (FS_FAST) */
335
 
336
#ifdef FS_FAST
337
#undef c_out_info_terminal_prefix
338
#endif /* defined (FS_FAST) */
339
NStringP
6 7u83 340
c_out_info_terminal_prefix(COutputInfoP info)
2 7u83 341
{
6 7u83 342
    return(&(info->prefixes[CPFX_TERMINAL]));
2 7u83 343
}
344
#ifdef FS_FAST
6 7u83 345
#define c_out_info_terminal_prefix(o)	(&((o)->prefixes[CPFX_TERMINAL]))
2 7u83 346
#endif /* defined (FS_FAST) */
347
 
348
#ifdef FS_FAST
349
#undef c_out_info_prefix
350
#endif /* defined (FS_FAST) */
351
NStringP
6 7u83 352
c_out_info_prefix(COutputInfoP info, CPrefixT prefix)
2 7u83 353
{
6 7u83 354
    return(&(info->prefixes[prefix]));
2 7u83 355
}
356
#ifdef FS_FAST
6 7u83 357
#define c_out_info_prefix(o, i)	(&((o)->prefixes[i]))
2 7u83 358
#endif /* defined (FS_FAST) */
359
 
360
#ifdef FS_FAST
361
#undef c_out_info_get_prototypes
362
#endif /* defined (FS_FAST) */
363
BoolT
6 7u83 364
c_out_info_get_prototypes(COutputInfoP info)
2 7u83 365
{
6 7u83 366
    return(info->prototypes);
2 7u83 367
}
368
#ifdef FS_FAST
6 7u83 369
#define c_out_info_get_prototypes(o)	((o)->prototypes)
2 7u83 370
#endif /* defined (FS_FAST) */
371
 
372
#ifdef FS_FAST
373
#undef c_out_info_set_prototypes
374
#endif /* defined (FS_FAST) */
375
void
6 7u83 376
c_out_info_set_prototypes(COutputInfoP info, BoolT prototypes)
2 7u83 377
{
378
    info->prototypes = prototypes;
379
}
380
#ifdef FS_FAST
6 7u83 381
#define c_out_info_set_prototypes(o, b)	((o)->prototypes = (b))
2 7u83 382
#endif /* defined (FS_FAST) */
383
 
384
#ifdef FS_FAST
385
#undef c_out_info_get_numeric_ids
386
#endif /* defined (FS_FAST) */
387
BoolT
6 7u83 388
c_out_info_get_numeric_ids(COutputInfoP info)
2 7u83 389
{
6 7u83 390
    return(info->numeric_ids);
2 7u83 391
}
392
#ifdef FS_FAST
6 7u83 393
#define c_out_info_get_numeric_ids(o)	((o)->numeric_ids)
2 7u83 394
#endif /* defined (FS_FAST) */
395
 
396
#ifdef FS_FAST
397
#undef c_out_info_set_numeric_ids
398
#endif /* defined (FS_FAST) */
399
void
6 7u83 400
c_out_info_set_numeric_ids(COutputInfoP info, BoolT numeric_ids)
2 7u83 401
{
402
    info->numeric_ids = numeric_ids;
403
}
404
#ifdef FS_FAST
6 7u83 405
#define c_out_info_set_numeric_ids(o, b)	((o)->numeric_ids = (b))
2 7u83 406
#endif /* defined (FS_FAST) */
407
 
408
#ifdef FS_FAST
409
#undef c_out_info_get_casts
410
#endif /* defined (FS_FAST) */
411
BoolT
6 7u83 412
c_out_info_get_casts(COutputInfoP info)
2 7u83 413
{
6 7u83 414
    return(info->casts);
2 7u83 415
}
416
#ifdef FS_FAST
6 7u83 417
#define c_out_info_get_casts(o)	((o)->casts)
2 7u83 418
#endif /* defined (FS_FAST) */
419
 
420
#ifdef FS_FAST
421
#undef c_out_info_set_casts
422
#endif /* defined (FS_FAST) */
423
void
6 7u83 424
c_out_info_set_casts(COutputInfoP info, BoolT casts)
2 7u83 425
{
426
    info->casts = casts;
427
}
428
#ifdef FS_FAST
6 7u83 429
#define c_out_info_set_casts(o, b)	((o)->casts = (b))
2 7u83 430
#endif /* defined (FS_FAST) */
431
 
432
#ifdef FS_FAST
433
#undef c_out_info_get_unreachable
434
#endif /* defined (FS_FAST) */
435
BoolT
6 7u83 436
c_out_info_get_unreachable(COutputInfoP info)
2 7u83 437
{
6 7u83 438
    return(info->unreachable);
2 7u83 439
}
440
#ifdef FS_FAST
6 7u83 441
#define c_out_info_get_unreachable(o)	((o)->unreachable)
2 7u83 442
#endif /* defined (FS_FAST) */
443
 
444
#ifdef FS_FAST
445
#undef c_out_info_set_unreachable
446
#endif /* defined (FS_FAST) */
447
void
6 7u83 448
c_out_info_set_unreachable(COutputInfoP info, BoolT unreachable)
2 7u83 449
{
450
    info->unreachable = unreachable;
451
}
452
#ifdef FS_FAST
6 7u83 453
#define c_out_info_set_unreachable(o, b)	((o)->unreachable = (b))
2 7u83 454
#endif /* defined (FS_FAST) */
455
 
456
#ifdef FS_FAST
457
#undef c_out_info_get_lines
458
#endif /* defined (FS_FAST) */
459
BoolT
6 7u83 460
c_out_info_get_lines(COutputInfoP info)
2 7u83 461
{
6 7u83 462
    return(info->lines);
2 7u83 463
}
464
#ifdef FS_FAST
6 7u83 465
#define c_out_info_get_lines(o)	((o)->lines)
2 7u83 466
#endif /* defined (FS_FAST) */
467
 
468
#ifdef FS_FAST
469
#undef c_out_info_set_lines
470
#endif /* defined (FS_FAST) */
471
void
6 7u83 472
c_out_info_set_lines(COutputInfoP info, BoolT lines)
2 7u83 473
{
474
    info->lines = lines;
475
}
476
#ifdef FS_FAST
6 7u83 477
#define c_out_info_set_lines(o, b)	((o)->lines = (b))
2 7u83 478
#endif /* defined (FS_FAST) */
479
 
480
#ifdef FS_FAST
481
#undef c_out_info_get_split
482
#endif /* defined (FS_FAST) */
483
unsigned
6 7u83 484
c_out_info_get_split(COutputInfoP info)
2 7u83 485
{
6 7u83 486
    return(info->split);
2 7u83 487
}
488
#ifdef FS_FAST
6 7u83 489
#define c_out_info_get_split(o)	((o)->split)
2 7u83 490
#endif /* defined (FS_FAST) */
491
 
492
#ifdef FS_FAST
493
#undef c_out_info_set_split
494
#endif /* defined (FS_FAST) */
495
void
6 7u83 496
c_out_info_set_split(COutputInfoP info, unsigned split)
2 7u83 497
{
498
    info->split = split;
499
}
500
#ifdef FS_FAST
6 7u83 501
#define c_out_info_set_split(o, n)	((o)->split = (n))
2 7u83 502
#endif /* defined (FS_FAST) */
503
 
504
/*
505
 * Local variables(smf):
506
 * eval: (include::add-path-entry "../os-interface" "../library")
507
 * eval: (include::add-path-entry "../transforms" "../output" "../generated")
508
 * end:
509
**/