From b5b05b766c4ab0e7a5a501550769e3d6b4059525 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 ---- src/anthem/IntegerVariableDetection.cpp | 8 -------- 10 files changed, 76 deletions(-) diff --git a/include/anthem/AST.h b/include/anthem/AST.h index d9ff875..3b96046 100644 --- a/include/anthem/AST.h +++ b/include/anthem/AST.h @@ -104,23 +104,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 6bce092..10c1a65 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; @@ -64,7 +63,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 0e8ac51..20c4a31 100644 --- a/include/anthem/Equality.h +++ b/include/anthem/Equality.h @@ -289,18 +289,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 5d1fec9..602b64b 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); @@ -168,13 +167,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 3fdd595..e19113d 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 db7a0ed..4786beb 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) diff --git a/src/anthem/IntegerVariableDetection.cpp b/src/anthem/IntegerVariableDetection.cpp index 6370e32..6edc33c 100644 --- a/src/anthem/IntegerVariableDetection.cpp +++ b/src/anthem/IntegerVariableDetection.cpp @@ -49,14 +49,6 @@ struct TermDomainVisitor return ast::VariableDeclaration::Domain::General; } - static ast::VariableDeclaration::Domain visit(ast::Constant &) - { - // Constants may be set to values of any type - - // TODO: implement explicit integer specifications - return ast::VariableDeclaration::Domain::General; - } - static ast::VariableDeclaration::Domain visit(ast::Function &) { // Functions may return values of any type