summaryrefslogtreecommitdiff
path: root/src/cjr_print.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2012-01-07 16:49:19 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2012-01-07 16:49:19 -0500
commitbc034c24a246d6abb6d5e172b26fcabbb447ab93 (patch)
tree2f701ab0292ca32e9125d4d042e093123b9c9434 /src/cjr_print.sml
parent09b5839acfe26561fa87c89168133fc93c1083cc (diff)
Finish function argument order-of-operations fix
Diffstat (limited to 'src/cjr_print.sml')
-rw-r--r--src/cjr_print.sml53
1 files changed, 45 insertions, 8 deletions
diff --git a/src/cjr_print.sml b/src/cjr_print.sml
index e69b87f1..65344ffb 100644
--- a/src/cjr_print.sml
+++ b/src/cjr_print.sml
@@ -1693,13 +1693,7 @@ and p_exp' par tail env (e, loc) =
| EFfiApp (m, x, es) => pFuncall env (m, x, es, NONE)
| EApp (f, args) =>
let
- fun default () = parenIf par (box [p_exp' true false env f,
- string "(ctx,",
- space,
- p_list_sep (box [string ",", space]) (p_exp' false false env) args,
- string ")"])
-
- fun isSelf n =
+ fun getSig n =
let
val (_, t) = E.lookupENamed env n
@@ -1707,8 +1701,51 @@ and p_exp' par tail env (e, loc) =
case #1 t of
TFun (dom, t) => getSig (t, dom :: args)
| _ => (args, t)
+ in
+ getSig (t, [])
+ end
- val (argts, ret) = getSig (t, [])
+ fun default () =
+ case (#1 f, args) of
+ (ENamed n, _ :: _ :: _) =>
+ let
+ val (args', ret) = getSig n
+ val args = ListPair.zip (args, args')
+ in
+ parenIf par (box [string "({",
+ newline,
+ p_list_sepi newline
+ (fn i => fn (e, t) =>
+ box [p_typ env t,
+ space,
+ string ("arg" ^ Int.toString i),
+ space,
+ string "=",
+ space,
+ p_exp' false false env e,
+ string ";"])
+ args,
+ newline,
+ p_exp' false false env f,
+ string "(ctx,",
+ space,
+ p_list_sepi (box [string ",", space])
+ (fn i => fn _ =>
+ string ("arg" ^ Int.toString i)) args,
+ string ");",
+ newline,
+ string "})"])
+ end
+ | _ =>
+ parenIf par (box [p_exp' true false env f,
+ string "(ctx,",
+ space,
+ p_list_sep (box [string ",", space]) (p_exp' false false env) args,
+ string ")"])
+
+ fun isSelf n =
+ let
+ val (argts, ret) = getSig n
in
parenIf par (box [string "({",
newline,