souffle  2.0.2-371-g6315b36
Public Member Functions | Private Member Functions
souffle::ast::transform::ExecutionPlanChecker Class Reference

#include <ExecutionPlanChecker.h>

Inheritance diagram for souffle::ast::transform::ExecutionPlanChecker:
Inheritance graph
Collaboration diagram for souffle::ast::transform::ExecutionPlanChecker:
Collaboration graph

Public Member Functions

ExecutionPlanCheckerclone () const override
 
std::string getName () const override
 
- Public Member Functions inherited from souffle::ast::transform::Transformer
bool apply (TranslationUnit &translationUnit)
 
virtual ~Transformer ()=default
 

Private Member Functions

bool transform (TranslationUnit &translationUnit) override
 

Detailed Description

Definition at line 31 of file ExecutionPlanChecker.h.

Member Function Documentation

◆ clone()

ExecutionPlanChecker* souffle::ast::transform::ExecutionPlanChecker::clone ( ) const
inlineoverridevirtual

Implements souffle::ast::transform::Transformer.

Definition at line 43 of file ExecutionPlanChecker.h.

◆ getName()

std::string souffle::ast::transform::ExecutionPlanChecker::getName ( ) const
inlineoverridevirtual

Implements souffle::ast::transform::Transformer.

Definition at line 39 of file ExecutionPlanChecker.h.

◆ transform()

bool souffle::ast::transform::ExecutionPlanChecker::transform ( TranslationUnit translationUnit)
overrideprivatevirtual

Implements souffle::ast::transform::Transformer.

Definition at line 42 of file ExecutionPlanChecker.cpp.

42  : relationSchedule->schedule()) {
43  const std::set<const Relation*>& scc = step.computed();
44  for (const Relation* rel : scc) {
45  for (const Clause* clause : getClauses(program, *rel)) {
46  if (!recursiveClauses->recursive(clause)) {
47  continue;
48  }
49  if (clause->getExecutionPlan() == nullptr) {
50  continue;
51  }
52  int version = 0;
53  for (const auto* atom : getBodyLiterals<Atom>(*clause)) {
54  if (scc.count(getAtomRelation(atom, &program)) != 0u) {
55  version++;
56  }
57  }
58  int maxVersion = -1;
59  for (auto const& cur : clause->getExecutionPlan()->getOrders()) {
60  maxVersion = std::max(cur.first, maxVersion);
61  }
62 
63  if (version <= maxVersion) {
64  for (const auto& cur : clause->getExecutionPlan()->getOrders()) {
65  if (cur.first >= version) {
66  report.addDiagnostic(Diagnostic(Diagnostic::Type::ERROR,
67  DiagnosticMessage(
68  "execution plan for version " + std::to_string(cur.first),
69  cur.second->getSrcLoc()),
70  {DiagnosticMessage("only versions 0.." + std::to_string(version - 1) +
71  " permitted")}));
72  }
73  }
74  }
75  }
76  }
77  }
78  return false;
79 }
80 
81 } // namespace souffle::ast::transform

References souffle::Diagnostic::ERROR, souffle::ast::getAtomRelation(), souffle::ast::getClauses(), and rel().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
souffle::Diagnostic::Type::ERROR
@ ERROR
souffle::ast::getClauses
std::vector< Clause * > getClauses(const Program &program, const QualifiedName &relationName)
Returns a vector of clauses in the program describing the relation with the given name.
Definition: Utils.cpp:77
souffle::ast::getAtomRelation
const Relation * getAtomRelation(const Atom *atom, const Program *program)
Returns the relation referenced by the given atom.
Definition: Utils.cpp:129
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086