From 96540ef0bb649f4bd5c90ff2b524e763b3b5db85 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Wed, 24 Nov 2010 10:36:46 -0800 Subject: move expr_call translation into helper function. --- src/comp/middle/trans.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/comp') diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 893c5691..f323d306 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -966,6 +966,17 @@ impure fn trans_cast(@block_ctxt cx, &ast.expr e, &ast.ann ann) -> result { ret e_res; } +impure fn trans_call(@block_ctxt cx, &ast.expr f, + vec[@ast.expr] args) -> result { + auto f_res = trans_lval(cx, f); + check (! f_res._1); + auto args_res = trans_exprs(f_res._0.bcx, args); + auto llargs = vec(cx.fcx.lltaskptr); + llargs += args_res._1; + ret res(args_res._0, + args_res._0.build.FastCall(f_res._0.val, llargs)); +} + impure fn trans_expr(@block_ctxt cx, &ast.expr e) -> result { alt (e.node) { case (ast.expr_lit(?lit, _)) { @@ -1022,14 +1033,7 @@ impure fn trans_expr(@block_ctxt cx, &ast.expr e) -> result { } case (ast.expr_call(?f, ?args, _)) { - auto f_res = trans_lval(cx, *f); - check (! f_res._1); - - auto args_res = trans_exprs(f_res._0.bcx, args); - auto llargs = vec(cx.fcx.lltaskptr); - llargs += args_res._1; - ret res(args_res._0, - args_res._0.build.FastCall(f_res._0.val, llargs)); + ret trans_call(cx, *f, args); } case (ast.expr_cast(?e, _, ?ann)) { -- cgit v1.2.3