1 /* Process source files and output type information.
2 Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING. If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21 /* A file position, mostly for error messages.
22 The FILE element may be compared using pointer equality. */
28 /* Kinds of types we can understand. */
40 typedef struct pair
*pair_p
;
41 typedef struct type
*type_p
;
42 typedef unsigned lang_bitmap
;
44 /* Option data for the 'nested_ptr' option. */
45 struct nested_ptr_data
{
47 const char *convert_to
;
48 const char *convert_from
;
51 /* A way to pass data through to the output end. */
52 typedef struct options
{
58 /* A name and a type. */
69 /* A description of a type. */
82 enum gc_used_enum gc_used
;
100 type_p param
[NUM_PARAM
];
107 ((x)->kind == TYPE_UNION || \
108 ((x)->kind == TYPE_LANG_STRUCT \
109 && (x)->u.s.lang_struct->kind == TYPE_UNION))
110 #define UNION_OR_STRUCT_P(x) \
111 ((x)->kind == TYPE_UNION \
112 || (x)->kind == TYPE_STRUCT \
113 || (x)->kind == TYPE_LANG_STRUCT)
115 /* The one and only TYPE_STRING. */
116 extern struct type string_type
;
118 /* Variables used to communicate between the lexer and the parser. */
119 extern int lexer_toplevel_done
;
120 extern struct fileloc lexer_line
;
122 /* Print an error message. */
123 extern void error_at_line
124 (struct fileloc
*pos
, const char *msg
, ...) ATTRIBUTE_PRINTF_2
;
126 /* Combines xmalloc() and vasprintf(). */
127 extern int xvasprintf (char **, const char *, va_list)
128 ATTRIBUTE_PRINTF (2, 0);
129 /* Like the above, but more convenient for quick coding. */
130 extern char * xasprintf (const char *, ...)
133 /* Constructor routines for types. */
134 extern void do_typedef (const char *s
, type_p t
, struct fileloc
*pos
);
135 extern type_p
resolve_typedef (const char *s
, struct fileloc
*pos
);
136 extern void new_structure (const char *name
, int isunion
,
137 struct fileloc
*pos
, pair_p fields
,
139 extern type_p
find_structure (const char *s
, int isunion
);
140 extern type_p
create_scalar_type (const char *name
, size_t name_len
);
141 extern type_p
create_pointer (type_p t
);
142 extern type_p
create_array (type_p t
, const char *len
);
143 extern options_p
create_option (const char *name
, void *info
);
144 extern type_p
adjust_field_type (type_p
, options_p
);
145 extern void note_variable (const char *s
, type_p t
, options_p o
,
146 struct fileloc
*pos
);
147 extern void note_yacc_type (options_p o
, pair_p fields
,
148 pair_p typeinfo
, struct fileloc
*pos
);
150 /* Lexer and parser routines, most automatically generated. */
151 extern int yylex (void);
152 extern void yyerror (const char *);
153 extern int yyparse (void);
154 extern void parse_file (const char *name
);
156 /* Output file handling. */
158 /* Structure representing an output file. */
168 typedef struct outf
* outf_p
;
170 /* An output file, suitable for definitions, that can see declarations
171 made in INPUT_FILE and is linked into every language that uses
173 extern outf_p get_output_file_with_visibility
174 (const char *input_file
);
175 const char *get_output_file_name (const char *);
177 /* A list of output files suitable for definitions. There is one
178 BASE_FILES entry for each language. */
179 extern outf_p base_files
[];
181 /* A bitmap that specifies which of BASE_FILES should be used to
182 output a definition that is different for each language and must be
183 defined once in each language that uses INPUT_FILE. */
184 extern lang_bitmap
get_base_file_bitmap (const char *input_file
);
186 /* Print, like fprintf, to O. */
187 extern void oprintf (outf_p o
, const char *S
, ...)