From 0b4ed64d295316146fc4de8a5a2e971b771058b8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 26 Oct 2007 18:25:50 +0000 Subject: [PATCH] * "trace" primop: write the trace to standard error. --- src/libexpr/primops.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 3d080dec3..b9ba3da64 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -296,18 +296,19 @@ static Expr prim_getEnv(EvalState & state, const ATermVector & args) return makeStr(getEnv(name)); } -/* for debugging purposes. print the first arg on stdout (perhaps stderr should be used?) - * and return the second + +/* Evaluate the first expression, and print its abstract syntax tree + on standard error. Then return the second expression. Useful for + debugging. */ static Expr prim_trace(EvalState & state, const ATermVector & args) { - //string str = evalStringNoCtx(state, args[0]); - - Expr a = evalExpr(state, args[0]); - printf("traced value: %s\n", atPrint(a).c_str()); + Expr e = evalExpr(state, args[0]); + printMsg(lvlError, format("trace: %1%") % e); return evalExpr(state, args[1]); } + static Expr prim_relativise(EvalState & state, const ATermVector & args) { PathSet context; /* !!! what to do? */