From bc01a5ded87d9ee31ff98e5dde6328a7524eadb1 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 16 Jun 2019 00:21:39 -0700 Subject: [PATCH] Make reduced ast call handler be a separate method --- schala-lang/language/src/reduced_ast.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/schala-lang/language/src/reduced_ast.rs b/schala-lang/language/src/reduced_ast.rs index 1ae39a2..4aff5be 100644 --- a/schala-lang/language/src/reduced_ast.rs +++ b/schala-lang/language/src/reduced_ast.rs @@ -149,10 +149,7 @@ impl Expression { }, _ => Expr::Val(name.clone()), }, - Call { f, arguments } => Expr::Call { - f: Box::new(f.node().reduce(symbol_table)), - args: arguments.iter().map(|arg| arg.node().reduce(symbol_table)).collect(), - }, + Call { f, arguments } => reduce_call_expression(f, arguments, symbol_table), TupleLiteral(exprs) => Expr::Tuple(exprs.iter().map(|e| e.node().reduce(symbol_table)).collect()), IfExpression { discriminator, body } => reduce_if_expression(discriminator, body, symbol_table), Lambda { params, body, .. } => reduce_lambda(params, body, symbol_table), @@ -173,6 +170,13 @@ fn reduce_lambda(params: &Vec, body: &Block, symbol_table: &SymbolT }) } +fn reduce_call_expression(func: &Meta, arguments: &Vec>, symbol_table: &SymbolTable) -> Expr { + Expr::Call { + f: Box::new(func.node().reduce(symbol_table)), + args: arguments.iter().map(|arg| arg.node().reduce(symbol_table)).collect(), + } +} + fn reduce_if_expression(discriminator: &Discriminator, body: &IfExpressionBody, symbol_table: &SymbolTable) -> Expr { let cond = Box::new(match *discriminator { Discriminator::Simple(ref expr) => expr.reduce(symbol_table),