souffle  2.0.2-371-g6315b36
IOType.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2019, 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 IOType.h
12  *
13  * Declares methods to identify a relation as input, output, or printsize.
14  *
15  ***********************************************************************/
16 
17 #pragma once
18 
19 #include "ast/Relation.h"
20 #include "ast/analysis/Analysis.h"
21 #include <iosfwd>
22 #include <map>
23 #include <set>
24 #include <string>
25 #include <utility>
26 
27 namespace souffle::ast {
28 
29 class TranslationUnit;
30 
31 namespace analysis {
32 
33 class IOTypeAnalysis : public Analysis {
34 public:
35  static constexpr const char* name = "IO-type-analysis";
36 
38 
39  void run(const TranslationUnit& translationUnit) override;
40 
41  void print(std::ostream& os) const override;
42 
43  bool isInput(const Relation* relation) const {
44  return inputRelations.count(relation) != 0;
45  }
46 
47  bool isOutput(const Relation* relation) const {
48  return outputRelations.count(relation) != 0;
49  }
50 
51  bool isPrintSize(const Relation* relation) const {
52  return printSizeRelations.count(relation) != 0;
53  }
54 
55  bool isLimitSize(const Relation* relation) const {
56  return limitSizeRelations.count(relation) != 0;
57  }
58 
59  std::size_t getLimitSize(const Relation* relation) const {
60  auto iter = limitSize.find(relation);
61  if (iter != limitSize.end()) {
62  return (*iter).second;
63  } else
64  return 0;
65  }
66 
67  bool isIO(const Relation* relation) const {
69  }
70 
71 private:
72  std::set<const Relation*> inputRelations;
73  std::set<const Relation*> outputRelations;
74  std::set<const Relation*> printSizeRelations;
75  std::set<const Relation*> limitSizeRelations;
76  std::map<const Relation*, std::size_t> limitSize;
77 };
78 
79 } // namespace analysis
80 } // namespace souffle::ast
souffle::ast::analysis::IOTypeAnalysis::print
void print(std::ostream &os) const override
print the analysis result in HTML format
Definition: IOType.cpp:61
souffle::ast::analysis::IOTypeAnalysis::printSizeRelations
std::set< const Relation * > printSizeRelations
Definition: IOType.h:80
souffle::ast::analysis::IOTypeAnalysis::IOTypeAnalysis
IOTypeAnalysis()
Definition: IOType.h:43
souffle::ast::analysis::Analysis::Analysis
Analysis(std::string identifier)
Definition: Analysis.h:40
souffle::ast::analysis::IOTypeAnalysis::isOutput
bool isOutput(const Relation *relation) const
Definition: IOType.h:53
souffle::ast::analysis::IOTypeAnalysis::isIO
bool isIO(const Relation *relation) const
Definition: IOType.h:73
relation
Relation & relation
Definition: Reader.h:130
souffle::ast::analysis::IOTypeAnalysis::name
static constexpr const char * name
Definition: IOType.h:41
souffle::ast::Relation
Defines a relation with a name, attributes, qualifiers, and internal representation.
Definition: Relation.h:49
souffle::ast::analysis::IOTypeAnalysis::limitSize
std::map< const Relation *, std::size_t > limitSize
Definition: IOType.h:82
Relation.h
souffle::ast::analysis::IOTypeAnalysis::isLimitSize
bool isLimitSize(const Relation *relation) const
Definition: IOType.h:61
souffle::ast::analysis::IOTypeAnalysis::limitSizeRelations
std::set< const Relation * > limitSizeRelations
Definition: IOType.h:81
souffle::ast::analysis::IOTypeAnalysis::outputRelations
std::set< const Relation * > outputRelations
Definition: IOType.h:79
souffle::ast::TranslationUnit
Translation unit class for the translation pipeline.
Definition: TranslationUnit.h:51
souffle::ast::analysis::IOTypeAnalysis::isInput
bool isInput(const Relation *relation) const
Definition: IOType.h:49
souffle::ast::analysis::IOTypeAnalysis::getLimitSize
std::size_t getLimitSize(const Relation *relation) const
Definition: IOType.h:65
souffle::ast::analysis::IOTypeAnalysis::run
void run(const TranslationUnit &translationUnit) override
run analysis for a Ast translation unit
Definition: IOType.cpp:38
souffle::ast::analysis::IOTypeAnalysis::isPrintSize
bool isPrintSize(const Relation *relation) const
Definition: IOType.h:57
souffle::ast
Definition: Aggregator.h:35
Analysis.h
souffle::ast::analysis::IOTypeAnalysis::inputRelations
std::set< const Relation * > inputRelations
Definition: IOType.h:78