Commits

Matthew Hammer committed 1220b30

made number of sheets into a parameter; eager scrambled semantics is sensitive to total number of sheets

Comments (0)

Files changed (3)

Source/As2/Global.ml

   | F_repl
   | F_stats_test of stats_test_param
 
-
+let num_sheets     = ref 20
 let func           = ref F_repl
 let verbose_errors = ref false
 let print_passes   = ref true
 let stats_out      = ref "as2-stats.out"
 let stateless_eval = ref true
 
+
 let rec args = [
-  ("--help",       Arg.Unit begin fun _ -> Arg.usage args "blah" ; exit 0 end, "print this help message" ) ;
-
   ("--stateless-eval",  Arg.Set stateless_eval, " use stateless evaluation semantics" ) ;
   ("--stateful-eval",   Arg.Clear stateless_eval, " use stateful evaluation semantics" ) ;
 
+  ("--num-sheets", Arg.Int begin fun i -> num_sheets := i end, " set the total number of sheets (default: 20)" );
   ("--repl",       Arg.Unit begin fun _ -> func := F_repl end, " functionality/mode: read-eval-print-loop (REPL)") ;
-  ("--stats-test",        Arg.Int begin fun n -> func := F_stats_test (n, `No_switch) end, " functionality/mode: run a predefined script, of a given size and record statisitics") ;
-  ("--stats-test-switch", Arg.Int begin fun n -> func := F_stats_test (n, `Switch) end,    " functionality/mode: run a predefined script (that switches), of a given size and record statisitics") ;
+  ("--stats-test",        Arg.Int begin fun n -> num_sheets := n; func := F_stats_test (n, `No_switch) end, " functionality/mode: run a predefined script, of a given size and record statisitics") ;
+  ("--stats-test-switch", Arg.Int begin fun n -> num_sheets := n; func := F_stats_test (n, `Switch) end,    " functionality/mode: run a predefined script (that switches), of a given size and record statisitics") ;
   ("--stats-out", Arg.String begin fun s -> stats_out := s end, " write out stats to the given file" ) ;
 
   ("--Random.self_init", Arg.Unit begin fun _ -> Random.self_init () end, " initialize the Random module's number generator" ) ;  

Source/As2/Interp.ml

   let read cur = get_val cur
     
   let update_cell_frm cur cell frm =
-    if A.is_self_adjusting then 
-      A.update_const cell.cell_frm frm
+    if A.is_self_adjusting then (
+      A.update_const cell.cell_frm frm ;
+      A.update_thunk cell.cell_val begin fun _ ->
+        if (! Global.stateless_eval ) then
+          Undef
+        else
+          A.force (cur.db.eval (sht_of_pos cur.pos) frm)
+      end
+    )
     else
       cur.db.cells <-
         Mp.add cur.pos { 
           cell_frm=(A.const frm);
-          cell_val= 
+          cell_val=
             if ! Global.stateless_eval 
-            then A.const Undef 
+            then (A.const Undef) 
             else cur.db.eval (sht_of_pos cur.pos) frm ;
         } cur.db.cells
       

Source/As2/Main.ml

 
 let ps = print_string
 
-let db_init  = Interp.empty (100,10,10)
-let cur_init = Interp.cursor (1,(1,1)) db_init
-
 let help () =
   ps "=========================================================================\n" ;
   ps "AS2 HELP:                                                                \n" ;
     (fun filename -> invalid_arg "No input files.." )
     "usage: runas2 [options]"
   in  
+  let db_init  = Interp.empty (!Global.num_sheets,10,10) in
+  let cur_init = Interp.cursor (1,(1,1)) db_init in
   match ! Global.func with
     | Global.F_repl -> repl cur_init
     | Global.F_stats_test (n, test_flags) -> test test_flags n cur_init