From ad5366c2ad43216ac9a61ccb1477ff9859d1a75c Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 16 Jun 2024 23:10:09 +0200 Subject: 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 --- src/libexpr/eval.hh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/libexpr/eval.hh') 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); + Expr & parseExprFromFile(const SourcePath & path); + Expr & parseExprFromFile(const SourcePath & path, std::shared_ptr & staticEnv); /** * Parse a Nix expression from the specified string. */ - Expr * parseExprFromString(std::string s, const SourcePath & basePath, std::shared_ptr & staticEnv); - Expr * parseExprFromString(std::string s, const SourcePath & basePath); + Expr & parseExprFromString(std::string s, const SourcePath & basePath, std::shared_ptr & 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); /** -- cgit v1.2.3