From b8cec6d61e8cf30e12924dbbc6b24fecea310a17 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 11 Aug 2022 22:01:45 +0300 Subject: feat(tvix/vm): add opcodes for new Value::NotFound sentinel This sentinel value is going to be used for certain nested accesses into attribute sets. There is a new instruction similar to `OpAttrsSelect` which leaves the sentinel on the stack if a key is not found, instead of raising an error. Additionally, a new jump instruction makes its jump operation conditional on finding such a sentinel value. Change-Id: I2642f0a0bcc85bbe0ead68ea09a7dd794dbedeac Reviewed-on: https://cl.tvl.fyi/c/depot/+/6166 Tested-by: BuildkiteCI Reviewed-by: sterni --- tvix/eval/src/value/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tvix/eval/src/value') diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs index 355678fb7496..e9fdc40ac5c6 100644 --- a/tvix/eval/src/value/mod.rs +++ b/tvix/eval/src/value/mod.rs @@ -26,6 +26,7 @@ pub enum Value { // are never returned to or created directly by users. AttrPath(Vec), Blackhole, + NotFound, } impl Value { @@ -48,7 +49,7 @@ impl Value { Value::List(_) => "list", // Internal types - Value::AttrPath(_) | Value::Blackhole => "internal", + Value::AttrPath(_) | Value::Blackhole | Value::NotFound => "internal", } } @@ -116,8 +117,9 @@ impl Display for Value { )), // internal types - Value::AttrPath(_) => f.write_str("internal"), - Value::Blackhole => f.write_str("internal"), + Value::AttrPath(_) => f.write_str("internal[attrpath]"), + Value::Blackhole => f.write_str("internal[blackhole]"), + Value::NotFound => f.write_str("internal[not found]"), } } } -- cgit 1.4.1