about summary refs log blame commit diff
path: root/tvix/eval/src/eval.rs
blob: 04aa93952868641cc5df318b9faa7f48f1d1e754 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
                                   
 
                              
 







                                                      
                                      

                                              
                                 

                                            
                                     
 
use rnix::{self, types::TypedNode};

use crate::errors::EvalResult;

pub fn interpret(code: String) -> EvalResult<String> {
    let ast = rnix::parse(&code);

    let errors = ast.errors();
    if !errors.is_empty() {
        todo!()
    }

    println!("{}", ast.root().dump());

    let code = crate::compiler::compile(ast)?;
    println!("code: {:?}", code);

    let value = crate::vm::run_chunk(code)?;
    Ok(format!("value: {:?}", value))
}