forked from lix-project/lix
libexpr: associate parsing and builtins with EvalContext
Change-Id: Iff56246bb344405c9acecb967423554d25fe47f5
This commit is contained in:
parent
7fa6e785ff
commit
71c392ae0f
6 changed files with 17 additions and 17 deletions
|
@ -416,7 +416,7 @@ static void queryInstSources(EvalState & state,
|
|||
loadSourceExpr(state, *instSource.nixExprPath, vArg);
|
||||
|
||||
for (auto & i : args) {
|
||||
Expr & eFun = state.parseExprFromString(i, CanonPath::fromCwd());
|
||||
Expr & eFun = state.ctx.parseExprFromString(i, CanonPath::fromCwd());
|
||||
Value vFun, vTmp;
|
||||
state.eval(eFun, vFun);
|
||||
vTmp.mkApp(&vFun, &vArg);
|
||||
|
|
|
@ -97,7 +97,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
|||
|
||||
/* Get the environment builder expression. */
|
||||
Value envBuilder;
|
||||
state.eval(state.parseExprFromString(
|
||||
state.eval(state.ctx.parseExprFromString(
|
||||
#include "buildenv.nix.gen.hh"
|
||||
, CanonPath::root), envBuilder);
|
||||
|
||||
|
|
|
@ -953,14 +953,14 @@ void EvalState::evalFile(const SourcePath & path_, Value & v)
|
|||
}
|
||||
|
||||
debug("evaluating file '%1%'", resolvedPath);
|
||||
Expr & e = parseExprFromFile(ctx.paths.checkSourcePath(resolvedPath));
|
||||
Expr & e = ctx.parseExprFromFile(ctx.paths.checkSourcePath(resolvedPath));
|
||||
|
||||
try {
|
||||
auto dts = ctx.debug
|
||||
? makeDebugTraceStacker(
|
||||
*this,
|
||||
e,
|
||||
this->builtins.env,
|
||||
ctx.builtins.env,
|
||||
e.getPos() ? std::make_shared<Pos>(ctx.positions[e.getPos()]) : nullptr,
|
||||
"while evaluating the file '%1%':", resolvedPath.to_string())
|
||||
: nullptr;
|
||||
|
@ -985,7 +985,7 @@ void EvalState::resetFileCache()
|
|||
|
||||
void EvalState::eval(Expr & e, Value & v)
|
||||
{
|
||||
e.eval(*this, builtins.env, v);
|
||||
e.eval(*this, ctx.builtins.env, v);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ static Flake getFlake(
|
|||
|
||||
// FIXME: symlink attack
|
||||
auto resolvedFlakeFile = resolveExprPath(state.ctx.paths.checkSourcePath(CanonPath(flakeFile)));
|
||||
Expr & flakeExpr = state.parseExprFromFile(state.ctx.paths.checkSourcePath(resolvedFlakeFile));
|
||||
Expr & flakeExpr = state.ctx.parseExprFromFile(state.ctx.paths.checkSourcePath(resolvedFlakeFile));
|
||||
|
||||
// Enforce that 'flake.nix' is a direct attrset, not a computation.
|
||||
if (!(dynamic_cast<ExprAttrs *>(&flakeExpr))) {
|
||||
|
@ -793,7 +793,7 @@ void callFlake(EvalState & state,
|
|||
|
||||
if (!state.caches.vCallFlake) {
|
||||
state.caches.vCallFlake = allocRootValue(state.ctx.mem.allocValue());
|
||||
state.eval(state.parseExprFromString(
|
||||
state.eval(state.ctx.parseExprFromString(
|
||||
#include "call-flake.nix.gen.hh"
|
||||
, CanonPath::root), **state.caches.vCallFlake);
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ static void import(EvalState & state, const PosIdx pos, Value & vPath, Value * v
|
|||
|
||||
if (!state.caches.vImportedDrvToDerivation) {
|
||||
state.caches.vImportedDrvToDerivation = allocRootValue(state.ctx.mem.allocValue());
|
||||
state.eval(state.parseExprFromString(
|
||||
state.eval(state.ctx.parseExprFromString(
|
||||
#include "imported-drv-to-derivation.nix.gen.hh"
|
||||
, CanonPath::root), **state.caches.vImportedDrvToDerivation);
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ static void import(EvalState & state, const PosIdx pos, Value & vPath, Value * v
|
|||
}
|
||||
|
||||
else if (path2 == corepkgsPrefix + "fetchurl.nix") {
|
||||
state.eval(state.parseExprFromString(
|
||||
state.eval(state.ctx.parseExprFromString(
|
||||
#include "fetchurl.nix.gen.hh"
|
||||
, CanonPath::root), v);
|
||||
}
|
||||
|
@ -235,10 +235,10 @@ static void import(EvalState & state, const PosIdx pos, Value & vPath, Value * v
|
|||
state.forceAttrs(*vScope, pos, "while evaluating the first argument passed to builtins.scopedImport");
|
||||
|
||||
Env * env = &state.ctx.mem.allocEnv(vScope->attrs->size());
|
||||
env->up = &state.builtins.env;
|
||||
env->up = &state.ctx.builtins.env;
|
||||
|
||||
auto staticEnv = std::make_shared<StaticEnv>(
|
||||
nullptr, state.builtins.staticEnv.get(), vScope->attrs->size()
|
||||
nullptr, state.ctx.builtins.staticEnv.get(), vScope->attrs->size()
|
||||
);
|
||||
|
||||
unsigned int displ = 0;
|
||||
|
@ -251,7 +251,7 @@ static void import(EvalState & state, const PosIdx pos, Value & vPath, Value * v
|
|||
// args[0]->attrs is already sorted.
|
||||
|
||||
debug("evaluating file '%1%'", path);
|
||||
Expr & e = state.parseExprFromFile(resolveExprPath(path), staticEnv);
|
||||
Expr & e = state.ctx.parseExprFromFile(resolveExprPath(path), staticEnv);
|
||||
|
||||
e.eval(state, *env, v);
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ void prim_exec(EvalState & state, const PosIdx pos, Value * * args, Value & v)
|
|||
auto output = runProgram(program, true, commandArgs);
|
||||
Expr * parsed;
|
||||
try {
|
||||
parsed = &state.parseExprFromString(std::move(output), CanonPath::root);
|
||||
parsed = &state.ctx.parseExprFromString(std::move(output), CanonPath::root);
|
||||
} catch (Error & e) {
|
||||
e.addTrace(state.ctx.positions[pos], "while parsing the output from '%1%'", program);
|
||||
throw;
|
||||
|
@ -1382,7 +1382,7 @@ static void prim_readDir(EvalState & state, const PosIdx pos, Value * * args, Va
|
|||
auto epath = state.ctx.mem.allocValue();
|
||||
epath->mkPath(path + name);
|
||||
if (!readFileType)
|
||||
readFileType = &state.builtins.get("readFileType");
|
||||
readFileType = &state.ctx.builtins.get("readFileType");
|
||||
attr.mkApp(readFileType, epath);
|
||||
} else {
|
||||
// This branch of the conditional is much more likely.
|
||||
|
@ -2847,8 +2847,8 @@ void EvalBuiltins::createBaseEnv(const SearchPath & searchPath, const Path & sto
|
|||
char code[] =
|
||||
#include "primops/derivation.nix.gen.hh"
|
||||
;
|
||||
auto & expr = *state.parse(
|
||||
code, sizeof(code), Pos::Hidden{}, {CanonPath::root}, state.builtins.staticEnv
|
||||
auto & expr = *state.ctx.parse(
|
||||
code, sizeof(code), Pos::Hidden{}, {CanonPath::root}, state.ctx.builtins.staticEnv
|
||||
);
|
||||
state.eval(expr, v);
|
||||
},
|
||||
|
|
|
@ -29,7 +29,7 @@ std::string resolveMirrorUrl(EvalState & state, const std::string & url)
|
|||
|
||||
Value vMirrors;
|
||||
// FIXME: use nixpkgs flake
|
||||
state.eval(state.parseExprFromString(
|
||||
state.eval(state.ctx.parseExprFromString(
|
||||
"import <nixpkgs/pkgs/build-support/fetchurl/mirrors.nix>",
|
||||
CanonPath::root),
|
||||
vMirrors);
|
||||
|
|
Loading…
Reference in a new issue