From 4da771036a2d7b5f2f2c84c1af6a28ef86c7b028 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 17 Feb 2017 21:34:41 -0800 Subject: [PATCH] Part of evaluation path for indexing done --- src/schala_lang/eval.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/schala_lang/eval.rs b/src/schala_lang/eval.rs index 8677e66..2889f59 100644 --- a/src/schala_lang/eval.rs +++ b/src/schala_lang/eval.rs @@ -310,8 +310,22 @@ impl<'a> Evaluator<'a> { } } } - Index(box expr, box index_expr) => { - (Null, None) + Index(mut expr, mut index_expr) => { + if index_expr.is_reducible() { + let mut side_effect = None; + take_mut::take(index_expr.as_mut(), |expr| { let (a, b) = self.reduce_expr(expr); side_effect = b; a}); + return (Index(expr, index_expr), side_effect) + } + + if expr.is_reducible() { + let mut side_effect = None; + take_mut::take(expr.as_mut(), |expr| { let (a, b) = self.reduce_expr(expr); side_effect = b; a}); + return (Index(expr, index_expr), side_effect); + } + + match expr { + _ => (Null, None) + } } } }