Mercurial > urweb
comparison src/cjr_print.sml @ 165:e52dfb1e6b19
Datatypes through cjrize, modulo decoding
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 29 Jul 2008 13:50:53 -0400 |
parents | f0d3402184d1 |
children | a991431b77eb |
comparison
equal
deleted
inserted
replaced
164:6847741e1f5f | 165:e52dfb1e6b19 |
---|---|
68 | TRecord i => box [string "struct", | 68 | TRecord i => box [string "struct", |
69 space, | 69 space, |
70 string "__lws_", | 70 string "__lws_", |
71 string (Int.toString i)] | 71 string (Int.toString i)] |
72 | TNamed n => | 72 | TNamed n => |
73 (string ("__lwt_" ^ #1 (E.lookupTNamed env n) ^ "_" ^ Int.toString n) | 73 (box [string "struct", |
74 space, | |
75 string ("__lwt_" ^ #1 (E.lookupTNamed env n) ^ "_" ^ Int.toString n ^ "*")] | |
74 handle CjrEnv.UnboundNamed _ => string ("__lwt_UNBOUND__" ^ Int.toString n)) | 76 handle CjrEnv.UnboundNamed _ => string ("__lwt_UNBOUND__" ^ Int.toString n)) |
75 | TFfi (m, x) => box [string "lw_", string m, string "_", string x] | 77 | TFfi (m, x) => box [string "lw_", string m, string "_", string x] |
76 | 78 |
77 and p_typ env = p_typ' false env | 79 and p_typ env = p_typ' false env |
78 | 80 |
189 space, | 191 space, |
190 string x, | 192 string x, |
191 string ";", | 193 string ";", |
192 newline]) xts, | 194 newline]) xts, |
193 string "};"] | 195 string "};"] |
196 | DDatatype (x, n, xncs) => | |
197 let | |
198 val xncsArgs = List.mapPartial (fn (x, n, NONE) => NONE | |
199 | (x, n, SOME t) => SOME (x, n, t)) xncs | |
200 in | |
201 box [string "enum", | |
202 space, | |
203 string ("__lwe_" ^ x ^ "_" ^ Int.toString n), | |
204 space, | |
205 string "{", | |
206 space, | |
207 p_list_sep (box [string ",", space]) (fn (x, n, _) => string ("__lwc_" ^ x ^ "_" ^ Int.toString n)) xncs, | |
208 space, | |
209 string "};", | |
210 newline, | |
211 newline, | |
212 string "struct", | |
213 space, | |
214 string ("_lwd_" ^ x ^ "_" ^ Int.toString n), | |
215 space, | |
216 string "{", | |
217 newline, | |
218 string "enum", | |
219 space, | |
220 string ("__lwe_" ^ x ^ "_" ^ Int.toString n), | |
221 space, | |
222 string "tag;", | |
223 newline, | |
224 box (case xncsArgs of | |
225 [] => [] | |
226 | _ => [string "union", | |
227 space, | |
228 string "{", | |
229 newline, | |
230 p_list_sep newline (fn (x, n, t) => box [p_typ env t, | |
231 space, | |
232 string ("__lwc_" ^ x), | |
233 string ";"]) xncsArgs, | |
234 newline, | |
235 string "}", | |
236 space, | |
237 string "data;", | |
238 newline]), | |
239 string "};"] | |
240 end | |
194 | 241 |
195 | DVal (x, n, t, e) => | 242 | DVal (x, n, t, e) => |
196 box [p_typ env t, | 243 box [p_typ env t, |
197 space, | 244 space, |
198 string ("__lwn_" ^ x ^ "_" ^ Int.toString n), | 245 string ("__lwn_" ^ x ^ "_" ^ Int.toString n), |