comparison src/cjr_print.sml @ 2215:639e62ca2530

Mostly finish effectfulness analysis.
author Ziv Scully <ziv@mit.edu>
date Fri, 31 Oct 2014 09:25:03 -0400
parents 365727ff68f4
children 70ec9bb337be
comparison
equal deleted inserted replaced
2214:edd634b889d0 2215:639e62ca2530
3392 string "static int uw_db_rollback(uw_context ctx) { return 0; };"], 3392 string "static int uw_db_rollback(uw_context ctx) { return 0; };"],
3393 newline, 3393 newline,
3394 newline, 3394 newline,
3395 3395
3396 (* For sqlcache. *) 3396 (* For sqlcache. *)
3397 (* TODO: also record between Cache.check and Cache.store. *)
3397 box (List.map 3398 box (List.map
3398 (fn {index, params} => 3399 (fn {index, params} =>
3399 let val i = Int.toString index 3400 let val i = Int.toString index
3400 fun paramRepeat itemi sep = 3401 fun paramRepeat itemi sep =
3401 let 3402 let
3410 val sets = paramRepeat (fn p => "param" ^ i ^ "_" ^ p 3411 val sets = paramRepeat (fn p => "param" ^ i ^ "_" ^ p
3411 ^ " = strdup(p" ^ p ^ ");") "\n" 3412 ^ " = strdup(p" ^ p ^ ");") "\n"
3412 val frees = paramRepeat (fn p => "free(param" ^ i ^ "_" ^ p ^ ");") "\n" 3413 val frees = paramRepeat (fn p => "free(param" ^ i ^ "_" ^ p ^ ");") "\n"
3413 val eqs = paramRepeat (fn p => "strcmp(param" ^ i ^ "_" ^ p 3414 val eqs = paramRepeat (fn p => "strcmp(param" ^ i ^ "_" ^ p
3414 ^ ", p" ^ p ^ ")") " || " 3415 ^ ", p" ^ p ^ ")") " || "
3415 in box [string "static char *cache", 3416 in box [string "static char *cacheQuery",
3417 string i,
3418 string " = NULL;",
3419 newline,
3420 string "static char *cacheWrite",
3416 string i, 3421 string i,
3417 string " = NULL;", 3422 string " = NULL;",
3418 newline, 3423 newline,
3419 string decls, 3424 string decls,
3420 newline, 3425 newline,
3422 string i, 3427 string i,
3423 string "(uw_context ctx, ", 3428 string "(uw_context ctx, ",
3424 string args, 3429 string args,
3425 string ") {\n puts(\"SQLCACHE: checked ", 3430 string ") {\n puts(\"SQLCACHE: checked ",
3426 string i, 3431 string i,
3427 string ".\");\n if (cache", 3432 string ".\");\n if (cacheQuery",
3428 string i, 3433 string i,
3429 (* ASK: is returning the pointer okay? Should we duplicate? *) 3434 (* ASK: is returning the pointer okay? Should we duplicate? *)
3430 string " == NULL || ", 3435 string " == NULL || ",
3431 string eqs, 3436 string eqs,
3432 string ") {\n puts(\"miss D:\"); puts(p0);\n return NULL;\n } else {\n puts(\"hit :D\");\n return cache", 3437 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,
3439 string ");\n return cacheQuery",
3433 string i, 3440 string i,
3434 string ";\n } };", 3441 string ";\n } };",
3435 newline, 3442 newline,
3436 string "static uw_unit uw_Sqlcache_store", 3443 string "static uw_unit uw_Sqlcache_store",
3437 string i, 3444 string i,
3438 string "(uw_context ctx, uw_Basis_string s, ", 3445 string "(uw_context ctx, uw_Basis_string s, ",
3439 string args, 3446 string args,
3440 string ") {\n free(cache", 3447 string ") {\n free(cacheQuery",
3448 string i,
3449 string "); free(cacheWrite",
3441 string i, 3450 string i,
3442 string ");", 3451 string ");",
3443 newline, 3452 newline,
3444 string frees, 3453 string frees,
3445 newline, 3454 newline,
3446 string "cache", 3455 string "cacheQuery",
3447 string i, 3456 string i,
3448 string " = strdup(s);", 3457 string " = strdup(s); cacheWrite",
3458 string i,
3459 string " = uw_recordingRead(ctx);",
3449 newline, 3460 newline,
3450 string sets, 3461 string sets,
3451 newline, 3462 newline,
3452 string "puts(\"SQLCACHE: stored ", 3463 string "puts(\"SQLCACHE: stored ",
3453 string i, 3464 string i,
3454 string ".\"); puts(p0);\n return uw_unit_v;\n };", 3465 string ".\");\n return uw_unit_v;\n };",
3455 newline, 3466 newline,
3456 string "static uw_unit uw_Sqlcache_flush", 3467 string "static uw_unit uw_Sqlcache_flush",
3457 string i, 3468 string i,
3458 string "(uw_context ctx) {\n free(cache", 3469 string "(uw_context ctx) {\n free(cacheQuery",
3459 string i, 3470 string i,
3460 string ");\n cache", 3471 string ");\n cacheQuery",
3461 string i, 3472 string i,
3462 string " = NULL;\n puts(\"SQLCACHE: flushed ", 3473 string " = NULL;\n puts(\"SQLCACHE: flushed ",
3463 string i, 3474 string i,
3464 string ".\");\n return uw_unit_v;\n };", 3475 string ".\");\n return uw_unit_v;\n };",
3465 newline, 3476 newline,