diff src/sqlcache.sml @ 2233:af1585e7d645

More work factoring out Sqlcache back end.
author Ziv Scully <ziv@mit.edu>
date Wed, 06 May 2015 23:11:30 -0400
parents a749acc51ae4
children 2f7ed04332a0
line wrap: on
line diff
--- a/src/sqlcache.sml	Wed May 06 14:51:09 2015 -0400
+++ b/src/sqlcache.sml	Wed May 06 23:11:30 2015 -0400
@@ -1,4 +1,4 @@
-structure Sqlcache (* :> SQLCACHE *) = struct
+structure Sqlcache :> SQLCACHE = struct
 
 open Mono
 
@@ -39,6 +39,10 @@
                      andalso not (m = "Basis" andalso SS.member (fs, f))
     end
 
+val cache = ref ToyCache.cache
+fun setCache c = cache := c
+fun getCache () = !cache
+
 
 (* Effect analysis. *)
 
@@ -366,6 +370,8 @@
 
 (* Program instrumentation. *)
 
+val {check, store, flush, ...} = getCache ()
+
 val dummyLoc = ErrorMsg.dummySpan
 
 fun stringExp s = (EPrim (Prim.String (Prim.Normal, s)), dummyLoc)
@@ -400,8 +406,8 @@
         (* We ensure before this step that all arguments aren't effectful.
            by turning them into local variables as needed. *)
         val argsInc = map (incRels 1) args
-        val check = (ToyCache.check (i, args), dummyLoc)
-        val store = (ToyCache.store (i, argsInc, urlifiedRel0), dummyLoc)
+        val check = (check (i, args), dummyLoc)
+        val store = (store (i, argsInc, urlifiedRel0), dummyLoc)
         val rel0 = (ERel 0, loc)
     in
         ECase (check,
@@ -545,7 +551,7 @@
 fun addFlushing (file, (tableToIndices, indexToQueryNumArgs, _)) =
     let
         val flushes = List.concat o
-                      map (fn (i, argss) => map (fn args => ToyCache.flush (i, args)) argss)
+                      map (fn (i, argss) => map (fn args => flush (i, args)) argss)
         val doExp =
          fn EDml (origDmlText, failureMode) =>
             let