22 : list_only(_list_only)
32 const json_irept no_comments_irep_converter(
false);
34 const auto sorted = goto_functions.
sorted();
36 for(
const auto &function_entry : sorted)
38 const irep_idt &function_name = function_entry->first;
44 json_function[
"isBodyAvailable"]=
52 auto json_parameter_id_range =
54 function.parameter_identifiers.begin(),
55 function.parameter_identifiers.end())
57 json_function[
"parameterIdentifiers"] =
json_arrayt{
58 json_parameter_id_range.
begin(), json_parameter_id_range.end()};
63 if(function.body_available())
68 function.body.instructions)
71 {
"instructionId",
json_stringt(instruction.to_string())},
73 json_numbert{std::to_string(instruction.location_number)}}};
75 if(instruction.source_location().is_not_nil())
77 instruction_entry[
"sourceLocation"] =
78 json(instruction.source_location());
81 std::ostringstream instruction_builder;
82 instruction.output(instruction_builder);
84 instruction_entry[
"instruction"]=
87 if(instruction.code().is_not_nil())
92 instruction_entry[
"code"] = std::move(code_object);
95 if(instruction.has_condition())
99 instruction.condition());
101 instruction_entry[
"guard"] = std::move(guard_object);
104 if(!instruction.targets.empty())
106 auto json_target_range =
107 make_range(instruction.targets.begin(), instruction.targets.end())
110 return json_numbert{std::to_string(target->location_number)};
112 instruction_entry[
"targets"] =
116 if(!instruction.labels.empty())
118 auto json_label_range =
119 make_range(instruction.labels.begin(), instruction.labels.end())
121 instruction_entry[
"labels"] =
125 json_instruction_array.
push_back(std::move(instruction_entry));
128 json_function[
"instructions"] = std::move(json_instruction_array);
151 out <<
convert(goto_functions);
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
bool starts_with(const char *s) const
equivalent of as_string().starts_with(s)
A collection of goto functions.
::goto_functiont goto_functiont
std::vector< function_mapt::const_iterator > sorted() const
returns a vector of the iterators in alphabetical order
This class represents an instruction in the GOTO intermediate representation.
instructionst::iterator targett
jsont & push_back(const jsont &json)
json_objectt convert_from_irep(const irept &) const
To convert to JSON from an irep structure by recursively generating JSON for the different sub trees.
static jsont json_boolean(bool value)
void operator()(const goto_functionst &goto_functions, std::ostream &out, bool append=true)
Print the json object generated by show_goto_functions_jsont::show_goto_functions to the provided str...
json_objectt convert(const goto_functionst &goto_functions)
Walks through all of the functions in the program and returns a JSON object representing all their fu...
show_goto_functions_jsont(bool _list_only=false)
For outputting the GOTO program in a readable JSON format.
Goto Programs with Functions.
static void json(json_objectT &result, const irep_idt &property_id, const property_infot &property_info)
ranget< iteratort > make_range(iteratort begin, iteratort end)