1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 23:11:16 +02:00

* 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.
This commit is contained in:
Eelco Dolstra 2010-04-13 12:25:42 +00:00
parent 10e8b1fd15
commit ac1e8f40d4
15 changed files with 228 additions and 101 deletions

View file

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