souffle  2.0.2-371-g6315b36
Public Member Functions | Protected Member Functions | Protected Attributes | Static Private Member Functions
souffle::ast::Term Class Reference

Defines an abstract term class used for functors and other constructors. More...

#include <Term.h>

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

Public Member Functions

void addArgument (Own< Argument > arg)
 Add argument to argument list. More...
 
void apply (const NodeMapper &map) override
 Apply the mapper to all child nodes. More...
 
std::vector< Argument * > getArguments () const
 Get arguments. More...
 
std::vector< const Node * > getChildNodes () const override
 Obtain a list of all embedded AST child nodes. More...
 
- Public Member Functions inherited from souffle::ast::Argument
Argumentclone () const override=0
 Create clone. More...
 
 Node (SrcLocation loc={})
 
- 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...
 
template<typename... Operands>
 Term (Operands &&... operands)
 
template<typename... Operands>
 Term (SrcLocation loc, Operands &&... operands)
 
 Term (VecOwn< Argument > operands, SrcLocation loc={})
 
- Protected Member Functions inherited from souffle::ast::Node
virtual void print (std::ostream &os) const =0
 Output to a given output stream. More...
 

Protected Attributes

VecOwn< Argumentargs
 Arguments. More...
 

Static Private Member Functions

template<typename... Operands>
static VecOwn< ArgumentasVec (Operands... ops)
 

Detailed Description

Defines an abstract term class used for functors and other constructors.

Definition at line 42 of file Term.h.

Constructor & Destructor Documentation

◆ Term() [1/3]

template<typename... Operands>
souffle::ast::Term::Term ( Operands &&...  operands)
inlineprotected

Definition at line 45 of file Term.h.

45 {})

◆ Term() [2/3]

template<typename... Operands>
souffle::ast::Term::Term ( SrcLocation  loc,
Operands &&...  operands 
)
inlineprotected

Definition at line 48 of file Term.h.

48  :
49  /** Get arguments */

◆ Term() [3/3]

souffle::ast::Term::Term ( VecOwn< Argument operands,
SrcLocation  loc = {} 
)
inlineprotected

Definition at line 51 of file Term.h.

55  {

Member Function Documentation

◆ addArgument()

void souffle::ast::Term::addArgument ( Own< Argument arg)
inline

Add argument to argument list.

Definition at line 61 of file Term.h.

61  : args) {
62  res.push_back(cur.get());
63  }

◆ apply()

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

Apply the mapper to all child nodes.

Reimplemented from souffle::ast::Node.

Definition at line 73 of file Term.h.

73  :
74  bool equal(const Node& node) const override {
75  const auto& other = static_cast<const Term&>(node);
76  return equal_targets(args, other.args);
77  }

References args, and souffle::equal_targets().

Here is the call graph for this function:

◆ asVec()

template<typename... Operands>
static VecOwn<Argument> souffle::ast::Term::asVec ( Operands...  ops)
inlinestaticprivate

Definition at line 90 of file Term.h.

◆ equal()

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

Abstract equality check for two AST nodes.

Reimplemented from souffle::ast::Node.

Reimplemented in souffle::ast::UserDefinedFunctor.

Definition at line 80 of file Term.h.

82  :
83  template <typename... Operands>

◆ getArguments()

std::vector<Argument*> souffle::ast::Term::getArguments ( ) const
inline

Get arguments.

Definition at line 56 of file Term.h.

◆ getChildNodes()

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

Obtain a list of all embedded AST child nodes.

Reimplemented from souffle::ast::Node.

Definition at line 65 of file Term.h.

67  {
68  for (auto& arg : args) {
69  arg = map(std::move(arg));
70  }
71  }

Field Documentation

◆ args

VecOwn<Argument> souffle::ast::Term::args
protected

The documentation for this class was generated from the following file:
souffle::ast::Term::args
VecOwn< Argument > args
Arguments.
Definition: Term.h:86
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::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::Node::Node
Node(SrcLocation loc={})
Definition: Node.h:42
souffle::ast::Term::equal
bool equal(const Node &node) const override
Abstract equality check for two AST nodes.
Definition: Term.h:80
souffle::ast::Term::Term
Term(Operands &&... operands)
Definition: Term.h:45