about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 7fb38c0fd79c..c2db006c1414 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -410,6 +410,19 @@ void EvalState::mkThunk_(Value & v, Expr * expr)
 }
 
 
+void EvalState::mkPos(Value & v, Pos * pos)
+{
+    if (pos) {
+        mkAttrs(v, 3);
+        mkString(*allocAttr(v, sFile), pos->file);
+        mkInt(*allocAttr(v, sLine), pos->line);
+        mkInt(*allocAttr(v, sColumn), pos->column);
+        v.attrs->sort();
+    } else
+        mkNull(v);
+}
+
+
 /* Create a thunk for the delayed computation of the given expression
    in the given environment.  But if the expression is a variable,
    then look it up right away.  This significantly reduces the number
@@ -1044,11 +1057,7 @@ 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();
+    state.mkPos(v, &pos);
 }