diff options
author | eldritch horrors <pennae@lix.systems> | 2024-06-16 23:10:09 +0200 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-06-17 19:46:44 +0000 |
commit | ad5366c2ad43216ac9a61ccb1477ff9859d1a75c (patch) | |
tree | e986b1f0e9510641279bba164b36bae9a96be6be /src/libexpr/primops.cc | |
parent | b8f49a8eaf619df6d228f2e0f9814c4a5fa4aec5 (diff) |
libexpr: pass Exprs as references, not pointers
almost all places where Exprs are passed as pointers expect the pointers
to be non-null. pass them as references to encode this constraint in the
type system as well (and also communicate that Exprs must not be freed).
Change-Id: Ia98f166fec3c23151f906e13acb4a0954a5980a2
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r-- | src/libexpr/primops.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index dba56c011..720ab1a3f 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -244,9 +244,9 @@ 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.parseExprFromFile(resolveExprPath(path), staticEnv); - e->eval(state, *env, v); + e.eval(state, *env, v); } } } @@ -390,13 +390,13 @@ 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), state.rootPath(CanonPath::root)); + parsed = &state.parseExprFromString(std::move(output), state.rootPath(CanonPath::root)); } catch (Error & e) { e.addTrace(state.positions[pos], "while parsing the output from '%1%'", program); throw; } try { - state.eval(parsed, v); + state.eval(*parsed, v); } catch (Error & e) { e.addTrace(state.positions[pos], "while evaluating the output from '%1%'", program); throw; @@ -4494,7 +4494,7 @@ void EvalState::createBaseEnv() // the parser needs two NUL bytes as terminators; one of them // is implied by being a C string. "\0"; - eval(parse(code, sizeof(code), derivationInternal, {CanonPath::root}, staticBaseEnv), *vDerivation); + eval(*parse(code, sizeof(code), derivationInternal, {CanonPath::root}, staticBaseEnv), *vDerivation); } |