Skip to content

Commit

Permalink
Replace cout by message stream in show-goto-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
peterschrammel committed Jan 12, 2018
1 parent d970673 commit d902ec8
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/cbmc/cbmc_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ int cbmc_parse_optionst::get_goto_program(
{
show_goto_functions(
goto_model,
get_message_handler(),
ui_message_handler.get_ui(),
cmdline.isset("list-goto-functions"));
return CPROVER_EXIT_SUCCESS;
Expand Down
2 changes: 2 additions & 0 deletions src/goto-diff/goto_diff_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,12 @@ int goto_diff_parse_optionst::doit()
{
show_goto_functions(
goto_model1,
get_message_handler(),
ui_message_handler.get_ui(),
cmdline.isset("list-goto-functions"));
show_goto_functions(
goto_model2,
get_message_handler(),
ui_message_handler.get_ui(),
cmdline.isset("list-goto-functions"));
return 0;
Expand Down
1 change: 1 addition & 0 deletions src/goto-instrument/goto_instrument_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ int goto_instrument_parse_optionst::doit()
{
show_goto_functions(
goto_model,
get_message_handler(),
ui_message_handler.get_ui(),
cmdline.isset("list-goto-functions"));
return CPROVER_EXIT_SUCCESS;
Expand Down
27 changes: 17 additions & 10 deletions src/goto-programs/show_goto_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,25 @@ Author: Peter Schrammel

void show_goto_functions(
const namespacet &ns,
message_handlert &message_handler,
ui_message_handlert::uit ui,
const goto_functionst &goto_functions,
bool list_only)
{
messaget msg(message_handler);
switch(ui)
{
case ui_message_handlert::uit::XML_UI:
{
show_goto_functions_xmlt xml_show_functions(ns, list_only);
xml_show_functions(goto_functions, std::cout);
msg.status() << xml_show_functions.convert(goto_functions);
}
break;

case ui_message_handlert::uit::JSON_UI:
{
show_goto_functions_jsont json_show_functions(ns, list_only);
json_show_functions(goto_functions, std::cout);
msg.status() << json_show_functions.convert(goto_functions);
}
break;

Expand All @@ -55,27 +57,32 @@ void show_goto_functions(
for(const auto &fun : goto_functions.function_map)
{
const symbolt &symbol = ns.lookup(fun.first);
std::cout << '\n'
<< symbol.display_name() << " /* " << symbol.name
<< (fun.second.body_available() ? ""
: ", body not available")
<< " */";
msg.status() << '\n'
<< symbol.display_name() << " /* " << symbol.name
<< (fun.second.body_available() ? ""
: ", body not available")
<< " */";
}

std::cout << std::endl;
msg.status() << messaget::eom;
}
else
goto_functions.output(ns, std::cout);
{
goto_functions.output(ns, msg.status());
msg.status() << messaget::eom;
}

break;
}
}

void show_goto_functions(
const goto_modelt &goto_model,
message_handlert &message_handler,
ui_message_handlert::uit ui,
bool list_only)
{
const namespacet ns(goto_model.symbol_table);
show_goto_functions(ns, ui, goto_model.goto_functions, list_only);
show_goto_functions(
ns, message_handler, ui, goto_model.goto_functions, list_only);
}
2 changes: 2 additions & 0 deletions src/goto-programs/show_goto_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ class goto_functionst;

void show_goto_functions(
const namespacet &ns,
message_handlert &message_handler,
ui_message_handlert::uit ui,
const goto_functionst &goto_functions,
bool list_only = false);

void show_goto_functions(
const goto_modelt &,
message_handlert &message_handler,
ui_message_handlert::uit ui,
bool list_only = false);

Expand Down
1 change: 1 addition & 0 deletions src/jbmc/jbmc_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ int jbmc_parse_optionst::get_goto_program(
{
show_goto_functions(
*goto_model,
get_message_handler(),
ui_message_handler.get_ui(),
cmdline.isset("list-goto-functions"));
return 0;
Expand Down

0 comments on commit d902ec8

Please sign in to comment.