1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-26 20:01:15 +02:00

* Implemented `map'.

This commit is contained in:
Eelco Dolstra 2010-03-30 13:47:59 +00:00
parent d78a05ab40
commit 5b72d8a749
4 changed files with 139 additions and 108 deletions

View file

@ -36,6 +36,7 @@ typedef enum {
tAttrs,
tList,
tThunk,
tApp,
tLambda,
tCopy,
tBlackhole,
@ -68,6 +69,9 @@ struct Value
Env * env;
Expr expr;
} thunk;
struct {
Value * left, * right;
} app;
struct {
Env * env;
Pattern pat;
@ -161,13 +165,16 @@ struct EvalState
void strictEval(Env & env, Expr e, Value & v);
/* If `v' is a thunk, enter it and overwrite `v' with the result
of the evaluation of the thunk. Otherwise, this is a no-op. */
of the evaluation of the thunk. If `v' is a delayed function
application, call the function and overwrite `v' with the
result. Otherwise, this is a no-op. */
void forceValue(Value & v);
/* Force `v', and then verify that it has the expected type. */
int forceInt(Value & v);
void forceAttrs(Value & v);
void forceList(Value & v);
void forceFunction(Value & v); // either lambda or primop
/* String coercion. Converts strings, paths and derivations to a
string. If `coerceMore' is set, also converts nulls, integers,
@ -196,6 +203,10 @@ private:
elements and attributes are compared recursively. */
bool eqValues(Value & v1, Value & v2);
void callFunction(Value & fun, Value & arg, Value & v);
public:
/* Allocation primitives. */
Value * allocValues(unsigned int count);
Env & allocEnv();