comparison src/mono_shake.sml @ 178:eb3f9913bf31

First part of getting cases through monoize
author Adam Chlipala <adamc@hcoop.net>
date Sun, 03 Aug 2008 09:26:49 -0400
parents 25b169416ea8
children 8e9f97508f0d
comparison
equal deleted inserted replaced
177:5d030ee143e2 178:eb3f9913bf31
45 let 45 let
46 val page_es = List.foldl 46 val page_es = List.foldl
47 (fn ((DExport (_, _, n, _), _), page_es) => n :: page_es 47 (fn ((DExport (_, _, n, _), _), page_es) => n :: page_es
48 | (_, page_es) => page_es) [] file 48 | (_, page_es) => page_es) [] file
49 49
50 val (cdef, edef) = foldl (fn ((DDatatype _, _), acc) => acc 50 val (cdef, edef) = foldl (fn ((DDatatype (_, n, xncs), _), (cdef, edef)) =>
51 | ((DVal (_, n, t, e, _), _), (cdef, edef)) => (cdef, IM.insert (edef, n, (t, e))) 51 (IM.insert (cdef, n, xncs), edef)
52 | ((DVal (_, n, t, e, _), _), (cdef, edef)) =>
53 (cdef, IM.insert (edef, n, (t, e)))
52 | ((DValRec vis, _), (cdef, edef)) => 54 | ((DValRec vis, _), (cdef, edef)) =>
53 (cdef, foldl (fn ((_, n, t, e, _), edef) => IM.insert (edef, n, (t, e))) edef vis) 55 (cdef, foldl (fn ((_, n, t, e, _), edef) => IM.insert (edef, n, (t, e))) edef vis)
54 | ((DExport _, _), acc) => acc) 56 | ((DExport _, _), acc) => acc)
55 (IM.empty, IM.empty) file 57 (IM.empty, IM.empty) file
56 58
58 case c of 60 case c of
59 TDatatype (n, _) => 61 TDatatype (n, _) =>
60 if IS.member (#con s, n) then 62 if IS.member (#con s, n) then
61 s 63 s
62 else 64 else
63 {exp = #exp s, 65 let
64 con = IS.add (#con s, n)} 66 val s' = {exp = #exp s,
67 con = IS.add (#con s, n)}
68 in
69 case IM.find (cdef, n) of
70 NONE => s'
71 | SOME xncs => foldl (fn ((_, _, to), s) =>
72 case to of
73 NONE => s
74 | SOME t => shakeTyp s t)
75 s' xncs
76 end
65 | _ => s 77 | _ => s
78
79 and shakeTyp s = U.Typ.fold typ s
66 80
67 fun exp (e, s) = 81 fun exp (e, s) =
68 case e of 82 case e of
69 ENamed n => 83 ENamed n =>
70 if IS.member (#exp s, n) then 84 if IS.member (#exp s, n) then