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

Transformer that executes a sub-transformer iff a condition holds. More...

#include <Conditional.h>

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

Public Member Functions

ConditionalTransformerclone () const override
 
 ConditionalTransformer (bool cond, Own< Transformer > transformer)
 
 ConditionalTransformer (std::function< bool()> cond, Own< Transformer > transformer)
 
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
 
- 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 executes a sub-transformer iff a condition holds.

Definition at line 43 of file Conditional.h.

Constructor & Destructor Documentation

◆ ConditionalTransformer() [1/2]

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

Definition at line 51 of file Conditional.h.

52  {

Referenced by disableTransformers().

◆ ConditionalTransformer() [2/2]

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

Definition at line 54 of file Conditional.h.

57  {

Member Function Documentation

◆ clone()

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

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

Definition at line 88 of file Conditional.h.

◆ disableTransformers()

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

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

Definition at line 76 of file Conditional.h.

76  {
78  }
79 
80 private:
81  std::function<bool()> condition;
82  Own<Transformer> transformer;

References souffle::clone(), condition, ConditionalTransformer(), and transformer.

Here is the call graph for this function:

◆ getName()

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

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

Definition at line 84 of file Conditional.h.

84  {
85  return condition() ? applySubtransformer(translationUnit, transformer.get()) : false;
86  }

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

Here is the call graph for this function:

◆ getSubtransformers()

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

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

Definition at line 57 of file Conditional.h.

57  {
58  this->verbose = verbose;
59  if (auto* mt = dynamic_cast<MetaTransformer*>(transformer.get())) {

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

◆ setDebugReport()

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

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

Definition at line 61 of file Conditional.h.

64  {
65  if (auto* mt = dynamic_cast<MetaTransformer*>(transformer.get())) {
66  mt->disableTransformers(transforms);
67  } else if (transforms.find(transformer->getName()) != transforms.end()) {

◆ setVerbosity()

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

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

Definition at line 69 of file Conditional.h.

72  {
73  return "ConditionalTransformer";
74  }

◆ transform()

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

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

Definition at line 96 of file Conditional.h.

Field Documentation

◆ condition

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

Definition at line 93 of file Conditional.h.

Referenced by disableTransformers(), and getName().

◆ transformer

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

Definition at line 94 of file Conditional.h.

Referenced by disableTransformers(), getName(), and getSubtransformers().


The documentation for this class was generated from the following file:
souffle::ast::transform::ConditionalTransformer::ConditionalTransformer
ConditionalTransformer(std::function< bool()> cond, Own< Transformer > transformer)
Definition: Conditional.h:51
souffle::ast::transform::ConditionalTransformer::condition
std::function< bool()> condition
Definition: Conditional.h:93
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::ConditionalTransformer::transformer
Own< Transformer > transformer
Definition: Conditional.h:94
souffle::ast::transform::MetaTransformer::applySubtransformer
bool applySubtransformer(TranslationUnit &translationUnit, Transformer *transformer)
Definition: Meta.cpp:30