aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/nixexpr.hh
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 07:37:45 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 07:37:45 +0100
commit6b279cd10ea82813decc4451fd3842b49ee9deea (patch)
treea88746796944a0d17294995bf54481f3ed6ad426 /src/libexpr/nixexpr.hh
parentcd326a2aa4a5ad9118a56d2eff459c73b2ec9226 (diff)
Merge pull request #9658 from pennae/env-diet
reduce the size of Env by one pointer (cherry picked from commit 83f5622545a2fc31eb7e7d5105f64ed6dd3058b3) Change-Id: I5636290526d0165cfc61aee1e7a5b94db4a26cef
Diffstat (limited to 'src/libexpr/nixexpr.hh')
-rw-r--r--src/libexpr/nixexpr.hh13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index cb952f5bb..2b5b72bc0 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -139,6 +139,7 @@ std::ostream & operator << (std::ostream & str, const Pos & pos);
struct Env;
struct Value;
class EvalState;
+struct ExprWith;
struct StaticEnv;
@@ -221,8 +222,11 @@ struct ExprVar : Expr
Symbol name;
/* Whether the variable comes from an environment (e.g. a rec, let
- or function argument) or from a "with". */
- bool fromWith;
+ or function argument) or from a "with".
+
+ `nullptr`: Not from a `with`.
+ Valid pointer: the nearest, innermost `with` expression to query first. */
+ ExprWith * fromWith;
/* In the former case, the value is obtained by going `level`
levels up from the current environment and getting the
@@ -380,6 +384,7 @@ struct ExprWith : Expr
PosIdx pos;
Expr * attrs, * body;
size_t prevWith;
+ ExprWith * parentWith;
ExprWith(const PosIdx & pos, Expr * attrs, Expr * body) : pos(pos), attrs(attrs), body(body) { };
PosIdx getPos() const override { return pos; }
COMMON_METHODS
@@ -473,14 +478,14 @@ extern ExprBlackHole eBlackHole;
runtime. */
struct StaticEnv
{
- bool isWith;
+ ExprWith * isWith;
const StaticEnv * up;
// Note: these must be in sorted order.
typedef std::vector<std::pair<Symbol, Displacement>> Vars;
Vars vars;
- StaticEnv(bool isWith, const StaticEnv * up, size_t expectedSize = 0) : isWith(isWith), up(up) {
+ StaticEnv(ExprWith * isWith, const StaticEnv * up, size_t expectedSize = 0) : isWith(isWith), up(up) {
vars.reserve(expectedSize);
};