From b27893b5d97e17160c620a13c6502a480401770c Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 24 Nov 2019 21:14:11 -0500 Subject: [PATCH] Replace CallByName and CallPointer with Call --- src/can/expr.rs | 3 +-- src/can/mod.rs | 13 ++++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/can/expr.rs b/src/can/expr.rs index 39766a156b..5c86543eba 100644 --- a/src/can/expr.rs +++ b/src/can/expr.rs @@ -40,8 +40,7 @@ pub enum Expr { Box>, ), - CallByName(Symbol, Vec>, CalledVia), - CallPointer(Box, Vec>, CalledVia), + Call(Box, Vec>, CalledVia), // Product Types Record(Variable, Vec, Located)>>), diff --git a/src/can/mod.rs b/src/can/mod.rs index b4d203be1f..d31769321c 100644 --- a/src/can/mod.rs +++ b/src/can/mod.rs @@ -301,22 +301,21 @@ fn canonicalize_expr( // We're not tail-calling a symbol (by name), we're tail-calling a function value. output.tail_call = None; - let expr = match &fn_expr.value { - &Var(_, ref sym) | &FunctionPointer(_, ref sym) => { + let expr = match fn_expr.value { + Var(_, ref sym) | FunctionPointer(_, ref sym) => { // In the FunctionPointer case, we're calling an inline closure; - // something like ((\a b -> a + b) 1 2) + // something like ((\a b -> a + b) 1 2). output.references.calls.insert(sym.clone()); - CallByName(sym.clone(), args, *application_style) + Call(Box::new(fn_expr.value), args, *application_style) } - &RuntimeError(_) => { + RuntimeError(_) => { // We can't call a runtime error; bail out by propagating it! return (fn_expr, output); } not_var => { // This could be something like ((if True then fn1 else fn2) arg1 arg2). - // Use CallPointer here. - panic!("TODO support function calls that aren't by name, via CallPointer, in this case: {:?}", not_var); + Call(Box::new(not_var), args, *application_style) } };