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

Add level / displacement types

This commit is contained in:
Eelco Dolstra 2020-02-24 14:33:01 +01:00
parent 81e7c40264
commit bcf4780006
3 changed files with 16 additions and 13 deletions

View file

@ -273,7 +273,7 @@ void ExprVar::bindVars(const StaticEnv & env)
/* Check whether the variable appears in the environment. If so,
set its level and displacement. */
const StaticEnv * curEnv;
unsigned int level;
Level level;
int withLevel = -1;
for (curEnv = &env, level = 0; curEnv; curEnv = curEnv->up, level++) {
if (curEnv->isWith) {
@ -326,7 +326,7 @@ void ExprAttrs::bindVars(const StaticEnv & env)
if (recursive) {
dynamicEnv = &newEnv;
unsigned int displ = 0;
Displacement displ = 0;
for (auto & i : attrs)
newEnv.vars.emplace_back(i.first, i.second.displ = displ++);
@ -359,7 +359,7 @@ void ExprLambda::bindVars(const StaticEnv & env)
(hasFormals() ? formals->formals.size() : 0) +
(arg.empty() ? 0 : 1));
unsigned int displ = 0;
Displacement displ = 0;
if (!arg.empty()) newEnv.vars.emplace_back(arg, displ++);
@ -387,7 +387,7 @@ void ExprLet::bindVars(const StaticEnv & env)
{
StaticEnv newEnv(false, &env, attrs->attrs.size());
unsigned int displ = 0;
Displacement displ = 0;
for (auto & i : attrs->attrs)
newEnv.vars.emplace_back(i.first, i.second.displ = displ++);
@ -405,7 +405,7 @@ void ExprWith::bindVars(const StaticEnv & env)
level so that `lookupVar' can look up variables in the previous
`with' if this one doesn't contain the desired attribute. */
const StaticEnv * curEnv;
unsigned int level;
Level level;
prevWith = 0;
for (curEnv = &env, level = 1; curEnv; curEnv = curEnv->up, level++)
if (curEnv->isWith) {