diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-03-30 09:22:33 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-03-30 09:22:33 +0000 |
commit | d78a05ab4014d75fd1e394961376f02cff20ed88 (patch) | |
tree | 69aa8ef7d829b11bd5ff9c8aa6558b23cb95143b /src/libexpr/eval.hh | |
parent | 31428c3a0675f7223470af726bc697dc7a228927 (diff) |
* Make `import' work.
Diffstat (limited to 'src/libexpr/eval.hh')
-rw-r--r-- | src/libexpr/eval.hh | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 8ca997f14..4706602d5 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -58,6 +58,7 @@ struct Value const char * s; const char * * context; } string; + const char * path; Bindings * attrs; struct { unsigned int length; @@ -107,6 +108,13 @@ static inline void mkString(Value & v, const char * s) } +static inline void mkPath(Value & v, const char * s) +{ + v.type = tPath; + v.path = s; +} + + typedef std::map<Path, PathSet> DrvRoots; typedef std::map<Path, Hash> DrvHashes; @@ -134,6 +142,10 @@ struct EvalState EvalState(); + /* Evaluate an expression read from the given file to normal + form. */ + void evalFile(const Path & path, Value & v); + /* Evaluate an expression to normal form, storing the result in value `v'. */ void eval(Expr e, Value & v); @@ -157,6 +169,18 @@ struct EvalState void forceAttrs(Value & v); void forceList(Value & v); + /* String coercion. Converts strings, paths and derivations to a + string. If `coerceMore' is set, also converts nulls, integers, + booleans and lists to a string. If `copyToStore' is set, + referenced paths are copied to the Nix store as a side effect.q */ + string coerceToString(Value & v, PathSet & context, + bool coerceMore = false, bool copyToStore = true); + + /* Path coercion. Converts strings, paths and derivations to a + path. The result is guaranteed to be a canonicalised, absolute + path. Nothing is copied to the store. */ + Path coerceToPath(Value & v, PathSet & context); + private: /* The base environment, containing the builtin functions and @@ -182,9 +206,6 @@ private: /* Evaluate an expression to normal form. */ Expr evalExpr(EvalState & state, Expr e); -/* Evaluate an expression read from the given file to normal form. */ -Expr evalFile(EvalState & state, const Path & path); - /* Evaluate an expression, and recursively evaluate list elements and attributes. If `canonicalise' is true, we remove things like position information and make sure that attribute sets are in @@ -202,17 +223,6 @@ ATermList evalList(EvalState & state, Expr e); a list). */ ATermList flattenList(EvalState & state, Expr e); -/* String coercion. Converts strings, paths and derivations to a - string. If `coerceMore' is set, also converts nulls, integers, - booleans and lists to a string. */ -string coerceToString(EvalState & state, Expr e, PathSet & context, - bool coerceMore = false, bool copyToStore = true); - -/* Path coercion. Converts strings, paths and derivations to a path. - The result is guaranteed to be an canonicalised, absolute path. - Nothing is copied to the store. */ -Path coerceToPath(EvalState & state, Expr e, PathSet & context); - /* Automatically call a function for which each argument has a default value or has a binding in the `args' map. Note: result is a call, not a normal form; it should be evaluated by calling evalExpr(). */ |