From b365a3fec74ab757d7f1cb141ca9873d4c645807 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sun, 24 Oct 2021 21:15:58 -0700 Subject: [PATCH] WIP if-expression reduction --- schala-lang/language/src/reduced_ir/mod.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/schala-lang/language/src/reduced_ir/mod.rs b/schala-lang/language/src/reduced_ir/mod.rs index e8e5740..849b8d0 100644 --- a/schala-lang/language/src/reduced_ir/mod.rs +++ b/schala-lang/language/src/reduced_ir/mod.rs @@ -126,10 +126,7 @@ impl<'a> Reducer<'a> { .collect(), }, TupleLiteral(exprs) => Expression::Tuple(exprs.iter().map(|e| self.expression(e)).collect()), - IfExpression { - discriminator, - body, - } => Unimplemented, //self.reduce_if_expression(deref_optional_box(discriminator), body), + IfExpression { discriminator, body, } => self.reduce_if_expression(discriminator.as_ref().map(|x| x.as_ref()), body), Lambda { params, body, .. } => { Expression::Callable(Function::Lambda { arity: params.len() as u8, @@ -144,6 +141,10 @@ impl<'a> Reducer<'a> { } } + fn reduce_if_expression(&mut self, discriminator: Option<&ast::Expression>, body: &ast::IfExpressionBody) -> Expression { + Expression::ReductionError("if expr".to_string()) + } + fn invocation_argument(&mut self, invoc: &ast::InvocationArgument) -> Expression { use crate::ast::InvocationArgument::*; match invoc {