-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathc2ada.h
1545 lines (1173 loc) · 37 KB
/
c2ada.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma once
#include <stddef.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <sys/stat.h>
#include <ctype.h>
#if defined(__unix__) || defined(__linux__) || defined(__CYGWIN__)
#include <unistd.h>
#endif
#include "hostinfo.h"
#define NODE_FNAME(n) file_name(n->node_def)
#define NODE_FLINE(n) line_number(n->node_def)
#ifdef NO_DEALLOC
#undef free
#define free(x)
#endif
#define NEW(type) ((type*)allocate(sizeof(type)))
#ifndef MAX_OUTBUF_LEN
#define MAX_OUTBUF_LEN 1024
#endif
#define COMMENT_BLOCKSIZE 10
#define EVAL_FAILED(x) ((x).eval_result_kind == eval_failed)
#define IS_EVAL_INT(x) ((x).eval_result_kind == eval_int)
#define IS_EVAL_FLOAT(x) ((x).eval_result_kind == eval_float)
#define IS_EVAL_STRING(x) ((x).eval_result_kind == eval_string)
#define EVAL_INT(x) ((x).eval_result.ival)
#define EVAL_FLOAT(x) ((x).eval_result.fval)
#define EVAL_STRING(x) ((x).eval_result.sval)
#define BUILTIN_FILE -2
#define BUILTIN_LINE -3
#define BAD_INPUT 3
#define PUNCT 0
#define PARAM_START 1
#define END_INPUT 2
#define ALPHA 4
#define DIGIT 8
#define XDIGIT 16
#define WHITE 32
#define END_OF_LINE 64
#define MSTART 128
#define is_eof(c) ((cpp_char_class[(int)(c)] & END_INPUT) != 0)
#define is_eol(c) ((cpp_char_class[(int)(c)] & END_OF_LINE) != 0)
#define is_hex_digit(c) ((cpp_char_class[(int)(c)] & XDIGIT) != 0)
#define is_octal_digit(c) ((c) >= '0' && (c) <= '7')
#define is_digit(c) ((cpp_char_class[(int)(c)] & DIGIT) != 0)
#define is_white(c) ((cpp_char_class[(int)(c)] & WHITE) != 0)
#define is_punct(c) (cpp_char_class[(int)(c)] == PUNCT)
#define is_alpha(c) ((cpp_char_class[(int)(c)] & ALPHA) != 0)
#define is_alpha_numeric(c) ((cpp_char_class[(int)(c)] & (ALPHA | DIGIT)) != 0)
#define classof(c) (cpp_char_class[(int)(c)])
#define int_modifier(c) ((c) == 'l' || (c) == 'L' || (c) == 'u' || (c) == 'U')
#define float_modifier(c) ((c) == 'F' || (c) == 'f' || (c) == 'D' || (c) == 'd')
#define is_magnitude(c) ((c) == 'E' || (c) == 'e')
#ifndef FILE_ORD_BITS
#define FILE_ORD_BITS 10
#endif
#if !defined(BITS_PER_BYTE)
#define BITS_PER_BYTE 8
#endif
#if !defined(SIZEOF_LONG)
#define SIZEOF_LONG 4
#endif
#define LINE_NUMBER_BITS ((SIZEOF_LONG * BITS_PER_BYTE) - FILE_ORD_BITS)
#define MAX_UNIQ_FNAMES (1 << FILE_ORD_BITS)
#define line_number(x) ((x) & ((1L << LINE_NUMBER_BITS) - 1))
#undef START_INDENT
#define START_INDENT 0
#ifndef COMMENT_POS
#define COMMENT_POS 64
#endif
#define MAX_INDENT(x) \
{ \
int _i = cur_indent(); \
if(_i > (x)) \
(x) = _i; \
}
#ifndef HASH_PRIME
#define HASH_PRIME 31741
#endif
#ifdef aix
#define C_VAR_PREFIX "."
#else
#define C_VAR_PREFIX "_"
#endif
#ifdef aix
#define C_SUBP_PREFIX "."
#else
#define C_SUBP_PREFIX "_"
#endif
#define SIZEOF_ENUM SIZEOF_INT
#define ALIGNOF_ENUM ALIGNOF_INT
#define ENUM_PREFIX '1'
#define STRUCT_PREFIX '2'
#define UNION_PREFIX '3'
#define TYPEMOD_EXTERN 0x0001
#define TYPEMOD_AUTO 0x0002
#define TYPEMOD_REGISTER 0x0004
#define TYPEMOD_SHORT 0x0008
#define TYPEMOD_STATIC 0x0010
#define TYPEMOD_SIGNED 0x0020
#define TYPEMOD_UNSIGNED 0x0040
#define TYPEMOD_VOLATILE 0x0080
#define TYPEMOD_TYPEDEF 0x0100
#define TYPEMOD_CONST 0x0200
#define TYPEMOD_LONG 0x1000
#define TYPEMOD_INLINE 0x2000
#define unimplemented() not_implemented(__FILE__, __LINE__)
typedef short int scope_id_t;
typedef unsigned long file_pos_t;
typedef int file_id_t;
typedef unsigned long line_nt;
typedef long cpp_int_t;
typedef int unit_n; /* (type of) unique output Ada PACKAGE number */
/*
* Internal types for all integer and floating point constants.
* If you decide to change these types you better check the
* print_value() and print_fp_value() routines in gen.c. They
* will most likely have to be updated.
*/
typedef unsigned long hash_t;
typedef long int host_int_t;
typedef double host_float_t;
struct cpp_file_t;
struct node_t;
struct symbol_t;
struct typeinfo_t;
typedef struct symbol_t symbol_t;
typedef struct cpp_file_t cpp_file_t, *cpp_file_pt;
typedef struct node_t* node_pt;
typedef struct typeinfo_t* typeinfo_pt;
typedef struct pkg_def_t* pkg_def_pt;
typedef struct comment_block* comment_block_pt;
typedef struct stmt_t* stmt_pt;
typedef enum
{
unspecified_vendor,
Rational,
VADS,
ICC, /* Irvine Compiler */
GNAT
} vendor_t;
/*
* Possible symbol declarations
*/
typedef enum
{
type_symbol = 256,
func_symbol,
param_symbol,
var_symbol,
enum_literal,
pkg_symbol /* designates an Ada output package */
} sym_kind_t;
typedef enum
{
eval_failed,
eval_int,
eval_float,
eval_string,
eval_type
} cpp_eval_result_kind_t;
enum
{
Define = 1,
Elif,
Else,
Endif,
Error,
Ident,
If,
Ifdef,
Ifndef,
Include,
Line,
Pragma,
Undef
};
typedef enum
{
Report_fatal,
Report_error,
Report_warning,
Report_inform
} report_t;
typedef enum
{
_Labelled,
_Case,
_Default,
_Compound,
_SList,
_Expr,
_If,
_Ifelse,
_Switch,
_While,
_Do,
_For,
_Goto,
_Continue,
_Break,
_Return,
_Null,
_FuncDef,
_MacroBody
} stmt_kind_t;
typedef enum
{
Unspecified_scope,
Func_scope,
File_scope,
Block_scope,
Proto_scope
} scope_kind_t;
/*
* Possible declaration types
*/
typedef enum
{
pointer_to = 128,
array_of,
struct_of,
union_of,
field_type,
int_type,
float_type,
void_type,
function_type,
enum_type,
typemodifier
} typekind_t;
typedef enum
{
Upper,
Lower,
Cap
} ident_case_t;
typedef enum
{
scan_file,
scan_macro_expansion,
scan_text
} scan_kind_t;
/*
* Our enums ordinals don't overlap nor do
* they start with zero so that it's easy
* to trap pointers to trash when debugging
*/
typedef enum
{
pointer_decl = 1,
int_decl,
fp_decl,
field_decl,
func_decl,
/* TBD: add separate enum for func_def ? */
enum_decl,
array_decl,
struct_decl
} decl_class_t;
/*
* expression kinds
*/
typedef enum
{
_Error = 32,
_Ellipsis,
_FP_Number, /* floating literal */
_Int_Number, /* integral literal */
_Char_Lit, /* character literal */
_Type,
_Sym,
_Ident,
_Macro_ID,
_String,
_List, /* first binary */
_Comma,
_Bit_Field,
_Dot_Selected,
_Arrow_Selected,
_Array_Index,
_Func_Call,
_Type_Cast,
_Assign,
_Mul_Assign,
_Div_Assign,
_Mod_Assign,
_Add_Assign,
_Sub_Assign,
_Shl_Assign,
_Shr_Assign,
_Band_Assign,
_Xor_Assign,
_Bor_Assign,
_Eq,
_Ne,
_Lt,
_Le,
_Gt,
_Ge,
_Land,
_Lor,
_Band,
_Bor,
_Xor,
_Add,
_Sub,
_Mul,
_Div,
_Rem,
_Shl,
_Shr, /* last binary */
_Exp, /* exponentiation (**), Ada only, binary */
_Concat, /* concatenation (&), Ada only, binary */
_Sizeof, /* first unary */
_Pre_Inc,
_Pre_Dec,
_Post_Inc,
_Post_Dec,
_Addrof,
_Unary_Plus,
_Unary_Minus,
_Ones_Complement,
_Not,
_Aggregate,
_Indirect, /* last unary */
_BoolTyp, /* cvt to Boolean, Ada only, unary */
_UnBool, /* cvt bool->int, Ada only, unary */
_Char_to_Int,
_Int_to_Char,
_Cond
} node_kind_t;
/*
* If a macro is a function, split up the right-hand-side
* into function name, # parameters, and parameter vector
*/
typedef struct macro_function_t
{
char* mf_fname; /* function name */
int mf_nparams; /* number of parameters */
char** mf_params; /* list of parameters */
char* mf_coercion; /* type coercion, if any */
int mf_is_pointer; /* is it a pointer-to-function? */
char* mf_rhs; /* right-hand-side of definition */
} macro_function_t;
typedef struct
{
cpp_eval_result_kind_t eval_result_kind;
union
{
cpp_int_t ival;
double fval;
char* sval;
typeinfo_pt tval;
} eval_result;
int base; /* 10, 8, or 16 */
typeinfo_pt explicit_type;
} cpp_eval_result_t;
typedef struct macro_t
{
char* macro_name;
char* macro_ada_name;
char* macro_body;
int macro_body_len;
int macro_params;
char** macro_param_vec;
file_pos_t macro_definition;
struct macro_t* macro_next;
hash_t macro_hash;
struct macro_t* macro_hash_link;
macro_function_t* macro_func;
struct comment_block* comment; /* preceding block comment */
char* eol_comment; /* comment on end-of-line */
cpp_eval_result_t const_value;
bool macro_declared_in_header : 1;
bool macro_gened : 1;
bool macro_valid : 1;
bool macro_eval_tried : 1;
bool macro_evald : 1;
} macro_t;
typedef struct node_t
{
node_kind_t node_kind;
file_pos_t node_def;
union
{ /* node. */
struct
{
struct node_t* boolval;
struct node_t* tru;
struct node_t* fals;
} cond;
struct
{
char* form;
int len;
} str;
struct
{
struct node_t *l, *r;
} binary;
struct
{ /* node.id. */
char* name;
char* cmnt;
symbol_t* sym;
} id;
struct macro_t* macro;
struct node_t* unary;
struct symbol_t* sym;
struct typeinfo_t* typ;
host_int_t ival;
host_float_t fval;
} node;
short int baseval; /* for integers */
unsigned int fixed : 1; /* does not need processing by
fix_expr */
unsigned int no_nul : 1; /* for _String: don't append Nul */
unsigned int char_lit : 1; /* for _Int_Number: is a char literal*/
struct typeinfo_t* type;
comment_block_pt comment;
} node_t;
/*
* Macros to get the file name and line number
* info from the original C source
*/
typedef struct typeinfo_t
{
typekind_t type_kind;
unsigned int is_unsigned : 1;
unsigned int is_signed : 1;
unsigned int is_short : 1;
unsigned int is_long : 1;
unsigned int is_long_long : 1;
unsigned int is_volatile : 1;
unsigned int is_constant : 1;
unsigned int is_extern : 1;
unsigned int is_static : 1;
unsigned int is_auto : 1;
unsigned int is_register : 1;
unsigned int is_typedef : 1;
unsigned int is_builtin : 1; /* An intrinsic type */
unsigned int is_anonymous : 1;
unsigned int is_anon_int : 1; /* no type changed to int */
unsigned int is_inline : 1; /* inline function */
unsigned int is_boolean : 1; /* special marker for Ada-output bool type */
/* type_info. */
union
{
/* array. */
struct
{
int elements;
node_pt size_expr;
} array;
typeinfo_pt struct_fields;
symbol_t* formals;
} type_info;
unsigned int type_sizeof;
unsigned int type_alignof;
unsigned int type_hash; /* Comparison heuristic */
symbol_t* type_base;
typeinfo_pt type_anonymous_list;
typeinfo_pt type_next;
} typeinfo_t;
typedef struct symbol_t
{
sym_kind_t sym_kind;
scope_id_t sym_scope_id;
unsigned char sym_scope;
unsigned int intrinsic : 1; /* intrinsic/builtin symbol */
unsigned int is_volatile : 1;
unsigned int is_const : 1;
unsigned int is_inline : 1; /* inline function */
unsigned int is_static : 1; /* declared "static" */
unsigned int is_created_name : 1; /* has synthesized name */
unsigned int is_created_by_reference : 1;
unsigned int is_declared_in_header : 1;
unsigned int is_struct_or_union_member : 1;
unsigned int has_initializer : 1;
unsigned int emit_initializer : 1;
/* on a local var,
* forces initializer rather
* than separate assignment statement
*/
unsigned int gened : 1; /* Has been passed to gen routines */
unsigned int cleared : 1; /* Symbol can be queued */
unsigned int stored : 1; /* Has been added to symbol table */
unsigned int interfaced : 1; /* interface done */
unsigned int emitted : 1; /* Ada has been output for this sym*/
unsigned int renames : 1; /* sym renames a designator expr */
unsigned int aliases : 1; /* This sym is equivalent to another
* sym, namely this->sym_value->
* aliased_sym.
*/
unsigned int has_return : 1; /* body for function sym contains
* a return statement.
*/
unsigned int isprivate : 1; /* configured as private */
unsigned int declare_in_spec : 1;
/* configured to ensure sym
* has a declaration in the Ada spec
*/
int traversal_unit; /* heuristic to eliminate
redundant unit traversals */
node_pt sym_ident; /* C name - node saved for comments */
char* sym_ada_name; /* Generated Ada name */
file_pos_t sym_def; /* File,line definition */
typeinfo_pt sym_type; /* Symbols type info */
int bitoffset; /* For fields only */
union
{ /* sym_value. */
node_pt initializer;
host_int_t intval;
struct stmt_t* body; /* "value" of func def is
its body */
pkg_def_pt pkg_def;
symbol_t* aliased_sym; /* If this->aliases is set,
* then this sym is equivalent
* to this->aliased_sym.
*/
} sym_value;
comment_block_pt comment; /* block comment */
symbol_t* sym_tags; /* List of struct/union fields
or enum literals */
struct symbol_t* sym_parse_list; /* List used by front end */
struct symbol_t* sym_scope_list; /* List used by front end */
struct symbol_t* sym_gen_list; /* List used by back end */
/* hash table info */
hash_t sym_hash; /* Comparison heuristic */
struct symbol_t* sym_hash_list;
} symbol_t;
typedef struct
{
macro_t* expand_macro;
char** expand_actuals;
int expand_nactuals;
} macro_expansion_t;
typedef struct scan_position_t
{
scan_kind_t scan_kind;
union
{
macro_expansion_t expansion;
cpp_file_pt file;
char* text;
} scan;
file_pos_t scan_pos;
int scan_index;
struct scan_position_t* scan_next;
} scan_position_t;
typedef struct
{
int skip_else;
int cur_scope;
int gen_scope;
int _parsing;
file_pos_t position;
} cpp_control_state_t;
typedef struct buffer_t
{
char buf[MAX_OUTBUF_LEN];
unsigned short head, tail;
struct buffer_t *next, *last;
} buffer_t;
struct comment_block
{
struct comment_block* next;
int count;
char* line[COMMENT_BLOCKSIZE];
};
typedef struct
{
node_pt* head;
node_pt* rest;
node_pt* tail; /* head + rest node */
} node_iter_t;
/* A statement is represented by a stmt_t structure. */
typedef struct stmt_t
{
file_pos_t stmt_def;
stmt_kind_t stmt_kind;
comment_block_pt comment;
scope_id_t scope;
union /* (stmt_kind) */
{
/* case _Labelled, _Case: */
struct
{
node_pt id;
stmt_pt stmt;
} label;
/* case _Default: */
stmt_pt default_stmt;
/* case _SList: */
struct
{
stmt_pt first; /* a single statement */
stmt_pt rest; /* a statement list, or null */
} stmt_list;
/* case _Compound */
struct
{
symbol_t* decls;
stmt_pt stmts;
} compound;
/* case _FuncDef */
struct
{
symbol_t* decl;
stmt_pt body;
} funcdef;
/* case _Expr: */
node_pt expr;
/* case _If, _Switch, _While, _Do: */
struct
{
node_pt expr;
stmt_pt stmt;
} controlled;
/* case _Ifelse */
struct
{
node_pt expr;
stmt_pt then_stmt, else_stmt;
} if_else_stmt;
/* case _For: */
struct
{
node_pt e1, e2, e3;
stmt_pt stmt;
} for_stmt;
/* case _Goto: */
node_pt goto_label;
/* case _Return: */
node_pt return_value;
/* case _MacroBody: */
char* macro_body;
/* case _Null, _Continue, _Break, - nothing */
} stmt;
} stmt_t;
typedef struct case_alist
{ /* list of alternatives */
node_pt exp; /* case 1: case 2: ... */
struct case_alist* rest;
} case_alist, *case_alist_pt;
typedef struct case_slist
{ /* list of statements after an alternative */
stmt_pt stm;
struct case_slist* rest;
} case_slist, *case_slist_pt;
typedef struct case_blist
{ /* list of blocks in case */
case_alist_pt alts; /* a block is an alist followed by an slist */
case_slist_pt stms;
struct case_blist* rest;
int has_default;
stmt_pt last_stmt;
} case_blist, *case_blist_pt;
typedef struct case_stmt
{ /* C switch stmt, Ada case stmt */
node_pt exp;
case_blist_pt branches;
case_blist_pt default_branch;
} case_stmt, *case_stmt_pt;
typedef void (*gen_unchecked_conversion_func_pt)(symbol_t* sym,
typeinfo_pt from_type,
typeinfo_pt to_type);
typedef void (*gen_stdarg_concat_func_pt)(typeinfo_pt type);
typedef void (*gen_use_type_decl_pt)(typeinfo_pt type);
extern symbol_t* anonymous_function_pointer;
extern bool configured;
extern bool at_file_start;
extern unsigned char cpp_char_class[];
extern macro_t* macro_list_head;
extern struct typeinfo_t* bogus_type;
extern int max_const_name_indent;
extern macro_t* unit_macros[];
extern symbol_t* ellipsis_sym;
extern bool current_unit_is_header;
extern char* predef_pkg;
extern vendor_t ada_compiler;
bool is_ada_keyword(char*);
void make_ada_identifier(char*, char*);
char* uniq_name(char*, int);
char* ada_name(char*, int);
ident_case_t id_case(char*);
void id_format(char*, ident_case_t);
/* return a pointer to the final component name in an Ada name */
char* tail(char* component);
bool same_ada_type(typeinfo_pt t1, typeinfo_pt t2);
char* new_string(char*);
char* new_strf(char*, ...); /* uses printf style formatting */
void* allocate(size_t size);
void deallocate(void* ptr);
void init_anonymous_types();
symbol_t* get_anonymous_type(typeinfo_pt);
int next_anonymous_ord();
typeinfo_pt find_anonymous_type(typeinfo_pt);
void store_anonymous_type(typeinfo_t* typ);
char* predef_name(char* s);
char* predef_name_copy(char* s);
/* $Source: /home/CVSROOT/c2ada/aux_decls.h,v $ */
/* $Revision: 1.1.1.1 $ $Date: 1999/02/02 12:01:51 $ */
symbol_t* unchecked_conversion_func(typeinfo_pt from_type,
typeinfo_pt to_type,
file_pos_t pos,
bool in_spec);
void gen_unchecked_conversion_funcs(unit_n unit, gen_unchecked_conversion_func_pt f);
/* Stdarg usage */
node_pt stdarg_empty_node(file_pos_t pos);
void use_stdarg_concat(unit_n unit, typeinfo_pt type);
void gen_stdarg_concat_funcs(unit_n unit, gen_stdarg_concat_func_pt f);
void use_type(unit_n unit, typeinfo_pt type);
void gen_use_type_decls(unit_n unit, gen_use_type_decl_pt f);
/* It goes against the grain to say this in C, but ... */
/*
* MAX_OUTBUF_LEN must be a power of 2 and it should
* be large enough that overflows are uncommon, but
* we use many automatic instances of the queues so
* it shouldn't be so large that our stack grows
* like Jack's beanstock.
*/
int buf_empty(buffer_t*);
int buf_count(buffer_t*);
void buf_add(buffer_t*, int);
void buf_add_str(buffer_t*, char*);
char buf_get(buffer_t*);
void buf_init(buffer_t*);
void buf_destroy(buffer_t*);
void buf_concat(buffer_t*, buffer_t*);
void buf_move_to(buffer_t*, char*);
char* buf_get_str(buffer_t*);
void add_comment_line(comment_block_pt block, char* line);
comment_block_pt new_comment_block();
void put_comment_block(comment_block_pt block, int indent);
void configure_project(char* filename);
char** configured_reserved_ids(int* count_p);
bool configured_source_flag(char* source, char* attribute, bool default_result);
bool configured_sym_info(symbol_t* sym, typeinfo_pt type);
void set_output_dir(char* pathname);
char* configured_output_dir();
char* configured_source_partner(char* fname);
char* configured_macro_replacement(file_id_t file,
char* macro_name,
char* macro_body,
int body_len,
int nformals,
char** formals,
char* eol_comment);
typedef struct context_t ctxt_t, *ctxt_pt;
ctxt_pt new_context(scope_id_t scope);
ctxt_pt copy_context(ctxt_pt);
void free_context(ctxt_pt);
bool changed_pre(ctxt_pt ctxt);
bool changed_post(ctxt_pt ctxt);
bool added_decls(ctxt_pt ctxt);
void reset_changed(ctxt_pt ctxt);
void clear_pre_and_post(ctxt_pt ctxt);
stmt_pt pre_stmts(ctxt_pt ctxt);
void set_pre(ctxt_pt ctxt, stmt_pt stmts);
void append_pre(ctxt_pt ctxt, stmt_pt stmt);
stmt_pt post_stmts(ctxt_pt ctxt);
void set_post(ctxt_pt ctxt, stmt_pt stmts);
void append_post(ctxt_pt ctxt, stmt_pt stmt);
symbol_t* decls(ctxt_pt ctxt, int scope_id);
void set_decls(ctxt_pt ctxt, symbol_t* decls); /* TBD: how linked? */
void append_decl(ctxt_pt ctxt, symbol_t* decl);
void append_decls(ctxt_pt ctxt, symbol_t* decls);
scope_id_t ctxt_scope(ctxt_pt ctxt);
int cpp_open(char* path);
void cpp_cleanup();
int cpp_getc();
void cpp_search_path(char*);
void cpp_system_search_path(char*);
int in_system_search_path(char*);
void cpp_show_predefines();
cpp_eval_result_t cpp_eval(char*);
/*
* The builtin cpp macros will be added to the hash table as normal
* macros. They are identified by their num_params field which will
* have one of the following builtin values.
*/
/*
* Character classes for the preprocessor
*/
int cpp_getc_from(buffer_t*);
void cpp_set_state(scan_position_t*, cpp_control_state_t*, scan_position_t**, cpp_control_state_t*);
void vreport(report_t severity, char* filename, int linenum, char* format, va_list ap);
void fatal(char*, int, char*, ...);
void error(char*, int, char*, ...);
void warning(char*, int, char*, ...);
void inform(char*, int, char*, ...);
void assert_failed(char*, int, char*);
void syserr(char*, int);
/*
* Routines for dealing with files and file names.
*
* The current file and line number during scanning is
* maintained int packed long int. This will reduce the size
* of a lot of our IL types.
*/
/*
* Upper FILE_ORD_BITS specify file ordinal.
* Rest of integer specifies line number.
*/