souffle
2.0.2-371-g6315b36
|
Go to the documentation of this file.
52 class Program :
public Node {
57 Program(VecOwn<Relation> rels, Own<Statement>
main,
std::map<std::string, Own<Statement>> subs)
59 assert(this->main !=
nullptr &&
"Main program is a null-pointer");
61 assert(
rel !=
nullptr &&
"Relation is a null-pointer");
64 assert(
sub.second !=
nullptr &&
"Subroutine is a null-pointer");
69 std::vector<const Node*> children;
70 children =
main->getChildNodes();
72 children.push_back(
rel.get());
75 children.push_back(
sub.second.get());
92 std::map<std::string, Statement*> subroutineRefs;
94 subroutineRefs.insert({
sub.first,
sub.second.get()});
96 return subroutineRefs;
116 void apply(
const NodeMapper&
map)
override {
127 void print(std::ostream& out)
const override {
128 out <<
"PROGRAM" << std::endl;
129 out <<
" DECLARATION" << std::endl;
131 out <<
" " << *
rel << std::endl;
133 out <<
" END DECLARATION" << std::endl;
135 out <<
" SUBROUTINE " <<
sub.first << std::endl;
136 sub.second->print(out, 2);
137 out <<
" END SUBROUTINE" << std::endl;
139 out <<
" BEGIN MAIN" << std::endl;
141 out <<
" END MAIN" << std::endl;
142 out <<
"END PROGRAM" << std::endl;
145 bool equal(
const Node& node)
const override {
146 const auto& other =
static_cast<const Program&
>(node);
VecOwn< Relation > relations
Relations of RAM program.
const Statement & getSubroutine(const std::string &name) const
Get a specific subroutine.
std::shared_ptr< Constraint< Var > > sub(const Var &a, const Var &b, const std::string &symbol="⊑")
A generic factory for constraints of the form.
std::map< std::string, Own< Statement > > subroutines
Subroutines for provenance system.
void apply(const NodeMapper &map) override
Apply the mapper to all child nodes.
Own< Statement > main
Main program.
auto map(const std::vector< A > &xs, F &&f)
Applies a function to each element of a vector and returns the results.
std::vector< const Node * > getChildNodes() const override
Obtain list of all embedded child nodes.
Program * clone() const override
Create a clone (i.e.
auto clone(const std::vector< A * > &xs)
const std::map< std::string, Statement * > getSubroutines() const
Get all subroutines of a RAM program.
bool equal_targets(const Container &a, const Container &b, const Comparator &comp)
A function testing whether two containers are equal with the given Comparator.
bool equal(const Node &node) const override
Equality check for two RAM nodes.
void print(std::ostream &out) const override
Print RAM node.
bool equal_ptr(const T *a, const T *b)
Compares two values referenced by a pointer where the case where both pointers are null is also consi...
std::vector< Relation * > getRelations() const
Get all relations of RAM program
Abstract class for RAM statements.
Statement & getMain() const
Get main program.
void rel(size_t limit, bool showLimit=true)
std::vector< T * > toPtrVector(const std::vector< std::unique_ptr< T >> &v)
A utility function enabling the creation of a vector of pointers.
std::vector< Own< A > > VecOwn