From e15a6b2e88ddef694f84c9627e49a79b58efd746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Thu, 19 Apr 2018 15:36:57 +0200 Subject: [PATCH] Remove Constant class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Constants are not a construct present in Clingo’s AST and were unintentionally made part of anthem’s AST. This removes the unused classes for clarity. --- include/anthem/AST.h | 17 ----------------- include/anthem/ASTCopy.h | 1 - include/anthem/ASTForward.h | 2 -- include/anthem/ASTVisitors.h | 6 ------ include/anthem/Equality.h | 12 ------------ include/anthem/SimplificationVisitors.h | 6 ------ include/anthem/output/AST.h | 8 -------- src/anthem/ASTCopy.cpp | 12 ------------ src/anthem/ASTUtils.cpp | 4 ---- 9 files changed, 68 deletions(-) diff --git a/include/anthem/AST.h b/include/anthem/AST.h index 587819d..f7298fb 100644 --- a/include/anthem/AST.h +++ b/include/anthem/AST.h @@ -103,23 +103,6 @@ struct Comparison //////////////////////////////////////////////////////////////////////////////////////////////////// -struct Constant -{ - explicit Constant(std::string &&name) - : name{std::move(name)} - { - } - - Constant(const Constant &other) = delete; - Constant &operator=(const Constant &other) = delete; - Constant(Constant &&other) = default; - Constant &operator=(Constant &&other) = default; - - std::string name; -}; - -//////////////////////////////////////////////////////////////////////////////////////////////////// - struct Function { explicit Function(std::string &&name) diff --git a/include/anthem/ASTCopy.h b/include/anthem/ASTCopy.h index ca2bae4..426763c 100644 --- a/include/anthem/ASTCopy.h +++ b/include/anthem/ASTCopy.h @@ -22,7 +22,6 @@ namespace ast BinaryOperation prepareCopy(const BinaryOperation &other); Boolean prepareCopy(const Boolean &other); Comparison prepareCopy(const Comparison &other); -Constant prepareCopy(const Constant &other); Function prepareCopy(const Function &other); In prepareCopy(const In &other); Integer prepareCopy(const Integer &other); diff --git a/include/anthem/ASTForward.h b/include/anthem/ASTForward.h index b70f2c2..5a0619a 100644 --- a/include/anthem/ASTForward.h +++ b/include/anthem/ASTForward.h @@ -24,7 +24,6 @@ struct BinaryOperation; struct Biconditional; struct Boolean; struct Comparison; -struct Constant; struct Exists; struct ForAll; struct Function; @@ -63,7 +62,6 @@ using Formula = Clingo::Variant< using Term = Clingo::Variant< BinaryOperation, Boolean, - Constant, Function, Integer, Interval, diff --git a/include/anthem/ASTVisitors.h b/include/anthem/ASTVisitors.h index 5f63691..9714fa8 100644 --- a/include/anthem/ASTVisitors.h +++ b/include/anthem/ASTVisitors.h @@ -123,12 +123,6 @@ struct RecursiveTermVisitor return T::accept(boolean, term, std::forward(arguments)...); } - template - ReturnType visit(Constant &constant, Term &term, Arguments &&... arguments) - { - return T::accept(constant, term, std::forward(arguments)...); - } - template ReturnType visit(Function &function, Term &term, Arguments &&... arguments) { diff --git a/include/anthem/Equality.h b/include/anthem/Equality.h index 06eb834..bbe3a09 100644 --- a/include/anthem/Equality.h +++ b/include/anthem/Equality.h @@ -298,18 +298,6 @@ struct TermEqualityVisitor : Tristate::False; } - Tristate visit(const Constant &constant, const Term &otherTerm) - { - if (!otherTerm.is()) - return Tristate::Unknown; - - const auto &otherConstant = otherTerm.get(); - - return (constant.name == otherConstant.name) - ? Tristate::True - : Tristate::False; - } - Tristate visit(const Function &function, const Term &otherTerm) { if (!otherTerm.is()) diff --git a/include/anthem/SimplificationVisitors.h b/include/anthem/SimplificationVisitors.h index bca0f30..e32b60e 100644 --- a/include/anthem/SimplificationVisitors.h +++ b/include/anthem/SimplificationVisitors.h @@ -137,12 +137,6 @@ struct TermSimplificationVisitor return T::accept(term, std::forward(arguments)...); } - template - SimplificationResult visit(Constant &, Term &term, Arguments &&... arguments) - { - return T::accept(term, std::forward(arguments)...); - } - template SimplificationResult visit(Function &function, Term &term, Arguments &&... arguments) { diff --git a/include/anthem/output/AST.h b/include/anthem/output/AST.h index c83632b..ff8c883 100644 --- a/include/anthem/output/AST.h +++ b/include/anthem/output/AST.h @@ -46,7 +46,6 @@ output::ColorStream &print(output::ColorStream &stream, const BinaryOperation &b output::ColorStream &print(output::ColorStream &stream, const Boolean &boolean, PrintContext &printContext, bool omitParentheses = false); output::ColorStream &print(output::ColorStream &stream, const Comparison &comparison, PrintContext &printContext, bool omitParentheses = false); output::ColorStream &print(output::ColorStream &stream, Comparison::Operator operator_, PrintContext &printContext, bool omitParentheses = false); -output::ColorStream &print(output::ColorStream &stream, const Constant &constant, PrintContext &printContext, bool omitParentheses = false); output::ColorStream &print(output::ColorStream &stream, const Function &function, PrintContext &printContext, bool omitParentheses = false); output::ColorStream &print(output::ColorStream &stream, const In &in, PrintContext &printContext, bool omitParentheses = false); output::ColorStream &print(output::ColorStream &stream, const Integer &integer, PrintContext &printContext, bool omitParentheses = false); @@ -167,13 +166,6 @@ inline output::ColorStream &print(output::ColorStream &stream, const Comparison //////////////////////////////////////////////////////////////////////////////////////////////////// -inline output::ColorStream &print(output::ColorStream &stream, const Constant &constant, PrintContext &, bool) -{ - return (stream << constant.name); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// - inline output::ColorStream &print(output::ColorStream &stream, const Function &function, PrintContext &printContext, bool) { stream << function.name; diff --git a/src/anthem/ASTCopy.cpp b/src/anthem/ASTCopy.cpp index 5f71b43..f67912a 100644 --- a/src/anthem/ASTCopy.cpp +++ b/src/anthem/ASTCopy.cpp @@ -103,13 +103,6 @@ Comparison prepareCopy(const Comparison &other) //////////////////////////////////////////////////////////////////////////////////////////////////// -Constant prepareCopy(const Constant &other) -{ - return Constant(std::string(other.name)); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// - Function prepareCopy(const Function &other) { return Function(std::string(other.name), prepareCopy(other.arguments)); @@ -293,11 +286,6 @@ struct FixDanglingVariablesInTermVisitor { } - template - void visit(Constant &, Arguments &&...) - { - } - template void visit(Function &function, Arguments &&... arguments) { diff --git a/src/anthem/ASTUtils.cpp b/src/anthem/ASTUtils.cpp index e25da41..3c7aa24 100644 --- a/src/anthem/ASTUtils.cpp +++ b/src/anthem/ASTUtils.cpp @@ -150,10 +150,6 @@ struct CollectFreeVariablesVisitor binaryOperation.right.accept(*this, variableStack, freeVariables); } - void visit(Constant &, VariableStack &, std::vector &) - { - } - void visit(Function &function, VariableStack &variableStack, std::vector &freeVariables) { for (auto &argument : function.arguments)