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)
77 instruction_entry[
"sourceLocation"] =
81 std::ostringstream instruction_builder;
82 instruction.
output(instruction_builder);
84 instruction_entry[
"instruction"]=
92 instruction_entry[
"code"] = std::move(code_object);
101 instruction_entry[
"guard"] = std::move(guard_object);
104 if(!instruction.
targets.empty())
106 auto json_target_range =
110 return json_numbert{std::to_string(target->location_number)};
112 instruction_entry[
"targets"] =
113 json_arrayt{json_target_range.begin(), json_target_range.end()};
116 if(!instruction.
labels.empty())
118 auto json_label_range =
121 instruction_entry[
"labels"] =
122 json_arrayt{json_label_range.begin(), json_label_range.end()};
125 json_instruction_array.
push_back(std::move(instruction_entry));
128 json_function[
"instructions"] = std::move(json_instruction_array);
151 out <<
convert(goto_functions);
bool starts_with(const char *s) const
equivalent of as_string().starts_with(s)
A collection of goto functions.
std::vector< function_mapt::const_iterator > sorted() const
returns a vector of the iterators in alphabetical order
::goto_functiont goto_functiont
This class represents an instruction in the GOTO intermediate representation.
const goto_instruction_codet & code() const
Get the code represented by this instruction.
bool has_condition() const
Does this instruction have a condition?
targetst targets
The list of successor instructions.
std::string to_string() const
unsigned location_number
A globally unique number to identify a program location.
std::ostream & output(std::ostream &) const
Output this instruction to the given stream.
const exprt & condition() const
Get the condition of gotos, assume, assert.
const source_locationt & source_location() const
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.
json_objectt & make_object()
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)