Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved relation-name-construction to new utils file.
- Loading branch information
Showing
9 changed files
with
113 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Souffle - A Datalog Compiler | ||
* Copyright (c) 2020 The Souffle Developers. All rights reserved | ||
* Licensed under the Universal Permissive License v 1.0 as shown at: | ||
* - https://opensource.org/licenses/UPL | ||
* - <souffle root>/licenses/SOUFFLE-UPL.txt | ||
*/ | ||
|
||
/************************************************************************ | ||
* | ||
* @file Utils.cpp | ||
* | ||
* A collection of utilities used in translation | ||
* | ||
***********************************************************************/ | ||
|
||
#include "ast2ram/utility/Utils.h" | ||
#include "ast/Atom.h" | ||
#include "ast/QualifiedName.h" | ||
#include "ast/Relation.h" | ||
#include "souffle/utility/StringUtil.h" | ||
#include <string> | ||
|
||
namespace souffle::ast2ram { | ||
|
||
std::string getConcreteRelationName(const ast::Atom* atom) { | ||
return getRelationName(atom->getQualifiedName()); | ||
} | ||
|
||
std::string getConcreteRelationName(const ast::Relation* rel, const std::string relationNamePrefix) { | ||
return relationNamePrefix + getRelationName(rel->getQualifiedName()); | ||
} | ||
|
||
std::string getDeltaRelationName(const ast::Relation* rel) { | ||
return getConcreteRelationName(rel, "@delta_"); | ||
} | ||
|
||
std::string getNewRelationName(const ast::Relation* rel) { | ||
return getConcreteRelationName(rel, "@new_"); | ||
} | ||
|
||
std::string getRelationName(const ast::QualifiedName& id) { | ||
return toString(join(id.getQualifiers(), ".")); | ||
} | ||
|
||
} // namespace souffle::ast2ram |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Souffle - A Datalog Compiler | ||
* Copyright (c) 2020 The Souffle Developers. All rights reserved | ||
* Licensed under the Universal Permissive License v 1.0 as shown at: | ||
* - https://opensource.org/licenses/UPL | ||
* - <souffle root>/licenses/SOUFFLE-UPL.txt | ||
*/ | ||
|
||
/************************************************************************ | ||
* | ||
* @file Utils.h | ||
* | ||
* A collection of utilities used in translation | ||
* | ||
***********************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace souffle::ast { | ||
class Atom; | ||
class QualifiedName; | ||
class Relation; | ||
} // namespace souffle::ast | ||
|
||
namespace souffle::ast2ram { | ||
|
||
/** Get the corresponding concretised RAM relation name for the atom */ | ||
std::string getConcreteRelationName(const ast::Atom* atom); | ||
|
||
/** Get the corresponding concretised RAM relation name for the relation */ | ||
std::string getConcreteRelationName(const ast::Relation* rel, const std::string relationNamePrefix = ""); | ||
|
||
/** converts the given relation identifier into a relation name */ | ||
std::string getRelationName(const ast::QualifiedName& id); | ||
|
||
/** Get the corresponding RAM delta relation name for the relation */ | ||
std::string getDeltaRelationName(const ast::Relation* rel); | ||
|
||
/** Get the corresponding RAM 'new' relation name for the relation */ | ||
std::string getNewRelationName(const ast::Relation* rel); | ||
|
||
} // namespace souffle::ast2ram |