summaryrefslogtreecommitdiff
path: root/expr.cc
diff options
context:
space:
mode:
Diffstat (limited to 'expr.cc')
-rw-r--r--expr.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/expr.cc b/expr.cc
index 0319e243..086f2494 100644
--- a/expr.cc
+++ b/expr.cc
@@ -111,6 +111,23 @@ value_t expr_t::calc(scope_t& scope) const
return NULL_VALUE;
}
+bool expr_t::is_constant() const
+{
+ return ptr.get() && ptr->is_value();
+}
+
+value_t& expr_t::constant_value()
+{
+ assert(is_constant());
+ return ptr->as_value_lval();
+}
+
+const value_t& expr_t::constant_value() const
+{
+ assert(is_constant());
+ return ptr->as_value();
+}
+
value_t expr_t::eval(const string& _expr, scope_t& scope)
{
return expr_t(_expr).calc(scope);