Skip to content

Commit

Permalink
Moved ram clear into a util function.
Browse files Browse the repository at this point in the history
Should move these out of the main translator.
  • Loading branch information
azreika committed Nov 16, 2020
1 parent 2ac190c commit 0652e75
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
6 changes: 1 addition & 5 deletions src/ast2ram/AstToRamTranslator.cpp
Expand Up @@ -375,7 +375,7 @@ Own<ram::Sequence> AstToRamTranslator::translateSCC(size_t scc, size_t idx) {
void AstToRamTranslator::clearExpiredRelations(
VecOwn<ram::Statement>& stmts, const std::set<const ast::Relation*>& expiredRelations) {
for (const auto& relation : expiredRelations) {
makeRamClear(stmts, relation);
appendStmt(stmts, makeRamClear(relation));
}
}

Expand Down Expand Up @@ -687,10 +687,6 @@ void AstToRamTranslator::makeRamStore(VecOwn<ram::Statement>& curStmts, const as
}
}

void AstToRamTranslator::makeRamClear(VecOwn<ram::Statement>& curStmts, const ast::Relation* relation) {
appendStmt(curStmts, mk<ram::Clear>(getConcreteRelationName(relation)));
}

void AstToRamTranslator::createRamRelation(size_t scc) {
const auto& isRecursive = sccGraph->isRecursive(scc);
const auto& allInterns = sccGraph->getInternalRelations(scc);
Expand Down
5 changes: 0 additions & 5 deletions src/ast2ram/AstToRamTranslator.h
Expand Up @@ -136,8 +136,6 @@ class AstToRamTranslator {

// TODO (b-scholz): revisit / refactor so that only one directive is translated
std::vector<std::map<std::string, std::string>> getInputDirectives(const ast::Relation* rel);

// TODO (b-scholz): revisit / refactor so that only one directive is translated
std::vector<std::map<std::string, std::string>> getOutputDirectives(const ast::Relation* rel);

/** Return a symbol table **/
Expand All @@ -155,9 +153,6 @@ class AstToRamTranslator {
/** translate RAM code for recursive relations in a strongly-connected component */
Own<ram::Statement> translateRecursiveRelation(const std::set<const ast::Relation*>& scc);

/** add a statement to store a relation */
void makeRamClear(VecOwn<ram::Statement>& curStmts, const ast::Relation* relation);

/** add a statement to drop a relation */
void makeRamStore(VecOwn<ram::Statement>& curStmts, const ast::Relation* relation);

Expand Down
4 changes: 1 addition & 3 deletions src/ast2ram/ValueTranslator.cpp
Expand Up @@ -44,9 +44,7 @@ Own<ram::Expression> ValueTranslator::translate(AstToRamTranslator& translator,
}

Own<ram::Expression> ValueTranslator::visitVariable(const ast::Variable& var) {
if (!index.isDefined(var)) {
fatal("variable `%s` is not grounded", var);
}
assert(index.isDefined(var) && "variable not grounded");
return makeRamTupleElement(index.getDefinitionPoint(var));
}

Expand Down
5 changes: 5 additions & 0 deletions src/ast2ram/utility/Utils.cpp
Expand Up @@ -19,6 +19,7 @@
#include "ast/QualifiedName.h"
#include "ast/Relation.h"
#include "ast2ram/Location.h"
#include "ram/Clear.h"
#include "ram/TupleElement.h"
#include "souffle/utility/ContainerUtil.h"
#include "souffle/utility/StringUtil.h"
Expand Down Expand Up @@ -50,4 +51,8 @@ Own<ram::TupleElement> makeRamTupleElement(const Location& loc) {
return mk<ram::TupleElement>(loc.identifier, loc.element);
}

Own<ram::Clear> makeRamClear(const ast::Relation* relation) {
return mk<ram::Clear>(getConcreteRelationName(relation));
}

} // namespace souffle::ast2ram
6 changes: 5 additions & 1 deletion src/ast2ram/utility/Utils.h
Expand Up @@ -26,8 +26,9 @@ class Relation;
} // namespace souffle::ast

namespace souffle::ram {
class Clear;
class TupleElement;
}
} // namespace souffle::ram

namespace souffle::ast2ram {

Expand All @@ -51,4 +52,7 @@ std::string getNewRelationName(const ast::Relation* rel);
/** create a RAM element access node */
Own<ram::TupleElement> makeRamTupleElement(const Location& loc);

/** add a statement to store a relation */
Own<ram::Clear> makeRamClear(const ast::Relation* relation);

} // namespace souffle::ast2ram

0 comments on commit 0652e75

Please sign in to comment.