Skip to content

Commit dee1f4b

Browse files
author
martin
committed
Add output_json to the dependence_graph abstract domain.
1 parent 0ca3ece commit dee1f4b

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/analyses/dependence_graph.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Date: August 2013
1111

1212
#include <cassert>
1313

14+
#include <util/json.h>
15+
1416
#include "goto_rw.h"
1517

1618
#include "dependence_graph.h"
@@ -351,6 +353,50 @@ void dep_graph_domaint::output(
351353
}
352354
}
353355

356+
/*******************************************************************\
357+
358+
Function: dep_graph_domaint::output_json
359+
360+
Inputs: The abstract interpreter and the namespace.
361+
362+
Outputs: The domain, formatted as a JSON object.
363+
364+
Purpose: Outputs the current value of the domain.
365+
366+
\*******************************************************************/
367+
368+
369+
jsont dep_graph_domaint::output_json(
370+
const ai_baset &ai,
371+
const namespacet &ns) const
372+
{
373+
json_arrayt graph;
374+
375+
for(dep_graph_domaint::depst::const_iterator cdi=control_deps.begin();
376+
cdi!=control_deps.end();
377+
++cdi)
378+
{
379+
json_objectt &link=graph.push_back().make_object();
380+
link["location_number"] = json_numbert(std::to_string((*cdi)->location_number));
381+
link["source_location"] = json_stringt((*cdi)->source_location.as_string());
382+
link["type"]=json_stringt("control");
383+
}
384+
385+
for(dep_graph_domaint::depst::const_iterator ddi=data_deps.begin();
386+
ddi!=data_deps.end();
387+
++ddi)
388+
{
389+
json_objectt &link=graph.push_back().make_object();
390+
link["location_number"] = json_numbert(std::to_string((*ddi)->location_number));
391+
link["source_location"] = json_stringt((*ddi)->source_location.as_string());
392+
link["type"]=json_stringt("data");
393+
}
394+
395+
return graph;
396+
}
397+
398+
399+
354400
/*******************************************************************\
355401
356402
Function: dependence_grapht::add_dep

0 commit comments

Comments
 (0)