From 7289504ab76e47a19840f6caae4cefacb1440bce Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Mon, 1 Nov 2021 01:21:03 -0700 Subject: [PATCH] Adjust types in TreeWalkEvaluator --- schala-lang/language/src/tree_walk_eval/evaluator.rs | 6 +++--- schala-lang/language/src/tree_walk_eval/mod.rs | 9 --------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/schala-lang/language/src/tree_walk_eval/evaluator.rs b/schala-lang/language/src/tree_walk_eval/evaluator.rs index da453a6..5769fb7 100644 --- a/schala-lang/language/src/tree_walk_eval/evaluator.rs +++ b/schala-lang/language/src/tree_walk_eval/evaluator.rs @@ -40,14 +40,14 @@ impl<'a, 'b> Evaluator<'a, 'b> { //TODO need to handle breaks, returns, etc. let mut ret = None; for stmt in statements.into_iter() { - if let Some(MemoryValue::Primitive(prim)) = self.statement(stmt)? { + if let Some(prim) = self.statement(stmt)? { ret = Some(prim); } } Ok(if let Some(ret) = ret { ret } else { self.expression(Expression::unit())? }) } - fn statement(&mut self, stmt: Statement) -> EvalResult> { + fn statement(&mut self, stmt: Statement) -> EvalResult> { match stmt { Statement::Binding { ref id, expr, constant: _ } => { let evaluated = self.expression(expr)?; @@ -56,7 +56,7 @@ impl<'a, 'b> Evaluator<'a, 'b> { } Statement::Expression(expr) => { let evaluated = self.expression(expr)?; - Ok(Some(evaluated.into())) + Ok(Some(evaluated)) } Statement::Return(expr) => unimplemented!(), Statement::Break => unimplemented!(), diff --git a/schala-lang/language/src/tree_walk_eval/mod.rs b/schala-lang/language/src/tree_walk_eval/mod.rs index 6e0fda1..a8bab2f 100644 --- a/schala-lang/language/src/tree_walk_eval/mod.rs +++ b/schala-lang/language/src/tree_walk_eval/mod.rs @@ -88,15 +88,6 @@ impl From for MemoryValue { } } -impl MemoryValue { - fn to_repl(&self, type_context: &TypeContext) -> String { - match self { - MemoryValue::Primitive(ref prim) => prim.to_repl(type_context), - MemoryValue::Function(..) => "".to_string(), - } - } -} - #[derive(Debug)] enum RuntimeValue { Expression(Expression),