Commit cfd28a15 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2006-05-17 15:03:40 by afrisch] Pas de warning fans les branches fantomes

Original author: afrisch
Date: 2006-05-17 15:03:41+00:00
parent 3579c0f6
......@@ -321,24 +321,24 @@ EXTEND
set_ref
(Var stk)
(concat (get_ref (Var stk)) (Pair (Var id_dummy,cst_nil))) in
let tag = mk _loc (Internal (Types.atom (Atoms.any))) in
let att = mk _loc (Internal Types.Record.any) in
let any = mk _loc (Internal Types.any) in
let tag = mknoloc (Internal (Types.atom (Atoms.any))) in
let att = mknoloc (Internal Types.Record.any) in
let any = mknoloc (Internal Types.any) in
let re = (SeqCapture(noloc,y,Star(Elem(any)))) in
let ct = mk _loc (Regexp re) in
let children = mk _loc (XmlT (tag, multi_prod _loc [att;ct])) in
let capt = mk _loc (And (mk _loc (And (mk _loc (PatVar [id_dummy]),p)),children)) in
let assign = exp _loc (seq assign ( exp _loc (Apply(Var(f) , Var(y) ) ) ) ) in
let ct = mknoloc (Regexp re) in
let children = mknoloc (XmlT (tag, multi_prod _loc [att;ct])) in
let capt = mknoloc (And (mknoloc (And (mknoloc (PatVar [id_dummy]),p)),children)) in
let assign = seq assign ( (Apply(Var(f) , Var(y) ) ) ) in
let xt = Xtrans ((Var x),[capt,assign]) in
let rf = Ref (cst_nil, mk _loc (Regexp (Star(Elem p)))) in
let targ = mk _loc (Regexp(Star(Elem(any)))) in
let rf = Ref (cst_nil, mknoloc (Regexp (Star(Elem p)))) in
let targ = mknoloc (Regexp(Star(Elem(any)))) in
let tres = targ in
let arg = mk _loc(PatVar [x]) in
let arg = mknoloc(PatVar [x]) in
let abst = {fun_name = Some (lop _loc,ident "f") ; fun_iface = [(targ, tres)] ;fun_body = [(arg,xt)] } in
let body =
let_in rf (mk _loc (PatVar [stk]))
(let_in (exp _loc (Abstraction abst)) (mk _loc (PatVar[ident "f"]))
(let_in (exp _loc (Apply(Var(f) , e) ) ) (mk _loc (Internal Types.any)) (get_ref (Var stk))))
let_in rf (mknoloc (PatVar [stk]))
(let_in ((Abstraction abst)) (mknoloc (PatVar[ident "f"]))
(let_in ((Apply(Var(f) , e) ) ) (mknoloc (Internal Types.any)) (get_ref (Var stk))))
in
exp _loc body
]
......
......@@ -75,6 +75,7 @@ and branches = {
and branch = {
br_loc : loc;
mutable br_used : bool;
br_ghost : bool;
mutable br_vars_empty : fv;
br_pat : tpat;
br_body : texpr
......
......@@ -593,11 +593,13 @@ and if_then_else loc cond yes no =
Typed.br_branches = [
{ Typed.br_loc = yes.Typed.exp_loc;
Typed.br_used = false;
Typed.br_ghost = false;
Typed.br_vars_empty = Fv.empty;
Typed.br_pat = pat_true;
Typed.br_body = yes };
{ Typed.br_loc = no.Typed.exp_loc;
Typed.br_used = false;
Typed.br_ghost = false;
Typed.br_vars_empty = Fv.empty;
Typed.br_pat = pat_false;
Typed.br_body = no } ];
......@@ -716,10 +718,12 @@ and branches env b =
let fv2 = Fv.diff fv2 fvp in
fv := Fv.cup !fv fv2;
accept := Types.cup !accept (Types.descr (Patterns.accept p));
let ghost = br_loc == noloc in
let br =
{
Typed.br_loc = br_loc;
Typed.br_used = br_loc == noloc;
Typed.br_used = ghost;
Typed.br_ghost = ghost;
Typed.br_vars_empty = fvp;
Typed.br_pat = p;
Typed.br_body = e } in
......@@ -761,6 +765,7 @@ and select_from_where env loc e from where =
(* transform e with p -> ... *)
let br = { Typed.br_loc = ploc;
Typed.br_used = false;
Typed.br_ghost = false;
Typed.br_vars_empty = fvp;
Typed.br_pat = p;
Typed.br_body = rest } in
......@@ -1142,8 +1147,8 @@ and type_rec_funs env l =
let rec unused_branches b =
List.iter
(fun (Branch (br,s)) ->
if not br.br_used
then warning br.br_loc "This branch is not used"
if br.br_ghost then ()
else if not br.br_used then warning br.br_loc "This branch is not used"
else (
if not (IdSet.is_empty br.br_vars_empty)
then (
......
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