about summary refs log tree commit diff
path: root/tvix/eval/src/eval.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-24T13·03+0300
committertazjin <tazjin@tvl.su>2022-09-02T12·59+0000
commite1147b57c74d23a3f18b1a1e7413e4d0b9d5e2ba (patch)
tree3ca30a9dc1ac2910c34569276927f0ebacf830c1 /tvix/eval/src/eval.rs
parentca90c0f45ad9892c35a2a0402939b857a6fca08e (diff)
feat(tvix/eval): introduce mechanism for defining builtins r/4588
Adds a new builtins module in which builtins can be constructed. The
functions in this module should return a correctly structured value to
be passed to the compiler's `globals`.

This is wired up all the way to the compiler with an example
`toString` builtin, available as a global. Note that this does not yet
actually behave like the real toString, which has some differences
from `Display`.

Change-Id: Ibb5f6fbe6207782fdf2434435567fc1bd80039a5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6254
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'tvix/eval/src/eval.rs')
-rw-r--r--tvix/eval/src/eval.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/tvix/eval/src/eval.rs b/tvix/eval/src/eval.rs
index d81744220568..8cb44b87ea08 100644
--- a/tvix/eval/src/eval.rs
+++ b/tvix/eval/src/eval.rs
@@ -3,6 +3,7 @@ use std::path::PathBuf;
 use rnix;
 
 use crate::{
+    builtins::global_builtins,
     errors::{ErrorKind, EvalResult},
     value::Value,
 };
@@ -28,7 +29,7 @@ pub fn interpret(code: &str, location: Option<PathBuf>) -> EvalResult<Value> {
         println!("{:?}", root_expr);
     }
 
-    let result = crate::compiler::compile(root_expr, location)?;
+    let result = crate::compiler::compile(root_expr, location, global_builtins())?;
 
     #[cfg(feature = "disassembler")]
     crate::disassembler::disassemble_chunk(&result.lambda.chunk);