Mercurial > urweb
comparison src/cjr_print.sml @ 1664:a12186d99e4f
Finish function argument order-of-operations fix
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sat, 07 Jan 2012 16:49:19 -0500 |
parents | 0577be31a435 |
children | ea292bf9431f |
comparison
equal
deleted
inserted
replaced
1663:0577be31a435 | 1664:a12186d99e4f |
---|---|
1691 end | 1691 end |
1692 | 1692 |
1693 | EFfiApp (m, x, es) => pFuncall env (m, x, es, NONE) | 1693 | EFfiApp (m, x, es) => pFuncall env (m, x, es, NONE) |
1694 | EApp (f, args) => | 1694 | EApp (f, args) => |
1695 let | 1695 let |
1696 fun default () = parenIf par (box [p_exp' true false env f, | 1696 fun getSig n = |
1697 string "(ctx,", | |
1698 space, | |
1699 p_list_sep (box [string ",", space]) (p_exp' false false env) args, | |
1700 string ")"]) | |
1701 | |
1702 fun isSelf n = | |
1703 let | 1697 let |
1704 val (_, t) = E.lookupENamed env n | 1698 val (_, t) = E.lookupENamed env n |
1705 | 1699 |
1706 fun getSig (t, args) = | 1700 fun getSig (t, args) = |
1707 case #1 t of | 1701 case #1 t of |
1708 TFun (dom, t) => getSig (t, dom :: args) | 1702 TFun (dom, t) => getSig (t, dom :: args) |
1709 | _ => (args, t) | 1703 | _ => (args, t) |
1710 | 1704 in |
1711 val (argts, ret) = getSig (t, []) | 1705 getSig (t, []) |
1706 end | |
1707 | |
1708 fun default () = | |
1709 case (#1 f, args) of | |
1710 (ENamed n, _ :: _ :: _) => | |
1711 let | |
1712 val (args', ret) = getSig n | |
1713 val args = ListPair.zip (args, args') | |
1714 in | |
1715 parenIf par (box [string "({", | |
1716 newline, | |
1717 p_list_sepi newline | |
1718 (fn i => fn (e, t) => | |
1719 box [p_typ env t, | |
1720 space, | |
1721 string ("arg" ^ Int.toString i), | |
1722 space, | |
1723 string "=", | |
1724 space, | |
1725 p_exp' false false env e, | |
1726 string ";"]) | |
1727 args, | |
1728 newline, | |
1729 p_exp' false false env f, | |
1730 string "(ctx,", | |
1731 space, | |
1732 p_list_sepi (box [string ",", space]) | |
1733 (fn i => fn _ => | |
1734 string ("arg" ^ Int.toString i)) args, | |
1735 string ");", | |
1736 newline, | |
1737 string "})"]) | |
1738 end | |
1739 | _ => | |
1740 parenIf par (box [p_exp' true false env f, | |
1741 string "(ctx,", | |
1742 space, | |
1743 p_list_sep (box [string ",", space]) (p_exp' false false env) args, | |
1744 string ")"]) | |
1745 | |
1746 fun isSelf n = | |
1747 let | |
1748 val (argts, ret) = getSig n | |
1712 in | 1749 in |
1713 parenIf par (box [string "({", | 1750 parenIf par (box [string "({", |
1714 newline, | 1751 newline, |
1715 p_list_sepi newline | 1752 p_list_sepi newline |
1716 (fn i => fn (e, t) => | 1753 (fn i => fn (e, t) => |