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

Binary constraint class. More...

#include <BinaryConstraint.h>

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

Public Member Functions

void apply (const NodeMapper &map) override
 
 BinaryConstraint (BinaryConstraintOp o, Own< Argument > ls, Own< Argument > rs, SrcLocation loc={})
 
BinaryConstraintclone () const override
 
BinaryConstraintOp getBaseOperator () const
 Return binary operator. More...
 
std::vector< const Node * > getChildNodes () const override
 
std::optional< BinaryConstraintOpgetFinalType () const
 
ArgumentgetLHS () const
 Return left-hand side argument. More...
 
ArgumentgetRHS () const
 Return right-hand side argument. More...
 
void setBaseOperator (BinaryConstraintOp op)
 Set binary operator. More...
 
void setFinalType (BinaryConstraintOp newType)
 
- Public Member Functions inherited from souffle::ast::analysis::Constraint< Var >
virtual bool update (Assignment< Var > &ass) const =0
 Requests the given assignment to be updated according to this constraint. More...
 
virtual ~Constraint ()=default
 A virtual destructor. More...
 

Protected Member Functions

bool equal (const Node &node) const override
 
void print (std::ostream &os) const override
 Adds print support for constraints (debugging) More...
 

Protected Attributes

std::optional< BinaryConstraintOpfinalTranslatorType
 
Own< Argumentlhs
 Left-hand side argument of binary constraint. More...
 
BinaryConstraintOp operation
 Constraint (base) operator. More...
 
Own< Argumentrhs
 Right-hand side argument of binary constraint. More...
 

Detailed Description

Binary constraint class.

Example: x = y

A binary constraint has a constraint operator, a left-hand side expression, and right-hand side expression.

Definition at line 53 of file BinaryConstraint.h.

Constructor & Destructor Documentation

◆ BinaryConstraint()

souffle::ast::BinaryConstraint::BinaryConstraint ( BinaryConstraintOp  o,
Own< Argument ls,
Own< Argument rs,
SrcLocation  loc = {} 
)
inline

Definition at line 55 of file BinaryConstraint.h.

58  {

Member Function Documentation

◆ apply()

void souffle::ast::BinaryConstraint::apply ( const NodeMapper map)
inlineoverride

Definition at line 86 of file BinaryConstraint.h.

86  {lhs.get(), rhs.get()};
87  }
88 
89  void setFinalType(BinaryConstraintOp newType) {

References lhs, and rhs.

◆ clone()

BinaryConstraint* souffle::ast::BinaryConstraint::clone ( ) const
inlineoverride

Definition at line 78 of file BinaryConstraint.h.

80  {
81  lhs = map(std::move(lhs));
82  rhs = map(std::move(rhs));
83  }
84 

◆ equal()

bool souffle::ast::BinaryConstraint::equal ( const Node node) const
inlineoverrideprotected

Definition at line 112 of file BinaryConstraint.h.

◆ getBaseOperator()

BinaryConstraintOp souffle::ast::BinaryConstraint::getBaseOperator ( ) const
inline

Return binary operator.

Definition at line 69 of file BinaryConstraint.h.

72  {

Referenced by souffle::ast::BindingStore::BindingStore(), and souffle::ast::transform::FoldAnonymousRecords::transformClause().

◆ getChildNodes()

std::vector<const Node*> souffle::ast::BinaryConstraint::getChildNodes ( ) const
inlineoverride

Definition at line 91 of file BinaryConstraint.h.

93  {

◆ getFinalType()

std::optional<BinaryConstraintOp> souffle::ast::BinaryConstraint::getFinalType ( ) const
inline

Definition at line 99 of file BinaryConstraint.h.

99  {
100  os << *lhs << " " << operation << " " << *rhs;
101  } else {

References lhs, operation, and rhs.

◆ getLHS()

Argument* souffle::ast::BinaryConstraint::getLHS ( ) const
inline

Return left-hand side argument.

Definition at line 59 of file BinaryConstraint.h.

63  {

◆ getRHS()

Argument* souffle::ast::BinaryConstraint::getRHS ( ) const
inline

Return right-hand side argument.

Definition at line 64 of file BinaryConstraint.h.

68  {

◆ print()

void souffle::ast::BinaryConstraint::print ( std::ostream &  out) const
inlineoverrideprotectedvirtual

Adds print support for constraints (debugging)

Implements souffle::ast::analysis::Constraint< Var >.

Definition at line 104 of file BinaryConstraint.h.

106  {
107  assert(isA<BinaryConstraint>(&node));
108  const auto& other = static_cast<const BinaryConstraint&>(node);
109  return operation == other.operation && equal_ptr(lhs, other.lhs) && equal_ptr(rhs, other.rhs);
110  }

◆ setBaseOperator()

void souffle::ast::BinaryConstraint::setBaseOperator ( BinaryConstraintOp  op)
inline

Set binary operator.

Definition at line 74 of file BinaryConstraint.h.

74  {
75  copy->setFinalType(finalTranslatorType.value());
76  }

References souffle::detail::brie::copy(), and finalTranslatorType.

Here is the call graph for this function:

◆ setFinalType()

void souffle::ast::BinaryConstraint::setFinalType ( BinaryConstraintOp  newType)
inline

Definition at line 95 of file BinaryConstraint.h.

97  :
98  void print(std::ostream& os) const override {

Field Documentation

◆ finalTranslatorType

std::optional<BinaryConstraintOp> souffle::ast::BinaryConstraint::finalTranslatorType
protected

Definition at line 128 of file BinaryConstraint.h.

Referenced by setBaseOperator().

◆ lhs

Own<Argument> souffle::ast::BinaryConstraint::lhs
protected

Left-hand side argument of binary constraint.

Definition at line 122 of file BinaryConstraint.h.

Referenced by apply(), and getFinalType().

◆ operation

BinaryConstraintOp souffle::ast::BinaryConstraint::operation
protected

Constraint (base) operator.

Definition at line 119 of file BinaryConstraint.h.

Referenced by getFinalType().

◆ rhs

Own<Argument> souffle::ast::BinaryConstraint::rhs
protected

Right-hand side argument of binary constraint.

Definition at line 125 of file BinaryConstraint.h.

Referenced by apply(), and getFinalType().


The documentation for this class was generated from the following file:
souffle::ast::BinaryConstraint::lhs
Own< Argument > lhs
Left-hand side argument of binary constraint.
Definition: BinaryConstraint.h:122
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::ast::BinaryConstraint::setFinalType
void setFinalType(BinaryConstraintOp newType)
Definition: BinaryConstraint.h:95
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::BinaryConstraintOp
BinaryConstraintOp
Binary Constraint Operators.
Definition: BinaryConstraintOps.h:41
souffle::ast::BinaryConstraint::rhs
Own< Argument > rhs
Right-hand side argument of binary constraint.
Definition: BinaryConstraint.h:125
souffle::ast::BinaryConstraint::print
void print(std::ostream &os) const override
Adds print support for constraints (debugging)
Definition: BinaryConstraint.h:104
souffle::detail::brie::copy
auto copy(span< A, arity > s)
Definition: Brie.h:98
souffle::ast::BinaryConstraint::BinaryConstraint
BinaryConstraint(BinaryConstraintOp o, Own< Argument > ls, Own< Argument > rs, SrcLocation loc={})
Definition: BinaryConstraint.h:55
souffle::ast::BinaryConstraint::finalTranslatorType
std::optional< BinaryConstraintOp > finalTranslatorType
Definition: BinaryConstraint.h:128
souffle::ast::BinaryConstraint::operation
BinaryConstraintOp operation
Constraint (base) operator.
Definition: BinaryConstraint.h:119