Skip to content

Commit 5bb48c8

Browse files
committed
Remove language_uit dependency from goto-diff
Parsing is encapsulated in initialize_goto_model.
1 parent 67c692f commit 5bb48c8

File tree

4 files changed

+18
-134
lines changed

4 files changed

+18
-134
lines changed

src/goto-diff/goto_diff_languages.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ Author: Daniel Kroening, [email protected]
99
/// \file
1010
/// Language Registration
1111

12-
#include "goto_diff_languages.h"
12+
#include "goto_diff_parse_options.h"
1313

1414
#include <langapi/mode.h>
1515

1616
#include <ansi-c/ansi_c_language.h>
1717
#include <cpp/cpp_language.h>
1818

19-
void goto_diff_languagest::register_languages()
19+
void goto_diff_parse_optionst::register_languages()
2020
{
2121
register_language(new_ansi_c_language);
2222
register_language(new_cpp_language);

src/goto-diff/goto_diff_languages.h

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/goto-diff/goto_diff_parse_options.cpp

Lines changed: 14 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Author: Peter Schrammel
2727
#include <goto-programs/adjust_float_expressions.h>
2828
#include <goto-programs/goto_convert_functions.h>
2929
#include <goto-programs/goto_inline.h>
30+
#include <goto-programs/initialize_goto_model.h>
3031
#include <goto-programs/instrument_preconditions.h>
3132
#include <goto-programs/link_to_library.h>
3233
#include <goto-programs/loop_ids.h>
@@ -62,20 +63,8 @@ Author: Peter Schrammel
6263

6364
goto_diff_parse_optionst::goto_diff_parse_optionst(int argc, const char **argv)
6465
: parse_options_baset(GOTO_DIFF_OPTIONS, argc, argv),
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(GOTO_DIFF_OPTIONS + extra_options, argc, argv),
76-
goto_diff_languagest(cmdline, ui_message_handler),
77-
ui_message_handler(cmdline, std::string("GOTO-DIFF ") + CBMC_VERSION),
78-
languages2(cmdline, ui_message_handler)
66+
messaget(ui_message_handler),
67+
ui_message_handler(cmdline, std::string("GOTO-DIFF ") + CBMC_VERSION)
7968
{
8069
}
8170

@@ -252,21 +241,21 @@ int goto_diff_parse_optionst::doit()
252241
return CPROVER_EXIT_INCORRECT_TASK;
253242
}
254243

255-
goto_modelt goto_model1, goto_model2;
244+
register_languages();
256245

257-
int get_goto_program_ret=
258-
get_goto_program(options, *this, goto_model1);
259-
if(get_goto_program_ret!=-1)
260-
return get_goto_program_ret;
261-
get_goto_program_ret=
262-
get_goto_program(options, languages2, goto_model2);
263-
if(get_goto_program_ret!=-1)
264-
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;
265254

266255
if(cmdline.isset("show-loops"))
267256
{
268-
show_loop_ids(get_ui(), goto_model1);
269-
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);
270259
return CPROVER_EXIT_SUCCESS;
271260
}
272261

@@ -323,65 +312,6 @@ int goto_diff_parse_optionst::doit()
323312
return CPROVER_EXIT_SUCCESS;
324313
}
325314

326-
int goto_diff_parse_optionst::get_goto_program(
327-
const optionst &options,
328-
goto_diff_languagest &languages,
329-
goto_modelt &goto_model)
330-
{
331-
status() << "Reading program from `" << cmdline.args[0] << "'" << eom;
332-
333-
if(is_goto_binary(cmdline.args[0]))
334-
{
335-
if(read_goto_binary(
336-
cmdline.args[0],
337-
goto_model.symbol_table,
338-
goto_model.goto_functions,
339-
languages.get_message_handler()))
340-
return CPROVER_EXIT_INCORRECT_TASK;
341-
342-
config.set(cmdline);
343-
344-
// This one is done.
345-
cmdline.args.erase(cmdline.args.begin());
346-
}
347-
else
348-
{
349-
// This is a a workaround to make parse() think that there is only
350-
// one source file.
351-
std::string arg2("");
352-
if(cmdline.args.size()==2)
353-
{
354-
arg2 = cmdline.args[1];
355-
cmdline.args.erase(--cmdline.args.end());
356-
}
357-
358-
if(languages.parse() ||
359-
languages.typecheck() ||
360-
languages.final())
361-
return CPROVER_EXIT_INCORRECT_TASK;
362-
363-
// we no longer need any parse trees or language files
364-
languages.clear_parse();
365-
366-
status() << "Generating GOTO Program" << eom;
367-
368-
goto_model.symbol_table=languages.symbol_table;
369-
goto_convert(
370-
goto_model.symbol_table,
371-
goto_model.goto_functions,
372-
ui_message_handler);
373-
374-
if(process_goto_program(options, goto_model))
375-
return CPROVER_EXIT_INTERNAL_ERROR;
376-
377-
// if we had a second argument then we will handle it next
378-
if(arg2!="")
379-
cmdline.args[0]=arg2;
380-
}
381-
382-
return -1; // no error, continue
383-
}
384-
385315
bool goto_diff_parse_optionst::process_goto_program(
386316
const optionst &options,
387317
goto_modelt &goto_model)

src/goto-diff/goto_diff_parse_options.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ Author: Peter Schrammel
2222
#include <goto-programs/show_goto_functions.h>
2323
#include <goto-programs/show_properties.h>
2424

25-
#include "goto_diff_languages.h"
26-
2725
class goto_modelt;
2826
class optionst;
2927

@@ -41,31 +39,20 @@ class optionst;
4139
"(compact-output)"
4240
// clang-format on
4341

44-
class goto_diff_parse_optionst:
45-
public parse_options_baset,
46-
public goto_diff_languagest
42+
class goto_diff_parse_optionst : public parse_options_baset, public messaget
4743
{
4844
public:
4945
virtual int doit();
5046
virtual void help();
5147

5248
goto_diff_parse_optionst(int argc, const char **argv);
53-
goto_diff_parse_optionst(
54-
int argc,
55-
const char **argv,
56-
const std::string &extra_options);
5749

5850
protected:
5951
ui_message_handlert ui_message_handler;
60-
goto_diff_languagest languages2;
52+
void register_languages();
6153

6254
void get_command_line_options(optionst &options);
6355

64-
virtual int get_goto_program(
65-
const optionst &options,
66-
goto_diff_languagest &languages,
67-
goto_modelt &goto_model);
68-
6956
bool process_goto_program(const optionst &options, goto_modelt &goto_model);
7057
};
7158

0 commit comments

Comments
 (0)