diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-11-18 20:14:54 +0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-11-18 20:16:02 +0100 |
commit | fc33fd86b7727365caab44c05a90d5b52209131b (patch) | |
tree | ba12d5e943e0e3b0d9aa5a9e25f1fa784dc369f0 /src/libexpr/eval.cc | |
parent | 90b5e692846d9b7a951155c5ed4fc7cf72b08e31 (diff) | |
download | guix-fc33fd86b7727365caab44c05a90d5b52209131b.tar.gz |
Add a symbol __curPos that expands to the current source location
I.e. an attribute set { file = <string>; line = <int>; column = <int>; }.
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r-- | src/libexpr/eval.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index b3fc6791a2..7fb38c0fd7 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -142,6 +142,9 @@ EvalState::EvalState() , sOutputs(symbols.create("outputs")) , sOutputName(symbols.create("outputName")) , sIgnoreNulls(symbols.create("__ignoreNulls")) + , sFile(symbols.create("file")) + , sLine(symbols.create("line")) + , sColumn(symbols.create("column")) , repair(false) , baseEnv(allocEnv(128)) , staticBaseEnv(false, 0) @@ -1039,6 +1042,16 @@ void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v) } +void ExprPos::eval(EvalState & state, Env & env, Value & v) +{ + state.mkAttrs(v, 3); + mkString(*state.allocAttr(v, state.sFile), pos.file); + mkInt(*state.allocAttr(v, state.sLine), pos.line); + mkInt(*state.allocAttr(v, state.sColumn), pos.column); + v.attrs->sort(); +} + + void EvalState::strictForceValue(Value & v) { forceValue(v); |