refactor(tvix/value): encapsulate attrset logic within value::attrs

The internal optimisations of the set representation were previously
leaking into the VM, which is highly undesirable.

Keeping it encapsulated allows us to do additional optimisations
within value::attrs without being concerned about its use in the VM.

Change-Id: I7e7020bb0983b9d355d3db747b049b2faa60131f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6108
Reviewed-by: eta <tvl@eta.st>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2022-08-10 16:35:16 +03:00 committed by tazjin
parent 6edbfe3cba
commit 293fb0ef53
3 changed files with 194 additions and 191 deletions

View file

@ -25,6 +25,7 @@ pub enum Value {
// Internal values that, while they technically exist at runtime,
// are never returned to or created directly by users.
AttrPath(Vec<NixString>),
Blackhole,
}
impl Value {
@ -47,7 +48,7 @@ impl Value {
Value::List(_) => "list",
// Internal types
Value::AttrPath(_) => "internal",
Value::AttrPath(_) | Value::Blackhole => "internal",
}
}
@ -85,7 +86,7 @@ impl Display for Value {
Value::List(list) => list.fmt(f),
// internal types
Value::AttrPath(_) => f.write_str("internal"),
Value::AttrPath(_) | Value::Blackhole => f.write_str("internal"),
}
}
}