WIP if-expression reduction

This commit is contained in:
Greg Shuflin 2021-10-24 21:15:58 -07:00
parent 37ce12b6d8
commit b365a3fec7

View File

@ -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 {