From 274bf80b5d318afe4d9d100352dfc82df58620b9 Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 24 Feb 2018 14:31:04 -0800 Subject: [PATCH] Function evaluation work --- src/schala_lang/eval.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/schala_lang/eval.rs b/src/schala_lang/eval.rs index 9e5006d..a7c0586 100644 --- a/src/schala_lang/eval.rs +++ b/src/schala_lang/eval.rs @@ -143,10 +143,14 @@ impl<'a> State<'a> { Expression(Value(identifier, _), _) => { match self.values.get(&identifier) { Some(&ValueEntry::Function { ref body }) => { - let new_state = State::new_with_parent(self); - let sub_ast = AST(body.clone()); - println!("LOL ALL FUNCTIONS EVALUATE TO 2!"); - Ok(FullyEvaluatedExpr::UnsignedInt(2)) + let mut new_state = State::new_with_parent(self); + let sub_ast = body.clone(); + + let mut ret: Option = None; + for statement in sub_ast.into_iter() { + ret = new_state.eval_statement(statement)?; + } + Ok(ret.unwrap_or(FullyEvaluatedExpr::Custom { string_rep: Rc::new("()".to_string()) })) }, _ => Err(format!("Function {} not found", identifier)), }