Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/compiler/FLINT/opt/optutils.sml
ViewVC logotype

Annotation of /sml/trunk/src/compiler/FLINT/opt/optutils.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 163 - (view) (download)

1 : monnier 163 (* copyright 1998 YALE FLINT PROJECT *)
2 :     (* monnier@cs.yale.edu *)
3 :    
4 :     signature OPT_UTILS =
5 :     sig
6 :    
7 :     (* takes the fk of a function and returns the fk of the wrapper
8 :     * along with the new fk of the actual body *)
9 :     val fk_wrap : FLINT.fkind * FLINT.lty list option ->
10 :     (FLINT.fkind * FLINT.fkind)
11 :    
12 :     (* sometimes I get fed up rewriting the identity function *)
13 :     val id : 'a -> 'a
14 :    
15 :     (* this is a known APL function, but I don't know its real name *)
16 :     val filter : bool list * 'a list -> 'a list
17 :     end
18 :    
19 :     structure OptUtils :> OPT_UTILS =
20 :     struct
21 :     local structure F = FLINT
22 :     structure LK = LtyKernel
23 :     in
24 :     fun bug msg = ErrorMsg.impossible ("OptUtils: "^msg)
25 :    
26 :     fun fk_wrap (F.FK_FCT,_) = (F.FK_FCT, F.FK_FCT)
27 :     | fk_wrap (F.FK_FUN{isrec,known,fixed,inline},rtys') =
28 :     let val fixed' = case fixed
29 :     of LK.FF_VAR(f1,f2) => LK.FF_VAR(true, f2)
30 :     | LK.FF_FIXED => LK.FF_FIXED
31 :     in (F.FK_FUN{isrec=isrec, known=known, fixed=fixed, inline=true},
32 :     F.FK_FUN{isrec=rtys', known=true, fixed=fixed', inline=inline})
33 :     end
34 :    
35 :     fun filter ([],[]) = []
36 :     | filter (true::fs,x::xs) = x::(filter(fs, xs))
37 :     | filter (false::fs,x::xs) = (filter(fs, xs))
38 :     | filter _ = bug "unmatched list length in filter"
39 :    
40 :     fun id x = x
41 :    
42 :     end
43 :     end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0