souffle  2.0.2-371-g6315b36
Functor.cpp
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.cpp
12  *
13  * Analysis that provides type information for functors
14  *
15  ***********************************************************************/
16 
17 #include "ast/analysis/Functor.h"
18 #include "FunctorOps.h"
19 #include "ast/FunctorDeclaration.h"
20 #include "ast/IntrinsicFunctor.h"
21 #include "ast/TranslationUnit.h"
22 #include "ast/utility/Utils.h"
23 
24 namespace souffle::ast::analysis {
25 
26 void FunctorAnalysis::run(const TranslationUnit& translationUnit) {
27  typeAnalysis = translationUnit.getAnalysis<TypeAnalysis>();
28 }
29 
30 bool FunctorAnalysis::isStateful(const UserDefinedFunctor* udf) const {
31  return typeAnalysis->isStatefulFunctor(udf);
32 }
33 
35  return typeAnalysis->getFunctorReturnType(functor);
36 }
37 
38 const std::vector<TypeAttribute>& FunctorAnalysis::getArgTypes(const UserDefinedFunctor& udf) const {
39  return typeAnalysis->getFunctorArgTypes(udf);
40 }
41 
42 /** Return argument type of functor */
43 TypeAttribute FunctorAnalysis::getArgType(const Functor* functor, const size_t idx) const {
44  return typeAnalysis->getFunctorArgType(functor, idx);
45 }
46 
47 bool FunctorAnalysis::isMultiResult(const Functor& functor) {
48  return TypeAnalysis::isMultiResultFunctor(functor);
49 }
50 
51 } // namespace souffle::ast::analysis
souffle::ast::analysis::FunctorAnalysis::isMultiResult
static bool isMultiResult(const Functor &functor)
Definition: Functor.cpp:53
TranslationUnit.h
TypeAttribute
Type attribute class.
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
Utils.h
souffle::ast::analysis::TypeAnalysis::getFunctorReturnType
TypeAttribute getFunctorReturnType(const Functor *functor) const
Definition: Type.cpp:145
souffle::ast::analysis::FunctorAnalysis::getReturnType
TypeAttribute getReturnType(const Functor *functor) const
Return return type of functor.
Definition: Functor.cpp:40
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::TypeAnalysis::getFunctorArgType
TypeAttribute getFunctorArgType(const Functor *functor, const size_t idx) const
Definition: Type.cpp:155
FunctorDeclaration.h
souffle::ast::analysis::FunctorAnalysis::getArgType
TypeAttribute getArgType(const Functor *functor, const size_t idx) const
Return argument type of functor.
Definition: Functor.cpp:49
Functor.h
souffle::ast::analysis::TypeAnalysis::isMultiResultFunctor
static bool isMultiResultFunctor(const Functor &functor)
Definition: Type.cpp:178
souffle::ast::analysis
Definition: Aggregate.cpp:39
souffle::ast::analysis::TypeAnalysis::getFunctorArgTypes
const std::vector< TypeAttribute > & getFunctorArgTypes(const UserDefinedFunctor &udf) const
Definition: Type.cpp:166
FunctorOps.h
souffle::ast::analysis::TypeAnalysis::isStatefulFunctor
bool isStatefulFunctor(const UserDefinedFunctor *udf) const
Definition: Type.cpp:170
souffle::ast::analysis::FunctorAnalysis::isStateful
bool isStateful(const UserDefinedFunctor *udf) const
Return whether a UDF is stateful.
Definition: Functor.cpp:36
souffle::ast::analysis::FunctorAnalysis::typeAnalysis
const TypeAnalysis * typeAnalysis
Definition: Functor.h:63