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

Diff of /typing/typer.ml

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

revision 383 by abate, Tue Jul 10 17:29:46 2007 UTC revision 384 by abate, Tue Jul 10 17:30:36 2007 UTC
# Line 909  Line 909 
909  and type_op loc op args =  and type_op loc op args =
910    match (op,args) with    match (op,args) with
911      | "+", [loc1,t1; loc2,t2] ->      | "+", [loc1,t1; loc2,t2] ->
912          check loc1 t1 int_cup_record          if (Types.is_empty t1) || (Types.is_empty t2) then Types.empty
913          "The first argument of + must be an integer or a record";          else if Types.subtype t1 Types.Int.any
914          let int = Types.Int.get t1 in          then (
         let int = if Intervals.is_empty int then None else Some int in  
         let r = if Types.Record.has_record t1 then Some t1 else None in  
         (match (int,r) with  
            | Some t1, None ->  
915                 check loc2 t2 Types.Int.any                 check loc2 t2 Types.Int.any
916                 "The second argument of + must be an integer";                  "The second argument of + must be an integer as the first one";
917                 Types.interval                 Types.interval
918                   (Intervals.add t1 (Types.Int.get t2));              (Intervals.add (Types.Int.get t1) (Types.Int.get t2))
919             | None, Some r1 ->          )
920            else (
921              check loc1 t1 Types.Record.any
922                    "The first argument of + must be a record or an integer";
923                 check loc2 t2 Types.Record.any                 check loc2 t2 Types.Record.any
924                 "The second argument of + must be a record";                  "The second argument of + must be a record as the first one";
925                 Types.Record.merge r1 t2            Types.Record.merge t1 t2
            | None, None ->  
                Types.empty  
            | Some t1, Some r1 ->  
                check loc2 t2 int_cup_record  
                "The second argument of + must be an integer or a record";  
                Types.cup  
                  (Types.interval (Intervals.add t1 (Types.Int.get t2)))  
                  (Types.Record.merge r1 t2)  
926          )          )
927      | "-", [loc1,t1; loc2,t2] ->      | "-", [loc1,t1; loc2,t2] ->
928          type_int_binop Intervals.sub loc1 t1 loc2 t2          type_int_binop Intervals.sub loc1 t1 loc2 t2

Legend:
Removed from v.383  
changed lines
  Added in v.384

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