summaryrefslogtreecommitdiff
path: root/src/context
diff options
context:
space:
mode:
authorTim King <taking@cs.nyu.edu>2012-04-24 18:36:40 +0000
committerTim King <taking@cs.nyu.edu>2012-04-24 18:36:40 +0000
commitc0f5194dd56c5127c5c6dab5e59997eccc2d78a5 (patch)
tree080d465b923832f14d67da4431642609d66b921b /src/context
parent5676b8bddcf001ba567ebb6d8e7b42dbd13ac9f3 (diff)
This commit merges in the branch branches/arithmetic/congruence into trunk. Here are a summary of the changes:
- Adds CDMaybe and CDRaised in cdmaybe.h - Add test for congruence over arithmetic terms and constants - Renames DifferenceManager to CongruenceManager - Changes a number of internal details for CongruenceManager
Diffstat (limited to 'src/context')
-rw-r--r--src/context/Makefile.am1
-rw-r--r--src/context/cdmaybe.h65
2 files changed, 66 insertions, 0 deletions
diff --git a/src/context/Makefile.am b/src/context/Makefile.am
index d0c2b9783..13a151ffc 100644
--- a/src/context/Makefile.am
+++ b/src/context/Makefile.am
@@ -23,5 +23,6 @@ libcontext_la_SOURCES = \
cdcirclist.h \
cdcirclist_forward.h \
cdvector.h \
+ cdmaybe.h \
stacking_map.h \
stacking_vector.h
diff --git a/src/context/cdmaybe.h b/src/context/cdmaybe.h
new file mode 100644
index 000000000..3c95ab126
--- /dev/null
+++ b/src/context/cdmaybe.h
@@ -0,0 +1,65 @@
+/**
+ * This implements a CDMaybe.
+ * This has either been set in the context or it has not.
+ * T must have a default constructor and support assignment.
+ */
+
+#include "cvc4_private.h"
+
+#pragma once
+
+#include "context/cdo.h"
+#include "context/context.h"
+
+namespace CVC4 {
+namespace context {
+
+class CDRaised {
+private:
+ context::CDO<bool> d_flag;
+
+public:
+ CDRaised(context::Context* c)
+ : d_flag(c, false)
+ {}
+
+
+ bool isRaised() const {
+ return d_flag.get();
+ }
+
+ void raise(){
+ Assert(!isRaised());
+ d_flag.set(true);
+ }
+
+}; /* class CDRaised */
+
+template <class T>
+class CDMaybe {
+private:
+ typedef std::pair<bool, T> BoolTPair;
+ context::CDO<BoolTPair> d_data;
+
+public:
+ CDMaybe(context::Context* c) : d_data(c, std::make_pair(false, T()))
+ {}
+
+ bool isSet() const {
+ return d_data.get().first;
+ }
+
+ void set(const T& d){
+ Assert(!isSet());
+ d_data.set(std::make_pair(true, d));
+ }
+
+ const T& get() const{
+ Assert(isSet());
+ return d_data.get().second;
+ }
+}; /* class CDMaybe<T> */
+
+}/* CVC4::context namespace */
+}/* CVC4 namespace */
+
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback