souffle  2.0.2-371-g6315b36
AuxArity.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 AuxArity.h
12  *
13  * Define of AST analyses classes
14  *
15  ***********************************************************************/
16 
17 #pragma once
18 
19 #include "ast/Atom.h"
20 #include "ast/Program.h"
21 #include "ast/Relation.h"
22 #include "ast/TranslationUnit.h"
23 #include "ast/analysis/Analysis.h"
24 #include "ast/utility/Utils.h"
25 #include <string>
26 
27 namespace souffle::ast::analysis {
28 
29 /**
30  * Determine the auxiliary arity for relations
31  */
32 class AuxiliaryArityAnalysis : public Analysis {
33 public:
34  static constexpr const char* name = "auxiliary-arity";
35 
37 
38  void run(const TranslationUnit& translationUnit) override {
39  program = &translationUnit.getProgram();
40  }
41 
42  /**
43  * Returns the number of auxiliary parameters of an atom's relation
44  * @param atom the atom to report on
45  * @return number of auxiliary attributes
46  */
47  size_t getArity(const Atom* atom) const {
49  }
50 
51  /**
52  * Returns the number of auxiliary parameters of a relation
53  * @param relation the relation to report on
54  * @return number of auxiliary attributes
55  */
56  size_t getArity(const Relation* relation) const {
57  return computeArity(relation);
58  }
59 
60 private:
61  /**
62  * Returns the number of auxiliary parameters of a relation
63  * @param relation the relation to report on
64  * @return number of auxiliary attributes
65  */
66  size_t computeArity(const Relation* relation) const;
67 
68  const Program* program = nullptr;
69 };
70 
71 } // namespace souffle::ast::analysis
TranslationUnit.h
souffle::ast::analysis::Analysis::Analysis
Analysis(std::string identifier)
Definition: Analysis.h:40
relation
Relation & relation
Definition: Reader.h:130
souffle::ast::Relation
Defines a relation with a name, attributes, qualifiers, and internal representation.
Definition: Relation.h:49
Relation.h
souffle::ast::Atom
An atom class.
Definition: Atom.h:51
Utils.h
souffle::ast::Program
The program class consists of relations, clauses and types.
Definition: Program.h:52
souffle::ast::Atom::getQualifiedName
const QualifiedName & getQualifiedName() const
Return qualified name.
Definition: Atom.h:57
souffle::ast::analysis::AuxiliaryArityAnalysis::run
void run(const TranslationUnit &translationUnit) override
run analysis for a Ast translation unit
Definition: AuxArity.h:50
souffle::ast::getRelation
Relation * getRelation(const Program &program, const QualifiedName &name)
Returns the relation with the given name in the program.
Definition: Utils.cpp:101
Atom.h
souffle::ast::analysis::AuxiliaryArityAnalysis::program
const Program * program
Definition: AuxArity.h:80
souffle::ast::TranslationUnit
Translation unit class for the translation pipeline.
Definition: TranslationUnit.h:51
souffle::ast::analysis::AuxiliaryArityAnalysis::name
static constexpr const char * name
Definition: AuxArity.h:46
souffle::ast::analysis::AuxiliaryArityAnalysis::computeArity
size_t computeArity(const Relation *relation) const
Returns the number of auxiliary parameters of a relation.
Definition: AuxArity.cpp:28
Program.h
souffle::ast::analysis::AuxiliaryArityAnalysis::getArity
size_t getArity(const Atom *atom) const
Returns the number of auxiliary parameters of an atom's relation.
Definition: AuxArity.h:59
souffle::ast::analysis
Definition: Aggregate.cpp:39
souffle::ast::TranslationUnit::getProgram
Program & getProgram() const
Return the program.
Definition: TranslationUnit.h:84
Analysis.h
souffle::ast::analysis::AuxiliaryArityAnalysis::AuxiliaryArityAnalysis
AuxiliaryArityAnalysis()
Definition: AuxArity.h:48