-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewriters: Hide internal details of rewriters
DivModRewriter is exposed to the outside world, but it was broken, because it was including "OsmtInternalException.h" which is not suppose to be exposed and which we do not install. Thus, trying to include "DivModRewriter.h" in another application results in a compilation error. We fix this problem by hiding the existing rewriters and exposing to the outside world only API methods to use this functionality.
- Loading branch information
Showing
13 changed files
with
119 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
add_library(rewriters OBJECT "") | ||
|
||
target_sources(rewriters | ||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/DistinctRewriter.cc" | ||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/Rewritings.cc" | ||
) | ||
|
||
install(FILES | ||
Substitutor.h | ||
Rewriter.h | ||
DivModRewriter.h | ||
Rewritings.h | ||
DESTINATION ${INSTALL_HEADERS_DIR} | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2024 Martin Blicha <martin.blicha@gmail.com> | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
*/ | ||
|
||
#include "Rewritings.h" | ||
|
||
#include "DistinctRewriter.h" | ||
#include "DivModRewriter.h" | ||
#include "TreeOps.h" | ||
|
||
namespace opensmt::rewritings { | ||
|
||
PTRef rewriteDistincts(Logic & logic, PTRef fla) { | ||
return DistinctRewriter(logic).rewrite(fla); | ||
} | ||
|
||
PTRef rewriteDistinctsKeepTopLevel(Logic & logic, PTRef fla) { | ||
vec<PTRef> topLevelConjuncts = ::topLevelConjuncts(logic, fla); | ||
KeepTopLevelDistinctRewriter::TopLevelDistincts topLevelDistincts; | ||
for (PTRef conj : topLevelConjuncts) { | ||
if (logic.isDisequality(conj)) { topLevelDistincts.insert(conj); } | ||
} | ||
return KeepTopLevelDistinctRewriter(logic, std::move(topLevelDistincts)).rewrite(fla); | ||
} | ||
|
||
PTRef rewriteDivMod(ArithLogic & logic, PTRef term) { | ||
return DivModRewriter(logic).rewrite(term); | ||
} | ||
|
||
std::optional<PTRef> tryGetOriginalDivModTerm(ArithLogic & logic, PTRef tr) { | ||
if (not logic.isVar(tr)) return std::nullopt; // Only variables can match | ||
auto symName = std::string_view(logic.getSymName(tr)); | ||
if (symName.compare(0, DivModConfig::divPrefix.size(), DivModConfig::divPrefix) == 0) { | ||
return DivModConfig::getDivTermFor(logic, tr); | ||
} else if (symName.compare(0, DivModConfig::modPrefix.size(), DivModConfig::modPrefix) == 0) { | ||
return DivModConfig::getModTermFor(logic, tr); | ||
} | ||
return std::nullopt; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2024 Martin Blicha <martin.blicha@gmail.com> | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
*/ | ||
|
||
#ifndef OPENSMT_REWRITINGS_H | ||
#define OPENSMT_REWRITINGS_H | ||
|
||
#include "ArithLogic.h" | ||
#include "PTRef.h" | ||
|
||
#include <optional> | ||
|
||
namespace opensmt::rewritings { | ||
|
||
PTRef rewriteDistincts(Logic & logic, PTRef fla); | ||
|
||
PTRef rewriteDistinctsKeepTopLevel(Logic & logic, PTRef fla); | ||
|
||
PTRef rewriteDivMod(ArithLogic & logic, PTRef fla); | ||
|
||
std::optional<PTRef> tryGetOriginalDivModTerm(ArithLogic & logic, PTRef term); | ||
|
||
} // opensmt::rewritings | ||
|
||
#endif // OPENSMT_REWRITINGS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters