Commit 4d6f889f authored by erwan's avatar erwan
Browse files

rdbg: save/restore the sasa state between each step to allow backward moves.

parent 35aa3bc2
(* Time-stamp: <modified the 03/04/2019 (at 23:02) by Erwan Jahier> *) (* Time-stamp: <modified the 07/05/2019 (at 17:50) by Erwan Jahier> *)
(** Process programmer API *) (** Process programmer API *)
type varT = It | Ft | Bt | Et of int | St | Nt | At of varT * int type varT = It | Ft | Bt | Et of int | St | Nt | At of varT * int
...@@ -18,20 +18,20 @@ type neighbor = { ...@@ -18,20 +18,20 @@ type neighbor = {
type enable_fun = neighbor list -> local_env -> action list type enable_fun = neighbor list -> local_env -> action list
type step_fun = neighbor list -> local_env -> action -> local_env type step_fun = neighbor list -> local_env -> action -> local_env
type int_tables = { type internal_tables = {
vars: (string, vars) Hashtbl.t; vars : (string, vars) Hashtbl.t;
init_vars: (string, neighbor list -> local_env) Hashtbl.t; init_vars: (string, neighbor list -> local_env) Hashtbl.t;
enable: (string, enable_fun) Hashtbl.t; enable : (string, enable_fun) Hashtbl.t;
step: (string, step_fun) Hashtbl.t; step : (string, step_fun) Hashtbl.t;
actions: (string, action list) Hashtbl.t; actions : (string, action list) Hashtbl.t;
} }
let tbls = { let tbls = {
vars = Hashtbl.create 1; vars = Hashtbl.create 1;
init_vars = Hashtbl.create 1; init_vars = Hashtbl.create 1;
enable = Hashtbl.create 1; enable = Hashtbl.create 1;
step = Hashtbl.create 1; step = Hashtbl.create 1;
actions = Hashtbl.create 1; actions = Hashtbl.create 1;
} }
let verbose_level = ref 0 let verbose_level = ref 0
...@@ -118,11 +118,14 @@ let rec (init_var: neighbor list -> varT -> value) = ...@@ -118,11 +118,14 @@ let rec (init_var: neighbor list -> varT -> value) =
| At(t,i) -> A(Array.make i (init_var nl t)) | At(t,i) -> A(Array.make i (init_var nl t))
let (reg_init_vars : algo_id -> (neighbor list -> local_env) -> unit) = fun algo_id x -> let (reg_init_vars : algo_id -> (neighbor list -> local_env) -> unit) =
if !verbose_level > 0 then Printf.printf "Registering %s init_vars\n" algo_id; fun algo_id x ->
flush stdout; if !verbose_level > 0 then Printf.printf "Registering %s init_vars\n" algo_id;
Hashtbl.replace tbls.init_vars algo_id x flush stdout;
let (get_init_vars : algo_id -> (string * varT) list -> (neighbor list -> local_env)) = Hashtbl.replace tbls.init_vars algo_id x
let (get_init_vars : algo_id -> (string * varT) list ->
(neighbor list -> local_env)) =
fun algo_id vars -> fun algo_id vars ->
let default_env = let default_env =
(fun nl v -> (fun nl v ->
...@@ -137,7 +140,8 @@ let (get_init_vars : algo_id -> (string * varT) list -> (neighbor list -> local_ ...@@ -137,7 +140,8 @@ let (get_init_vars : algo_id -> (string * varT) list -> (neighbor list -> local_
try user_env nl v try user_env nl v
with e -> with e ->
if !verbose_level > 1 then if !verbose_level > 1 then
Printf.eprintf "No init value for '%s' in user init function (%s).\n" v Printf.eprintf
"No init value for '%s' in user init function (%s).\n" v
(Printexc.to_string e); (Printexc.to_string e);
default_env nl v) default_env nl v)
with Not_found -> with Not_found ->
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment