comparison src/mono_opt.sml @ 486:8e055bbbd28b

Remove some allocation
author Adam Chlipala <adamc@hcoop.net>
date Sun, 09 Nov 2008 18:19:47 -0500
parents 3f1b9231a37b
children 98f85c1bc867
comparison
equal deleted inserted replaced
485:3ce20b0b6914 486:8e055bbbd28b
318 else 318 else
319 e 319 e
320 320
321 | EWrite (EQuery {exps, tables, state, query, 321 | EWrite (EQuery {exps, tables, state, query,
322 initial = (EPrim (Prim.String ""), _), 322 initial = (EPrim (Prim.String ""), _),
323 body}, loc) =>
324 let
325 fun passLets (depth, (e', _), lets) =
326 case e' of
327 EStrcat ((ERel x, _), e'') =>
328 if x = depth then
329 let
330 val body = (optExp (EWrite e'', loc), loc)
331 val body = foldl (fn ((x, t, e'), e) =>
332 (ELet (x, t, e', e), loc))
333 body lets
334 in
335 EQuery {exps = exps, tables = tables, query = query,
336 state = (TRecord [], loc),
337 initial = (ERecord [], loc),
338 body = body}
339 end
340 else
341 e
342 | ELet (x, t, e', e'') =>
343 passLets (depth + 1, e'', (x, t, e') :: lets)
344 | _ => e
345 in
346 passLets (0, body, [])
347 end
348
349 (*| EWrite (EQuery {exps, tables, state, query,
350 initial = (EPrim (Prim.String ""), _),
323 body = (EStrcat ((ERel 0, _), e'), _)}, loc) => 351 body = (EStrcat ((ERel 0, _), e'), _)}, loc) =>
324 EQuery {exps = exps, tables = tables, query = query, 352 EQuery {exps = exps, tables = tables, query = query,
325 state = (TRecord [], loc), 353 state = (TRecord [], loc),
326 initial = (ERecord [], loc), 354 initial = (ERecord [], loc),
327 body = (optExp (EWrite e', loc), loc)} 355 body = (optExp (EWrite e', loc), loc)}*)
328 356
329 | EWrite (ELet (x, t, e1, e2), loc) => 357 | EWrite (ELet (x, t, e1, e2), loc) =>
330 optExp (ELet (x, t, e1, (EWrite e2, loc)), loc) 358 optExp (ELet (x, t, e1, (EWrite e2, loc)), loc)
331 359
332 | EWrite (EPrim (Prim.String ""), loc) => 360 | EWrite (EPrim (Prim.String ""), loc) =>