From 87dcd6ee93850828b8dceca61aec5a5fdd49488f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Fri, 13 Apr 2018 15:48:03 +0200 Subject: [PATCH] Add domain specifier to variable declarations With this change, the domain of variable declarations can be specified. While the default is the general domain of all precomputed value, this adds support for integer variables, for which advanced simplification rules apply. --- include/anthem/AST.h | 11 ++++++++++- include/anthem/output/AST.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/anthem/AST.h b/include/anthem/AST.h index 587819d..04ca0b8 100644 --- a/include/anthem/AST.h +++ b/include/anthem/AST.h @@ -343,13 +343,21 @@ struct VariableDeclaration Body }; + enum class Domain + { + General, + Integer + }; + explicit VariableDeclaration(Type type) - : type{type} + : type{type}, + domain{Domain::General} { } explicit VariableDeclaration(Type type, std::string &&name) : type{type}, + domain{Domain::General}, name{std::move(name)} { } @@ -360,6 +368,7 @@ struct VariableDeclaration VariableDeclaration &operator=(VariableDeclaration &&other) = default; Type type; + Domain domain; std::string name; }; diff --git a/include/anthem/output/AST.h b/include/anthem/output/AST.h index c83632b..5790f74 100644 --- a/include/anthem/output/AST.h +++ b/include/anthem/output/AST.h @@ -323,7 +323,7 @@ inline output::ColorStream &print(output::ColorStream &stream, const Variable &v inline output::ColorStream &print(output::ColorStream &stream, const VariableDeclaration &variableDeclaration, PrintContext &printContext, bool) { const auto printVariableDeclaration = - [&stream, &variableDeclaration](const auto *prefix, auto &variableIDs) -> output::ColorStream & + [&](const auto *prefix, auto &variableIDs) -> output::ColorStream & { auto matchingVariableID = variableIDs.find(&variableDeclaration);