souffle  2.0.2-371-g6315b36
Loop.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2018, The Souffle Developers. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 /************************************************************************
10  *
11  * @file Loop.h
12  *
13  * Defines the interface for RAM transformation passes.
14  *
15  ***********************************************************************/
16 
17 #pragma once
18 
19 #include "ram/TranslationUnit.h"
20 #include "ram/transform/Meta.h"
21 #include <memory>
22 #include <string>
23 #include <utility>
24 
25 namespace souffle::ram::transform {
26 
27 /**
28  * @Class LoopTransformer
29  * @Brief Composite loop transformer
30  *
31  * A transformation is invoked iteratively until no further change
32  * is made.
33  */
34 class LoopTransformer : public MetaTransformer {
35 public:
36  LoopTransformer(Own<Transformer> tLoop) : loop(std::move(tLoop)) {}
37  std::string getName() const override {
38  return "LoopTransformer";
39  }
40  bool transform(TranslationUnit& tU) override {
41  int ctr = 0;
42  while (loop->apply(tU)) {
43  ctr++;
44  }
45  return ctr > 0;
46  }
47 
48 protected:
49  /** transformer of the loop */
51 };
52 
53 } // namespace souffle::ram::transform
souffle::ram::transform
Definition: ChoiceConversion.cpp:30
souffle::Own
std::unique_ptr< A > Own
Definition: ContainerUtil.h:42
Meta.h
souffle::ram::TranslationUnit
Translating a RAM program.
Definition: TranslationUnit.h:55
TranslationUnit.h
souffle::ram::transform::LoopTransformer::getName
std::string getName() const override
@Brief get name of the transformer
Definition: Loop.h:49
souffle::ram::transform::LoopTransformer::loop
Own< Transformer > loop
transformer of the loop
Definition: Loop.h:62
souffle::ram::transform::LoopTransformer::LoopTransformer
LoopTransformer(Own< Transformer > tLoop)
Definition: Loop.h:48
std
Definition: Brie.h:3053
souffle::ram::transform::LoopTransformer::transform
bool transform(TranslationUnit &tU) override
@Brief transform the translation unit / used by apply @Param translationUnit that will be transformed...
Definition: Loop.h:52