use crate::compiler::Chunk; use crate::parser::Ast; use crate::spans::Spanned; use imbl::{HashMap, Vector}; use std::cell::RefCell; use std::rc::Rc; #[derive(Clone, Debug, PartialEq)] pub struct LBox { pub name: usize, pub cell: RefCell, } #[derive(Clone, Debug, PartialEq)] pub struct LFn { pub name: &'static str, pub body: Vec>, pub doc: Option<&'static str>, pub enclosing: Vec<(usize, Value)>, pub has_run: bool, pub input: &'static str, pub src: &'static str, } #[derive(Clone, Debug, PartialEq)] pub enum Value { Nil, Boolean(bool), Keyword(usize), // use an idx, rather than a raw index Interned(usize), FnDecl(usize), String(Rc), Number(f64), List(Box>), Dict(Box>), Box(Rc), Fn(Rc>), } impl Value { fn show(&self, ctx: &Chunk) -> String { use Value::*; match &self { Nil => format!("nil"), } } }