Commit b59ef008 authored by Julien Lopez's avatar Julien Lopez

Remove old attempt to add a variable to each pattern at compile time

parent ed82611c
......@@ -181,18 +181,10 @@ and compile_branches env (brs : Typed.branches) =
(* p_i / t_i -> br.Typed.br_pat / br.Typed.br_type
* p_i / t_i is used here to add elements to env.gamma *)
and compile_branch env br =
(* We add a fresh variable "pat<nb>:x" for each pattern *)
let t, fv, d = br.Typed.br_pat.Patterns.descr in
let fv, d = incr Patterns.counter;
let freshname = "pat" ^ (string_of_int !Patterns.counter) ^ ":x" in
let fv = fv @ [!Patterns.counter, freshname] in
fv, Patterns.Cap((Types.any, fv, Patterns.Capture(!Patterns.counter, freshname)), (t, fv, d))
in
let pat = { br.Typed.br_pat with Patterns.descr=(t,fv,d); Patterns.fv=fv } in
let env = List.fold_left enter_local env fv in
let m = Patterns.filter (Types.descr (Patterns.accept pat)) pat in
let env = List.fold_left enter_local env (Patterns.fv br.Typed.br_pat) in
let m = Patterns.filter (Types.descr (Patterns.accept br.Typed.br_pat)) br.Typed.br_pat in
let env = { env with gamma = IdMap.union_disj m env.gamma } in
(pat, compile env br.Typed.br_body )
(br.Typed.br_pat, compile env br.Typed.br_body)
let enter_globals env n = match env.cu with
| None -> List.fold_left enter_global_toplevel env n
......
......@@ -370,13 +370,10 @@ x=(1,2)
| Cup ((a1,_,_) as p1,p2) ->
approx_var seen p2 (Types.diff t a1)
(approx_var seen p1 (Types.cap t a1) xs)
| Cap ((_,fv1,d1) as p1,((_,fv2,d2) as p2)) ->
(match d1 with
| Capture(_, name) when Str.string_match (Str.regexp "pat[0-9]+:") (Encodings.Utf8.get_str name) 0 ->
(match d2 with | Constr _ -> fv2 | _ -> approx_var seen p2 t xs)
| _ -> IdSet.cup
(approx_var seen p1 t (IdSet.cap fv1 xs))
(approx_var seen p2 t (IdSet.cap fv2 xs)))
| Cap ((_,fv1,_) as p1,((_,fv2,_) as p2)) ->
IdSet.cup
(approx_var seen p1 t (IdSet.cap fv1 xs))
(approx_var seen p2 t (IdSet.cap fv2 xs))
| Capture _ ->
xs
| Constant (_,c) ->
......
Markdown is supported
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