comparison src/monoize.sml @ 684:f0224c7f12bb

Expunging nullable fields
author Adam Chlipala <adamc@hcoop.net>
date Sun, 29 Mar 2009 14:13:50 -0400
parents 9a2c18dab11d
children a3ddf05fb3e3
comparison
equal deleted inserted replaced
683:9a2c18dab11d 684:f0224c7f12bb
2498 (L.CApp ((L.CFfi ("Basis", "channel"), _), _), _)) => 2498 (L.CApp ((L.CFfi ("Basis", "channel"), _), _), _)) =>
2499 ((x, Channel) :: nullable, notNullable) 2499 ((x, Channel) :: nullable, notNullable)
2500 | _ => st) 2500 | _ => st)
2501 | _ => st) ([], []) xts 2501 | _ => st) ([], []) xts
2502 2502
2503 fun cond (x, v) =
2504 (L'.EStrcat ((L'.EPrim (Prim.String ("uw_" ^ x
2505 ^ (case v of
2506 Client => ""
2507 | Channel => " >> 32")
2508 ^ " = ")), loc),
2509 target), loc)
2510
2511 val e =
2512 foldl (fn ((x, v), e) =>
2513 (L'.ESeq (
2514 (L'.EDml (L'.EStrcat (
2515 (L'.EPrim (Prim.String ("UPDATE uw_"
2516 ^ tab
2517 ^ " SET uw_"
2518 ^ x
2519 ^ " = NULL WHERE ")), loc),
2520 cond (x, v)), loc), loc),
2521 e), loc))
2522 e nullable
2523
2503 val e = 2524 val e =
2504 case notNullable of 2525 case notNullable of
2505 [] => e 2526 [] => e
2506 | eb :: ebs => 2527 | eb :: ebs =>
2507 let 2528 (L'.ESeq (
2508 fun cond (x, v) = 2529 (L'.EDml (foldl
2509 (L'.EStrcat ((L'.EPrim (Prim.String ("uw_" ^ x 2530 (fn (eb, s) =>
2510 ^ (case v of 2531 (L'.EStrcat (s,
2511 Client => "" 2532 (L'.EStrcat ((L'.EPrim (Prim.String " AND "),
2512 | Channel => " >> 32") 2533 loc),
2513 ^ " = ")), loc), 2534 cond eb), loc)), loc))
2514 target), loc) 2535 (L'.EStrcat ((L'.EPrim (Prim.String ("DELETE FROM uw_"
2515 in 2536 ^ tab
2516 (L'.ESeq ( 2537 ^ " WHERE ")), loc),
2517 (L'.EDml (foldl 2538 cond eb), loc)
2518 (fn (eb, s) => 2539 ebs), loc),
2519 (L'.EStrcat (s, 2540 e), loc)
2520 (L'.EStrcat ((L'.EPrim (Prim.String " AND "),
2521 loc),
2522 cond eb), loc)), loc))
2523 (L'.EStrcat ((L'.EPrim (Prim.String ("DELETE FROM uw_"
2524 ^ tab
2525 ^ " WHERE ")), loc),
2526 cond eb), loc)
2527 ebs), loc),
2528 e), loc)
2529 end
2530 in 2541 in
2531 e 2542 e
2532 end 2543 end
2533 | _ => e 2544 | _ => e
2534 2545