souffle  2.0.2-371-g6315b36
Public Member Functions | Private Member Functions | Private Attributes
souffle::ast::transform::WhileTransformer Class Reference

Transformer that repeatedly executes a sub-transformer while a condition is met. More...

#include <While.h>

Inheritance diagram for souffle::ast::transform::WhileTransformer:
Inheritance graph
Collaboration diagram for souffle::ast::transform::WhileTransformer:
Collaboration graph

Public Member Functions

WhileTransformerclone () const override
 
void disableTransformers (const std::set< std::string > &transforms) override
 
std::string getName () const override
 
std::vector< Transformer * > getSubtransformers () const override
 
void setDebugReport () override
 
void setVerbosity (bool verbose) override
 
 WhileTransformer (bool cond, Own< Transformer > transformer)
 
 WhileTransformer (std::function< bool()> cond, Own< Transformer > transformer)
 
- Public Member Functions inherited from souffle::ast::transform::MetaTransformer
bool applySubtransformer (TranslationUnit &translationUnit, Transformer *transformer)
 
- Public Member Functions inherited from souffle::ast::transform::Transformer
bool apply (TranslationUnit &translationUnit)
 
virtual ~Transformer ()=default
 

Private Member Functions

bool transform (TranslationUnit &translationUnit) override
 

Private Attributes

std::function< bool()> condition
 
Own< Transformertransformer
 

Additional Inherited Members

- Protected Attributes inherited from souffle::ast::transform::MetaTransformer
bool verbose = false
 

Detailed Description

Transformer that repeatedly executes a sub-transformer while a condition is met.

Definition at line 39 of file While.h.

Constructor & Destructor Documentation

◆ WhileTransformer() [1/2]

souffle::ast::transform::WhileTransformer::WhileTransformer ( std::function< bool()>  cond,
Own< Transformer transformer 
)
inline

Definition at line 45 of file While.h.

46  {

◆ WhileTransformer() [2/2]

souffle::ast::transform::WhileTransformer::WhileTransformer ( bool  cond,
Own< Transformer transformer 
)
inline

Definition at line 48 of file While.h.

49  {

Member Function Documentation

◆ clone()

WhileTransformer* souffle::ast::transform::WhileTransformer::clone ( ) const
inlineoverridevirtual

Implements souffle::ast::transform::MetaTransformer.

Definition at line 81 of file While.h.

81  {
82  bool changed = false;
83  while (condition()) {

References souffle::ast::transform::MetaTransformer::applySubtransformer(), condition, and transformer.

Here is the call graph for this function:

◆ disableTransformers()

void souffle::ast::transform::WhileTransformer::disableTransformers ( const std::set< std::string > &  transforms)
inlineoverridevirtual

Implements souffle::ast::transform::MetaTransformer.

Definition at line 69 of file While.h.

69  {
70  return "WhileTransformer";
71  }
72 
73  WhileTransformer* clone() const override {
75  }

◆ getName()

std::string souffle::ast::transform::WhileTransformer::getName ( ) const
inlineoverridevirtual

Implements souffle::ast::transform::Transformer.

Definition at line 77 of file While.h.

77  :
78  std::function<bool()> condition;
79  Own<Transformer> transformer;

◆ getSubtransformers()

std::vector<Transformer*> souffle::ast::transform::WhileTransformer::getSubtransformers ( ) const
inlineoverridevirtual

Implements souffle::ast::transform::MetaTransformer.

Definition at line 51 of file While.h.

54  {

◆ setDebugReport()

void souffle::ast::transform::WhileTransformer::setDebugReport ( )
inlineoverridevirtual

Implements souffle::ast::transform::MetaTransformer.

Definition at line 54 of file While.h.

54  {
55  this->verbose = verbose;
56  if (auto* mt = dynamic_cast<MetaTransformer*>(transformer.get())) {
57  mt->setVerbosity(verbose);
58  }
59  }
60 

References transformer, and souffle::ast::transform::MetaTransformer::verbose.

◆ setVerbosity()

void souffle::ast::transform::WhileTransformer::setVerbosity ( bool  verbose)
inlineoverridevirtual

Implements souffle::ast::transform::MetaTransformer.

Definition at line 62 of file While.h.

62  {
63  mt->disableTransformers(transforms);
64  } else if (transforms.find(transformer->getName()) != transforms.end()) {
65  transformer = mk<NullTransformer>();
66  }
67  }

◆ transform()

bool souffle::ast::transform::WhileTransformer::transform ( TranslationUnit translationUnit)
inlineoverrideprivatevirtual

Implements souffle::ast::transform::Transformer.

Definition at line 89 of file While.h.

Field Documentation

◆ condition

std::function<bool()> souffle::ast::transform::WhileTransformer::condition
private

Definition at line 86 of file While.h.

Referenced by clone().

◆ transformer

Own<Transformer> souffle::ast::transform::WhileTransformer::transformer
private

Definition at line 87 of file While.h.

Referenced by clone(), and setDebugReport().


The documentation for this class was generated from the following file:
souffle::ast::transform::WhileTransformer::WhileTransformer
WhileTransformer(std::function< bool()> cond, Own< Transformer > transformer)
Definition: While.h:45
souffle::ast::transform::WhileTransformer::clone
WhileTransformer * clone() const override
Definition: While.h:81
souffle::clone
auto clone(const std::vector< A * > &xs)
Definition: ContainerUtil.h:172
souffle::ast::transform::MetaTransformer::verbose
bool verbose
Definition: Meta.h:44
souffle::ast::transform::WhileTransformer::transformer
Own< Transformer > transformer
Definition: While.h:87
souffle::ast::transform::WhileTransformer::condition
std::function< bool()> condition
Definition: While.h:86