const T& get() const { return d_data; }
/**
- * For convenience, define operator T to be the same as get().
+ * For convenience, define operator T() to be the same as get().
*/
operator T() { return get(); }
+ /**
+ * For convenience, define operator const T() to be the same as get().
+ */
+ operator const T() const { return get(); }
+
/**
* For convenience, define operator= that takes an object of type T.
*/
* creation of new Scope objects in the current memory region.
*/
static void* operator new(size_t size, ContextMemoryManager* pCMM) {
+ Trace("context_mm") << "Scope::new " << size << " in " << pCMM << std::endl;
return pCMM->newData(size);
}
* memory, privately declare (but don't define) an operator
* new(size_t) and destructor (as currently in the Link class, in
* src/theory/uf/ecdata.h).
- *
+ *
* 2. For data structures that may or may not be allocated in context
* memory, and are designed to be that way (esp. if they contain
* ContextObj instances), they should be heavily documented --
* especially the destructor, since it _may_or_may_not_be_called_.
- *
+ *
* 3. There's also an issue for generic code -- some class Foo<T>
* might be allocated in context memory, and that might normally be
* fine, but if T is a ContextObj this requires certain care.
/**
* Pointer to Scope in which this object was last modified.
*/
- Scope* d_pScope;
+ Scope* d_pScope;
/**
* Pointer to most recent version of same ContextObj in a previous Scope
* to be done using the restore method.
*/
static void* operator new(size_t size, ContextMemoryManager* pCMM) {
+ Trace("context_mm") << "Context::new " << size << " in " << pCMM << std::endl;
return pCMM->newData(size);
}
/**
* Pre-process an Node. This is expected to be highly-variable,
* with a lot of "source-level configurability" to add multiple
- * passes over the Node. TODO: may need to specify a LEVEL of
- * preprocessing (certain contexts need more/less ?).
+ * passes over the Node.
*/
static Node preprocess(SmtEngine& smt, TNode n)
throw(NoSuchFunctionException, AssertionException);
"Cannot get value when produce-models options is off.";
throw ModalException(msg);
}
- if(d_status.asSatisfiabilityResult() != Result::SAT ||
+ if(d_status.isNull() ||
+ d_status.asSatisfiabilityResult() != Result::SAT ||
d_haveAdditions) {
const char* msg =
"Cannot get value unless immediately proceded by SAT/INVALID response.";
"produce-assignments option is off.";
throw ModalException(msg);
}
- // TODO also check that the last query was sat/unknown, without intervening
- // assertions
+ if(d_status.isNull() ||
+ d_status.asSatisfiabilityResult() != Result::SAT ||
+ d_haveAdditions) {
+ const char* msg =
+ "Cannot get value unless immediately proceded by SAT/INVALID response.";
+ throw ModalException(msg);
+ }
NodeManagerScope nms(d_nodeManager);
vector<SExpr> sexprs;
bool isUnknown() const {
return isSat() == SAT_UNKNOWN && isValid() == VALIDITY_UNKNOWN;
}
+ bool isNull() const {
+ return d_which == TYPE_NONE;
+ }
enum UnknownExplanation whyUnknown() const {
AlwaysAssert( isUnknown(),
"This result is not unknown, so the reason for "