comparison src/cjrize.sml @ 186:88d46972de53

bool in Basis
author Adam Chlipala <adamc@hcoop.net>
date Sun, 03 Aug 2008 18:53:20 -0400
parents 19ee24bffbc0
children 8e9f97508f0d
comparison
equal deleted inserted replaced
185:19ee24bffbc0 186:88d46972de53
101 end 101 end
102 | L.TFfi mx => ((L'.TFfi mx, loc), sm) 102 | L.TFfi mx => ((L'.TFfi mx, loc), sm)
103 103
104 val dummye = (L'.EPrim (Prim.Int 0), ErrorMsg.dummySpan) 104 val dummye = (L'.EPrim (Prim.Int 0), ErrorMsg.dummySpan)
105 105
106 fun cifyPatCon pc = 106 fun cifyPatCon (pc, sm) =
107 case pc of 107 case pc of
108 L.PConVar n => L'.PConVar n 108 L.PConVar n => (L'.PConVar n, sm)
109 | L.PConFfi mx => L'.PConFfi mx 109 | L.PConFfi {mod = m, datatyp, con, arg} =>
110 let
111 val (arg, sm) =
112 case arg of
113 NONE => (NONE, sm)
114 | SOME t =>
115 let
116 val (t, sm) = cifyTyp (t, sm)
117 in
118 (SOME t, sm)
119 end
120 in
121 (L'.PConFfi {mod = m, datatyp = datatyp, con = con, arg = arg}, sm)
122 end
110 123
111 fun cifyPat ((p, loc), sm) = 124 fun cifyPat ((p, loc), sm) =
112 case p of 125 case p of
113 L.PWild => ((L'.PWild, loc), sm) 126 L.PWild => ((L'.PWild, loc), sm)
114 | L.PVar (x, t) => 127 | L.PVar (x, t) =>
116 val (t, sm) = cifyTyp (t, sm) 129 val (t, sm) = cifyTyp (t, sm)
117 in 130 in
118 ((L'.PVar (x, t), loc), sm) 131 ((L'.PVar (x, t), loc), sm)
119 end 132 end
120 | L.PPrim p => ((L'.PPrim p, loc), sm) 133 | L.PPrim p => ((L'.PPrim p, loc), sm)
121 | L.PCon (pc, NONE) => ((L'.PCon (cifyPatCon pc, NONE), loc), sm) 134 | L.PCon (pc, NONE) =>
135 let
136 val (pc, sm) = cifyPatCon (pc, sm)
137 in
138 ((L'.PCon (pc, NONE), loc), sm)
139 end
122 | L.PCon (pc, SOME p) => 140 | L.PCon (pc, SOME p) =>
123 let 141 let
142 val (pc, sm) = cifyPatCon (pc, sm)
124 val (p, sm) = cifyPat (p, sm) 143 val (p, sm) = cifyPat (p, sm)
125 in 144 in
126 ((L'.PCon (cifyPatCon pc, SOME p), loc), sm) 145 ((L'.PCon (pc, SOME p), loc), sm)
127 end 146 end
128 | L.PRecord xps => 147 | L.PRecord xps =>
129 let 148 let
130 val (xps, sm) = ListUtil.foldlMap (fn ((x, p, t), sm) => 149 val (xps, sm) = ListUtil.foldlMap (fn ((x, p, t), sm) =>
131 let 150 let
152 let 171 let
153 val (e, sm) = cifyExp (e, sm) 172 val (e, sm) = cifyExp (e, sm)
154 in 173 in
155 (SOME e, sm) 174 (SOME e, sm)
156 end 175 end
157 in 176 val (pc, sm) = cifyPatCon (pc, sm)
158 ((L'.ECon (cifyPatCon pc, eo), loc), sm) 177 in
178 ((L'.ECon (pc, eo), loc), sm)
159 end 179 end
160 | L.EFfi mx => ((L'.EFfi mx, loc), sm) 180 | L.EFfi mx => ((L'.EFfi mx, loc), sm)
161 | L.EFfiApp (m, x, es) => 181 | L.EFfiApp (m, x, es) =>
162 let 182 let
163 val (es, sm) = ListUtil.foldlMap cifyExp sm es 183 val (es, sm) = ListUtil.foldlMap cifyExp sm es