tvl-depot/users/tazjin/rlox/src/bytecode/mod.rs
Vincent Ambo 995d024f03 feat(tazjin/rlox): Wire up bytecode interpreter & print results
This makes the bytecode interpreter actually usable.

Change-Id: I24afc7ce461c6673dc42581378f6e14da7aece5c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2566
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-28 11:14:03 +00:00

30 lines
581 B
Rust

//! Bytecode interpreter for Lox.
//!
//! https://craftinginterpreters.com/chunks-of-bytecode.html
mod chunk;
mod compiler;
mod errors;
mod opcode;
mod value;
mod vm;
use chunk::Chunk;
pub struct Interpreter {}
impl crate::Lox for Interpreter {
type Error = errors::Error;
type Value = value::Value;
fn create() -> Self {
Interpreter {}
}
fn interpret(
&mut self,
code: String,
) -> Result<Self::Value, Vec<Self::Error>> {
let chunk = compiler::compile(&code)?;
vm::interpret(chunk).map_err(|e| vec![e])
}
}