/[svn]/typing/typer.ml
ViewVC logotype

Diff of /typing/typer.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 313 by abate, Tue Jul 10 17:21:59 2007 UTC revision 314 by abate, Tue Jul 10 17:24:30 2007 UTC
# Line 479  Line 479 
479    
480  module Fv = IdSet  module Fv = IdSet
481    
482    let all_branches = ref []
483    
484  (* IDEA: introduce a node Loc in the AST to override nolocs  (* IDEA: introduce a node Loc in the AST to override nolocs
485     in sub-expressions *)     in sub-expressions *)
486    
# Line 568  Line 570 
570    and branches loc b =    and branches loc b =
571      let fv = ref Fv.empty in      let fv = ref Fv.empty in
572      let accept = ref Types.empty in      let accept = ref Types.empty in
573      let b = List.map      let branch (p,e) =
574                (fun (p,e) ->        let br_loc = merge_loc p.loc e.loc in
575                   let (fv2,e) = expr loc e in                   let (fv2,e) = expr loc e in
576                   let p = pat p in                   let p = pat p in
577                   let fv2 = Fv.diff fv2 (Patterns.fv p) in                   let fv2 = Fv.diff fv2 (Patterns.fv p) in
578                   fv := Fv.cup !fv fv2;                   fv := Fv.cup !fv fv2;
579                   accept := Types.cup !accept (Types.descr (Patterns.accept p));                   accept := Types.cup !accept (Types.descr (Patterns.accept p));
580                   { Typed.br_used = false;        let br =
581            {
582              Typed.br_loc = br_loc;
583              Typed.br_used = br_loc = noloc;
584                     Typed.br_pat = p;                     Typed.br_pat = p;
585                     Typed.br_body = e }            Typed.br_body = e } in
586                ) b in        all_branches := br :: !all_branches;
587          br in
588        let b = List.map branch b in
589      (!fv,      (!fv,
590       {       {
591         Typed.br_typ = Types.empty;         Typed.br_typ = Types.empty;
# Line 1011  Line 1018 
1018                 (t2,Types.Int.any,                 (t2,Types.Int.any,
1019                  "The second argument must be an integer"));                  "The second argument must be an integer"));
1020    Types.Int.put    Types.Int.put
1021      (f (Types.Int.get t1) (Types.Int.get t2));      (f (Types.Int.get t1) (Types.Int.get t2))
1022    
1023    
1024    
1025    
1026    let report_unused_branches () =
1027      List.iter
1028        (fun b ->
1029           if not b.br_used then
1030             warning b.br_loc "This branch is not used"
1031        )
1032        !all_branches;
1033      all_branches := []
1034    

Legend:
Removed from v.313  
changed lines
  Added in v.314

CVS Admin">CVS Admin
ViewVC Help
Powered by ViewVC 1.1.5