OLD | NEW |
1 /* Factored pre-parsed header (PPH) support for C++ | 1 /* Factored pre-parsed header (PPH) support for C++ |
2 Copyright (C) 2010, 2011 Free Software Foundation, Inc. | 2 Copyright (C) 2010, 2011 Free Software Foundation, Inc. |
3 Contributed by Lawrence Crowl <crowl@google.com> and | 3 Contributed by Lawrence Crowl <crowl@google.com> and |
4 Diego Novillo <dnovillo@google.com>. | 4 Diego Novillo <dnovillo@google.com>. |
5 | 5 |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
8 GCC is free software; you can redistribute it and/or modify it | 8 GCC is free software; you can redistribute it and/or modify it |
9 under the terms of the GNU General Public License as published by | 9 under the terms of the GNU General Public License as published by |
10 the Free Software Foundation; either version 3, or (at your option) | 10 the Free Software Foundation; either version 3, or (at your option) |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 fprintf (pph_logfile, "%s", name); | 173 fprintf (pph_logfile, "%s", name); |
174 fprintf (pph_logfile, "%c\n", angle_brackets ? '>' : '"'); | 174 fprintf (pph_logfile, "%c\n", angle_brackets ? '>' : '"'); |
175 } | 175 } |
176 | 176 |
177 read_text_file_p = true; | 177 read_text_file_p = true; |
178 pph_file = query_pph_include_map (name); | 178 pph_file = query_pph_include_map (name); |
179 if (pph_file != NULL | 179 if (pph_file != NULL |
180 && pph_is_valid_here (name, loc) | 180 && pph_is_valid_here (name, loc) |
181 && !cpp_included_before (reader, name, input_location)) | 181 && !cpp_included_before (reader, name, input_location)) |
182 { | 182 { |
| 183 pph_stream *include; |
| 184 |
183 /* Hack. We do this to mimic what the non-pph compiler does in | 185 /* Hack. We do this to mimic what the non-pph compiler does in |
184 _cpp_stack_include as our goal is to have identical line_tables. */ | 186 _cpp_stack_include as our goal is to have identical line_tables. */ |
185 line_table->highest_location--; | 187 line_table->highest_location--; |
186 | 188 |
187 pph_read_file (pph_file); | 189 include = pph_read_file (pph_file); |
| 190 |
| 191 /* If we are generating a new PPH image, add the stream we just |
| 192 » read to the list of includes. This way, the parser will be |
| 193 » able to resolve references to symbols in INCLUDE and its |
| 194 » children. */ |
| 195 if (pph_writer_enabled_p ()) |
| 196 » pph_writer_add_include (include); |
| 197 |
188 read_text_file_p = false; | 198 read_text_file_p = false; |
189 } | 199 } |
190 | 200 |
191 return read_text_file_p; | 201 return read_text_file_p; |
192 } | 202 } |
193 | 203 |
194 | 204 |
195 /* The initial order of the size of the lexical lookaside table, | 205 /* The initial order of the size of the lexical lookaside table, |
196 which will accomodate as many as half of its slots in use. */ | 206 which will accomodate as many as half of its slots in use. */ |
197 | 207 |
(...skipping 20 matching lines...) Expand all Loading... |
218 fprintf (pph_logfile, "PPH: Initializing.\n"); | 228 fprintf (pph_logfile, "PPH: Initializing.\n"); |
219 | 229 |
220 /* Set up the libcpp handler for #include. */ | 230 /* Set up the libcpp handler for #include. */ |
221 cb = cpp_get_callbacks (parse_in); | 231 cb = cpp_get_callbacks (parse_in); |
222 cb->include = pph_include_handler; | 232 cb->include = pph_include_handler; |
223 | 233 |
224 table = cpp_lt_exchange (parse_in, | 234 table = cpp_lt_exchange (parse_in, |
225 cpp_lt_create (cpp_lt_order, flag_pph_debug/2)); | 235 cpp_lt_create (cpp_lt_order, flag_pph_debug/2)); |
226 gcc_assert (table == NULL); | 236 gcc_assert (table == NULL); |
227 | 237 |
| 238 pph_streamer_init (); |
| 239 |
228 /* If we are generating a PPH file, initialize the writer. */ | 240 /* If we are generating a PPH file, initialize the writer. */ |
229 if (pph_writer_enabled_p ()) | 241 if (pph_writer_enabled_p ()) |
230 pph_writer_init (); | 242 pph_writer_init (); |
231 | |
232 pph_init_preloaded_cache (); | |
233 | |
234 pph_read_images = NULL; | |
235 } | 243 } |
236 | 244 |
237 | 245 |
238 /* Finalize PPH support. */ | 246 /* Finalize PPH support. */ |
239 | 247 |
240 void | 248 void |
241 pph_finish (void) | 249 pph_finish (void) |
242 { | 250 { |
243 /* Finalize the writer. */ | 251 /* Finalize the streamer. */ |
244 pph_writer_finish (); | 252 pph_streamer_finish (); |
245 | |
246 /* Finalize the reader. */ | |
247 pph_reader_finish (); | |
248 | 253 |
249 /* Close log files. */ | 254 /* Close log files. */ |
250 if (flag_pph_tracer >= 1) | 255 if (flag_pph_tracer >= 1) |
251 fprintf (pph_logfile, "PPH: Finishing.\n"); | 256 fprintf (pph_logfile, "PPH: Finishing.\n"); |
252 | 257 |
253 if (flag_pph_logfile) | 258 if (flag_pph_logfile) |
254 fclose (pph_logfile); | 259 fclose (pph_logfile); |
255 } | 260 } |
OLD | NEW |