comparison src/cjr_print.sml @ 2216:70ec9bb337be

Progress towards invalidation based on equalities of fields.
author Ziv Scully <ziv@mit.edu>
date Mon, 10 Nov 2014 22:04:40 -0500
parents 639e62ca2530
children 278e10629ba1
comparison
equal deleted inserted replaced
2215:639e62ca2530 2216:70ec9bb337be
3398 box (List.map 3398 box (List.map
3399 (fn {index, params} => 3399 (fn {index, params} =>
3400 let val i = Int.toString index 3400 let val i = Int.toString index
3401 fun paramRepeat itemi sep = 3401 fun paramRepeat itemi sep =
3402 let 3402 let
3403 val rec f = 3403 fun f n =
3404 fn 0 => itemi (Int.toString 0) 3404 if n < 0 then ""
3405 | n => f (n-1) ^ itemi (Int.toString n) 3405 else if n = 0 then itemi (Int.toString 0)
3406 else f (n-1) ^ sep ^ itemi (Int.toString n)
3406 in 3407 in
3407 f (params - 1) 3408 f (params - 1)
3408 end 3409 end
3409 val args = paramRepeat (fn p => "uw_Basis_string p" ^ p) ", " 3410 fun paramRepeatInit itemi sep =
3411 if params = 0 then "" else sep ^ paramRepeat itemi sep
3412 val args = paramRepeatInit (fn p => "uw_Basis_string p" ^ p) ", "
3410 val decls = paramRepeat (fn p => "uw_Basis_string param" ^ i ^ "_" ^ p ^ " = NULL;") "\n" 3413 val decls = paramRepeat (fn p => "uw_Basis_string param" ^ i ^ "_" ^ p ^ " = NULL;") "\n"
3411 val sets = paramRepeat (fn p => "param" ^ i ^ "_" ^ p 3414 val sets = paramRepeat (fn p => "param" ^ i ^ "_" ^ p
3412 ^ " = strdup(p" ^ p ^ ");") "\n" 3415 ^ " = strdup(p" ^ p ^ ");") "\n"
3413 val frees = paramRepeat (fn p => "free(param" ^ i ^ "_" ^ p ^ ");") "\n" 3416 val frees = paramRepeat (fn p => "free(param" ^ i ^ "_" ^ p ^ ");") "\n"
3414 val eqs = paramRepeat (fn p => "strcmp(param" ^ i ^ "_" ^ p 3417 (* Starting || makes logic easier when there are no parameters. *)
3415 ^ ", p" ^ p ^ ")") " || " 3418 val eqs = paramRepeatInit (fn p => "strcmp(param" ^ i ^ "_" ^ p
3419 ^ ", p" ^ p ^ ")")
3420 " || "
3416 in box [string "static char *cacheQuery", 3421 in box [string "static char *cacheQuery",
3417 string i, 3422 string i,
3418 string " = NULL;", 3423 string " = NULL;",
3419 newline, 3424 newline,
3420 string "static char *cacheWrite", 3425 string "static char *cacheWrite",
3423 newline, 3428 newline,
3424 string decls, 3429 string decls,
3425 newline, 3430 newline,
3426 string "static uw_Basis_string uw_Sqlcache_check", 3431 string "static uw_Basis_string uw_Sqlcache_check",
3427 string i, 3432 string i,
3428 string "(uw_context ctx, ", 3433 string "(uw_context ctx",
3429 string args, 3434 string args,
3430 string ") {\n puts(\"SQLCACHE: checked ", 3435 string ") {\n puts(\"SQLCACHE: checked ",
3431 string i, 3436 string i,
3432 string ".\");\n if (cacheQuery", 3437 string ".\");\n if (cacheQuery",
3433 string i, 3438 string i,
3434 (* ASK: is returning the pointer okay? Should we duplicate? *) 3439 (* ASK: is returning the pointer okay? Should we duplicate? *)
3435 string " == NULL || ", 3440 string " == NULL",
3436 string eqs, 3441 string eqs,
3437 string ") {\n puts(\"miss D:\");\n uw_recordingStart(ctx);\n return NULL;\n } else {\n puts(\"hit :D\");\n uw_write(ctx, cacheWrite", 3442 string ") {\n puts(\"miss D:\");\n uw_recordingStart(ctx);\n return NULL;\n } else {\n puts(\"hit :D\");\n uw_write(ctx, cacheWrite",
3438 string i, 3443 string i,
3439 string ");\n return cacheQuery", 3444 string ");\n return cacheQuery",
3440 string i, 3445 string i,
3441 string ";\n } };", 3446 string ";\n } };",
3442 newline, 3447 newline,
3443 string "static uw_unit uw_Sqlcache_store", 3448 string "static uw_unit uw_Sqlcache_store",
3444 string i, 3449 string i,
3445 string "(uw_context ctx, uw_Basis_string s, ", 3450 string "(uw_context ctx, uw_Basis_string s",
3446 string args, 3451 string args,
3447 string ") {\n free(cacheQuery", 3452 string ") {\n free(cacheQuery",
3448 string i, 3453 string i,
3449 string "); free(cacheWrite", 3454 string "); free(cacheWrite",
3450 string i, 3455 string i,