Commit 40288341 authored by Julien Lopez's avatar Julien Lopez

Try adding a fresh variable with a capture (not working)

parent cb63b921
......@@ -181,22 +181,12 @@ 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 (except Constr) *)
(* We add a fresh variable "pat<nb>:x" for each pattern *)
let t, _, d = br.Typed.br_pat.Patterns.descr in
let fv, d = match d with
| Patterns.Constr(_) -> Patterns.fv br.Typed.br_pat, d
| Patterns.Cap((t1, _, d1), (t2, _, d2)) -> incr Patterns.counter;
let fv = (Patterns.fv br.Typed.br_pat)
@ [!Patterns.counter, "pat" ^ (string_of_int !Patterns.counter) ^ ":x"] in
fv, Patterns.Cap((t1, fv, d1), (t2, fv, d2))
| Patterns.Cup((t1, _, d1), (t2, _, d2)) -> incr Patterns.counter;
let fv = (Patterns.fv br.Typed.br_pat)
@ [!Patterns.counter, "pat" ^ (string_of_int !Patterns.counter) ^ ":x"] in
fv, Patterns.Cup((t1, fv, d1), (t2, fv, d2))
| _ -> incr Patterns.counter;
let fv = (Patterns.fv br.Typed.br_pat)
@ [!Patterns.counter, "pat" ^ (string_of_int !Patterns.counter) ^ ":x"] in
fv, d
let fv, d = incr Patterns.counter;
let freshname = "pat" ^ (string_of_int !Patterns.counter) ^ ":x" in
let fv = (Patterns.fv br.Typed.br_pat) @ [!Patterns.counter, freshname] in
fv, Patterns.Cap((Types.any, fv, Patterns.Capture(!Patterns.counter, freshname)), (t, [], 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
......
......@@ -338,7 +338,7 @@ and filter_node t p : Types.Positive.v id_map =
let res = IdMap.map_from_slist (fun _ -> Types.Positive.forward ()) fv in
memo_filter := MemoFilter.add (t,p) res !memo_filter;
let r = filter_descr t (descr p) in
(* IdMap.collide Types.Positive.define res r;*) (* Had to comment this to add fresh variables for patterns *)
IdMap.collide Types.Positive.define res r; (* Had to comment this to add fresh variables for patterns *)
r
let filter t p =
......@@ -391,7 +391,7 @@ x=(1,2)
(approx_var_node seen q1 (pi1 ~kind:`XML t) xs)
(approx_var_node seen q2 (pi2 ~kind:`XML t) xs)
| Record _ -> IdSet.empty
| Constr _ -> xs (* Needed to add fresh variables to patterns *)
(* | Constr _ -> xs (* Needed to add fresh variables to patterns *)*)
| _ -> assert false
and approx_var_node seen q t xs =
......
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