souffle  2.0.2-371-g6315b36
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
souffle::ram::Program Class Reference

RAM program relation declaration and functions. More...

#include <Program.h>

Inheritance diagram for souffle::ram::Program:
Inheritance graph
Collaboration diagram for souffle::ram::Program:
Collaboration graph

Public Member Functions

void apply (const NodeMapper &map) override
 Apply the mapper to all child nodes. More...
 
Programclone () const override
 Create a clone (i.e. More...
 
std::vector< const Node * > getChildNodes () const override
 Obtain list of all embedded child nodes. More...
 
StatementgetMain () const
 Get main program. More...
 
std::vector< Relation * > getRelations () const
 Get all relations of RAM program
More...
 
const StatementgetSubroutine (const std::string &name) const
 Get a specific subroutine. More...
 
const std::map< std::string, Statement * > getSubroutines () const
 Get all subroutines of a RAM program. More...
 
 Program (VecOwn< Relation > rels, Own< Statement > main, std::map< std::string, Own< Statement >> subs)
 
- Public Member Functions inherited from souffle::ram::Node
bool operator!= (const Node &other) const
 Inequality check for two RAM nodes. More...
 
bool operator== (const Node &other) const
 Equivalence check for two RAM nodes. More...
 
virtual void rewrite (const Node *oldNode, Own< Node > newNode)
 Rewrite a child node. More...
 
virtual ~Node ()=default
 

Protected Member Functions

bool equal (const Node &node) const override
 Equality check for two RAM nodes. More...
 
void print (std::ostream &out) const override
 Print RAM node. More...
 

Protected Attributes

Own< Statementmain
 Main program. More...
 
VecOwn< Relationrelations
 Relations of RAM program. More...
 
std::map< std::string, Own< Statement > > subroutines
 Subroutines for provenance system. More...
 

Private Member Functions

 Program ()=default
 

Detailed Description

RAM program relation declaration and functions.

A typical example:

PROGRAM
DECLARATION
A(x:i:number)
END DECLARATION
BEGIN MAIN
...
END MAIN
END PROGRAM

Definition at line 58 of file Program.h.

Constructor & Destructor Documentation

◆ Program() [1/2]

souffle::ram::Program::Program ( )
privatedefault

◆ Program() [2/2]

souffle::ram::Program::Program ( VecOwn< Relation rels,
Own< Statement main,
std::map< std::string, Own< Statement >>  subs 
)
inline

Definition at line 63 of file Program.h.

63  : subroutines) {
64  assert(sub.second != nullptr && "Subroutine is a null-pointer");
65  }
66  }
67 
68  std::vector<const Node*> getChildNodes() const override {
69  std::vector<const Node*> children;
70  children = main->getChildNodes();
71  for (auto& rel : relations) {
72  children.push_back(rel.get());

References souffle::ast::analysis::sub().

Here is the call graph for this function:

Member Function Documentation

◆ apply()

void souffle::ram::Program::apply ( const NodeMapper )
inlineoverridevirtual

Apply the mapper to all child nodes.

Reimplemented from souffle::ram::Node.

Definition at line 122 of file Program.h.

126  :
127  void print(std::ostream& out) const override {
128  out << "PROGRAM" << std::endl;
129  out << " DECLARATION" << std::endl;
130  for (const auto& rel : relations) {

◆ clone()

Program* souffle::ram::Program::clone ( ) const
inlineoverridevirtual

Create a clone (i.e.

deep copy) of this node

Implements souffle::ram::Node.

Definition at line 110 of file Program.h.

110  : subroutines) {
111  res->subroutines[sub.first] = souffle::clone(sub.second);
112  }
113  return res;
114  }
115 
116  void apply(const NodeMapper& map) override {
117  main = map(std::move(main));
118  for (auto& rel : relations) {
119  rel = map(std::move(rel));
120  }

References souffle::clone(), and souffle::ast::analysis::sub().

Here is the call graph for this function:

◆ equal()

bool souffle::ram::Program::equal ( const Node ) const
inlineoverrideprotectedvirtual

Equality check for two RAM nodes.

Default action is that nothing needs to be checked.

Reimplemented from souffle::ram::Node.

Definition at line 151 of file Program.h.

152  :
153  /** Relations of RAM program */
154  VecOwn<Relation> relations;
155 
156  /** Main program */

◆ getChildNodes()

std::vector<const Node*> souffle::ram::Program::getChildNodes ( ) const
inlineoverridevirtual

Obtain list of all embedded child nodes.

Reimplemented from souffle::ram::Node.

Definition at line 74 of file Program.h.

74  : subroutines) {
75  children.push_back(sub.second.get());
76  }
77  return children;
78  }
79 
80  /** @brief Get main program */
81  Statement& getMain() const {
82  return *main;
83  }
84 

References souffle::ast::analysis::sub().

Here is the call graph for this function:

◆ getMain()

Statement& souffle::ram::Program::getMain ( ) const
inline

Get main program.

Definition at line 87 of file Program.h.

◆ getRelations()

std::vector<Relation*> souffle::ram::Program::getRelations ( ) const
inline

Get all relations of RAM program

Definition at line 92 of file Program.h.

93  : subroutines) {
94  subroutineRefs.insert({sub.first, sub.second.get()});

References souffle::ast::analysis::sub().

Here is the call graph for this function:

◆ getSubroutine()

const Statement& souffle::ram::Program::getSubroutine ( const std::string &  name) const
inline

Get a specific subroutine.

Definition at line 106 of file Program.h.

107  : relations) {
108  res->relations.push_back(souffle::clone(rel));

◆ getSubroutines()

const std::map<std::string, Statement*> souffle::ram::Program::getSubroutines ( ) const
inline

Get all subroutines of a RAM program.

Definition at line 97 of file Program.h.

100  {
101  return *subroutines.at(name);
102  }
103 

◆ print()

void souffle::ram::Program::print ( std::ostream &  out) const
inlineoverrideprotectedvirtual

Print RAM node.

Implements souffle::ram::Node.

Definition at line 133 of file Program.h.

134  : subroutines) {
135  out << " SUBROUTINE " << sub.first << std::endl;
136  sub.second->print(out, 2);
137  out << " END SUBROUTINE" << std::endl;
138  }
139  out << " BEGIN MAIN" << std::endl;
140  main->print(out, 2);
141  out << " END MAIN" << std::endl;
142  out << "END PROGRAM" << std::endl;
143  }
144 
145  bool equal(const Node& node) const override {
146  const auto& other = static_cast<const Program&>(node);
147 
148  return equal_targets(relations, other.relations) && equal_ptr(main, other.main) &&
149  equal_targets(subroutines, other.subroutines);

References souffle::ast::analysis::sub().

Here is the call graph for this function:

Field Documentation

◆ main

Own<Statement> souffle::ram::Program::main
protected

Main program.

Definition at line 163 of file Program.h.

◆ relations

VecOwn<Relation> souffle::ram::Program::relations
protected

Relations of RAM program.

Definition at line 160 of file Program.h.

◆ subroutines

std::map<std::string, Own<Statement> > souffle::ram::Program::subroutines
protected

Subroutines for provenance system.

Definition at line 166 of file Program.h.


The documentation for this class was generated from the following file:
souffle::ram::Program::relations
VecOwn< Relation > relations
Relations of RAM program.
Definition: Program.h:160
souffle::ast::analysis::sub
std::shared_ptr< Constraint< Var > > sub(const Var &a, const Var &b, const std::string &symbol="⊑")
A generic factory for constraints of the form.
Definition: ConstraintSystem.h:228
souffle::ram::Program::subroutines
std::map< std::string, Own< Statement > > subroutines
Subroutines for provenance system.
Definition: Program.h:166
souffle::ram::Program::apply
void apply(const NodeMapper &map) override
Apply the mapper to all child nodes.
Definition: Program.h:122
souffle::ram::Program::main
Own< Statement > main
Main program.
Definition: Program.h:163
souffle::map
auto map(const std::vector< A > &xs, F &&f)
Applies a function to each element of a vector and returns the results.
Definition: ContainerUtil.h:158
souffle::ram::Program::getChildNodes
std::vector< const Node * > getChildNodes() const override
Obtain list of all embedded child nodes.
Definition: Program.h:74
souffle::clone
auto clone(const std::vector< A * > &xs)
Definition: ContainerUtil.h:172
i
size_t i
Definition: json11.h:663
souffle::ram::Program::Program
Program()=default
souffle::equal_targets
bool equal_targets(const Container &a, const Container &b, const Comparator &comp)
A function testing whether two containers are equal with the given Comparator.
Definition: ContainerUtil.h:433
souffle::ram::Program::equal
bool equal(const Node &node) const override
Equality check for two RAM nodes.
Definition: Program.h:151
souffle::ram::Program::print
void print(std::ostream &out) const override
Print RAM node.
Definition: Program.h:133
souffle::equal_ptr
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...
Definition: MiscUtil.h:130
souffle::ram::Program::getMain
Statement & getMain() const
Get main program.
Definition: Program.h:87
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086