souffle  2.0.2-371-g6315b36
Public Member Functions | Static Public Attributes | Private Attributes
souffle::ast::analysis::PrecedenceGraphAnalysis Class Reference

Analysis pass computing the precedence graph of the relations of the datalog progam. More...

#include <PrecedenceGraph.h>

Inheritance diagram for souffle::ast::analysis::PrecedenceGraphAnalysis:
Inheritance graph
Collaboration diagram for souffle::ast::analysis::PrecedenceGraphAnalysis:
Collaboration graph

Public Member Functions

const Graph< const Relation *, NameComparison > & graph () const
 
 PrecedenceGraphAnalysis ()
 
void print (std::ostream &os) const override
 Output precedence graph in graphviz format to a given stream. More...
 
void run (const TranslationUnit &translationUnit) override
 run analysis for a Ast translation unit More...
 
- Public Member Functions inherited from souffle::ast::analysis::Analysis
 Analysis (std::string identifier)
 
virtual const std::string & getName () const
 get name of the analysis More...
 
virtual ~Analysis ()=default
 

Static Public Attributes

static constexpr const char * name = "precedence-graph"
 

Private Attributes

Graph< const Relation *, NameComparisonbackingGraph
 Adjacency list of precedence graph (determined by the dependencies of the relations) More...
 

Additional Inherited Members

- Protected Attributes inherited from souffle::ast::analysis::Analysis
const std::string identifier
 

Detailed Description

Analysis pass computing the precedence graph of the relations of the datalog progam.

Definition at line 43 of file PrecedenceGraph.h.

Constructor & Destructor Documentation

◆ PrecedenceGraphAnalysis()

souffle::ast::analysis::PrecedenceGraphAnalysis::PrecedenceGraphAnalysis ( )
inline

Definition at line 47 of file PrecedenceGraph.h.

50 :
51  /** Adjacency list of precedence graph (determined by the dependencies of the relations) */

Member Function Documentation

◆ graph()

const Graph<const Relation*, NameComparison>& souffle::ast::analysis::PrecedenceGraphAnalysis::graph ( ) const
inline

Definition at line 54 of file PrecedenceGraph.h.

◆ print()

void souffle::ast::analysis::PrecedenceGraphAnalysis::print ( std::ostream &  os) const
overridevirtual

Output precedence graph in graphviz format to a given stream.

Reimplemented from souffle::ast::analysis::Analysis.

Definition at line 63 of file PrecedenceGraph.cpp.

66  : backingGraph.vertices()) {
67  if (rel != nullptr) {
68  for (const Relation* adjRel : backingGraph.successors(rel)) {
69  if (adjRel != nullptr) {
70  ss << "\t\"" << rel->getQualifiedName() << "\" -> \"" << adjRel->getQualifiedName()
71  << "\";\n";
72  }
73  }
74  }
75  }
76  ss << "}\n";
77  printHTMLGraph(os, ss.str(), getName());
78 }
79 
80 } // namespace souffle::ast::analysis

◆ run()

void souffle::ast::analysis::PrecedenceGraphAnalysis::run ( const TranslationUnit )
overridevirtual

run analysis for a Ast translation unit

Implements souffle::ast::analysis::Analysis.

Definition at line 45 of file PrecedenceGraph.cpp.

45  {
46  backingGraph.insert(relationDetail.getRelation(atom.getQualifiedName()), r);
47  });
48  visitDepthFirst(c->getHead()->getArguments(), [&](const Atom& atom) {
49  backingGraph.insert(relationDetail.getRelation(atom.getQualifiedName()), r);
50  });
51  }
52  }
53 }
54 
55 void PrecedenceGraphAnalysis::print(std::ostream& os) const {
56  /* Print dependency graph */
57  std::stringstream ss;
58  ss << "digraph {\n";
59  /* Print node of dependence graph */
60  for (const Relation* rel : backingGraph.vertices()) {
61  if (rel != nullptr) {

Field Documentation

◆ backingGraph

Graph<const Relation*, NameComparison> souffle::ast::analysis::PrecedenceGraphAnalysis::backingGraph
private

Adjacency list of precedence graph (determined by the dependencies of the relations)

Definition at line 60 of file PrecedenceGraph.h.

◆ name

constexpr const char* souffle::ast::analysis::PrecedenceGraphAnalysis::name = "precedence-graph"
staticconstexpr

Definition at line 45 of file PrecedenceGraph.h.


The documentation for this class was generated from the following files:
souffle::printHTMLGraph
void printHTMLGraph(std::ostream &out, const std::string &dotSpec, const std::string &id)
Definition: GraphUtils.h:226
souffle::ast::analysis::Analysis::getName
virtual const std::string & getName() const
get name of the analysis
Definition: Analysis.h:50
souffle::ast::analysis::PrecedenceGraphAnalysis::backingGraph
Graph< const Relation *, NameComparison > backingGraph
Adjacency list of precedence graph (determined by the dependencies of the relations)
Definition: PrecedenceGraph.h:60
souffle::ast::visitDepthFirst
void visitDepthFirst(const Node &root, Visitor< R, Ps... > &visitor, Args &... args)
A utility function visiting all nodes within the ast rooted by the given node recursively in a depth-...
Definition: Visitor.h:273
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086
souffle::ast::analysis::PrecedenceGraphAnalysis::print
void print(std::ostream &os) const override
Output precedence graph in graphviz format to a given stream.
Definition: PrecedenceGraph.cpp:63
souffle::profile::ss
class souffle::profile::Tui ss
Definition: Tui.h:336