souffle
2.0.2-371-g6315b36
ast
transform
PragmaChecker.cpp
Go to the documentation of this file.
1
/*
2
* Souffle - A Datalog Compiler
3
* Copyright (c) 2017, 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 PragmaChecker.cpp
12
*
13
* Defines a transformer that applies pragmas found in parsed input.
14
*
15
***********************************************************************/
16
17
#include "
ast/transform/PragmaChecker.h
"
18
#include "
Global.h
"
19
#include "
ast/Pragma.h
"
20
#include "
ast/Program.h
"
21
#include "
ast/TranslationUnit.h
"
22
#include "
ast/utility/Visitor.h
"
23
#include <utility>
24
#include <vector>
25
26
namespace
souffle::ast::transform
{
27
bool
PragmaChecker::transform
(TranslationUnit& translationUnit) {
28
bool
changed =
false
;
29
Program& program = translationUnit.getProgram();
30
31
// Take in pragma options from the datalog file
32
visitDepthFirst
(program, [&](
const
Pragma& pragma) {
33
std::pair<std::string, std::string> kvp = pragma.getkvp();
34
35
// Command line options take precedence
36
if
(!
Global::config
().has(kvp.first)) {
37
changed = true;
38
Global::config().set(kvp.first, kvp.second);
39
}
40
});
41
42
return
changed;
43
}
44
}
// namespace souffle::ast::transform
TranslationUnit.h
Global.h
souffle::ast::transform
Definition:
Program.h:45
PragmaChecker.h
souffle::ast::transform::PragmaChecker::transform
bool transform(TranslationUnit &) override
Definition:
PragmaChecker.cpp:33
Pragma.h
souffle::Global::config
static MainConfig & config()
Definition:
Global.h:141
Program.h
Visitor.h
souffle::ast::visitDepthFirst
void visitDepthFirst(const Node &root, Visitor< R, Ps... > &visitor, Args &... args)
A utility function visiting all nodes within the ast rooted by the given node recursively in a depth-...
Definition:
Visitor.h:273
Generated by
1.8.17