finally figure out how to hold closures
This commit is contained in:
parent
69f31db23b
commit
f805290a4b
8 changed files with 98 additions and 89 deletions
|
|
@ -26,7 +26,7 @@ use crate::eval::eval;
|
|||
pub type FTable = HashMap<String, Rc<RefCell<Function>>>;
|
||||
|
||||
// Standardized function signature for stdlib functions
|
||||
pub type InternalOperation = impl Fn(Ast, Rc<RefCell<VTable>>, Rc<RefCell<FTable>>) -> Ctr;
|
||||
//pub type InternalOperation = impl Fn(Ast, Rc<RefCell<VTable>>, Rc<RefCell<FTable>>) -> Ctr;
|
||||
pub struct ExternalOperation {
|
||||
// Un-evaluated abstract syntax tree
|
||||
// TODO: Intermediate evaluation to simplify branches with no argument in them
|
||||
|
|
@ -41,7 +41,7 @@ pub struct ExternalOperation {
|
|||
* or a syntax tree to eval with the arguments
|
||||
*/
|
||||
pub enum Operation {
|
||||
Internal(InternalOperation),
|
||||
Internal(Box<dyn Fn(Ast, Rc<RefCell<VTable>>, Rc<RefCell<FTable>>)->Ctr>),
|
||||
External(ExternalOperation)
|
||||
}
|
||||
|
||||
|
|
@ -160,9 +160,10 @@ pub fn func_call(
|
|||
}
|
||||
|
||||
match &called_func.function {
|
||||
Operation::Internal(f) => Ok((f)(n_args, vars, funcs)),
|
||||
Operation::Internal(f) => {
|
||||
return Ok(f(n_args, vars, funcs))
|
||||
},
|
||||
Operation::External(f) => {
|
||||
|
||||
for n in 0..f.arg_syms.len() {
|
||||
let iter_arg = list_idx(n_args.clone(), n as u128);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue