more complex tests
This commit is contained in:
parent
df5cb47cb4
commit
2c30975571
6 changed files with 179 additions and 320 deletions
12
src/func.rs
12
src/func.rs
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue