#include <ClauseNormalisation.h>
Definition at line 46 of file ClauseNormalisation.h.
◆ NormalisedClause() [1/2]
souffle::ast::analysis::NormalisedClause::NormalisedClause |
( |
| ) |
|
|
default |
◆ NormalisedClause() [2/2]
souffle::ast::analysis::NormalisedClause::NormalisedClause |
( |
const Clause * |
clause | ) |
|
Definition at line 51 of file ClauseNormalisation.cpp.
52 {.name = name, .params = headVars});
55 for (
const auto* lit : clause->getBodyLiterals()) {
61 const std::string& qualifier,
const std::string& scopeID,
const Atom* atom) {
62 QualifiedName name(atom->getQualifiedName());
63 name.prepend(qualifier);
◆ addClauseAtom()
void souffle::ast::analysis::NormalisedClause::addClauseAtom |
( |
const std::string & |
qualifier, |
|
|
const std::string & |
scopeID, |
|
|
const Atom * |
atom |
|
) |
| |
|
private |
Parse an atom with a preset name qualifier into the element list.
Definition at line 66 of file ClauseNormalisation.cpp.
67 : atom->getArguments()) {
74 if (
const auto* atom =
dynamic_cast<const Atom*
>(lit)) {
76 }
else if (
const auto* neg =
dynamic_cast<const Negation*
>(lit)) {
References normaliseArgument().
◆ addClauseBodyLiteral()
void souffle::ast::analysis::NormalisedClause::addClauseBodyLiteral |
( |
const std::string & |
scopeID, |
|
|
const Literal * |
lit |
|
) |
| |
|
private |
Parse a body literal into the element list.
Definition at line 79 of file ClauseNormalisation.cpp.
81 std::vector<std::string> vars;
82 vars.push_back(scopeID);
83 vars.push_back(normaliseArgument(bc->getLHS()));
84 vars.push_back(normaliseArgument(bc->getRHS()));
85 clauseElements.push_back({.name = name, .params = vars});
87 assert(lit != nullptr && "unexpected
nullptr lit
");
88 fullyNormalised = false;
89 std::stringstream qualifier;
90 qualifier << "@min:unhandled:lit:
" << scopeID;
91 QualifiedName name(toString(*lit));
92 name.prepend(qualifier.str());
93 clauseElements.push_back({.name = name, .params = std::vector<std::string>()});
97 std::string NormalisedClause::normaliseArgument(const Argument* arg) {
98 if (auto* stringCst = dynamic_cast<const StringConstant*>(arg)) {
99 std::stringstream name;
100 name << "@min:cst:
str" << *stringCst;
101 constants.insert(name.str());
◆ getConstants()
const std::set<std::string>& souffle::ast::analysis::NormalisedClause::getConstants |
( |
| ) |
const |
|
inline |
◆ getElements()
◆ getVariables()
const std::set<std::string>& souffle::ast::analysis::NormalisedClause::getVariables |
( |
| ) |
const |
|
inline |
◆ isFullyNormalised()
bool souffle::ast::analysis::NormalisedClause::isFullyNormalised |
( |
| ) |
const |
|
inline |
◆ normaliseArgument()
std::string souffle::ast::analysis::NormalisedClause::normaliseArgument |
( |
const Argument * |
arg | ) |
|
|
private |
Return a normalised string repr of an argument.
Definition at line 103 of file ClauseNormalisation.cpp.
104 std::stringstream name;
105 name <<
"@min:cst:num:" << *numericCst;
108 }
else if (isA<NilConstant>(arg)) {
110 return "@min:cst:nil";
111 }
else if (
auto* var =
dynamic_cast<const ast::Variable*
>(arg)) {
112 auto name = var->getName();
115 }
else if (
dynamic_cast<const UnnamedVariable*
>(arg)) {
116 static size_t countUnnamed = 0;
117 std::stringstream name;
118 name <<
"@min:unnamed:" << countUnnamed++;
121 }
else if (
auto* aggr =
dynamic_cast<const Aggregator*
>(arg)) {
123 std::stringstream scopeID;
128 std::stringstream aggrTypeSignature;
129 aggrTypeSignature <<
"@min:aggrtype";
130 std::vector<std::string> aggrTypeSignatureComponents;
133 aggrTypeSignature <<
":" << aggr->getBaseOperator();
136 aggrTypeSignatureComponents.push_back(scopeID.str());
139 if (aggr->getTargetExpression() !=
nullptr) {
141 aggrTypeSignatureComponents.push_back(normalisedExpr);
145 clauseElements.push_back({.name = aggrTypeSignature.str(), .params = aggrTypeSignatureComponents});
148 for (
const auto* literal : aggr->getBodyLiterals()) {
153 return scopeID.str();
156 return "@min:unhandled:arg";
161 const auto& program = translationUnit.getProgram();
162 for (
const auto* clause : program.getClauses()) {
163 assert(!
contains(normalisations, clause) &&
"clause already processed");
Referenced by addClauseAtom().
◆ aggrScopeCount
size_t souffle::ast::analysis::NormalisedClause::aggrScopeCount {0} |
|
private |
◆ clauseElements
◆ constants
std::set<std::string> souffle::ast::analysis::NormalisedClause::constants {} |
|
private |
◆ fullyNormalised
bool souffle::ast::analysis::NormalisedClause::fullyNormalised {true} |
|
private |
◆ variables
std::set<std::string> souffle::ast::analysis::NormalisedClause::variables {} |
|
private |
The documentation for this class was generated from the following files: