about summary refs log tree commit diff
path: root/tvix/eval/src/value/mod.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-08T14·27+0300
committertazjin <tazjin@tvl.su>2022-08-13T11·50+0000
commit2ed38a7cdbd248deb518afff790977243f169a8f (patch)
tree00aab465bde13cde5eed4c82df439be6288b08c6 /tvix/eval/src/value/mod.rs
parentba03226e514b9bc55e5da35830d5fe6cadcf988c (diff)
feat(tvix/eval): add Value variants for strings & attrsets r/4423
Change-Id: Idebf663ab7fde3955aae50f635320f7eb6c353e8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6087
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'tvix/eval/src/value/mod.rs')
-rw-r--r--tvix/eval/src/value/mod.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs
index 628eefb8fdd8..ea0c89e6b6c4 100644
--- a/tvix/eval/src/value/mod.rs
+++ b/tvix/eval/src/value/mod.rs
@@ -1,18 +1,23 @@
 //! This module implements the backing representation of runtime
 //! values in the Nix language.
 use std::fmt::Display;
-
-use crate::errors::{Error, EvalResult};
+use std::rc::Rc;
 
 mod attrs;
 mod string;
 
-#[derive(Clone, Copy, Debug, PartialEq)]
+use crate::errors::{Error, EvalResult};
+use attrs::NixAttrs;
+use string::NixString;
+
+#[derive(Clone, Debug, PartialEq)]
 pub enum Value {
     Null,
     Bool(bool),
     Integer(i64),
     Float(f64),
+    String(NixString),
+    Attrs(Rc<NixAttrs>),
 }
 
 impl Value {
@@ -30,6 +35,8 @@ impl Value {
             Value::Bool(_) => "bool",
             Value::Integer(_) => "int",
             Value::Float(_) => "float",
+            Value::String(_) => "string",
+            Value::Attrs(_) => "set",
         }
     }
 
@@ -52,6 +59,8 @@ impl Display for Value {
             Value::Bool(false) => f.write_str("false"),
             Value::Integer(num) => f.write_fmt(format_args!("{}", num)),
             Value::Float(num) => f.write_fmt(format_args!("{}", num)),
+            Value::String(s) => s.fmt(f),
+            Value::Attrs(attrs) => attrs.fmt(f),
         }
     }
 }