summaryrefslogtreecommitdiff
path: root/src/value.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/value.h')
-rw-r--r--src/value.h29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/value.h b/src/value.h
index 1c1d8b6c..3252ed65 100644
--- a/src/value.h
+++ b/src/value.h
@@ -57,6 +57,7 @@ namespace ledger {
DECLARE_EXCEPTION(value_error, std::runtime_error);
class scope_t;
+class expr_t;
/**
* @class value_t
@@ -108,7 +109,8 @@ public:
STRING, // a string object
MASK, // a regular expression mask
SEQUENCE, // a vector of value_t objects
- SCOPE // a pointer to a scope
+ SCOPE, // a pointer to a scope
+ EXPR // a pointer to a value expression
};
private:
@@ -135,7 +137,8 @@ private:
string, // STRING
mask_t, // MASK
sequence_t *, // SEQUENCE
- scope_t * // SCOPE
+ scope_t *, // SCOPE
+ expr_t * // EXPR
> data;
type_t type;
@@ -351,6 +354,10 @@ public:
TRACE_CTOR(value_t, "scope_t *");
set_scope(item);
}
+ explicit value_t(const expr_t& item) {
+ TRACE_CTOR(value_t, "const expr_t&");
+ set_expr(item);
+ }
/**
* Destructor. This does not do anything, because the intrusive_ptr
@@ -723,6 +730,22 @@ public:
}
/**
+ * Dealing with expr pointers.
+ */
+ bool is_expr() const {
+ return is_type(EXPR);
+ }
+ expr_t& as_expr_lval() const {
+ VERIFY(is_expr());
+ return *boost::get<expr_t *>(storage->data);
+ }
+ const expr_t& as_expr() const {
+ VERIFY(is_expr());
+ return *boost::get<expr_t *>(storage->data);
+ }
+ void set_expr(const expr_t& val);
+
+ /**
* Data conversion methods. These methods convert a value object to
* its underlying type, where possible. If not possible, an
* exception is thrown.
@@ -908,6 +931,8 @@ public:
return _("a sequence");
case SCOPE:
return _("a scope");
+ case EXPR:
+ return _("a expr");
default:
assert(false);
break;