souffle
2.0.2-371-g6315b36
|
Namespaces | |
detail | |
Data Structures | |
class | AlgebraicDataType |
Aggregates types using sums and products. More... | |
struct | all_type_factory |
A factory for computing sets of types covering all potential types. More... | |
class | Analysis |
Abstract class for a AST Analysis. More... | |
class | Assignment |
An assignment maps a list of variables to values of their respective property space. More... | |
class | AuxiliaryArityAnalysis |
Determine the auxiliary arity for relations. More... | |
class | ClauseNormalisationAnalysis |
class | ComponentLookupAnalysis |
class | ConstantType |
Representing the type assigned to a constant. More... | |
class | Constraint |
A generic base class for constraints on variables. More... | |
class | ConstraintAnalysis |
A base class for ConstraintAnalysis collecting constraints for an analysis by visiting every node of a given AST. More... | |
struct | ConstraintAnalysisVar |
A variable type to be utilized by AST constraint analysis. More... | |
class | FunctorAnalysis |
class | IOTypeAnalysis |
class | NormalisedClause |
class | PolymorphicObjectsAnalysis |
class | PrecedenceGraphAnalysis |
Analysis pass computing the precedence graph of the relations of the datalog progam. More... | |
class | PrimitiveType |
PrimitiveType = Number/Unsigned/Float/Symbol The class representing pre-built, concrete types. More... | |
class | Problem |
A problem is a list of constraints for which a solution is desired. More... | |
class | ProfileUseAnalysis |
Analysis that loads profile data and has a profile query interface. More... | |
struct | property_space |
A MPL type for defining a property space. More... | |
struct | RecordType |
A record type combining a list of fields into a new, aggregated type. More... | |
class | RecursiveClausesAnalysis |
Analysis pass identifying clauses which are recursive. More... | |
class | RedundantRelationsAnalysis |
Analysis pass identifying relations which do not contribute to the computation of the output relations. More... | |
class | RelationDetailCacheAnalysis |
Analysis pass mapping identifiers with relations and clauses. More... | |
class | RelationScheduleAnalysis |
Analysis pass computing a schedule for computing relations. More... | |
class | RelationScheduleAnalysisStep |
A single step in a relation schedule, consisting of the relations computed in the step and the relations that are no longer required at that step. More... | |
class | SCCGraphAnalysis |
Analysis pass computing the strongly connected component (SCC) graph for the datalog program. More... | |
struct | set_property_space |
A property space for set-based properties based on sub-set lattices. More... | |
struct | sub_type |
An implementation of a meet operation between sets of types computing the set of pair-wise greatest common subtypes. More... | |
class | SubsetType |
A type being a subset of another type. More... | |
class | SumTypeBranchesAnalysis |
class | TopologicallySortedSCCGraphAnalysis |
Analysis pass computing a topologically sorted strongly connected component (SCC) graph. More... | |
class | Type |
An abstract base class for types to be covered within a type environment. More... | |
struct | type_lattice |
The type lattice forming the property space for the Type analysis. More... | |
class | TypeAnalysis |
class | TypeBinding |
Class that encapsulates std::map of types binding that comes from .init c = Comp<MyType> Type binding in this example would be T->MyType if the component code is .comp Comp<T> ... More... | |
class | TypeConstraintsAnalysis |
Constraint analysis framework for types. More... | |
class | TypeEnvironment |
A type environment is a set of types. More... | |
class | TypeEnvironmentAnalysis |
struct | TypeSet |
A collection to represent sets of types. More... | |
struct | TypeVisitor |
A visitor for Types. More... | |
class | UnionType |
A union type combining a list of types into a new, aggregated type. More... | |
struct | Variable |
A variable to be utilized within constraints to be handled by the constraint solver. More... | |
class | VisitOnceTypeVisitor |
A visitor for types visiting each type only once (effectively breaking recursive cycles). More... | |
Typedefs | |
using | TypeConstraint = std::shared_ptr< Constraint< TypeVar > > |
The definition of the type of constraint to be utilized in the type analysis. More... | |
using | TypeVar = ConstraintAnalysisVar< type_lattice > |
The definition of the type of variable to be utilized in the type analysis. More... | |
Functions | |
bool | areEquivalentTypes (const Type &a, const Type &b) |
Determine if two types are equivalent. More... | |
std::string | findUniqueRelationName (const Program &program, std::string base) |
Find a new relation name. More... | |
std::string | findUniqueVariableName (const Clause &clause, std::string base) |
Find a variable name using base to form a string like base1 Use this when you need to limit the scope of a variable to the inside of an aggregate. More... | |
static const Type & | getBaseType (const Type *type) |
TypeSet | getGreatestCommonSubtypes (const Type &a, const Type &b) |
Computes the greatest common sub types of the two given types. More... | |
template<typename... Types> | |
TypeSet | getGreatestCommonSubtypes (const Types &... types) |
Computes the greatest common sub types of the given types. More... | |
TypeSet | getGreatestCommonSubtypes (const TypeSet &a, const TypeSet &b) |
The set of pair-wise greatest common sub types of the types in the two given sets. More... | |
TypeSet | getGreatestCommonSubtypes (const TypeSet &set) |
Computes the greatest common sub types of all the types in the given set. More... | |
std::map< const Argument *, bool > | getGroundedTerms (const TranslationUnit &tu, const Clause &clause) |
Analyse the given clause and computes for each contained argument whether it is a grounded value or not. More... | |
std::set< std::string > | getInjectedVariables (const TranslationUnit &tu, const Clause &clause, const Aggregator &aggregate) |
Given an aggregate and a clause, we find all the variables that have been injected into the aggregate. More... | |
std::set< std::string > | getLocalVariables (const TranslationUnit &tu, const Clause &clause, const Aggregator &aggregate) |
Computes the set of local variables in an aggregate expression. More... | |
TypeAttribute | getTypeAttribute (const Type &type) |
std::optional< TypeAttribute > | getTypeAttribute (const TypeSet &type) |
std::string | getTypeQualifier (const Type &type) |
Returns full type qualifier for a given type. More... | |
std::set< std::string > | getVariablesOutsideAggregate (const Clause &clause, const Aggregator &aggregate) |
Computes the set of variables occurring outside the aggregate. More... | |
std::set< std::string > | getWitnessVariables (const TranslationUnit &tu, const Clause &clause, const Aggregator &aggregate) |
Computes the set of witness variables that are used in the aggregate A variable is a witness if it occurs in the aggregate body (but not in an inner aggregate) and also occurs ungrounded in the outer scope. More... | |
static TypeConstraint | hasSuperTypeInSet (const TypeVar &var, TypeSet values) |
A constraint factory ensuring that all the types associated to the variable are subtypes of some type in the provided set (values) More... | |
bool | haveCommonSupertype (const Type &a, const Type &b) |
Determine if there exist a type t such that a <: t and b <: t. More... | |
bool | isADTEnum (const AlgebraicDataType &type) |
Determine if ADT is enumerations (are all constructors empty) More... | |
bool | isNumericType (const TypeSet &type) |
bool | isOfKind (const Type &type, TypeAttribute kind) |
Check if the type is of a kind corresponding to the TypeAttribute. More... | |
bool | isOfKind (const TypeSet &typeSet, TypeAttribute kind) |
bool | isOfRootType (const Type &type, const Type &root) |
Determines whether the given type is a sub-type of the given root type. More... | |
bool | isOrderableType (const TypeSet &type) |
bool | isSubtypeOf (const Type &a, const Type &b) |
Determines whether type a is a subtype of type b. More... | |
static TypeConstraint | isSubtypeOf (const TypeVar &a, const TypeVar &b) |
A constraint factory ensuring that all the types associated to the variable a are subtypes of the variable b. More... | |
static TypeConstraint | isSubtypeOf (const TypeVar &variable, const Type &type) |
A constraint factory ensuring that all the types associated to the variable a are subtypes of type b. More... | |
static TypeConstraint | isSubtypeOfComponent (const TypeVar &elementVariable, const TypeVar &recordVariable, size_t index) |
Constraint on record type and its elements. More... | |
static TypeConstraint | satisfiesOverload (const TypeEnvironment &typeEnv, IntrinsicFunctors overloads, TypeVar result, std::vector< TypeVar > args, bool subtypeResult) |
Given a set of overloads, wait the list of candidates to reduce to one and then apply its constraints. More... | |
template<typename Var , typename Val = typename Var::property_space::value_type> | |
std::shared_ptr< Constraint< Var > > | sub (const Val &a, const Var &b, const std::string &symbol="⊑") |
A generic factory for constraints of the form. More... | |
template<typename Var > | |
std::shared_ptr< Constraint< Var > > | sub (const Var &a, const Var &b, const std::string &symbol="⊑") |
A generic factory for constraints of the form. More... | |
static TypeConstraint | subtypesOfTheSameBaseType (const TypeVar &left, const TypeVar &right) |
Ensure that types of left and right have the same base types. More... | |
using souffle::ast::analysis::TypeConstraint = typedef std::shared_ptr<Constraint<TypeVar> > |
The definition of the type of constraint to be utilized in the type analysis.
Definition at line 75 of file TypeConstraints.h.
using souffle::ast::analysis::TypeVar = typedef ConstraintAnalysisVar<type_lattice> |
The definition of the type of variable to be utilized in the type analysis.
Definition at line 72 of file TypeConstraints.h.
Determine if two types are equivalent.
That is, check if a <: b and b <: a
Definition at line 373 of file TypeSystem.cpp.
std::string souffle::ast::analysis::findUniqueRelationName | ( | const Program & | program, |
std::string | base | ||
) |
Find a new relation name.
I use this when I create new relations either for aggregate bodies or singleton aggregates.
Definition at line 190 of file Aggregate.cpp.
std::string souffle::ast::analysis::findUniqueVariableName | ( | const Clause & | clause, |
std::string | base | ||
) |
Find a variable name using base to form a string like base1 Use this when you need to limit the scope of a variable to the inside of an aggregate.
Definition at line 179 of file Aggregate.cpp.
Referenced by souffle::ast::transform::SimplifyAggregateTargetExpressionTransformer::transform().
Definition at line 118 of file TypeConstraints.cpp.
Computes the greatest common sub types of the two given types.
Definition at line 254 of file TypeSystem.cpp.
Referenced by getGreatestCommonSubtypes().
TypeSet souffle::ast::analysis::getGreatestCommonSubtypes | ( | const Types &... | types | ) |
Computes the greatest common sub types of the given types.
Definition at line 542 of file TypeSystem.h.
The set of pair-wise greatest common sub types of the types in the two given sets.
Definition at line 311 of file TypeSystem.cpp.
Computes the greatest common sub types of all the types in the given set.
Definition at line 295 of file TypeSystem.cpp.
References getGreatestCommonSubtypes().
std::map< const Argument *, bool > souffle::ast::analysis::getGroundedTerms | ( | const TranslationUnit & | tu, |
const Clause & | clause | ||
) |
Analyse the given clause and computes for each contained argument whether it is a grounded value or not.
tu | the translation unit containing the clause |
clause | the clause to be analyzed |
Definition at line 278 of file Ground.cpp.
std::set< std::string > souffle::ast::analysis::getInjectedVariables | ( | const TranslationUnit & | tu, |
const Clause & | clause, | ||
const Aggregator & | aggregate | ||
) |
Given an aggregate and a clause, we find all the variables that have been injected into the aggregate.
This means that the variable occurs grounded in an outer scope. BUT does not occur in the target expression.
This means that the variable occurs grounded in an outer scope.
Imagine we have this:
A(letter, x) :- a(letter, _), x = min y : { a(l, y), y < max y : { a(letter, y) } }, z = max y : {B(y) }.
We need to figure out the base literal in which this aggregate occurs, so that we don't delete them Other aggregates occurring in the rule are irrelevant, so we'll replace the aggregate with a dummy aggregate variable. Then after that,
We should also ground all the aggr_vars so that this grounding transfers to whatever variable they might be assigned to.
A(letter, x) :- a(letter, _), x = min y : { a(l, y), y < max y : { a(letter, y) } }, z = aggr_var_0, grounding_atom(aggr_var_0).
Remember to negate the head atom and add it to the body. The clause we deal with will have a dummy head (*())
*() :- !A(letter, x), a(letter, _), x = min y : { a(l, y), y < max y : { a(letter, y) } }, z = aggr_var_0, grounding_atom(aggr_var_0).
Replace the original aggregate with the same shit because we can't be counting local variables n shit
*() :- !A(letter, x), a(letter, _), x = min y : { a(l, y), y < aggr_var_1 } }, z = aggr_var_0, grounding_atom(aggr_var_0).
Now, as long as we recorded all of the variables that occurred inside the aggregate, the intersection of these two sets (variables in an outer scope) and (variables occurring in t
A variable is considered injected into an aggregate if it occurs both within the aggregate AS WELL AS grounded in the outer scope. An outer scope could be an outer aggregate, or also just the base/rule scope. (i.e. not inside of another aggregate that is not an ancestor of this one).
So then in order to calculate the set of variables that have been injected into an aggregate, we perform the following steps:
Definition at line 205 of file Aggregate.cpp.
std::set< std::string > souffle::ast::analysis::getLocalVariables | ( | const TranslationUnit & | tu, |
const Clause & | clause, | ||
const Aggregator & | aggregate | ||
) |
Computes the set of local variables in an aggregate expression.
This is just the set of all variables occurring in the aggregate MINUS the injected variables MINUS the witness variables. :)
Definition at line 55 of file Aggregate.cpp.
TypeAttribute souffle::ast::analysis::getTypeAttribute | ( | const Type & | type | ) |
Definition at line 353 of file TypeSystem.cpp.
std::optional< TypeAttribute > souffle::ast::analysis::getTypeAttribute | ( | const TypeSet & | type | ) |
Definition at line 363 of file TypeSystem.cpp.
std::string souffle::ast::analysis::getTypeQualifier | ( | const Type & | type | ) |
Returns full type qualifier for a given type.
Definition at line 204 of file TypeSystem.cpp.
Referenced by souffle::ast::transform::IOAttributesTransformer::getRecordsTypes().
std::set< std::string > souffle::ast::analysis::getVariablesOutsideAggregate | ( | const Clause & | clause, |
const Aggregator & | aggregate | ||
) |
Computes the set of variables occurring outside the aggregate.
Find the set of variable names occurring outside of the given aggregate.
This is equivalent to taking the set minus of the set of all variable names occurring in the clause minus the set of all variable names occurring in the aggregate.
Definition at line 164 of file Aggregate.cpp.
Referenced by souffle::ast::transform::SimplifyAggregateTargetExpressionTransformer::transform().
std::set< std::string > souffle::ast::analysis::getWitnessVariables | ( | const TranslationUnit & | tu, |
const Clause & | clause, | ||
const Aggregator & | aggregate | ||
) |
Computes the set of witness variables that are used in the aggregate A variable is a witness if it occurs in the aggregate body (but not in an inner aggregate) and also occurs ungrounded in the outer scope.
Computes the set of witness variables that are used in the aggregate.
Definition at line 75 of file Aggregate.cpp.
Referenced by souffle::ast::transform::SimplifyAggregateTargetExpressionTransformer::transform().
|
static |
A constraint factory ensuring that all the types associated to the variable are subtypes of some type in the provided set (values)
Values can't be all.
Definition at line 77 of file TypeConstraints.cpp.
Determine if there exist a type t such that a <: t and b <: t.
Definition at line 337 of file TypeSystem.cpp.
bool souffle::ast::analysis::isADTEnum | ( | const AlgebraicDataType & | type | ) |
Determine if ADT is enumerations (are all constructors empty)
Definition at line 377 of file TypeSystem.cpp.
|
inline |
Definition at line 512 of file TypeSystem.h.
bool souffle::ast::analysis::isOfKind | ( | const Type & | type, |
TypeAttribute | kind | ||
) |
Check if the type is of a kind corresponding to the TypeAttribute.
Definition at line 189 of file TypeSystem.cpp.
Referenced by isOfKind(), and souffle::ast::transform::TypeCheckerImpl::visitVariable().
bool souffle::ast::analysis::isOfKind | ( | const TypeSet & | typeSet, |
TypeAttribute | kind | ||
) |
Definition at line 199 of file TypeSystem.cpp.
References isOfKind(), souffle::Signed, and souffle::Unsigned.
Determines whether the given type is a sub-type of the given root type.
Definition at line 155 of file TypeSystem.cpp.
|
inline |
Definition at line 517 of file TypeSystem.h.
|
static |
A constraint factory ensuring that all the types associated to the variable a are subtypes of the variable b.
Definition at line 27 of file TypeConstraints.cpp.
Referenced by souffle::ast::analysis::TypeEnvironment::print(), and souffle::ast::analysis::TypeConstraintsAnalysis::visitNegation().
|
static |
A constraint factory ensuring that all the types associated to the variable a are subtypes of type b.
Definition at line 35 of file TypeConstraints.cpp.
|
static |
|
static |
Given a set of overloads, wait the list of candidates to reduce to one and then apply its constraints.
NOTE: subtypeResult
implies that func <: overload-return-type
, rather than func = overload-return-type
. This is required for old type semantics. See #1296 and tests/semantic/type_system4
Definition at line 230 of file TypeConstraints.cpp.
Referenced by souffle::ast::analysis::TypeConstraintsAnalysis::visitFunctor().
std::shared_ptr<Constraint<Var> > souffle::ast::analysis::sub | ( | const Val & | a, |
const Var & | b, | ||
const std::string & | symbol = "⊑" |
||
) |
A generic factory for constraints of the form.
a ⊑ b
where b is a variables, a is a value of b's property space, and ⊑ is the order relation induced by b's property space.
Definition at line 257 of file ConstraintSystem.h.
std::shared_ptr<Constraint<Var> > souffle::ast::analysis::sub | ( | const Var & | a, |
const Var & | b, | ||
const std::string & | symbol = "⊑" |
||
) |
A generic factory for constraints of the form.
a ⊑ b
where a and b are variables and ⊑ is the order relation induced by their associated property space.
Definition at line 228 of file ConstraintSystem.h.
References b.
Referenced by souffle::ram::Program::clone(), souffle::ram::Program::getChildNodes(), souffle::ram::Program::getRelations(), souffle::ram::Program::print(), souffle::ram::Program::Program(), and souffle::ast::transform::reduceSubstitution().
|
static |
Ensure that types of left and right have the same base types.
Definition at line 130 of file TypeConstraints.cpp.
Referenced by souffle::ast::analysis::TypeConstraintsAnalysis::visitFunctor().