diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-03-31T20·09+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-03-31T20·09+0000 |
commit | dc31305b381f69de5ac5fd4776df1a802045ff00 (patch) | |
tree | 8dceb2635eb1f61caf1860206ced3a4828573d25 /src | |
parent | 979f163615745db74f3a94a71818e66c75baf9ac (diff) |
* Fixed the trace primop and path comparison.
* Removed exprToString and stringToExpr because there is no ATerm representation to work on anymore (and exposing the internals of the evaluator like this is not a good idea anyway).
Diffstat (limited to 'src')
-rw-r--r-- | src/libexpr/eval.cc | 3 | ||||
-rw-r--r-- | src/libexpr/primops.cc | 49 |
2 files changed, 11 insertions, 41 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 6e504f879edc..2bfcdac07edc 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -852,6 +852,9 @@ bool EvalState::eqValues(Value & v1, Value & v2) /* !!! contexts */ return strcmp(v1.string.s, v2.string.s) == 0; + case tPath: + return strcmp(v1.path, v2.path) == 0; + case tNull: return true; diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index e16cd2419c9f..65b736787463 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -191,23 +191,18 @@ static void prim_getEnv(EvalState & state, Value * * args, Value & v) } -#if 0 -/* Evaluate the first expression, and print its abstract syntax tree - on standard error. Then return the second expression. Useful for - debugging. - */ +/* Evaluate the first expression and print it on standard error. Then + return the second expression. Useful for debugging. */ static void prim_trace(EvalState & state, Value * * args, Value & v) { - Expr e = evalExpr(state, args[0]); - string s; - PathSet context; - if (matchStr(e, s, context)) - printMsg(lvlError, format("trace: %1%") % s); + state.forceValue(*args[0]); + if (args[0]->type == tString) + printMsg(lvlError, format("trace: %1%") % args[0]->string.s); else - printMsg(lvlError, format("trace: %1%") % e); - return evalExpr(state, args[1]); + printMsg(lvlError, format("trace: %1%") % *args[0]); + state.forceValue(*args[1]); + v = *args[1]; } -#endif /************************************************************* @@ -986,28 +981,6 @@ static void prim_unsafeDiscardOutputDependency(EvalState & state, Value * * args return makeStr(s, context2); } - - -/* Expression serialization/deserialization */ - - -static void prim_exprToString(EvalState & state, Value * * args, Value & v) -{ - /* !!! this disregards context */ - return makeStr(atPrint(evalExpr(state, args[0]))); -} - - -static void prim_stringToExpr(EvalState & state, Value * * args, Value & v) -{ - /* !!! this can introduce arbitrary garbage terms in the - evaluator! */; - string s; - PathSet l; - if (!matchStr(evalExpr(state, args[0]), s, l)) - throw EvalError("stringToExpr needs string argument!"); - return ATreadFromString(s.c_str()); -} #endif @@ -1083,13 +1056,7 @@ void EvalState::createBaseEnv() addPrimOp("__tryEval", 1, prim_tryEval); #endif addPrimOp("__getEnv", 1, prim_getEnv); -#if 0 addPrimOp("__trace", 2, prim_trace); - - // Expr <-> String - addPrimOp("__exprToString", 1, prim_exprToString); - addPrimOp("__stringToExpr", 1, prim_stringToExpr); -#endif // Derivations addPrimOp("derivation", 1, prim_derivationStrict); |