souffle  2.0.2-371-g6315b36
Functor.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2020 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 Functor.h
12  *
13  * Analysis that provides type information for functors
14  *
15  ***********************************************************************/
16 
17 #pragma once
18 
19 #include "ast/IntrinsicFunctor.h"
20 #include "ast/Program.h"
21 #include "ast/UserDefinedFunctor.h"
22 #include "ast/analysis/Analysis.h"
23 #include "ast/utility/Visitor.h"
24 #include <memory>
25 #include <ostream>
26 #include <string>
27 #include <vector>
28 
29 namespace souffle::ast::analysis {
30 
31 class TypeAnalysis;
32 
33 class FunctorAnalysis : public Analysis {
34 public:
35  static constexpr const char* name = "functor-analysis";
36 
38 
39  void run(const TranslationUnit& translationUnit) override;
40 
41  void print(std::ostream& /* os */) const override {}
42 
43  /** Return return type of functor */
44  TypeAttribute getReturnType(const Functor* functor) const;
45 
46  /** Return argument type of functor */
47  TypeAttribute getArgType(const Functor* functor, const size_t idx) const;
48 
49  static bool isMultiResult(const Functor& functor);
50 
51  const std::vector<TypeAttribute>& getArgTypes(const UserDefinedFunctor& udf) const;
52 
53  /** Return whether a UDF is stateful */
54  bool isStateful(const UserDefinedFunctor* udf) const;
55 
56 private:
57  const TypeAnalysis* typeAnalysis = nullptr;
58 };
59 
60 } // namespace souffle::ast::analysis
souffle::ast::analysis::FunctorAnalysis::isMultiResult
static bool isMultiResult(const Functor &functor)
Definition: Functor.cpp:53
souffle::ast::analysis::Analysis::Analysis
Analysis(std::string identifier)
Definition: Analysis.h:40
TypeAttribute
Type attribute class.
souffle::ast::analysis::FunctorAnalysis::print
void print(std::ostream &) const override
print the analysis result in HTML format
Definition: Functor.h:47
souffle::ast::analysis::FunctorAnalysis::getArgTypes
const std::vector< TypeAttribute > & getArgTypes(const UserDefinedFunctor &udf) const
Definition: Functor.cpp:44
souffle::ast::UserDefinedFunctor
User-Defined functor class.
Definition: UserDefinedFunctor.h:46
IntrinsicFunctor.h
UserDefinedFunctor.h
souffle::ast::analysis::FunctorAnalysis::FunctorAnalysis
FunctorAnalysis()
Definition: Functor.h:43
souffle::ast::analysis::FunctorAnalysis::getReturnType
TypeAttribute getReturnType(const Functor *functor) const
Return return type of functor.
Definition: Functor.cpp:40
souffle::ast::TranslationUnit
Translation unit class for the translation pipeline.
Definition: TranslationUnit.h:51
souffle::ast::analysis::FunctorAnalysis::run
void run(const TranslationUnit &translationUnit) override
run analysis for a Ast translation unit
Definition: Functor.cpp:32
souffle::ast::Functor
Abstract functor class.
Definition: Functor.h:36
souffle::ast::analysis::FunctorAnalysis::getArgType
TypeAttribute getArgType(const Functor *functor, const size_t idx) const
Return argument type of functor.
Definition: Functor.cpp:49
Program.h
Visitor.h
souffle::ast::analysis
Definition: Aggregate.cpp:39
souffle::ast::analysis::TypeAnalysis
Definition: Type.h:45
souffle::ast::analysis::FunctorAnalysis::name
static constexpr const char * name
Definition: Functor.h:41
souffle::ast::analysis::FunctorAnalysis::isStateful
bool isStateful(const UserDefinedFunctor *udf) const
Return whether a UDF is stateful.
Definition: Functor.cpp:36
Analysis.h
souffle::ast::analysis::FunctorAnalysis::typeAnalysis
const TypeAnalysis * typeAnalysis
Definition: Functor.h:63