about summary refs log tree commit diff
path: root/src/libexpr/nixexpr.hh
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-04-13T12·25+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-04-13T12·25+0000
commitac1e8f40d4a5c380d68bb6f1c7cef6f1e7987c1a (patch)
treebcdb22f27c39948cdb254afd560ac198ae675f56 /src/libexpr/nixexpr.hh
parent10e8b1fd15d59dc541c15f6da56f8baf58eb3aa3 (diff)
* Use a symbol table to represent identifiers and attribute names
  efficiently.  The symbol table ensures that there is only one copy
  of each symbol, thus allowing symbols to be compared efficiently
  using a pointer equality test.

Diffstat (limited to 'src/libexpr/nixexpr.hh')
-rw-r--r--src/libexpr/nixexpr.hh26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index 725f9fe88e52..f0c05d4352ff 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -3,7 +3,7 @@
 
 #include <map>
 
-#include "types.hh"
+#include "symbol-table.hh"
 
 
 namespace nix {
@@ -75,33 +75,33 @@ struct ExprPath : Expr
 
 struct ExprVar : Expr
 {
-    string name;
-    ExprVar(const string & name) : name(name) { };
+    Symbol name;
+    ExprVar(const Symbol & name) : name(name) { };
     COMMON_METHODS
 };
 
 struct ExprSelect : Expr
 {
     Expr * e;
-    string name;
-    ExprSelect(Expr * e, const string & name) : e(e), name(name) { };
+    Symbol name;
+    ExprSelect(Expr * e, const Symbol & name) : e(e), name(name) { };
     COMMON_METHODS
 };
 
 struct ExprOpHasAttr : Expr
 {
     Expr * e;
-    string name;
-    ExprOpHasAttr(Expr * e, const string & name) : e(e), name(name) { };
+    Symbol name;
+    ExprOpHasAttr(Expr * e, const Symbol & name) : e(e), name(name) { };
     COMMON_METHODS
 };
 
 struct ExprAttrs : Expr
 {
     bool recursive;
-    typedef std::map<string, Expr *> Attrs;
+    typedef std::map<Symbol, Expr *> Attrs;
     Attrs attrs;
-    list<string> inherited;
+    list<Symbol> inherited;
     ExprAttrs() : recursive(false) { };
     COMMON_METHODS
 };
@@ -115,9 +115,9 @@ struct ExprList : Expr
 
 struct Formal
 {
-    string name;
+    Symbol name;
     Expr * def;
-    Formal(const string & name, Expr * def) : name(name), def(def) { };
+    Formal(const Symbol & name, Expr * def) : name(name), def(def) { };
 };
 
 struct Formals
@@ -130,11 +130,11 @@ struct Formals
 struct ExprLambda : Expr
 {
     Pos pos;
-    string arg;
+    Symbol arg;
     bool matchAttrs;
     Formals * formals;
     Expr * body;
-    ExprLambda(const Pos & pos, const string & arg, bool matchAttrs, Formals * formals, Expr * body)
+    ExprLambda(const Pos & pos, const Symbol & arg, bool matchAttrs, Formals * formals, Expr * body)
         : pos(pos), arg(arg), matchAttrs(matchAttrs), formals(formals), body(body) { };
     COMMON_METHODS
 };