diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-04-14T22·59+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-04-14T22·59+0000 |
commit | 267dc693d2ca8dea13199f92c265fc35fdb047f6 (patch) | |
tree | 580534be3b6b2cb5de74135f19128a3115e99a48 /src/libexpr/eval.cc | |
parent | 81de12bc8fa09a89dae958a3ffc93e7a4c245db1 (diff) |
* Fix builtins.
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r-- | src/libexpr/eval.cc | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index ccd359ba7c37..f9502d8fba84 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -43,7 +43,7 @@ std::ostream & operator << (std::ostream & str, Value & v) break; case tAttrs: str << "{ "; - foreach (Bindings::iterator, i, *v.attrs) + foreach (Bindings::iterator, i, *v.attrs) str << (string) i->first << " = " << i->second << "; "; str << "}"; break; @@ -99,6 +99,8 @@ EvalState::EvalState() , sMeta(symbols.create("meta")) , sName(symbols.create("name")) , baseEnv(allocEnv(128)) + , baseEnvDispl(0) + , staticBaseEnv(false, 0) { nrValues = nrEnvs = nrEvaluated = recursionDepth = maxRecursionDepth = 0; deepestStack = (char *) -1; @@ -117,28 +119,24 @@ EvalState::~EvalState() void EvalState::addConstant(const string & name, Value & v) { -#if 0 - baseEnv.bindings[symbols.create(name)] = v; + staticBaseEnv.vars[symbols.create(name)] = baseEnvDispl; + baseEnv.values[baseEnvDispl++] = v; string name2 = string(name, 0, 2) == "__" ? string(name, 2) : name; - (*baseEnv.bindings[symbols.create("builtins")].attrs)[symbols.create(name2)] = v; - nrValues += 2; -#endif + (*baseEnv.values[0].attrs)[symbols.create(name2)] = v; } void EvalState::addPrimOp(const string & name, unsigned int arity, PrimOp primOp) { -#if 0 Value v; v.type = tPrimOp; v.primOp.arity = arity; v.primOp.fun = primOp; - baseEnv.bindings[symbols.create(name)] = v; + staticBaseEnv.vars[symbols.create(name)] = baseEnvDispl; + baseEnv.values[baseEnvDispl++] = v; string name2 = string(name, 0, 2) == "__" ? string(name, 2) : name; - (*baseEnv.bindings[symbols.create("builtins")].attrs)[symbols.create(name2)] = v; - nrValues += 2; -#endif + (*baseEnv.values[0].attrs)[symbols.create(name2)] = v; } |