comparison src/mono_shake.sml @ 808:d8f58d488cfb

Mutual datatypes through Pathcheck
author Adam Chlipala <adamc@hcoop.net>
date Sat, 16 May 2009 15:55:15 -0400
parents 8688e01ae469
children b2311dfb3158
comparison
equal deleted inserted replaced
807:61a1f5c5ae2c 808:d8f58d488cfb
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 | ((DDatabase {expunge = n1, initialize = n2, ...}, _), page_es) => n1 :: n2 :: page_es 48 | ((DDatabase {expunge = n1, initialize = n2, ...}, _), page_es) => n1 :: n2 :: page_es
49 | (_, page_es) => page_es) [] file 49 | (_, page_es) => page_es) [] file
50 50
51 val (cdef, edef) = foldl (fn ((DDatatype (_, n, xncs), _), (cdef, edef)) => 51 val (cdef, edef) = foldl (fn ((DDatatype dts, _), (cdef, edef)) =>
52 (IM.insert (cdef, n, xncs), edef) 52 (foldl (fn ((_, n, xncs), cdef) => IM.insert (cdef, n, xncs)) cdef dts, edef)
53 | ((DVal (_, n, t, e, _), _), (cdef, edef)) => 53 | ((DVal (_, n, t, e, _), _), (cdef, edef)) =>
54 (cdef, IM.insert (edef, n, (t, e))) 54 (cdef, IM.insert (edef, n, (t, e)))
55 | ((DValRec vis, _), (cdef, edef)) => 55 | ((DValRec vis, _), (cdef, edef)) =>
56 (cdef, foldl (fn ((_, n, t, e, _), edef) => IM.insert (edef, n, (t, e))) edef vis) 56 (cdef, foldl (fn ((_, n, t, e, _), edef) => IM.insert (edef, n, (t, e))) edef vis)
57 | ((DExport _, _), acc) => acc 57 | ((DExport _, _), acc) => acc
109 val s = foldl (fn (n, s) => 109 val s = foldl (fn (n, s) =>
110 case IM.find (edef, n) of 110 case IM.find (edef, n) of
111 NONE => raise Fail "Shake: Couldn't find 'val'" 111 NONE => raise Fail "Shake: Couldn't find 'val'"
112 | SOME (t, e) => shakeExp s e) s page_es 112 | SOME (t, e) => shakeExp s e) s page_es
113 in 113 in
114 List.filter (fn (DDatatype (_, n, _), _) => IS.member (#con s, n) 114 List.filter (fn (DDatatype dts, _) => List.exists (fn (_, n, _) => IS.member (#con s, n)) dts
115 | (DVal (_, n, _, _, _), _) => IS.member (#exp s, n) 115 | (DVal (_, n, _, _, _), _) => IS.member (#exp s, n)
116 | (DValRec vis, _) => List.exists (fn (_, n, _, _, _) => IS.member (#exp s, n)) vis 116 | (DValRec vis, _) => List.exists (fn (_, n, _, _, _) => IS.member (#exp s, n)) vis
117 | (DExport _, _) => true 117 | (DExport _, _) => true
118 | (DTable _, _) => true 118 | (DTable _, _) => true
119 | (DSequence _, _) => true 119 | (DSequence _, _) => true