Commits

camlspotter committed 2568d25

added type lazy syntax (just syntax, no meaning yet)

  • Participants
  • Parent commits b3927ec
  • Branches coinductive_type

Comments (0)

Files changed (16)

 asmcomp/selection.cmi: asmcomp/mach.cmi asmcomp/cmm.cmi
 asmcomp/spill.cmi: asmcomp/mach.cmi
 asmcomp/split.cmi: asmcomp/mach.cmi
-asmcomp/arch.cmo:
-asmcomp/arch.cmx:
+asmcomp/arch.cmo: utils/misc.cmi utils/config.cmi
+asmcomp/arch.cmx: utils/misc.cmx utils/config.cmx
 asmcomp/asmgen.cmo: bytecomp/translmod.cmi asmcomp/split.cmi \
     asmcomp/spill.cmi asmcomp/selection.cmi asmcomp/scheduling.cmi \
     asmcomp/reload.cmi asmcomp/reg.cmi asmcomp/proc.cmi asmcomp/printmach.cmi \
 asmcomp/debuginfo.cmx: parsing/location.cmx bytecomp/lambda.cmx \
     asmcomp/debuginfo.cmi
 asmcomp/emit.cmo: asmcomp/reg.cmi asmcomp/proc.cmi utils/misc.cmi \
-    asmcomp/mach.cmi asmcomp/linearize.cmi asmcomp/emitaux.cmi \
-    asmcomp/debuginfo.cmi utils/config.cmi asmcomp/compilenv.cmi \
-    asmcomp/cmm.cmi utils/clflags.cmi asmcomp/arch.cmo asmcomp/emit.cmi
+    asmcomp/mach.cmi parsing/location.cmi asmcomp/linearize.cmi \
+    asmcomp/emitaux.cmi asmcomp/debuginfo.cmi utils/config.cmi \
+    asmcomp/compilenv.cmi asmcomp/cmm.cmi utils/clflags.cmi asmcomp/arch.cmo \
+    asmcomp/emit.cmi
 asmcomp/emit.cmx: asmcomp/reg.cmx asmcomp/proc.cmx utils/misc.cmx \
-    asmcomp/mach.cmx asmcomp/linearize.cmx asmcomp/emitaux.cmx \
-    asmcomp/debuginfo.cmx utils/config.cmx asmcomp/compilenv.cmx \
-    asmcomp/cmm.cmx utils/clflags.cmx asmcomp/arch.cmx asmcomp/emit.cmi
+    asmcomp/mach.cmx parsing/location.cmx asmcomp/linearize.cmx \
+    asmcomp/emitaux.cmx asmcomp/debuginfo.cmx utils/config.cmx \
+    asmcomp/compilenv.cmx asmcomp/cmm.cmx utils/clflags.cmx asmcomp/arch.cmx \
+    asmcomp/emit.cmi
 asmcomp/emitaux.cmo: asmcomp/reg.cmi asmcomp/linearize.cmi \
     asmcomp/debuginfo.cmi asmcomp/cmm.cmi asmcomp/arch.cmo \
     asmcomp/emitaux.cmi
     asmcomp/mach.cmx asmcomp/debuginfo.cmx asmcomp/cmm.cmx asmcomp/arch.cmx \
     asmcomp/printmach.cmi
 asmcomp/proc.cmo: asmcomp/reg.cmi utils/misc.cmi asmcomp/mach.cmi \
-    utils/config.cmi asmcomp/cmm.cmi utils/ccomp.cmi asmcomp/arch.cmo \
-    asmcomp/proc.cmi
+    utils/config.cmi asmcomp/cmm.cmi utils/clflags.cmi utils/ccomp.cmi \
+    asmcomp/arch.cmo asmcomp/proc.cmi
 asmcomp/proc.cmx: asmcomp/reg.cmx utils/misc.cmx asmcomp/mach.cmx \
-    utils/config.cmx asmcomp/cmm.cmx utils/ccomp.cmx asmcomp/arch.cmx \
-    asmcomp/proc.cmi
+    utils/config.cmx asmcomp/cmm.cmx utils/clflags.cmx utils/ccomp.cmx \
+    asmcomp/arch.cmx asmcomp/proc.cmi
 asmcomp/reg.cmo: asmcomp/cmm.cmi asmcomp/reg.cmi
 asmcomp/reg.cmx: asmcomp/cmm.cmx asmcomp/reg.cmi
 asmcomp/reload.cmo: asmcomp/reloadgen.cmi asmcomp/reg.cmi asmcomp/mach.cmi \
-    asmcomp/cmm.cmi utils/clflags.cmi asmcomp/arch.cmo asmcomp/reload.cmi
+    asmcomp/cmm.cmi asmcomp/arch.cmo asmcomp/reload.cmi
 asmcomp/reload.cmx: asmcomp/reloadgen.cmx asmcomp/reg.cmx asmcomp/mach.cmx \
-    asmcomp/cmm.cmx utils/clflags.cmx asmcomp/arch.cmx asmcomp/reload.cmi
+    asmcomp/cmm.cmx asmcomp/arch.cmx asmcomp/reload.cmi
 asmcomp/reloadgen.cmo: asmcomp/reg.cmi utils/misc.cmi asmcomp/mach.cmi \
     asmcomp/reloadgen.cmi
 asmcomp/reloadgen.cmx: asmcomp/reg.cmx utils/misc.cmx asmcomp/mach.cmx \
     asmcomp/selectgen.cmi
 asmcomp/selection.cmo: asmcomp/selectgen.cmi asmcomp/reg.cmi asmcomp/proc.cmi \
     utils/misc.cmi asmcomp/mach.cmi asmcomp/debuginfo.cmi asmcomp/cmm.cmi \
-    utils/clflags.cmi asmcomp/arch.cmo asmcomp/selection.cmi
+    asmcomp/arch.cmo asmcomp/selection.cmi
 asmcomp/selection.cmx: asmcomp/selectgen.cmx asmcomp/reg.cmx asmcomp/proc.cmx \
     utils/misc.cmx asmcomp/mach.cmx asmcomp/debuginfo.cmx asmcomp/cmm.cmx \
-    utils/clflags.cmx asmcomp/arch.cmx asmcomp/selection.cmi
+    asmcomp/arch.cmx asmcomp/selection.cmi
 asmcomp/spill.cmo: asmcomp/reg.cmi asmcomp/proc.cmi utils/misc.cmi \
     asmcomp/mach.cmi asmcomp/spill.cmi
 asmcomp/spill.cmx: asmcomp/reg.cmx asmcomp/proc.cmx utils/misc.cmx \

File parsing/parser.mly

               ptype_kind = kind;
               ptype_private = private_flag;
               ptype_manifest = manifest;
+              ptype_lazy = false;
+              ptype_variance = variance;
+              ptype_loc = symbol_rloc()}) }
+
+  | LAZY type_parameters LIDENT type_kind constraints
+      { let (params, variance) = List.split $2 in
+        let (kind, private_flag, manifest) = $4 in
+        ($3, {ptype_params = params;
+              ptype_cstrs = List.rev $5;
+              ptype_kind = kind;
+              ptype_private = private_flag;
+              ptype_manifest = manifest;
+              ptype_lazy = true;
               ptype_variance = variance;
               ptype_loc = symbol_rloc()}) }
 ;
                          ptype_kind = Ptype_abstract;
                          ptype_manifest = Some $5;
                          ptype_private = $4;
+                         ptype_lazy = false;
                          ptype_variance = variance;
                          ptype_loc = symbol_rloc()}) }
     /* used label_longident instead of type_longident to disallow
                               ptype_kind = Ptype_abstract;
                               ptype_manifest = Some $5;
                               ptype_private = Public;
+                              ptype_lazy = false;
+                              ptype_variance = variance;
+                              ptype_loc = symbol_rloc()}) }
+  | TYPE LAZY type_parameters label_longident with_type_binder core_type constraints
+      { let params, variance = List.split $3 in
+        ($4, Pwith_type {ptype_params = params;
+                         ptype_cstrs = List.rev $7;
+                         ptype_kind = Ptype_abstract;
+                         ptype_manifest = Some $6;
+                         ptype_private = $5;
+                         ptype_lazy = true;
+                         ptype_variance = variance;
+                         ptype_loc = symbol_rloc()}) }
+    /* used label_longident instead of type_longident to disallow
+       functor applications in type path */
+  | TYPE LAZY type_parameters label_longident COLONEQUAL core_type
+      { let params, variance = List.split $3 in
+        ($4, Pwith_typesubst {ptype_params = params;
+                              ptype_cstrs = [];
+                              ptype_kind = Ptype_abstract;
+                              ptype_manifest = Some $6;
+                              ptype_private = Public;
+                              ptype_lazy = true;
                               ptype_variance = variance;
                               ptype_loc = symbol_rloc()}) }
   | MODULE mod_longident EQUAL mod_ext_longident

File parsing/parsetree.mli

     ptype_kind: type_kind;
     ptype_private: private_flag;
     ptype_manifest: core_type option;
+    ptype_lazy: bool;
     ptype_variance: (bool * bool) list;
     ptype_loc: Location.t }
 

File typing/ctype.ml

       type_kind = tk;
       type_manifest = tm;
       type_private = priv;
+      type_lazy = decl.type_lazy;
       type_variance = decl.type_variance;
     }
   with Not_found ->

File typing/oprint.ml

       fprintf ppf "@[<2>%s %a :@ %a%a@]" kwd value_ident name !out_type
         ty pr_prims prims
 
-and print_out_type_decl kwd ppf (name, args, ty, priv, constraints) =
+and print_out_type_decl kwd ppf (name, args, ty, priv, constraints, is_lazy) =
   let print_constraints ppf params =
     List.iter
       (fun (ty1, ty2) ->
     | _ -> ()
   in
   let print_name_args ppf =
-    fprintf ppf "%s %t%a" kwd type_defined print_manifest ty
+    fprintf ppf "%s %s%t%a" kwd (if is_lazy then "lazy " else "") type_defined print_manifest ty
   in
   let ty =
     match ty with

File typing/outcometree.mli

   | Osig_value of string * out_type * string list
 and out_type_decl =
   string * (string * (bool * bool)) list * out_type * Asttypes.private_flag *
-  (out_type * out_type) list
+  (out_type * out_type) list * bool (* lazy or not *)
 and out_rec_status =
   | Orec_not
   | Orec_first

File typing/predef.ml

      type_kind = Type_abstract;
      type_private = Public;
      type_manifest = None;
+     type_lazy = false;
      type_variance = []}
   and decl_bool =
     {type_params = [];
      type_kind = Type_variant(["false", []; "true", []]);
      type_private = Public;
      type_manifest = None;
+     type_lazy = false;
      type_variance = []}
   and decl_unit =
     {type_params = [];
      type_kind = Type_variant(["()", []]);
      type_private = Public;
      type_manifest = None;
+     type_lazy = false;
      type_variance = []}
   and decl_exn =
     {type_params = [];
      type_kind = Type_variant [];
      type_private = Public;
      type_manifest = None;
+     type_lazy = false;
      type_variance = []}
   and decl_array =
     let tvar = newgenvar() in
      type_kind = Type_abstract;
      type_private = Public;
      type_manifest = None;
+     type_lazy = false;
      type_variance = [true, true, true]}
   and decl_list =
     let tvar = newgenvar() in
        Type_variant(["[]", []; "::", [tvar; type_list tvar]]);
      type_private = Public;
      type_manifest = None;
+     type_lazy = false;
      type_variance = [true, false, false]}
   and decl_format6 =
     {type_params = [
      type_kind = Type_abstract;
      type_private = Public;
      type_manifest = None;
+     type_lazy = false;
      type_variance = [
        true, true, true; true, true, true;
        true, true, true; true, true, true;
      type_kind = Type_variant(["None", []; "Some", [tvar]]);
      type_private = Public;
      type_manifest = None;
+     type_lazy = false;
      type_variance = [true, false, false]}
   and decl_lazy_t =
     let tvar = newgenvar() in
      type_kind = Type_abstract;
      type_private = Public;
      type_manifest = None;
+     type_lazy = false;
      type_variance = [true, false, false]}
   in
 

File typing/printtyp.ml

         tree_of_manifest (Otyp_record (List.map tree_of_label lbls)),
         decl.type_private
   in
-  (name, args, ty, priv, constraints)
+  let is_lazy = decl.type_lazy in
+  (name, args, ty, priv, constraints, is_lazy)
 
 and tree_of_constructor (name, args) =
   (name, tree_of_typlist false args)

File typing/subst.ml

         | Some ty -> Some(typexp s ty)
         end;
       type_private = decl.type_private;
+      type_lazy = decl.type_lazy;
       type_variance = decl.type_variance;
     }
   in

File typing/typeclass.ml

        type_kind = Type_abstract;
        type_private = Public;
        type_manifest = Some ty;
+       type_lazy = false; (* CR jfuruse: ? *)
        type_variance = List.map (fun _ -> true, true, true) !params}
       env
   in
      type_kind = Type_abstract;
      type_private = Public;
      type_manifest = Some obj_ty;
+     type_lazy = false;
      type_variance = List.map (fun _ -> true, true, true) obj_params}
   in
   let (cl_params, cl_ty) =
      type_kind = Type_abstract;
      type_private = Public;
      type_manifest = Some cl_ty;
+     type_lazy = false;
      type_variance = List.map (fun _ -> true, true, true) cl_params}
   in
   ((cl, id, clty, ty_id, cltydef, obj_id, obj_abbr, cl_id, cl_abbr,

File typing/typecore.ml

         type_kind = Type_abstract;
         type_private = Public;
         type_manifest = None;
+        type_lazy = false;
         type_variance = [];
       }
       in

File typing/typedecl.ml

       type_manifest =
         begin match sdecl.ptype_manifest with None -> None
         | Some _ -> Some(Ctype.newvar ()) end;
+      type_lazy = sdecl.ptype_lazy;
       type_variance = List.map (fun _ -> true, true, true) sdecl.ptype_params;
     }
   in
             Type_record(lbls', rep)
         end;
       type_private = sdecl.ptype_private;
+      type_lazy = sdecl.ptype_lazy;
       type_manifest =
         begin match sdecl.ptype_manifest with
           None -> None
         | Some sty ->
             Some(transl_simple_type env no_row sty)
         end;
+      type_lazy = sdecl.ptype_lazy;
       type_variance = [];
     }
   in
       type_kind = Type_abstract;
       type_private = Public;
       type_manifest = None;
+      type_lazy = false; (* CR jfuruse: ? *)
       type_variance = replicate_list (true, true, true) arity } in
   Ctype.end_def();
   generalize_decl decl;

File typing/typemod.ml

             type_kind = Type_abstract;
             type_private = Private;
             type_manifest = None;
+            type_lazy = sdecl.ptype_lazy; (* CR jfuruse: ? *) 
             type_variance =
               List.map (fun (c,n) -> (not n, not c, not c))
               sdecl.ptype_variance }

File typing/types.ml

     type_kind: type_kind;
     type_private: private_flag;
     type_manifest: type_expr option;
+    type_lazy: bool; 
     type_variance: (bool * bool * bool) list }
             (* covariant, contravariant, weakly contravariant *)
 

File typing/types.mli

     type_kind: type_kind;
     type_private: private_flag;
     type_manifest: type_expr option;
-    type_variance: (bool * bool * bool) list }
+    type_lazy: bool; 
+    type_variance: (bool * bool * bool) list; }
             (* covariant, contravariant, weakly contravariant *)
 
 and type_kind =

File typing/typetexp.ml

                ptype_kind = Ptype_abstract;
                ptype_private = Asttypes.Public;
                ptype_manifest = if fake then None else Some t;
+               ptype_lazy = false;
                ptype_variance = [];
                ptype_loc = loc} in
       {pmty_desc=Pmty_with (mty, [ Longident.Lident s, Pwith_type d ]); pmty_loc=loc}