@@ -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
@@ -253,21 +238,21 @@ int goto_diff_parse_optionst::doit()
253
238
return CPROVER_EXIT_INCORRECT_TASK;
254
239
}
255
240
256
- goto_modelt goto_model1, goto_model2 ;
241
+ register_languages () ;
257
242
258
- int get_goto_program_ret =
259
- get_goto_program (options, * this , goto_model1 );
260
- if (get_goto_program_ret!=- 1 )
261
- return get_goto_program_ret ;
262
- get_goto_program_ret =
263
- get_goto_program (options, languages2, goto_model2 );
264
- if (get_goto_program_ret!=- 1 )
265
- return get_goto_program_ret ;
243
+ goto_modelt goto_model1 =
244
+ initialize_goto_model ({cmdline. args [ 0 ]}, ui_message_handler, options );
245
+ if (process_goto_program (options, goto_model1) )
246
+ return CPROVER_EXIT_INTERNAL_ERROR ;
247
+ goto_modelt goto_model2 =
248
+ initialize_goto_model ({cmdline. args [ 1 ]}, ui_message_handler, options );
249
+ if (process_goto_program (options, goto_model2) )
250
+ return CPROVER_EXIT_INTERNAL_ERROR ;
266
251
267
252
if (cmdline.isset (" show-loops" ))
268
253
{
269
- show_loop_ids (get_ui (), goto_model1);
270
- show_loop_ids (get_ui (), goto_model2);
254
+ show_loop_ids (ui_message_handler. get_ui (), goto_model1);
255
+ show_loop_ids (ui_message_handler. get_ui (), goto_model2);
271
256
return CPROVER_EXIT_SUCCESS;
272
257
}
273
258
@@ -324,65 +309,6 @@ int goto_diff_parse_optionst::doit()
324
309
return CPROVER_EXIT_SUCCESS;
325
310
}
326
311
327
- int goto_diff_parse_optionst::get_goto_program (
328
- const optionst &options,
329
- goto_diff_languagest &languages,
330
- goto_modelt &goto_model)
331
- {
332
- status () << " Reading program from `" << cmdline.args [0 ] << " '" << eom;
333
-
334
- if (is_goto_binary (cmdline.args [0 ]))
335
- {
336
- auto tmp_goto_model =
337
- read_goto_binary (cmdline.args [0 ], languages.get_message_handler ());
338
- if (!tmp_goto_model.has_value ())
339
- return CPROVER_EXIT_INCORRECT_TASK;
340
-
341
- goto_model = std::move (*tmp_goto_model);
342
-
343
- config.set (cmdline);
344
-
345
- // This one is done.
346
- cmdline.args .erase (cmdline.args .begin ());
347
- }
348
- else
349
- {
350
- // This is a a workaround to make parse() think that there is only
351
- // one source file.
352
- std::string arg2 (" " );
353
- if (cmdline.args .size ()==2 )
354
- {
355
- arg2 = cmdline.args [1 ];
356
- cmdline.args .erase (--cmdline.args .end ());
357
- }
358
-
359
- if (languages.parse () ||
360
- languages.typecheck () ||
361
- languages.final ())
362
- return CPROVER_EXIT_INCORRECT_TASK;
363
-
364
- // we no longer need any parse trees or language files
365
- languages.clear_parse ();
366
-
367
- status () << " Generating GOTO Program" << eom;
368
-
369
- goto_model.symbol_table =languages.symbol_table ;
370
- goto_convert (
371
- goto_model.symbol_table ,
372
- goto_model.goto_functions ,
373
- ui_message_handler);
374
-
375
- if (process_goto_program (options, goto_model))
376
- return CPROVER_EXIT_INTERNAL_ERROR;
377
-
378
- // if we had a second argument then we will handle it next
379
- if (arg2!=" " )
380
- cmdline.args [0 ]=arg2;
381
- }
382
-
383
- return -1 ; // no error, continue
384
- }
385
-
386
312
bool goto_diff_parse_optionst::process_goto_program (
387
313
const optionst &options,
388
314
goto_modelt &goto_model)
0 commit comments