about summary refs log tree commit diff
path: root/tvix/eval/src/eval.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/eval.rs')
-rw-r--r--tvix/eval/src/eval.rs23
1 files changed, 21 insertions, 2 deletions
diff --git a/tvix/eval/src/eval.rs b/tvix/eval/src/eval.rs
index 89a375b69a32..0c4900e7e59d 100644
--- a/tvix/eval/src/eval.rs
+++ b/tvix/eval/src/eval.rs
@@ -1,5 +1,24 @@
+use rnix::{self, types::TypedNode};
+use std::fmt::Write;
+
 use crate::errors::{Error, EvalResult};
 
-pub fn interpret(code: String) -> EvalResult<()> {
-    Ok(())
+pub fn interpret(code: String) -> EvalResult<String> {
+    let ast = rnix::parse(&code);
+
+    let errors = ast.errors();
+    if !errors.is_empty() {
+        todo!()
+    }
+
+    let mut out = String::new();
+    writeln!(out, "{}", ast.root().dump()).ok();
+
+    let code = crate::compiler::compile(ast)?;
+    writeln!(out, "code: {:?}", code).ok();
+
+    let value = crate::vm::run_chunk(code)?;
+    writeln!(out, "value: {:?}", value).ok();
+
+    Ok(out)
 }