about summary refs log tree commit diff
path: root/src/libexpr/nixexpr.hh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-04-04T15·53+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-04-04T16·59+0200
commitb72c8d2e5b5bbdc218f7c00694027cdd75b6a584 (patch)
tree7173dfa3232031d57e12348d16e5255006f1f03d /src/libexpr/nixexpr.hh
parent3f8e1f56825f3ec2a9d99715609e362fe5e5a218 (diff)
Include position info in function application
This allows error messages like:

  error: the anonymous function at `/etc/nixos/configuration.nix:1:1'
    called without required argument `foo', at
    `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix:77:59'
Diffstat (limited to 'src/libexpr/nixexpr.hh')
-rw-r--r--src/libexpr/nixexpr.hh18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index a5c5d0533cc9..527589147e9c 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -273,6 +273,23 @@ struct ExprBuiltin : Expr
     COMMON_METHODS
 };
 
+struct ExprApp : Expr
+{
+    Pos pos;
+    Expr * e1, * e2;
+    ExprApp(Expr * e1, Expr * e2) : e1(e1), e2(e2) { };
+    ExprApp(const Pos & pos, Expr * e1, Expr * e2) : pos(pos), e1(e1), e2(e2) { };
+    void show(std::ostream & str)
+    {
+        str << *e1 << " " << *e2;
+    }
+    void bindVars(const StaticEnv & env)
+    {
+        e1->bindVars(env); e2->bindVars(env);
+    }
+    void eval(EvalState & state, Env & env, Value & v);
+};
+
 #define MakeBinOp(name, s) \
     struct Expr##name : Expr \
     { \
@@ -289,7 +306,6 @@ struct ExprBuiltin : Expr
         void eval(EvalState & state, Env & env, Value & v); \
     };
 
-MakeBinOp(App, "")
 MakeBinOp(OpEq, "==")
 MakeBinOp(OpNEq, "!=")
 MakeBinOp(OpAnd, "&&")