souffle
2.0.2-371-g6315b36
|
Transformation pass that removes (binary) constraints on the anonymous records. More...
#include <FoldAnonymousRecords.h>
Public Member Functions | |
FoldAnonymousRecords * | clone () 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 | containsValidRecordConstraint (const Clause &) |
Determine if the clause contains at least one binary constraint which can be expanded. More... | |
VecOwn< Literal > | expandRecordBinaryConstraint (const BinaryConstraint &) |
Expand constraint on records position-wise. More... | |
bool | isValidRecordConstraint (const Literal *literal) |
Determine if binary constraint can be expanded. More... | |
bool | transform (TranslationUnit &translationUnit) override |
void | transformClause (const Clause &clause, VecOwn< Clause > &newClauses) |
Process a single clause. More... | |
Transformation pass that removes (binary) constraints on the anonymous records.
After resolving aliases this is equivalent to completely removing anonymous records.
e.g. [a, b, c] = [x, y, z] → a = x, b = y, c = z. [a, b, c] != [x, y, z] → a != x b != y c != z (expanded to three new clauses)
In a single pass, in case of equalities a transformation expands a single level of records in every clause. (e.g. [[a]] = [[1]] => [a] = [1]) In case of inequalities, it expands at most a single inequality in every clause
This transformation does not resolve aliases. E.g. A = [a, b], A = [c, d] Thus it should be called in conjunction with ResolveAnonymousRecordAliases.
Definition at line 54 of file FoldAnonymousRecords.h.
|
inlineoverridevirtual |
Implements souffle::ast::transform::Transformer.
Definition at line 66 of file FoldAnonymousRecords.h.
|
private |
Determine if the clause contains at least one binary constraint which can be expanded.
Definition at line 70 of file FoldAnonymousRecords.cpp.
Referenced by transform().
|
private |
Expand constraint on records position-wise.
eg. [1, 2, 3] = [a, b, c] => vector(1 = a, 2 = b, 3 = c) [x, y, z] != [a, b, c] => vector(x != a, x != b, z != c)
Procedure assumes that argument has a valid operation, that children are of type RecordInit and that the size of both sides is the same
Definition at line 78 of file FoldAnonymousRecords.cpp.
Referenced by transformClause().
|
inlineoverridevirtual |
Implements souffle::ast::transform::Transformer.
Definition at line 62 of file FoldAnonymousRecords.h.
|
private |
Determine if binary constraint can be expanded.
Definition at line 41 of file FoldAnonymousRecords.cpp.
Referenced by transformClause().
|
overrideprivatevirtual |
Implements souffle::ast::transform::Transformer.
Definition at line 164 of file FoldAnonymousRecords.cpp.
References containsValidRecordConstraint(), and transformClause().
|
private |
Process a single clause.
@parem clause Clause to be processed.
newClauses | a destination for the newly produced clauses. |
Definition at line 110 of file FoldAnonymousRecords.cpp.
References souffle::clone(), expandRecordBinaryConstraint(), souffle::ast::BinaryConstraint::getBaseOperator(), souffle::isEqConstraint(), and isValidRecordConstraint().
Referenced by transform().