@@ -15,6 +15,7 @@ Module: Read Goto Programs
15
15
16
16
#include < util/config.h>
17
17
#include < util/message.h>
18
+ #include < util/replace_symbol.h>
18
19
#include < util/tempfile.h>
19
20
20
21
#ifdef _MSC_VER
@@ -270,59 +271,46 @@ bool is_goto_binary(
270
271
// / \param file_name: file name of the goto binary
271
272
// / \param dest: the goto model returned
272
273
// / \param message_handler: for diagnostics
273
- // / \return true on error, false otherwise
274
- bool read_object_and_link (
274
+ // / \return nullopt on error, type replacements to be applied otherwise
275
+ static optionalt<replace_symbolt::expr_mapt> read_object_and_link (
275
276
const std::string &file_name,
276
277
goto_modelt &dest,
277
278
message_handlert &message_handler)
278
279
{
279
- messaget (message_handler).statistics () << " Reading: "
280
- << file_name << messaget::eom;
280
+ messaget (message_handler).status ()
281
+ << " Reading GOTO program from file " << file_name << messaget::eom;
281
282
282
283
// we read into a temporary model
283
284
auto temp_model = read_goto_binary (file_name, message_handler);
284
285
if (!temp_model.has_value ())
285
- return true ;
286
-
287
- try
288
- {
289
- link_goto_model (dest, *temp_model, message_handler);
290
- }
291
- catch (...)
292
- {
293
- return true ;
294
- }
295
-
296
- // reading successful, let's update config
297
- config.set_from_symbol_table (dest.symbol_table );
286
+ return {};
298
287
299
- return false ;
288
+ return link_goto_model (dest, std::move (*temp_model), message_handler) ;
300
289
}
301
290
302
- // / \brief reads an object file, and also updates the config
303
- // / \param file_name: file name of the goto binary
304
- // / \param dest_symbol_table: symbol table to update
305
- // / \param dest_functions: collection of goto functions to update
306
- // / \param message_handler: for diagnostics
307
- // / \return true on error, false otherwise
308
- bool read_object_and_link (
309
- const std::string &file_name,
310
- symbol_tablet &dest_symbol_table,
311
- goto_functionst &dest_functions,
291
+ bool read_objects_and_link (
292
+ const std::list<std::string> &file_names,
293
+ goto_modelt &dest,
312
294
message_handlert &message_handler)
313
295
{
314
- goto_modelt goto_model;
296
+ if (file_names.empty ())
297
+ return false ;
298
+
299
+ replace_symbolt::expr_mapt object_type_updates;
315
300
316
- goto_model.symbol_table .swap (dest_symbol_table);
317
- goto_model.goto_functions .swap (dest_functions);
301
+ for (const auto &file_name : file_names)
302
+ {
303
+ auto updates_opt = read_object_and_link (file_name, dest, message_handler);
304
+ if (!updates_opt.has_value ())
305
+ return true ;
306
+
307
+ object_type_updates.insert (updates_opt->begin (), updates_opt->end ());
308
+ }
318
309
319
- bool result=read_object_and_link (
320
- file_name,
321
- goto_model,
322
- message_handler);
310
+ finalize_linking (dest, object_type_updates);
323
311
324
- goto_model. symbol_table . swap (dest_symbol_table);
325
- goto_model. goto_functions . swap (dest_functions );
312
+ // reading successful, let's update config
313
+ config. set_from_symbol_table (dest. symbol_table );
326
314
327
- return result ;
315
+ return false ;
328
316
}
0 commit comments