souffle  2.0.2-371-g6315b36
Public Member Functions | Protected Member Functions | Protected Attributes
souffle::ast::Component Class Reference

Component class. More...

#include <Component.h>

Inheritance diagram for souffle::ast::Component:
Inheritance graph
Collaboration diagram for souffle::ast::Component:
Collaboration graph

Public Member Functions

void addBaseComponent (Own< ComponentType > component)
 Add base components. More...
 
void addClause (Own< Clause > c)
 Add clause. More...
 
void addComponent (Own< Component > c)
 Add components. More...
 
void addDirective (Own< Directive > directive)
 Add directive. More...
 
void addInstantiation (Own< ComponentInit > i)
 Add instantiation. More...
 
void addOverride (const std::string &name)
 Add override. More...
 
void addRelation (Own< Relation > r)
 Add relation. More...
 
void addType (Own< Type > t)
 Add type. More...
 
void apply (const NodeMapper &mapper) override
 Apply the mapper to all child nodes. More...
 
Componentclone () const override
 Create a clone (i.e. More...
 
void copyBaseComponents (const Component &other)
 Copy base components. More...
 
const std::vector< ComponentType * > getBaseComponents () const
 Get base components. More...
 
std::vector< const Node * > getChildNodes () const override
 Obtain a list of all embedded AST child nodes. More...
 
std::vector< Clause * > getClauses () const
 Get clauses. More...
 
std::vector< Component * > getComponents () const
 Get components. More...
 
const ComponentTypegetComponentType () const
 Get component type. More...
 
std::vector< Directive * > getDirectives () const
 Get directive statements. More...
 
std::vector< ComponentInit * > getInstantiations () const
 Get instantiation. More...
 
const std::set< std::string > & getOverridden () const
 Get override. More...
 
std::vector< Relation * > getRelations () const
 Get relations. More...
 
std::vector< Type * > getTypes () const
 Get types. More...
 
void setComponentType (Own< ComponentType > other)
 Set component type. More...
 
- Public Member Functions inherited from souffle::ast::Node
std::string extloc () const
 Return source location of the syntactic element. More...
 
const SrcLocationgetSrcLoc () const
 Return source location of the Node. More...
 
 Node (SrcLocation loc={})
 
bool operator!= (const Node &other) const
 Inequality check for two AST nodes. More...
 
bool operator== (const Node &other) const
 Equivalence check for two AST nodes. More...
 
void setSrcLoc (SrcLocation l)
 Set source location for the Node. More...
 
virtual ~Node ()=default
 

Protected Member Functions

bool equal (const Node &node) const override
 Abstract equality check for two AST nodes. More...
 
void print (std::ostream &os) const override
 Output to a given output stream. More...
 

Protected Attributes

VecOwn< ComponentTypebaseComponents
 Base components of component. More...
 
VecOwn< Clauseclauses
 Clauses. More...
 
VecOwn< Componentcomponents
 Nested components. More...
 
Own< ComponentTypecomponentType
 Name of component and its formal component arguments. More...
 
VecOwn< Directivedirectives
 I/O directives. More...
 
VecOwn< ComponentInitinstantiations
 Nested component instantiations. More...
 
std::set< std::string > overrideRules
 Clauses of relations that are overwritten by this component. More...
 
VecOwn< Relationrelations
 Relations. More...
 
VecOwn< Typetypes
 Types declarations. More...
 

Detailed Description

Component class.

Example: .comp X = { .decl A(y:number) A(1). }

Component consists of type declaration, relations, rules, etc.

Definition at line 58 of file Component.h.

Member Function Documentation

◆ addBaseComponent()

void souffle::ast::Component::addBaseComponent ( Own< ComponentType component)
inline

Add base components.

Definition at line 76 of file Component.h.

◆ addClause()

void souffle::ast::Component::addClause ( Own< Clause c)
inline

Add clause.

Definition at line 106 of file Component.h.

110  {

◆ addComponent()

void souffle::ast::Component::addComponent ( Own< Component c)
inline

Add components.

Definition at line 126 of file Component.h.

130  {

◆ addDirective()

void souffle::ast::Component::addDirective ( Own< Directive directive)
inline

Add directive.

Definition at line 116 of file Component.h.

120  {

◆ addInstantiation()

void souffle::ast::Component::addInstantiation ( Own< ComponentInit i)
inline

Add instantiation.

Definition at line 136 of file Component.h.

◆ addOverride()

void souffle::ast::Component::addOverride ( const std::string &  name)
inline

Add override.

Definition at line 146 of file Component.h.

149  {

◆ addRelation()

void souffle::ast::Component::addRelation ( Own< Relation r)
inline

Add relation.

Definition at line 96 of file Component.h.

100  {

◆ addType()

void souffle::ast::Component::addType ( Own< Type t)
inline

Add type.

Definition at line 81 of file Component.h.

85  {

◆ apply()

void souffle::ast::Component::apply ( const NodeMapper )
inlineoverridevirtual

Apply the mapper to all child nodes.

Reimplemented from souffle::ast::Node.

Definition at line 169 of file Component.h.

171  : instantiations) {
172  cur = mapper(std::move(cur));
173  }
174  for (auto& cur : types) {
175  cur = mapper(std::move(cur));
176  }
177  for (auto& cur : relations) {
178  cur = mapper(std::move(cur));
179  }
180  for (auto& cur : clauses) {
181  cur = mapper(std::move(cur));
182  }
183  for (auto& cur : directives) {
184  cur = mapper(std::move(cur));
185  }
186  }
187 
188  std::vector<const Node*> getChildNodes() const override {
189  std::vector<const Node*> res;
190 
191  res.push_back(componentType.get());
192  for (const auto& cur : baseComponents) {

◆ clone()

Component* souffle::ast::Component::clone ( ) const
inlineoverridevirtual

Create a clone (i.e.

deep copy) of this node

Implements souffle::ast::Node.

Definition at line 155 of file Component.h.

163  {
164  componentType = mapper(std::move(componentType));
165  for (auto& cur : baseComponents) {
166  cur = mapper(std::move(cur));
167  }

◆ copyBaseComponents()

void souffle::ast::Component::copyBaseComponents ( const Component other)
inline

Copy base components.

Definition at line 91 of file Component.h.

◆ equal()

bool souffle::ast::Component::equal ( const Node ) const
inlineoverrideprotectedvirtual

Abstract equality check for two AST nodes.

Reimplemented from souffle::ast::Node.

Definition at line 242 of file Component.h.

242  {
243  return false;
244  }
245  if (!equal_targets(components, other.components)) {
246  return false;
247  }
248  if (!equal_targets(instantiations, other.instantiations)) {
249  return false;
250  }
251  if (!equal_targets(types, other.types)) {
252  return false;
253  }
254  if (!equal_targets(relations, other.relations)) {
255  return false;
256  }
257  if (!equal_targets(clauses, other.clauses)) {
258  return false;
259  }
260  if (!equal_targets(directives, other.directives)) {
261  return false;
262  }
263  if (overrideRules != other.overrideRules) {
264  return false;
265  }
266  return true;
267  }
268 
269  /** Name of component and its formal component arguments. */
270  Own<ComponentType> componentType;
271 
272  /** Base components of component */
273  VecOwn<ComponentType> baseComponents;

◆ getBaseComponents()

const std::vector<ComponentType*> souffle::ast::Component::getBaseComponents ( ) const
inline

Get base components.

Definition at line 71 of file Component.h.

75  {

◆ getChildNodes()

std::vector<const Node*> souffle::ast::Component::getChildNodes ( ) const
inlineoverridevirtual

Obtain a list of all embedded AST child nodes.

Reimplemented from souffle::ast::Node.

Definition at line 194 of file Component.h.

195  : components) {
196  res.push_back(cur.get());
197  }
198  for (const auto& cur : instantiations) {
199  res.push_back(cur.get());
200  }
201  for (const auto& cur : types) {
202  res.push_back(cur.get());
203  }
204  for (const auto& cur : relations) {
205  res.push_back(cur.get());
206  }
207  for (const auto& cur : clauses) {
208  res.push_back(cur.get());
209  }
210  for (const auto& cur : directives) {
211  res.push_back(cur.get());
212  }
213  return res;
214  }
215 
216 protected:
217  void print(std::ostream& os) const override {
218  auto show = [&](auto&& xs, char const* sep = "\n", char const* prefix = "") {
219  if (xs.empty()) return;
220  os << prefix << join(xs, sep) << "\n";

◆ getClauses()

std::vector<Clause*> souffle::ast::Component::getClauses ( ) const
inline

Get clauses.

Definition at line 111 of file Component.h.

◆ getComponents()

std::vector<Component*> souffle::ast::Component::getComponents ( ) const
inline

Get components.

Definition at line 131 of file Component.h.

Referenced by souffle::ast::analysis::ComponentLookupAnalysis::run().

◆ getComponentType()

const ComponentType* souffle::ast::Component::getComponentType ( ) const
inline

Get component type.

Definition at line 61 of file Component.h.

◆ getDirectives()

std::vector<Directive*> souffle::ast::Component::getDirectives ( ) const
inline

Get directive statements.

Definition at line 121 of file Component.h.

◆ getInstantiations()

std::vector<ComponentInit*> souffle::ast::Component::getInstantiations ( ) const
inline

Get instantiation.

Definition at line 141 of file Component.h.

◆ getOverridden()

const std::set<std::string>& souffle::ast::Component::getOverridden ( ) const
inline

Get override.

Definition at line 151 of file Component.h.

◆ getRelations()

std::vector<Relation*> souffle::ast::Component::getRelations ( ) const
inline

Get relations.

Definition at line 101 of file Component.h.

◆ getTypes()

std::vector<Type*> souffle::ast::Component::getTypes ( ) const
inline

Get types.

Definition at line 86 of file Component.h.

90  {

◆ print()

void souffle::ast::Component::print ( std::ostream &  os) const
inlineoverrideprotectedvirtual

Output to a given output stream.

Implements souffle::ast::Node.

Definition at line 223 of file Component.h.

224  : ");
225  os << "{\n";
226  show(components);
227  show(instantiations);
228  show(types);
229  show(relations);
230  show(overrideRules, ",", ".override ");
231  show(clauses, "\n\n");
232  show(directives, "\n\n");
233  os << "}\n";
234  }
235 
236  bool equal(const Node& node) const override {
237  const auto& other = static_cast<const Component&>(node);
238 
239  if (equal_ptr(componentType, other.componentType)) {
240  return true;

◆ setComponentType()

void souffle::ast::Component::setComponentType ( Own< ComponentType other)
inline

Set component type.

Definition at line 66 of file Component.h.

70  {

Field Documentation

◆ baseComponents

VecOwn<ComponentType> souffle::ast::Component::baseComponents
protected

Base components of component.

Definition at line 279 of file Component.h.

◆ clauses

VecOwn<Clause> souffle::ast::Component::clauses
protected

Clauses.

Definition at line 288 of file Component.h.

◆ components

VecOwn<Component> souffle::ast::Component::components
protected

Nested components.

Definition at line 294 of file Component.h.

◆ componentType

Own<ComponentType> souffle::ast::Component::componentType
protected

Name of component and its formal component arguments.

Definition at line 276 of file Component.h.

◆ directives

VecOwn<Directive> souffle::ast::Component::directives
protected

I/O directives.

Definition at line 291 of file Component.h.

◆ instantiations

VecOwn<ComponentInit> souffle::ast::Component::instantiations
protected

Nested component instantiations.

Definition at line 297 of file Component.h.

◆ overrideRules

std::set<std::string> souffle::ast::Component::overrideRules
protected

Clauses of relations that are overwritten by this component.

Definition at line 300 of file Component.h.

◆ relations

VecOwn<Relation> souffle::ast::Component::relations
protected

Relations.

Definition at line 285 of file Component.h.

◆ types

VecOwn<Type> souffle::ast::Component::types
protected

Types declarations.

Definition at line 282 of file Component.h.


The documentation for this class was generated from the following file:
souffle::ast::Component::components
VecOwn< Component > components
Nested components.
Definition: Component.h:294
n
var n
Definition: htmlJsChartistMin.h:15
souffle::ast::Component::getChildNodes
std::vector< const Node * > getChildNodes() const override
Obtain a list of all embedded AST child nodes.
Definition: Component.h:194
souffle::join
detail::joined_sequence< Iter, Printer > join(const Iter &a, const Iter &b, const std::string &sep, const Printer &p)
Creates an object to be forwarded to some output stream for printing sequences of elements interspers...
Definition: StreamUtil.h:175
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::ast::Component::types
VecOwn< Type > types
Types declarations.
Definition: Component.h:282
souffle::ast::Component::clauses
VecOwn< Clause > clauses
Clauses.
Definition: Component.h:288
souffle::ast::Component::componentType
Own< ComponentType > componentType
Name of component and its formal component arguments.
Definition: Component.h:276
souffle::ast::Component::directives
VecOwn< Directive > directives
I/O directives.
Definition: Component.h:291
souffle::ast::Component::instantiations
VecOwn< ComponentInit > instantiations
Nested component instantiations.
Definition: Component.h:297
souffle::ast::Component::overrideRules
std::set< std::string > overrideRules
Clauses of relations that are overwritten by this component.
Definition: Component.h:300
souffle::ast::Component::print
void print(std::ostream &os) const override
Output to a given output stream.
Definition: Component.h:223
souffle::ast::Component::baseComponents
VecOwn< ComponentType > baseComponents
Base components of component.
Definition: Component.h:279
souffle::ast::Component::relations
VecOwn< Relation > relations
Relations.
Definition: Component.h:285