mirror of
https://github.com/NixOS/nix
synced 2025-06-26 20:01:15 +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:
parent
10e8b1fd15
commit
ac1e8f40d4
15 changed files with 228 additions and 101 deletions
|
@ -4,6 +4,7 @@
|
|||
#include <map>
|
||||
|
||||
#include "nixexpr.hh"
|
||||
#include "symbol-table.hh"
|
||||
|
||||
|
||||
namespace nix {
|
||||
|
@ -14,9 +15,7 @@ class EvalState;
|
|||
struct Env;
|
||||
struct Value;
|
||||
|
||||
typedef string Sym;
|
||||
|
||||
typedef std::map<Sym, Value> Bindings;
|
||||
typedef std::map<Symbol, Value> Bindings;
|
||||
|
||||
|
||||
struct Env
|
||||
|
@ -161,6 +160,10 @@ class EvalState
|
|||
public:
|
||||
DrvHashes drvHashes; /* normalised derivation hashes */
|
||||
|
||||
SymbolTable symbols;
|
||||
|
||||
const Symbol sWith, sOutPath, sDrvPath, sType, sMeta, sName;
|
||||
|
||||
private:
|
||||
SrcToStore srcToStore;
|
||||
|
||||
|
@ -235,6 +238,13 @@ private:
|
|||
void addPrimOp(const string & name,
|
||||
unsigned int arity, PrimOp primOp);
|
||||
|
||||
Value * lookupVar(Env * env, const Symbol & name);
|
||||
|
||||
Value * lookupWith(Env * env, const Symbol & name);
|
||||
|
||||
friend class ExprVar;
|
||||
friend class ExprAttrs;
|
||||
|
||||
public:
|
||||
|
||||
/* Do a deep equality test between two values. That is, list
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue