@@ -20,8 +20,8 @@ module Pass = Pass.Make(struct
2020 let rec compute_tree closed (l ,pi :loc * _ proc_init ) : HirU.statement M.t =
2121 let closed = FieldSet. add pi.proc closed in (* no cycle *)
2222
23- let * p = find_process_source (mk_locatable l pi.proc) pi.mloc procs (* fixme : grammar to allow :: syntax *) in
24- let * p = M. throw_if_none Logging. (make_msg l @@ Fmt. str " process '%s' is unknown" pi.proc) p in
23+ let * p = find_process_source (mk_locatable l pi.proc) pi.mloc procs (* fixme : grammar to allow :: syntax *)
24+ >> = M. throw_if_none Logging. (make_msg l @@ Fmt. str " process '%s' is unknown" pi.proc) in
2525 let * tag = M. fresh_prefix p.p_name in
2626 let prefix = (Fmt. str " %s_%s_" tag) in
2727 let read_params,write_params = p.p_interface.p_shared_vars in
@@ -34,9 +34,11 @@ module Pass = Pass.Make(struct
3434 let * () = param_arg_mismatch " init" p.p_interface.p_params pi.params in
3535
3636
37+ (* correspondence between shared variables names (given, original) *)
3738 let rename_l = List. map2 (fun subx x -> (fst x.value,subx.value) )
3839 (pi.read @ pi.write)
3940 (fst p.p_interface.p_shared_vars @ snd p.p_interface.p_shared_vars) in
41+ (* if the id corresponds to a shared variable, replace it by the name of the provided variable *)
4042 let rename = fun id -> match List. assoc_opt id rename_l with Some v -> v | None -> id in
4143
4244 (* add process local (but persistant) vars *)
@@ -68,10 +70,9 @@ module Pass = Pass.Make(struct
6870 return (process_cond cond s)
6971
7072 | Run (id ,cond ) ->
71- M. throw_if Logging. (make_msg l " not allowed to call Main process explicitely" ) (id.value = Constants. main_process) >> = fun () ->
72- M. throw_if Logging. (make_msg l " not allowed to have recursive process" ) (FieldSet. mem id.value closed) >> = fun () ->
7373 let * pi = M. throw_if_none Logging. (make_msg l @@ Fmt. str " no proc init called '%s'" id.value)
7474 (List. find_opt (fun p -> p.value.id = id.value) p.p_body.proc_init) in
75+ M. throw_if Logging. (make_msg l " not allowed to have recursive process" ) (FieldSet. mem pi.value.proc closed) >> = fun () ->
7576 let read = List. map (fun (id :l_str ) -> mk_locatable id.loc @@ prefix id.value) pi.value.read in
7677 let write = List. map (fun (id :l_str ) -> mk_locatable id.loc @@ prefix id.value) pi.value.write in
7778 let params = List. map (AstU. rename_var prefix) pi.value.params in
0 commit comments