summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorTim King <taking@cs.nyu.edu>2012-04-12 13:26:30 +0000
committerTim King <taking@cs.nyu.edu>2012-04-12 13:26:30 +0000
commit318b75fa9d97f1aed7465c6a1761f103d2c0ec25 (patch)
tree8293c8af51aede3e72eab3df4006e05dbce0ad38 /src/util
parentd01d291be3213368985f28d0072905c4f033d5ff (diff)
Adds an operator<< to SExpr::SexprTypes. This fixes bug 317. In debug builds, an Unhandled(SExpr::SexprTypes) could not compile on debian.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/sexpr.h48
1 files changed, 35 insertions, 13 deletions
diff --git a/src/util/sexpr.h b/src/util/sexpr.h
index 005d9411d..42867cf5b 100644
--- a/src/util/sexpr.h
+++ b/src/util/sexpr.h
@@ -34,12 +34,13 @@ namespace CVC4 {
*/
class CVC4_PUBLIC SExpr {
- enum {
+ enum SexprTypes {
SEXPR_STRING,
SEXPR_INTEGER,
SEXPR_RATIONAL,
SEXPR_NOT_ATOM
- } d_atomType;
+ } d_sexprType;
+ friend std::ostream &operator<<(std::ostream&, SexprTypes);
/** The value of an atomic integer-valued S-expression. */
Integer d_integerValue;
@@ -55,7 +56,7 @@ class CVC4_PUBLIC SExpr {
public:
SExpr() :
- d_atomType(SEXPR_STRING),
+ d_sexprType(SEXPR_STRING),
d_integerValue(0),
d_rationalValue(0),
d_stringValue(""),
@@ -63,7 +64,7 @@ public:
}
SExpr(const Integer& value) :
- d_atomType(SEXPR_INTEGER),
+ d_sexprType(SEXPR_INTEGER),
d_integerValue(value),
d_rationalValue(0),
d_stringValue(""),
@@ -71,7 +72,7 @@ public:
}
SExpr(const Rational& value) :
- d_atomType(SEXPR_RATIONAL),
+ d_sexprType(SEXPR_RATIONAL),
d_integerValue(0),
d_rationalValue(value),
d_stringValue(""),
@@ -79,7 +80,7 @@ public:
}
SExpr(const std::string& value) :
- d_atomType(SEXPR_STRING),
+ d_sexprType(SEXPR_STRING),
d_integerValue(0),
d_rationalValue(0),
d_stringValue(value),
@@ -87,7 +88,7 @@ public:
}
SExpr(const std::vector<SExpr> children) :
- d_atomType(SEXPR_NOT_ATOM),
+ d_sexprType(SEXPR_NOT_ATOM),
d_integerValue(0),
d_rationalValue(0),
d_stringValue(""),
@@ -132,25 +133,46 @@ public:
};/* class SExpr */
+inline std::ostream &operator<<(std::ostream& out, SExpr::SexprTypes type){
+ switch(type){
+ case SExpr::SEXPR_STRING:
+ out << "SEXPR_STRING";
+ break;
+ case SExpr::SEXPR_INTEGER:
+ out << "SEXPR_INTEGER";
+ break;
+ case SExpr::SEXPR_RATIONAL:
+ out << "SEXPR_RATIONAL";
+ break;
+ case SExpr::SEXPR_NOT_ATOM:
+ out << "SEXPR_NOT_ATOM";
+ break;
+ default:
+ Unimplemented();
+ break;
+ }
+ return out;
+}
+
inline bool SExpr::isAtom() const {
- return d_atomType != SEXPR_NOT_ATOM;
+ return d_sexprType != SEXPR_NOT_ATOM;
}
inline bool SExpr::isInteger() const {
- return d_atomType == SEXPR_INTEGER;
+ return d_sexprType == SEXPR_INTEGER;
}
inline bool SExpr::isRational() const {
- return d_atomType == SEXPR_RATIONAL;
+ return d_sexprType == SEXPR_RATIONAL;
}
inline bool SExpr::isString() const {
- return d_atomType == SEXPR_STRING;
+ return d_sexprType == SEXPR_STRING;
}
inline const std::string SExpr::getValue() const {
AlwaysAssert( isAtom() );
- switch(d_atomType) {
+ switch(d_sexprType) {
case SEXPR_INTEGER:
return d_integerValue.toString();
case SEXPR_RATIONAL:
@@ -158,7 +180,7 @@ inline const std::string SExpr::getValue() const {
case SEXPR_STRING:
return d_stringValue;
default:
- Unhandled(d_atomType);
+ Unhandled(d_sexprType);
}
return d_stringValue;
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback