diff --git a/src/ast2ram/AstToRamTranslator.cpp b/src/ast2ram/AstToRamTranslator.cpp index c2f016f45c0..fe2e31254fd 100644 --- a/src/ast2ram/AstToRamTranslator.cpp +++ b/src/ast2ram/AstToRamTranslator.cpp @@ -122,11 +122,14 @@ namespace souffle::ast2ram { AstToRamTranslator::AstToRamTranslator() = default; AstToRamTranslator::~AstToRamTranslator() = default; -/** append statement to a list of statements */ -void AstToRamTranslator::appendStmt(VecOwn& stmtList, Own stmt) { - if (stmt) { - stmtList.push_back(std::move(stmt)); - } +void AstToRamTranslator::addRamSubroutine(std::string subroutineID, Own subroutine) { + assert(!contains(ramSubroutines, subroutineID) && "subroutine ID should not already exist"); + ramSubroutines[subroutineID] = std::move(subroutine); +} + +void AstToRamTranslator::addRamRelation(std::string relationName, Own ramRelation) { + assert(!contains(ramRelations, relationName) && "ram relation should not already exist"); + ramRelations[relationName] = std::move(ramRelation); } size_t AstToRamTranslator::getEvaluationArity(const ast::Atom* atom) const { @@ -747,16 +750,6 @@ void AstToRamTranslator::finaliseAstTypes() { }); } -void AstToRamTranslator::addRamSubroutine(std::string subroutineID, Own subroutine) { - assert(!contains(ramSubroutines, subroutineID) && "subroutine ID should not already exist"); - ramSubroutines[subroutineID] = std::move(subroutine); -} - -void AstToRamTranslator::addRamRelation(std::string relationName, Own ramRelation) { - assert(!contains(ramRelations, relationName) && "ram relation should not already exist"); - ramRelations[relationName] = std::move(ramRelation); -} - Own AstToRamTranslator::translateProgram(const ast::TranslationUnit& translationUnit) { // keep track of relevant analyses ioType = translationUnit.getAnalysis(); diff --git a/src/ast2ram/AstToRamTranslator.h b/src/ast2ram/AstToRamTranslator.h index 570f44a0d95..b15fd795217 100644 --- a/src/ast2ram/AstToRamTranslator.h +++ b/src/ast2ram/AstToRamTranslator.h @@ -118,7 +118,6 @@ class AstToRamTranslator { const ast::analysis::PolymorphicObjectsAnalysis* polyAnalysis = nullptr; void nameUnnamedVariables(ast::Clause* clause); - void appendStmt(VecOwn& stmtList, Own stmt); Own translateSCC(size_t scc, size_t idx); virtual void addNegation(ast::Clause& clause, const ast::Atom* atom); virtual void clearExpiredRelations( diff --git a/src/ast2ram/utility/Utils.cpp b/src/ast2ram/utility/Utils.cpp index c36f903352d..9bb6746fa8a 100644 --- a/src/ast2ram/utility/Utils.cpp +++ b/src/ast2ram/utility/Utils.cpp @@ -24,6 +24,7 @@ #include "souffle/utility/ContainerUtil.h" #include "souffle/utility/StringUtil.h" #include +#include namespace souffle::ast2ram { @@ -47,6 +48,12 @@ std::string getRelationName(const ast::QualifiedName& id) { return toString(join(id.getQualifiers(), ".")); } +void appendStmt(VecOwn& stmtList, Own stmt) { + if (stmt) { + stmtList.push_back(std::move(stmt)); + } +} + Own makeRamTupleElement(const Location& loc) { return mk(loc.identifier, loc.element); } diff --git a/src/ast2ram/utility/Utils.h b/src/ast2ram/utility/Utils.h index c2dc35c7cba..9f06536b28c 100644 --- a/src/ast2ram/utility/Utils.h +++ b/src/ast2ram/utility/Utils.h @@ -27,6 +27,7 @@ class Relation; namespace souffle::ram { class Clear; +class Statement; class TupleElement; } // namespace souffle::ram @@ -49,10 +50,13 @@ std::string getDeltaRelationName(const ast::Relation* rel); /** Get the corresponding RAM 'new' relation name for the relation */ std::string getNewRelationName(const ast::Relation* rel); -/** create a RAM element access node */ +/** Append statement to a list of statements */ +void appendStmt(VecOwn& stmtList, Own stmt); + +/** Create a RAM element access node */ Own makeRamTupleElement(const Location& loc); -/** add a statement to store a relation */ +/** Add a statement to store a relation */ Own makeRamClear(const ast::Relation* relation); } // namespace souffle::ast2ram