about summary refs log tree commit diff
path: root/src/libexpr/nixexpr.hh
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2012-01-07T17·26+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2012-01-07T17·26+0000
commit9fe24c5a0d1e694c6338d584a101034cfbff10bf (patch)
treef938de94275a6a3337a60a111c0c74cd15fb6991 /src/libexpr/nixexpr.hh
parentd4e6b9f2d62ef77ff46397bd130350f03723ce50 (diff)
* Don't create thunks for simple constants (integers, strings, paths)
  and allocate them only once.
* Move Value and related functions into value.hh.

Diffstat (limited to 'src/libexpr/nixexpr.hh')
-rw-r--r--src/libexpr/nixexpr.hh13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index 1c5cc07afe18..6eb771a726b4 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -1,6 +1,7 @@
 #ifndef __NIXEXPR_H
 #define __NIXEXPR_H
 
+#include "value.hh"
 #include "symbol-table.hh"
 
 #include <map>
@@ -66,15 +67,19 @@ std::ostream & operator << (std::ostream & str, Expr & e);
 struct ExprInt : Expr
 {
     int n;
-    ExprInt(int n) : n(n) { };
+    Value v;
+    ExprInt(int n) : n(n) { mkInt(v, n); };
     COMMON_METHODS
+    Value * maybeThunk(EvalState & state, Env & env);
 };
 
 struct ExprString : Expr
 {
     Symbol s;
-    ExprString(const Symbol & s) : s(s) { };
+    Value v;
+    ExprString(const Symbol & s) : s(s) { mkString(v, s); };
     COMMON_METHODS
+    Value * maybeThunk(EvalState & state, Env & env);
 };
 
 /* Temporary class used during parsing of indented strings. */
@@ -87,8 +92,10 @@ struct ExprIndStr : Expr
 struct ExprPath : Expr
 {
     string s;
-    ExprPath(const string & s) : s(s) { };
+    Value v;
+    ExprPath(const string & s) : s(s) { mkPathNoCopy(v, this->s.c_str()); };
     COMMON_METHODS
+    Value * maybeThunk(EvalState & state, Env & env);
 };
 
 struct VarRef