Mercurial > urweb
comparison src/shake.sml @ 248:d5b12daa9b47
Fix shaking of tables
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 31 Aug 2008 09:05:33 -0400 |
parents | 5c50b17f5e4a |
children | 42dfb0d61cf0 |
comparison
equal
deleted
inserted
replaced
247:5c50b17f5e4a | 248:d5b12daa9b47 |
---|---|
43 | 43 |
44 val dummye = (EPrim (Prim.String ""), ErrorMsg.dummySpan) | 44 val dummye = (EPrim (Prim.String ""), ErrorMsg.dummySpan) |
45 | 45 |
46 fun shake file = | 46 fun shake file = |
47 let | 47 let |
48 val page_es = List.foldl | 48 val (page_es, table_cs) = |
49 (fn ((DExport (_, n), _), page_es) => n :: page_es | 49 List.foldl |
50 | (_, page_es) => page_es) [] file | 50 (fn ((DExport (_, n), _), (page_es, table_cs)) => (n :: page_es, table_cs) |
51 | ((DTable (_, _, c, _), _), (page_es, table_cs)) => (page_es, c :: table_cs) | |
52 | (_, acc) => acc) ([], []) file | |
51 | 53 |
52 val (cdef, edef) = foldl (fn ((DCon (_, n, _, c), _), (cdef, edef)) => (IM.insert (cdef, n, [c]), edef) | 54 val (cdef, edef) = foldl (fn ((DCon (_, n, _, c), _), (cdef, edef)) => (IM.insert (cdef, n, [c]), edef) |
53 | ((DDatatype (_, n, _, xncs), _), (cdef, edef)) => | 55 | ((DDatatype (_, n, _, xncs), _), (cdef, edef)) => |
54 (IM.insert (cdef, n, List.mapPartial #3 xncs), edef) | 56 (IM.insert (cdef, n, List.mapPartial #3 xncs), edef) |
55 | ((DVal (_, n, t, e, _), _), (cdef, edef)) => (cdef, IM.insert (edef, n, (t, e))) | 57 | ((DVal (_, n, t, e, _), _), (cdef, edef)) => (cdef, IM.insert (edef, n, (t, e))) |
102 | 104 |
103 val s = foldl (fn (n, s) => | 105 val s = foldl (fn (n, s) => |
104 case IM.find (edef, n) of | 106 case IM.find (edef, n) of |
105 NONE => raise Fail "Shake: Couldn't find 'val'" | 107 NONE => raise Fail "Shake: Couldn't find 'val'" |
106 | SOME (t, e) => shakeExp (shakeCon s t) e) s page_es | 108 | SOME (t, e) => shakeExp (shakeCon s t) e) s page_es |
109 | |
110 val s = foldl (fn (c, s) => shakeCon s c) s table_cs | |
107 in | 111 in |
108 List.filter (fn (DCon (_, n, _, _), _) => IS.member (#con s, n) | 112 List.filter (fn (DCon (_, n, _, _), _) => IS.member (#con s, n) |
109 | (DDatatype (_, n, _, _), _) => IS.member (#con s, n) | 113 | (DDatatype (_, n, _, _), _) => IS.member (#con s, n) |
110 | (DVal (_, n, _, _, _), _) => IS.member (#exp s, n) | 114 | (DVal (_, n, _, _, _), _) => IS.member (#exp s, n) |
111 | (DValRec vis, _) => List.exists (fn (_, n, _, _, _) => IS.member (#exp s, n)) vis | 115 | (DValRec vis, _) => List.exists (fn (_, n, _, _, _) => IS.member (#exp s, n)) vis |