* 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).
This commit is contained in:
parent
979f163615
commit
dc31305b38
2 changed files with 11 additions and 41 deletions
|
@ -852,6 +852,9 @@ bool EvalState::eqValues(Value & v1, Value & v2)
|
||||||
/* !!! contexts */
|
/* !!! contexts */
|
||||||
return strcmp(v1.string.s, v2.string.s) == 0;
|
return strcmp(v1.string.s, v2.string.s) == 0;
|
||||||
|
|
||||||
|
case tPath:
|
||||||
|
return strcmp(v1.path, v2.path) == 0;
|
||||||
|
|
||||||
case tNull:
|
case tNull:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -191,23 +191,18 @@ static void prim_getEnv(EvalState & state, Value * * args, Value & v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
/* Evaluate the first expression and print it on standard error. Then
|
||||||
/* Evaluate the first expression, and print its abstract syntax tree
|
return the second expression. Useful for debugging. */
|
||||||
on standard error. Then return the second expression. Useful for
|
|
||||||
debugging.
|
|
||||||
*/
|
|
||||||
static void prim_trace(EvalState & state, Value * * args, Value & v)
|
static void prim_trace(EvalState & state, Value * * args, Value & v)
|
||||||
{
|
{
|
||||||
Expr e = evalExpr(state, args[0]);
|
state.forceValue(*args[0]);
|
||||||
string s;
|
if (args[0]->type == tString)
|
||||||
PathSet context;
|
printMsg(lvlError, format("trace: %1%") % args[0]->string.s);
|
||||||
if (matchStr(e, s, context))
|
|
||||||
printMsg(lvlError, format("trace: %1%") % s);
|
|
||||||
else
|
else
|
||||||
printMsg(lvlError, format("trace: %1%") % e);
|
printMsg(lvlError, format("trace: %1%") % *args[0]);
|
||||||
return evalExpr(state, args[1]);
|
state.forceValue(*args[1]);
|
||||||
|
v = *args[1];
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
|
@ -986,28 +981,6 @@ static void prim_unsafeDiscardOutputDependency(EvalState & state, Value * * args
|
||||||
|
|
||||||
return makeStr(s, context2);
|
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
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -1083,14 +1056,8 @@ void EvalState::createBaseEnv()
|
||||||
addPrimOp("__tryEval", 1, prim_tryEval);
|
addPrimOp("__tryEval", 1, prim_tryEval);
|
||||||
#endif
|
#endif
|
||||||
addPrimOp("__getEnv", 1, prim_getEnv);
|
addPrimOp("__getEnv", 1, prim_getEnv);
|
||||||
#if 0
|
|
||||||
addPrimOp("__trace", 2, prim_trace);
|
addPrimOp("__trace", 2, prim_trace);
|
||||||
|
|
||||||
// Expr <-> String
|
|
||||||
addPrimOp("__exprToString", 1, prim_exprToString);
|
|
||||||
addPrimOp("__stringToExpr", 1, prim_stringToExpr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Derivations
|
// Derivations
|
||||||
addPrimOp("derivation", 1, prim_derivationStrict);
|
addPrimOp("derivation", 1, prim_derivationStrict);
|
||||||
//addPrimOp("derivation", 1, prim_derivationLazy);
|
//addPrimOp("derivation", 1, prim_derivationLazy);
|
||||||
|
|
Loading…
Reference in a new issue