souffle  2.0.2-371-g6315b36
ResolveAnonymousRecordAliases.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2015, Oracle and/or its affiliates. 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 ResolveAnonymousRecordAliases.h
12  *
13  ***********************************************************************/
14 
15 #pragma once
16 
17 #include "ast/Clause.h"
18 #include "ast/RecordInit.h"
19 #include "ast/TranslationUnit.h"
21 #include <map>
22 #include <string>
23 
24 namespace souffle::ast::transform {
25 
26 /**
27  * Transformer resolving aliases for anonymous records.
28  *
29  * The transformer works by searching the clause for equalities
30  * of the form a = [...], where a is an anonymous record, and replacing
31  * all occurrences of a with the RHS.
32  *
33  * The transformer is to be called in conjunction with FoldAnonymousRecords.
34  **/
35 class ResolveAnonymousRecordAliasesTransformer : public Transformer {
36 public:
37  std::string getName() const override {
38  return "ResolveAnonymousRecordAliases";
39  }
40 
43  }
44 
45 private:
46  bool transform(TranslationUnit& translationUnit) override;
47 
48  /**
49  * Use mapping found by findVariablesRecordMapping to substitute
50  * a records for each variable that operates on records.
51  **/
53 
54  /**
55  * For each variable equal to some anonymous record,
56  * assign a value of that record.
57  **/
58  std::map<std::string, const RecordInit*> findVariablesRecordMapping(TranslationUnit&, const Clause&);
59 
60  /**
61  * For unnamed variables, replace each equation _ op record with true.
62  **/
64 };
65 
66 } // namespace souffle::ast::transform
souffle::ast::transform::ResolveAnonymousRecordAliasesTransformer::replaceNamedVariables
bool replaceNamedVariables(TranslationUnit &, Clause &)
Use mapping found by findVariablesRecordMapping to substitute a records for each variable that operat...
Definition: ResolveAnonymousRecordAliases.cpp:99
TranslationUnit.h
Transformer.h
souffle::ast::Clause
Intermediate representation of a horn clause.
Definition: Clause.h:51
souffle::ast::transform::ResolveAnonymousRecordAliasesTransformer
Transformer resolving aliases for anonymous records.
Definition: ResolveAnonymousRecordAliases.h:39
souffle::ast::TranslationUnit
Translation unit class for the translation pipeline.
Definition: TranslationUnit.h:51
souffle::ast::transform
Definition: Program.h:45
souffle::ast::transform::ResolveAnonymousRecordAliasesTransformer::transform
bool transform(TranslationUnit &translationUnit) override
Definition: ResolveAnonymousRecordAliases.cpp:161
souffle::ast::transform::ResolveAnonymousRecordAliasesTransformer::getName
std::string getName() const override
Definition: ResolveAnonymousRecordAliases.h:45
souffle::ast::transform::ResolveAnonymousRecordAliasesTransformer::replaceUnnamedVariable
bool replaceUnnamedVariable(Clause &)
For unnamed variables, replace each equation _ op record with true.
Definition: ResolveAnonymousRecordAliases.cpp:129
Clause.h
souffle::ast::transform::ResolveAnonymousRecordAliasesTransformer::clone
ResolveAnonymousRecordAliasesTransformer * clone() const override
Definition: ResolveAnonymousRecordAliases.h:49
souffle::ast::transform::ResolveAnonymousRecordAliasesTransformer::findVariablesRecordMapping
std::map< std::string, const RecordInit * > findVariablesRecordMapping(TranslationUnit &, const Clause &)
For each variable equal to some anonymous record, assign a value of that record.
Definition: ResolveAnonymousRecordAliases.cpp:44
RecordInit.h