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

Add a symbol __curPos that expands to the current source location

I.e. an attribute set { file = <string>; line = <int>; column = <int>; }.
This commit is contained in:
Eelco Dolstra 2013-11-18 20:14:54 +01:00
parent 90b5e69284
commit fc33fd86b7
7 changed files with 43 additions and 2 deletions

View file

@ -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);