WIP commit:

- Big organizational updates
- Class of errors brought down to borrow checker level
This commit is contained in:
Ava Hahn 2023-02-15 20:05:48 -08:00
parent 6dcb804d34
commit b680e3ca9a
Signed by untrusted user who does not match committer: affine
GPG key ID: 3A4645B8CF806069
6 changed files with 162 additions and 138 deletions

View file

@ -26,7 +26,7 @@ use std::env;
*/
pub struct VTable<'a>(HashMap<String, Box<Ctr<'a>>>);
impl<'a> VTable<'a> {
impl<'a, 'b> VTable<'a> {
// WARNING: make sure var_tree is properly evaluated before storing
pub fn insert(&'a mut self, identifier: String, data: Box<Ctr<'a>>) {
if let Some(datum) = self.0.insert(identifier, data) {
@ -34,14 +34,14 @@ impl<'a> VTable<'a> {
}
}
pub fn get(&'a self, id: String) -> Option<Box<Ctr<'a>>> {
pub fn get(&'a self, id: String) -> Option<Box<Ctr<'b>>> {
match self.0.get(&id) {
Some(s) => Some(s.clone()),
None => None,
}
}
pub fn remove(&self, id: String) {
pub fn remove(&mut self, id: String) {
self.0.remove(&id);
}
@ -66,10 +66,10 @@ pub fn get_export<'a>(env_cfg: bool) -> Function<'a>{
}
fn _export_callback<'a> (ast: &'a Seg, vars: &'a mut VTable, funcs: &'a mut FTable, env_cfg: bool) -> Ctr<'a> {
fn _export_callback<'a> (ast: &Seg, vars: &mut VTable, funcs: &mut FTable, env_cfg: bool) -> Ctr<'a> {
if let Ctr::Symbol(ref identifier) = *ast.car {
match *ast.cdr {
Ctr::Seg(data_tree) => match eval(&Box::new(data_tree), vars, funcs, false) {
match &*ast.cdr {
Ctr::Seg(data_tree) => match eval(&Box::new(data_tree), vars, funcs, false, true) {
Ok(seg) => match *seg {
Ctr::Seg(val) => {
vars.insert(identifier.clone(), val.car);