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/eval.hh | |
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/eval.hh')
-rw-r--r-- | src/libexpr/eval.hh | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 411364d9f..ec6e2bb5e 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -340,16 +340,16 @@ public: /** * Parse a Nix expression from the specified file. */ - Expr * parseExprFromFile(const SourcePath & path); - Expr * parseExprFromFile(const SourcePath & path, std::shared_ptr<StaticEnv> & staticEnv); + Expr & parseExprFromFile(const SourcePath & path); + Expr & parseExprFromFile(const SourcePath & path, std::shared_ptr<StaticEnv> & staticEnv); /** * Parse a Nix expression from the specified string. */ - Expr * parseExprFromString(std::string s, const SourcePath & basePath, std::shared_ptr<StaticEnv> & staticEnv); - Expr * parseExprFromString(std::string s, const SourcePath & basePath); + Expr & parseExprFromString(std::string s, const SourcePath & basePath, std::shared_ptr<StaticEnv> & staticEnv); + Expr & parseExprFromString(std::string s, const SourcePath & basePath); - Expr * parseStdin(); + Expr & parseStdin(); /** * Evaluate an expression read from the given file to normal @@ -390,15 +390,15 @@ public: * * @param [out] v The resulting is stored here. */ - void eval(Expr * e, Value & v); + void eval(Expr & e, Value & v); /** * Evaluation the expression, then verify that it has the expected * type. */ - inline bool evalBool(Env & env, Expr * e); - inline bool evalBool(Env & env, Expr * e, const PosIdx pos, std::string_view errorCtx); - inline void evalAttrs(Env & env, Expr * e, Value & v, const PosIdx pos, std::string_view errorCtx); + inline bool evalBool(Env & env, Expr & e); + inline bool evalBool(Env & env, Expr & e, const PosIdx pos, std::string_view errorCtx); + inline void evalAttrs(Env & env, Expr & e, Value & v, const PosIdx pos, std::string_view errorCtx); /** * If `v` is a thunk, enter it and overwrite `v` with the result @@ -619,7 +619,7 @@ public: } void mkList(Value & v, size_t length); - void mkThunk_(Value & v, Expr * expr); + void mkThunk_(Value & v, Expr & expr); void mkPos(Value & v, PosIdx pos); /** |