more complex tests

This commit is contained in:
Aidan Hahn 2021-07-19 23:59:03 -07:00
parent df5cb47cb4
commit 2c30975571
No known key found for this signature in database
GPG key ID: 327711E983899316
6 changed files with 179 additions and 320 deletions

View file

@ -77,7 +77,7 @@ pub fn func_call(
vars: Rc<RefCell<VTable>>,
funcs: Rc<RefCell<FTable>>
) -> Result<Ctr, String> {
let called_func = function.borrow_mut();
let called_func = function.borrow();
let mut n_args: Ast = args.clone();
if !called_func.eval_lazy {
match eval(args, vars.clone(), funcs.clone(), called_func.loose_syms) {
@ -172,18 +172,21 @@ pub fn func_call(
);
}
let mut result = Ctr::None;
let mut result: Ctr;
let mut iterate = f.ast.clone();
loop {
if let Ctr::Seg(ast) = iterate.borrow().clone().car {
match eval(ast, vars.clone(), funcs.clone(), called_func.loose_syms) {
Ok(ctr) => {
if let Ctr::Seg(ast) = ctr {
result = ast.borrow().clone().car;
match ctr {
Ctr::Seg(ast) => result = ast.borrow().clone().car,
_ => result = ctr
}
},
Err(e) => return Err(e)
}
} else {
panic!("function body not in standard form!")
}
match iterate.clone().borrow().clone().cdr {
@ -192,7 +195,6 @@ pub fn func_call(
_ => panic!("function body not in standard form!")
}
}
for n in 0..f.arg_syms.len() {
vars.borrow_mut().remove(&f.arg_syms[n].clone());
}