Skip to content

Commit 3eed077

Browse files
author
martin
committed
Add output_json to the dependence_graph abstract domain.
1 parent baa5741 commit 3eed077

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/analyses/dependence_graph.cpp

Lines changed: 50 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"
@@ -345,6 +347,54 @@ void dep_graph_domaint::output(
345347
}
346348
}
347349

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

src/analyses/dependence_graph.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ class dep_graph_domaint:public ai_domain_baset
8787
const ai_baset &ai,
8888
const namespacet &ns) const final;
8989

90+
jsont output_json(
91+
const ai_baset &ai,
92+
const namespacet &ns) const override;
93+
9094
void make_top() final
9195
{
9296
assert(node_id!=std::numeric_limits<node_indext>::max());

0 commit comments

Comments
 (0)