|
7 | 7 |
|
8 | 8 | #include "java_bytecode_language.h"
|
9 | 9 |
|
| 10 | +#include <goto-programs/initialize_goto_model.h> |
10 | 11 | #include <goto-programs/read_goto_binary.h>
|
11 |
| -#include <goto-programs/rebuild_goto_start_function.h> |
12 | 12 |
|
13 | 13 | #include <langapi/mode.h>
|
14 | 14 |
|
@@ -163,103 +163,19 @@ void lazy_goto_modelt::initialize(
|
163 | 163 | }
|
164 | 164 | else
|
165 | 165 | {
|
166 |
| - for(const auto &filename : sources) |
167 |
| - { |
168 |
| -#ifdef _MSC_VER |
169 |
| - std::ifstream infile(widen(filename)); |
170 |
| -#else |
171 |
| - std::ifstream infile(filename); |
172 |
| -#endif |
173 |
| - |
174 |
| - if(!infile) |
175 |
| - { |
176 |
| - throw system_exceptiont( |
177 |
| - "failed to open input file '" + filename + '\''); |
178 |
| - } |
179 |
| - |
180 |
| - language_filet &lf = add_language_file(filename); |
181 |
| - lf.language = get_language_from_filename(filename); |
182 |
| - |
183 |
| - if(lf.language == nullptr) |
184 |
| - { |
185 |
| - throw invalid_source_file_exceptiont( |
186 |
| - "failed to figure out type of file '" + filename + '\''); |
187 |
| - } |
188 |
| - |
189 |
| - languaget &language = *lf.language; |
190 |
| - language.set_message_handler(message_handler); |
191 |
| - language.set_language_options(options); |
192 |
| - |
193 |
| - msg.status() << "Parsing " << filename << messaget::eom; |
194 |
| - |
195 |
| - if(language.parse(infile, filename)) |
196 |
| - { |
197 |
| - throw invalid_source_file_exceptiont("PARSING ERROR"); |
198 |
| - } |
199 |
| - |
200 |
| - lf.get_modules(); |
201 |
| - } |
202 |
| - |
203 |
| - msg.status() << "Converting" << messaget::eom; |
204 |
| - |
205 |
| - if(language_files.typecheck(symbol_table)) |
206 |
| - { |
207 |
| - throw invalid_source_file_exceptiont("CONVERSION ERROR"); |
208 |
| - } |
209 |
| - } |
210 |
| - |
211 |
| - for(const std::string &file : binaries) |
212 |
| - { |
213 |
| - msg.status() << "Reading GOTO program from file" << messaget::eom; |
214 |
| - |
215 |
| - if(read_object_and_link(file, *goto_model, message_handler)) |
216 |
| - { |
217 |
| - source_locationt source_location; |
218 |
| - source_location.set_file(file); |
219 |
| - throw incorrect_goto_program_exceptiont( |
220 |
| - "failed to read/link goto model", source_location); |
221 |
| - } |
| 166 | + initialize_from_source_files( |
| 167 | + sources, options, language_files, symbol_table, message_handler); |
222 | 168 | }
|
223 | 169 |
|
224 |
| - bool binaries_provided_start = |
225 |
| - symbol_table.has_symbol(goto_functionst::entry_point()); |
226 |
| - |
227 |
| - bool entry_point_generation_failed = false; |
228 |
| - |
229 |
| - if(binaries_provided_start && options.is_set("function")) |
230 |
| - { |
231 |
| - // The goto binaries provided already contain a __CPROVER_start |
232 |
| - // function that may be tied to a different entry point `function`. |
233 |
| - // Hence, we will rebuild the __CPROVER_start function. |
234 |
| - |
235 |
| - // Get the language annotation of the existing __CPROVER_start function. |
236 |
| - std::unique_ptr<languaget> language = |
237 |
| - get_entry_point_language(symbol_table, options, message_handler); |
238 |
| - |
239 |
| - // To create a new entry point we must first remove the old one |
240 |
| - remove_existing_entry_point(symbol_table); |
241 |
| - |
242 |
| - // Create the new entry-point |
243 |
| - entry_point_generation_failed = |
244 |
| - language->generate_support_functions(symbol_table); |
| 170 | + read_goto_binaries_and_link(binaries, *goto_model, message_handler); |
245 | 171 |
|
246 |
| - // Remove the function from the goto functions so it is copied back in |
247 |
| - // from the symbol table during goto_convert |
248 |
| - if(!entry_point_generation_failed) |
249 |
| - unload(goto_functionst::entry_point()); |
250 |
| - } |
251 |
| - else if(!binaries_provided_start) |
252 |
| - { |
253 |
| - // Allow all language front-ends to try to provide the user-specified |
254 |
| - // (--function) entry-point, or some language-specific default: |
255 |
| - entry_point_generation_failed = |
256 |
| - language_files.generate_support_functions(symbol_table); |
257 |
| - } |
258 |
| - |
259 |
| - if(entry_point_generation_failed) |
260 |
| - { |
261 |
| - throw invalid_source_file_exceptiont("SUPPORT FUNCTION GENERATION ERROR"); |
262 |
| - } |
| 172 | + set_up_custom_entry_point( |
| 173 | + language_files, |
| 174 | + symbol_table, |
| 175 | + [this](const irep_idt &id) { goto_functions.unload(id); }, |
| 176 | + options, |
| 177 | + false, |
| 178 | + message_handler); |
263 | 179 |
|
264 | 180 | // stupid hack
|
265 | 181 | config.set_object_bits_from_symbol_table(symbol_table);
|
|
0 commit comments