diff 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
line wrap: on
line diff
--- a/src/cjr_print.sml	Tue Oct 14 18:07:09 2014 -0400
+++ b/src/cjr_print.sml	Fri Oct 31 09:25:03 2014 -0400
@@ -3394,6 +3394,7 @@
              newline,
 
              (* For sqlcache. *)
+             (* TODO: also record between Cache.check and Cache.store. *)
              box (List.map
                       (fn {index, params} =>
                           let val i = Int.toString index
@@ -3412,7 +3413,11 @@
                               val frees = paramRepeat (fn p => "free(param" ^ i ^ "_" ^ p ^ ");") "\n"
                               val eqs = paramRepeat (fn p => "strcmp(param" ^ i ^ "_" ^ p
                                                              ^ ", p" ^ p ^ ")") " || "
-                          in box [string "static char *cache",
+                          in box [string "static char *cacheQuery",
+                                  string i,
+                                  string " = NULL;",
+                                  newline,
+                                  string "static char *cacheWrite",
                                   string i,
                                   string " = NULL;",
                                   newline,
@@ -3424,12 +3429,14 @@
                                   string args,
                                   string ") {\n puts(\"SQLCACHE: checked ",
                                   string i,
-                                  string ".\");\n if (cache",
+                                  string ".\");\n if (cacheQuery",
                                   string i,
                                   (* ASK: is returning the pointer okay? Should we duplicate? *)
                                   string " == NULL || ",
                                   string eqs,
-                                  string ") {\n puts(\"miss D:\"); puts(p0);\n return NULL;\n } else {\n puts(\"hit :D\");\n return cache",
+                                  string ") {\n puts(\"miss D:\");\n uw_recordingStart(ctx);\n return NULL;\n } else {\n puts(\"hit :D\");\n uw_write(ctx, cacheWrite",
+                                  string i,
+                                  string ");\n return cacheQuery",
                                   string i,
                                   string ";\n } };",
                                   newline,
@@ -3437,27 +3444,31 @@
                                   string i,
                                   string "(uw_context ctx, uw_Basis_string s, ",
                                   string args,
-                                  string ") {\n free(cache",
+                                  string ") {\n free(cacheQuery",
+                                  string i,
+                                  string "); free(cacheWrite",
                                   string i,
                                   string ");",
                                   newline,
                                   string frees,
                                   newline,
-                                  string "cache",
+                                  string "cacheQuery",
                                   string i,
-                                  string " = strdup(s);",
+                                  string " = strdup(s); cacheWrite",
+                                  string i,
+                                  string " = uw_recordingRead(ctx);",
                                   newline,
                                   string sets,
                                   newline,
                                   string "puts(\"SQLCACHE: stored ",
                                   string i,
-                                  string ".\"); puts(p0);\n return uw_unit_v;\n };",
+                                  string ".\");\n return uw_unit_v;\n };",
                                   newline,
                                   string "static uw_unit uw_Sqlcache_flush",
                                   string i,
-                                  string "(uw_context ctx) {\n free(cache",
+                                  string "(uw_context ctx) {\n free(cacheQuery",
                                   string i,
-                                  string ");\n cache",
+                                  string ");\n cacheQuery",
                                   string i,
                                   string " = NULL;\n puts(\"SQLCACHE: flushed ",
                                   string i,