Skip to content

Commit 026f2de

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

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/analyses/dependence_graph.cpp

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

1212
#include <cassert>
1313

14+
#include <util/json.h>
15+
#include <util/json_expr.h>
16+
1417
#include "goto_rw.h"
1518

1619
#include "dependence_graph.h"
@@ -347,6 +350,46 @@ void dep_graph_domaint::output(
347350

348351
/*******************************************************************\
349352
353+
Function: dep_graph_domaint::output_json
354+
355+
Inputs: The abstract interpreter and the namespace.
356+
357+
Outputs: The domain, formatted as a JSON object.
358+
359+
Purpose: Outputs the current value of the domain.
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(const auto &cd : control_deps)
370+
{
371+
json_objectt &link=graph.push_back().make_object();
372+
link["locationNumber"]=
373+
json_numbert(std::to_string(cd->location_number));
374+
link["sourceLocation"]=json(cd->source_location);
375+
link["type"]=json_stringt("control");
376+
}
377+
378+
for(const auto &dd : data_deps)
379+
{
380+
json_objectt &link=graph.push_back().make_object();
381+
link["locationNumber"]=
382+
json_numbert(std::to_string(dd->location_number));
383+
link["sourceLocation"]=json(dd->source_location);
384+
json_stringt(dd->source_location.as_string());
385+
link["type"]=json_stringt("data");
386+
}
387+
388+
return graph;
389+
}
390+
391+
/*******************************************************************\
392+
350393
Function: dependence_grapht::add_dep
351394
352395
Inputs:

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)