This commit is contained in:
Mylloon 2023-12-15 13:13:03 +01:00
parent 1921101d45
commit edb1219070
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -126,15 +126,15 @@ let free_variables =
let rec fvs = function let rec fvs = function
| S.Literal _ -> M.empty | S.Literal _ -> M.empty
| S.Variable x -> M.singleton x | S.Variable x -> M.singleton x
| S.While (cond, e) -> unions fvs [cond;e] | S.While (cond, e) -> unions fvs [ cond; e ]
| S.Define (vd, a) -> | S.Define (vd, a) ->
let liste_def_valeur = let liste_def_valeur =
match vd with match vd with
| S.SimpleValue (id,expr) -> [(id,expr)] | S.SimpleValue (id, expr) -> [ id, expr ]
| S.RecFunctions (list) -> list | S.RecFunctions list -> list
in in
let id, expr = List.split liste_def_valeur in let id, expr = List.split liste_def_valeur in
M.diff (unions fvs (a::expr)) (M.of_list id) M.diff (unions fvs (a :: expr)) (M.of_list id)
| S.ReadBlock (a, b) -> unions fvs [ a; b ] | S.ReadBlock (a, b) -> unions fvs [ a; b ]
| S.Apply (a, b) -> unions fvs (a :: b) | S.Apply (a, b) -> unions fvs (a :: b)
| S.WriteBlock (a, b, c) | S.IfThenElse (a, b, c) -> unions fvs [ a; b; c ] | S.WriteBlock (a, b, c) | S.IfThenElse (a, b, c) -> unions fvs [ a; b; c ]
@ -149,7 +149,7 @@ let free_variables =
unions fvs ((a :: ExtStd.Array.present_to_list b) @ c) unions fvs ((a :: ExtStd.Array.present_to_list b) @ c)
in in
fun e -> M.elements (fvs e) fun e -> M.elements (fvs e)
;;
(** A closure compilation environment relates an identifier to the way (** A closure compilation environment relates an identifier to the way
it is accessed in the compiled version of the function's it is accessed in the compiled version of the function's