souffle  2.0.2-371-g6315b36
Relation.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 Relation.cpp
12  *
13  * Implementation of RAM Relation Analysis
14  *
15  ***********************************************************************/
16 
17 #include "ram/analysis/Relation.h"
18 #include "ram/utility/Visitor.h"
20 #include <algorithm>
21 #include <cassert>
22 #include <utility>
23 #include <vector>
24 
25 namespace souffle::ram::analysis {
26 
27 const ram::Relation& RelationAnalysis::lookup(const std::string& name) const {
28  auto it = relationMap.find(name);
29  assert(it != relationMap.end() && "relation not found");
30  return *(it->second);
31 }
32 
33 void RelationAnalysis::run(const TranslationUnit& translationUnit) {
34  visitDepthFirst(translationUnit.getProgram(),
35  [&](const Relation& relation) { relationMap[relation.getName()] = &relation; });
36 }
37 
38 } // namespace souffle::ram::analysis
relation
Relation & relation
Definition: Reader.h:130
souffle::ram::analysis
Definition: Analysis.h:32
MiscUtil.h
souffle::ram::analysis::RelationAnalysis::name
static constexpr const char * name
Definition: Relation.h:40
souffle::ram::TranslationUnit::getProgram
Program & getProgram() const
Get the RAM Program of the translation unit
Definition: TranslationUnit.h:107
souffle::ram::TranslationUnit
Translating a RAM program.
Definition: TranslationUnit.h:55
Relation.h
Visitor.h
souffle::ram::Relation
An abstract class for performing indexed operations.
Definition: Relation.h:40
souffle::ram::analysis::RelationAnalysis::run
void run(const TranslationUnit &) override
Run analysis for a RAM translation unit.
Definition: Relation.cpp:39
souffle::ram::analysis::RelationAnalysis::relationMap
std::map< std::string, const ram::Relation * > relationMap
Definition: Relation.h:47
souffle::ram::analysis::RelationAnalysis::lookup
const ram::Relation & lookup(const std::string &name) const
Definition: Relation.cpp:33
souffle::ram::visitDepthFirst
void visitDepthFirst(const Node &root, Visitor< R, Ps... > &visitor, Args &... args)
A utility function visiting all nodes within the RAM fragments rooted by the given node recursively i...
Definition: Visitor.h:357