|
| 1 | +/*******************************************************************\ |
| 2 | +
|
| 3 | +Module: Show goto functions |
| 4 | +
|
| 5 | +Author: Peter Schrammel |
| 6 | +
|
| 7 | +\*******************************************************************/ |
| 8 | + |
| 9 | +#include <iostream> |
| 10 | + |
| 11 | +#include <util/xml.h> |
| 12 | +#include <util/json.h> |
| 13 | +#include <util/i2string.h> |
| 14 | +#include <util/xml_expr.h> |
| 15 | + |
| 16 | +#include <langapi/language_util.h> |
| 17 | + |
| 18 | +#include "show_goto_functions.h" |
| 19 | +#include "goto_functions.h" |
| 20 | +#include "goto_model.h" |
| 21 | + |
| 22 | +/*******************************************************************\ |
| 23 | +
|
| 24 | +Function: cbmc_parseoptionst::show_goto_functions |
| 25 | +
|
| 26 | + Inputs: |
| 27 | +
|
| 28 | + Outputs: |
| 29 | +
|
| 30 | + Purpose: |
| 31 | +
|
| 32 | +\*******************************************************************/ |
| 33 | + |
| 34 | +void show_goto_functions( |
| 35 | + const namespacet &ns, |
| 36 | + ui_message_handlert::uit ui, |
| 37 | + const goto_functionst &goto_functions) |
| 38 | +{ |
| 39 | + switch(ui) |
| 40 | + { |
| 41 | + case ui_message_handlert::XML_UI: |
| 42 | + { |
| 43 | + //This only prints the list of functions |
| 44 | + xmlt xml_functions("functions"); |
| 45 | + for(goto_functionst::function_mapt::const_iterator |
| 46 | + it=goto_functions.function_map.begin(); |
| 47 | + it!=goto_functions.function_map.end(); |
| 48 | + it++) |
| 49 | + { |
| 50 | + xmlt &xml_function=xml_functions.new_element("function"); |
| 51 | + xml_function.set_attribute("name", id2string(it->first)); |
| 52 | + } |
| 53 | + |
| 54 | + std::cout << xml_functions << std::endl; |
| 55 | + } |
| 56 | + break; |
| 57 | + |
| 58 | + case ui_message_handlert::JSON_UI: |
| 59 | + { |
| 60 | + //This only prints the list of functions |
| 61 | + json_arrayt json_functions; |
| 62 | + for(goto_functionst::function_mapt::const_iterator |
| 63 | + it=goto_functions.function_map.begin(); |
| 64 | + it!=goto_functions.function_map.end(); |
| 65 | + it++) |
| 66 | + { |
| 67 | + json_objectt &json_function= |
| 68 | + json_functions.push_back(jsont()).make_object(); |
| 69 | + json_function["name"]=json_stringt(id2string(it->first)); |
| 70 | + } |
| 71 | + json_objectt json_result; |
| 72 | + json_result["functions"]=json_functions; |
| 73 | + std::cout << ",\n" << json_result; |
| 74 | + } |
| 75 | + break; |
| 76 | + |
| 77 | + case ui_message_handlert::PLAIN: |
| 78 | + goto_functions.output(ns, std::cout); |
| 79 | + break; |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +/*******************************************************************\ |
| 84 | +
|
| 85 | +Function: show_goto_functions |
| 86 | +
|
| 87 | + Inputs: |
| 88 | +
|
| 89 | + Outputs: |
| 90 | +
|
| 91 | + Purpose: |
| 92 | +
|
| 93 | +\*******************************************************************/ |
| 94 | + |
| 95 | +void show_goto_functions( |
| 96 | + const goto_modelt &goto_model, |
| 97 | + ui_message_handlert::uit ui) |
| 98 | +{ |
| 99 | + const namespacet ns(goto_model.symbol_table); |
| 100 | + show_goto_functions(ns, ui, goto_model.goto_functions); |
| 101 | +} |
| 102 | + |
| 103 | + |
| 104 | + |
0 commit comments