about summary refs log tree commit diff
path: root/src/libexpr/primops.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r--src/libexpr/primops.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 93a699b4170b..f08ad0464feb 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -703,6 +703,20 @@ static Expr primCurrentTime(EvalState & state, const ATermVector & args)
 }
 
 
+static Expr primGetAttr(EvalState & state, const ATermVector & args)
+{
+    string attr = evalString(state, args[0]);
+    return evalExpr(state, makeSelect(args[1], toATerm(attr)));
+}
+
+
+static Expr primHasAttr(EvalState & state, const ATermVector & args)
+{
+    string attr = evalString(state, args[0]);
+    return evalExpr(state, makeOpHasAttr(args[1], toATerm(attr)));
+}
+
+
 static Expr primRemoveAttrs(EvalState & state, const ATermVector & args)
 {
     ATermMap attrs(128); /* !!! */
@@ -749,6 +763,8 @@ void EvalState::addPrimOps()
     addPrimOp("abort", 1, primAbort);
 
     addPrimOp("map", 2, primMap);
+    addPrimOp("__getAttr", 2, primGetAttr);
+    addPrimOp("__hasAttr", 2, primHasAttr);
     addPrimOp("removeAttrs", 2, primRemoveAttrs);
     addPrimOp("relativise", 2, primRelativise);
 }