Changeset 3023:604e19595093

Show
Ignore:
Timestamp:
02/20/12 15:57:55 (3 months ago)
Author:
Etienne Millon <etienne . millon AT eads . net>
Branch:
default
Message:

ptrtype: introduce type schemes

Location:
src/ptrtype
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • src/ptrtype/infer.ml

    r3021 r3023  
    312312    ; T.args = extract_types fdec.T.args 
    313313    ; T.position = fdec.T.position 
    314     ; T.fdectype = te 
     314    ; T.fdectype = T.Forall ([], te) 
    315315    } 
    316316  in 
  • src/ptrtype/npk2tpk.ml

    r3021 r3023  
    104104    ; T.body = c_blk f.N.body 
    105105    ; T.position = f.N.position 
    106     ; T.fdectype = nil_ty 
     106    ; T.fdectype = T.Forall ([], nil_ty) 
    107107    } 
    108108  in 
  • src/ptrtype/tyspeak.ml

    r3022 r3023  
    4343  body : 'ty blk; 
    4444  position: Newspeak.location; 
    45   fdectype : 'ty; 
     45  fdectype : 'ty scheme; 
    4646} 
     47 
     48and 'ty scheme = Forall of int list * 'ty 
    4749 
    4850and 'ty globals = (string, 'ty) Hashtbl.t 
     
    332334    Buffer.contents buf 
    333335 
     336let string_of_scheme sty (Forall (bv, t)) = 
     337  let s_forall = 
     338    if bv == [] then 
     339      "" 
     340    else 
     341      String.concat " " (List.map string_of_int bv) ^ " . " 
     342  in 
     343  s_forall ^ sty t 
     344 
     345 
    334346let string_of_fundec sty name declaration = 
    335347  Printf.sprintf 
    336348    "%s : %s\n%s %s%s%s {\n%s}\n" 
    337349       name 
    338        (sty declaration.fdectype) 
     350       (string_of_scheme sty declaration.fdectype) 
    339351       (string_of_ret sty declaration.rets) 
    340352       (string_of_loc_as_prefix declaration.position) 
  • src/ptrtype/tyspeak.mli

    r3021 r3023  
    7676  body : 'ty blk; 
    7777  position: Newspeak.location; 
    78   fdectype : 'ty; 
     78  fdectype : 'ty scheme; 
    7979} 
     80 
     81and 'ty scheme = Forall of int list * 'ty 
    8082 
    8183and 'ty globals = (string, 'ty) Hashtbl.t