feat(tvix/eval): introduce Value::Thunk variant
Introduces the representation of runtime thunks, that is lazily evaluated values. Their representation is very similar to closures. Change-Id: I24d1ab7947c070ae72ca6260a7bbe6198bc8c7c5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6343 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
49296cebe3
commit
1f37275cfb
2 changed files with 61 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ mod builtin;
|
|||
mod function;
|
||||
mod list;
|
||||
mod string;
|
||||
mod thunk;
|
||||
|
||||
use crate::errors::{ErrorKind, EvalResult};
|
||||
use crate::opcode::StackIdx;
|
||||
|
|
@ -16,6 +17,7 @@ pub use builtin::Builtin;
|
|||
pub use function::{Closure, Lambda};
|
||||
pub use list::NixList;
|
||||
pub use string::NixString;
|
||||
pub use thunk::Thunk;
|
||||
|
||||
#[warn(variant_size_differences)]
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
@ -33,6 +35,7 @@ pub enum Value {
|
|||
|
||||
// Internal values that, while they technically exist at runtime,
|
||||
// are never returned to or created directly by users.
|
||||
Thunk(Thunk),
|
||||
AttrPath(Vec<NixString>),
|
||||
AttrNotFound,
|
||||
DynamicUpvalueMissing(NixString),
|
||||
|
|
@ -58,7 +61,8 @@ impl Value {
|
|||
Value::Closure(_) | Value::Builtin(_) => "lambda",
|
||||
|
||||
// Internal types
|
||||
Value::AttrPath(_)
|
||||
Value::Thunk(_)
|
||||
| Value::AttrPath(_)
|
||||
| Value::AttrNotFound
|
||||
| Value::DynamicUpvalueMissing(_)
|
||||
| Value::Blueprint(_)
|
||||
|
|
@ -169,6 +173,7 @@ impl Display for Value {
|
|||
}
|
||||
|
||||
// internal types
|
||||
Value::Thunk(_) => f.write_str("internal[thunk]"),
|
||||
Value::AttrPath(path) => write!(f, "internal[attrpath({})]", path.len()),
|
||||
Value::AttrNotFound => f.write_str("internal[not found]"),
|
||||
Value::Blueprint(_) => f.write_str("internal[blueprint]"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue