@@ -27,6 +27,7 @@ Author: Peter Schrammel
27
27
#include < goto-programs/adjust_float_expressions.h>
28
28
#include < goto-programs/goto_convert_functions.h>
29
29
#include < goto-programs/goto_inline.h>
30
+ #include < goto-programs/initialize_goto_model.h>
30
31
#include < goto-programs/instrument_preconditions.h>
31
32
#include < goto-programs/link_to_library.h>
32
33
#include < goto-programs/loop_ids.h>
@@ -62,24 +63,8 @@ Author: Peter Schrammel
62
63
63
64
goto_diff_parse_optionst::goto_diff_parse_optionst (int argc, const char **argv)
64
65
: parse_options_baset(GOTO_DIFF_OPTIONS, argc, argv, ui_message_handler),
65
- goto_diff_languagest(cmdline, ui_message_handler),
66
- ui_message_handler(cmdline, std::string(" GOTO-DIFF " ) + CBMC_VERSION),
67
- languages2(cmdline, ui_message_handler)
68
- {
69
- }
70
-
71
- ::goto_diff_parse_optionst::goto_diff_parse_optionst (
72
- int argc,
73
- const char **argv,
74
- const std::string &extra_options)
75
- : parse_options_baset(
76
- GOTO_DIFF_OPTIONS + extra_options,
77
- argc,
78
- argv,
79
- ui_message_handler),
80
- goto_diff_languagest(cmdline, ui_message_handler),
81
- ui_message_handler(cmdline, std::string(" GOTO-DIFF " ) + CBMC_VERSION),
82
- languages2(cmdline, ui_message_handler)
66
+ messaget(ui_message_handler),
67
+ ui_message_handler(cmdline, std::string(" GOTO-DIFF " ) + CBMC_VERSION)
83
68
{
84
69
}
85
70
@@ -256,21 +241,21 @@ int goto_diff_parse_optionst::doit()
256
241
return CPROVER_EXIT_INCORRECT_TASK;
257
242
}
258
243
259
- goto_modelt goto_model1, goto_model2 ;
244
+ register_languages () ;
260
245
261
- int get_goto_program_ret =
262
- get_goto_program (options, * this , goto_model1 );
263
- if (get_goto_program_ret!=- 1 )
264
- return get_goto_program_ret ;
265
- get_goto_program_ret =
266
- get_goto_program (options, languages2, goto_model2 );
267
- if (get_goto_program_ret!=- 1 )
268
- return get_goto_program_ret ;
246
+ goto_modelt goto_model1 =
247
+ initialize_goto_model ({cmdline. args [ 0 ]}, ui_message_handler, options );
248
+ if (process_goto_program (options, goto_model1) )
249
+ return CPROVER_EXIT_INTERNAL_ERROR ;
250
+ goto_modelt goto_model2 =
251
+ initialize_goto_model ({cmdline. args [ 1 ]}, ui_message_handler, options );
252
+ if (process_goto_program (options, goto_model2) )
253
+ return CPROVER_EXIT_INTERNAL_ERROR ;
269
254
270
255
if (cmdline.isset (" show-loops" ))
271
256
{
272
- show_loop_ids (get_ui (), goto_model1);
273
- show_loop_ids (get_ui (), goto_model2);
257
+ show_loop_ids (ui_message_handler. get_ui (), goto_model1);
258
+ show_loop_ids (ui_message_handler. get_ui (), goto_model2);
274
259
return CPROVER_EXIT_SUCCESS;
275
260
}
276
261
@@ -327,65 +312,6 @@ int goto_diff_parse_optionst::doit()
327
312
return CPROVER_EXIT_SUCCESS;
328
313
}
329
314
330
- int goto_diff_parse_optionst::get_goto_program (
331
- const optionst &options,
332
- goto_diff_languagest &languages,
333
- goto_modelt &goto_model)
334
- {
335
- status () << " Reading program from `" << cmdline.args [0 ] << " '" << eom;
336
-
337
- if (is_goto_binary (cmdline.args [0 ]))
338
- {
339
- auto tmp_goto_model =
340
- read_goto_binary (cmdline.args [0 ], languages.get_message_handler ());
341
- if (!tmp_goto_model.has_value ())
342
- return CPROVER_EXIT_INCORRECT_TASK;
343
-
344
- goto_model = std::move (*tmp_goto_model);
345
-
346
- config.set (cmdline);
347
-
348
- // This one is done.
349
- cmdline.args .erase (cmdline.args .begin ());
350
- }
351
- else
352
- {
353
- // This is a a workaround to make parse() think that there is only
354
- // one source file.
355
- std::string arg2 (" " );
356
- if (cmdline.args .size ()==2 )
357
- {
358
- arg2 = cmdline.args [1 ];
359
- cmdline.args .erase (--cmdline.args .end ());
360
- }
361
-
362
- if (languages.parse () ||
363
- languages.typecheck () ||
364
- languages.final ())
365
- return CPROVER_EXIT_INCORRECT_TASK;
366
-
367
- // we no longer need any parse trees or language files
368
- languages.clear_parse ();
369
-
370
- status () << " Generating GOTO Program" << eom;
371
-
372
- goto_model.symbol_table =languages.symbol_table ;
373
- goto_convert (
374
- goto_model.symbol_table ,
375
- goto_model.goto_functions ,
376
- ui_message_handler);
377
-
378
- if (process_goto_program (options, goto_model))
379
- return CPROVER_EXIT_INTERNAL_ERROR;
380
-
381
- // if we had a second argument then we will handle it next
382
- if (arg2!=" " )
383
- cmdline.args [0 ]=arg2;
384
- }
385
-
386
- return -1 ; // no error, continue
387
- }
388
-
389
315
bool goto_diff_parse_optionst::process_goto_program (
390
316
const optionst &options,
391
317
goto_modelt &goto_model)
0 commit comments