camlspotter avatar camlspotter committed 1fd4dcd

update

Comments (0)

Files changed (12)

 spot.cmi :
 spotconfig.cmi : spotconfig_intf.cmo
 spoteval.cmi : utils.cmi spot.cmi
-spotfile.cmi : spoteval.cmi spotconfig_intf.cmo spot.cmi
+spotfile.cmi : spoteval.cmi spot.cmi
 treeset.cmi : xset.cmi
+ttfold.cmi :
 typeFix.cmi :
 typeexpand.cmi :
 utils.cmi :
 locident.cmx : locident.cmi
 name.cmo : name.cmi
 name.cmx : name.cmi
-ocamlspot.cmo : utils.cmi spoteval.cmi spotconfig.cmi spot.cmi ext.cmo
-ocamlspot.cmx : utils.cmx spoteval.cmx spotconfig.cmx spot.cmx ext.cmx
+ocamlspot.cmo : utils.cmi spotfile.cmi spoteval.cmi spotconfig.cmi spot.cmi \
+    ext.cmo
+ocamlspot.cmx : utils.cmx spotfile.cmx spoteval.cmx spotconfig.cmx spot.cmx \
+    ext.cmx
 pathreparse.cmo : utils.cmi spot.cmi locident.cmi ext.cmo pathreparse.cmi
 pathreparse.cmx : utils.cmx spot.cmx locident.cmx ext.cmx pathreparse.cmi
-spot.cmo : utils.cmi treeset.cmi ext.cmo spot.cmi
-spot.cmx : utils.cmx treeset.cmx ext.cmx spot.cmi
+spot.cmo : utils.cmi ttfold.cmi treeset.cmi ext.cmo spot.cmi
+spot.cmx : utils.cmx ttfold.cmx treeset.cmx ext.cmx spot.cmi
 spotconfig.cmo : utils.cmi spot.cmi ext.cmo spotconfig.cmi
 spotconfig.cmx : utils.cmx spot.cmx ext.cmx spotconfig.cmi
 spotconfig_intf.cmo : spot.cmi ext.cmo
     dotfile.cmx spotfile.cmi
 treeset.cmo : xset.cmi treeset.cmi
 treeset.cmx : xset.cmx treeset.cmi
+ttfold.cmo : ttfold.cmi
+ttfold.cmx : ttfold.cmi
+ttfold.out.cmo :
+ttfold.out.cmx :
 typeFix.cmo : utils.cmi name.cmi typeFix.cmi
 typeFix.cmx : utils.cmx name.cmx typeFix.cmi
+typedeclfold.cmo :
+typedeclfold.cmx :
+typedtreefold.cmo :
+typedtreefold.cmx :
 typeexpand.cmo : utils.cmi typeexpand.cmi
 typeexpand.cmx : utils.cmx typeexpand.cmi
 utils.cmo : utils.cmi
 utils.cmx : utils.cmi
+x.cmo :
+x.cmx :
 xident.cmo : name.cmi xident.cmi
 xident.cmx : name.cmx xident.cmi
 xlongident.cmo : xlongident.cmi
 # Various commands and dir
 ##########################
 CAMLRUN= ocamlrun
-OCAMLC   = ocamlc -annot -bin-annot -w Ae-9 -warn-error Ae-9
-OCAMLOPT = ocamlopt -annot -bin-annot -w Ae-9 -warn-error Ae-9
+OCAMLC   = ocamlc -annot -bin-annot -w Ae-9 -warn-error Ae-9-32-33-34-27
+OCAMLOPT = ocamlopt -annot -bin-annot -w Ae-9 -warn-error Ae-9-32-33-34-27
 OCAMLDEP = ocamldep
 OCAMLLEX = ocamllex
 OCAMLYACC= ocamlyacc
 INCLUDES_DEP=-I $(OCAMLDIR)/compiler-libs
 
 # Requires unix!
-COMPFLAGS= $(INCLUDES_DEP) -I $(OTHERS)/unix
+COMPFLAGS= $(INCLUDES_DEP) -I +unix
 
 MODULES= utils dotfile xset treeset command typeexpand \
-	xlongident name xident xpath locident typeFix xprinttyp ext spot spoteval spotconfig_intf spotconfig pathreparse ocamlspot
+	xlongident name xident xpath locident typeFix xprinttyp ext ttfold spot spoteval spotconfig_intf spotconfig spotfile pathreparse ocamlspot
 
 OBJS=		$(addsuffix .cmo, $(MODULES))
 
 typedtreefold.cmo: typedtreefold.ml
 	$(OCAMLC) -I +compiler-libs -pp 'camlp4o Camlp4FoldGenerator.cmo' typedtreefold.ml
 
+ttfold.out.ml: typedtreefold.ml
+	camlp4o -printer Camlp4OCamlPrinter Camlp4FoldGenerator.cmo typedtreefold.ml > $@
+
 .ml.cmo:
 	$(OCAMLC) $(OCAMLPP) $(COMPFLAGS) -c $<
 
 
 (* module names may corride in different source/spot files *)
 
-(*
 open Format
 open Utils
 
 open Spot
 open Spoteval
 
-*)
 module C = Spotconfig
 
+module File = Spotfile.Make(C)
+
 open Cmt_format
 
 module SAbs = Spot.Abstraction
 
-let _ =
-  match C.mode with
-  | `Dump p ->
-      begin match Cmt_format.read p with
-      | _, None -> Format.eprintf "%s : oops@." p
-      | _, Some cmti ->
-          let v = 
-            match cmti.cmt_annots with
-            | Implementation str -> SAbs.structure str
-            | Interface sg -> SAbs.signature sg
-            | Partial_implementation _parts | Partial_interface _parts ->
-                assert false
-            | _ -> assert false
-          in
-          Format.eprintf "%a@."
-            SAbs.format_module_expr v
-      end
-  | _ -> assert false
-    
-
 (*
 type binary_annots =
   | Packed of Types.signature * string list
   | Partial_module_type of module_type
 *)
 
-(* module File = Spotfile.Make(C) *)
-    
+let _ =
+  match C.mode with
+  | `Dump p ->
+      begin match File.load ~load_paths:["."] p with
+      | f ->
+          Spotfile.dump_file f;
+      end
+  | _ -> assert false
+
+
 (*
 module Dump = struct
   (* mainly debugging purpose *)
     | Tmodtype_abstract -> AMod_abstract
     | Tmodtype_manifest mty -> module_type mty
 
+  let rec flatten str = List.concat_map flatten_item str
+
+  and flatten_item item = match item with
+    | AStr_value     _
+    | AStr_type      _
+    | AStr_exception _
+    | AStr_class     _
+    | AStr_cltype    _ -> [item]
+    | AStr_module  (_, mexp)
+    | AStr_modtype (_, mexp) -> item :: flatten_module_expr mexp
+    | AStr_include (mexp, aliases) ->
+        let flats = flatten_module_expr mexp in
+        List.map (fun (id, kid) ->
+          List.find (fun sitem -> ident_of_structure_item sitem = Some kid) flats)
+          aliases
+        @ flats
+
+  and flatten_module_expr = function
+    | AMod_ident _ -> []
+    | AMod_packed _ -> []
+    | AMod_structure str -> flatten str
+    | AMod_functor _ -> []
+    | AMod_apply (_, m) -> flatten_module_expr m
+    | AMod_constraint (m, _) -> flatten_module_expr m
+    | AMod_unpack m -> flatten_module_expr m
+    | AMod_abstract -> []
 end
 
 let protect name f v =
       ()
 *)
 
-      
-
   module Record = struct
     open Asttypes
     open Typedtree
     module A = Abstraction
 
-    let rec structure str = List.iter structure_item str
-      
-    and structure_item sitem = 
-      let loc = sitem.str_loc in
-      List.iter (fun sitem -> record loc (Str sitem)) (A.structure_item sitem);
-      structure_item_desc sitem.str_desc
+    class fold = object (self)
+      inherit Ttfold.fold as super
 
-    and structure_item_desc = function
-      | Tstr_eval e -> expression e
-      | Tstr_value (_, pe_list) -> 
-          List.iter (fun (p, e) -> 
-            pattern p;
-            expression e
-          ) pe_list
-      | Tstr_primitive (id, {loc}, _vdesc) -> 
-          record loc (Str (A.AStr_value id))
-      | Tstr_type id_loc_tdecl_list ->
-          List.iter (fun (id, {loc}, tdecl) -> 
-            record loc (Str (A.AStr_type id));
-            type_declaration tdecl) id_loc_tdecl_list
-      | Tstr_exception (id, {loc}, ed) ->
-          record loc (Str (A.AStr_exception id));
-          exception_declaration ed
-      | Tstr_exn_rebind (_id, _loc, path, {loc}) -> 
-          record loc (Use (Kind.Exception, path))
-      | Tstr_module (id, {loc}, mexp) -> 
-          record loc (Str (A.AStr_module 
-	                  (id, 
-	                  (A.module_expr mexp))));
-          module_expr mexp (* should do           record loc (Mod_type modl.Typedtree.mod_type)) *)
-      | Tstr_recmodule id_loc_mtype_mexp_list ->
-          List.iter (fun (id,{loc},mtype,mexp) ->
-            record loc (Str (A.AStr_module 
-	                       (id, 
-	                        (A.module_expr mexp))));
-            module_type mtype;
-            module_expr mexp) id_loc_mtype_mexp_list
-      | Tstr_modtype (id, {loc}, mty) -> 
-          record loc (Str (A.AStr_modtype
-                             (id,
-                              A.module_type mty)));
-          module_type mty
-      | Tstr_open (path, {loc}) -> 
-          record loc (Use (Kind.Module, path)) 
-      
-      | Tstr_class cdecl_names_vf_list -> 
-          List.iter (fun (cdecl, _names, _vf) ->
-            class_declaration cdecl) cdecl_names_vf_list
-      | Tstr_class_type id_loc_cltyped_list ->
-          List.iter (fun (_id, (* {loc} *) _, cltyd) ->
-            (* CR jfuruse: class type declaration record *)
-            class_type_declaration cltyd) id_loc_cltyped_list
-      | Tstr_include (mexp, _ids) -> 
-          module_expr mexp
-(* already done in the parent?!
-          let abs = Abstraction.module_expr modl in
-          match abs with
-          | A.AMod_structure str ->
-              List.iter (fun sitem -> record loc (Str sitem)) str
-          | _ -> assert false)
-*)
-
-    and expression e = 
-      record e.exp_loc (Type (e.exp_type, e.exp_env, `Expr));
-      (* CR jfuruse: todo: exp_extra *)
-(*
-and exp_extra =
-  | Texp_constraint of core_type option * core_type option
-  | Texp_open of Path.t * Longident.t loc * Env.t
-*)
-      let p_e_list = List.iter (fun (p,e) -> pattern p; expression e) in
-
-      match e.exp_desc with
-      | Texp_ident (path, {loc}, _) -> record loc (Use (Kind.Value, path))
-      | Texp_constant _ -> ()
-      | Texp_function (_, pel, _) -> p_e_list pel
-      | Texp_apply (e, l_eopt_opt_list) -> 
-          expression e; 
-          List.iter (fun (_, eopt, _) -> Option.iter ~f:expression eopt) l_eopt_opt_list
-      | Texp_let (_, pel, e) -> p_e_list pel; expression e
-      | Texp_match (e, pel, _) 
-      | Texp_try (e, pel) -> 
-          expression e; p_e_list pel
-      | Texp_tuple el
-      | Texp_array el -> List.iter expression el
-      | Texp_construct (p, {loc}, _, el, _) -> 
-          record loc (Use (Kind.Type, p));
-          List.iter expression el
-      | Texp_variant (_, Some e) -> expression e 
-      | Texp_variant (_, None) -> ()
-      | Texp_record (fields, expopt) -> 
-          List.iter (fun (path, {loc}, _, e) ->
-            record loc (Use (Kind.Type, path));
-            expression e) fields;
-          Option.iter ~f:expression expopt
-      | Texp_field (e, p, {loc}, _) ->
-          expression e; 
-          record loc (Use (Kind.Type, p))
-      | Texp_setfield (e, p, {loc}, _, e') ->
-          expression e;
-          record loc (Use (Kind.Type, p));
-          expression e'
-      | Texp_ifthenelse (e, e', eopt) -> 
-          expression e; expression e'; Option.iter ~f:expression eopt
-      | Texp_sequence (e, e') 
-      | Texp_while (e, e') 
-      | Texp_when (e, e') -> 
-          expression e; expression e'
-      | Texp_for (id, {loc}, e, e', _, e'') -> 
-          record loc (Str (A.AStr_value id));
-          expression e;
-          expression e';
-          expression e''
-      | Texp_send (e, _, eopt) -> 
-          expression e;
-          Option.iter ~f:expression eopt
-      | Texp_new (p, {loc}, clsdcl) -> 
-          record loc (Use (Kind.Class, p));
-          (* class_declaration_ clsdcl *) (* CR jfuruse: it is not typedtree, so not sourcee related? *)
-      | Texp_instvar (p, p', {loc}) -> 
-          (* CR jfuruse: p and p' share the same position?!?! *)
-          record loc (Use (Kind.Class, p));
-          record loc (Use (Kind.Value, p'))
-      | Texp_setinstvar (p, p', {loc}, e) -> 
-          (* CR jfuruse: p and p' share the same position?!?! *)
-          record loc (Use (Kind.Class, p));
-          record loc (Use (Kind.Value, p'));
-          expression e
-      | Texp_override (p, p_loc_e_list) -> 
-          (* CR jfuruse: no loc *)
-          let loc = e.exp_loc in
-          record loc (Use (Kind.Value, p));
-          List.iter (fun (p, {loc}, e) ->
-            record loc (Use (Kind.Type, p));
-            expression e) p_loc_e_list
-      | Texp_letmodule (id, {loc}, mexp, e) ->
-          record loc (Str (A.AStr_module (id, A.module_expr mexp)));
-          module_expr mexp;
-          expression e
-      | Texp_assertfalse -> ()
-      | Texp_assert e 
-      | Texp_lazy e
-        -> expression e
-      | Texp_poly (e, core_ty) ->  expression e; core_type core_ty
-      | Texp_object (clstr, _names) -> class_structure clstr
-      | Texp_newtype (_name (* CR jfuruse: todo *), e) -> expression e
-      | Texp_pack mexp -> module_expr mexp
-
-    and pattern p =
-      record p.pat_loc (Type (p.pat_type, p.pat_env, `Pattern));
-      (* CR jfuruse: pat_extra *)
-(*
-and pat_extra =
-  | Tpat_constraint of core_type
-  | Tpat_type of Path.t * Longident.t loc
-  | Tpat_unpack
-*)
-      match p.pat_desc with 
-      | Tpat_any -> ()
-      | Tpat_var (id, {loc}) -> 
-          record loc (Str (A.AStr_value id))
-      | Tpat_alias (p, id, {loc}) -> 
-          pattern p;
-          record loc (Str (A.AStr_value id))
-      | Tpat_constant _ -> ()
-      | Tpat_tuple ps -> List.iter pattern ps
-      | Tpat_construct (p, {loc}, _, ps, _) -> 
-          record loc (Use (Kind.Type, p));
-          List.iter pattern ps
-      | Tpat_variant (_, popt, _) -> 
-          Option.iter ~f:pattern popt
-      | Tpat_record (p_loc_ldesc_p_list, _) -> 
-          List.iter (fun (path, {loc}, _, p) ->
-            record loc (Use (Kind.Type, path));
-            pattern p) p_loc_ldesc_p_list
-      | Tpat_array ps -> List.iter pattern ps
-      | Tpat_or (p1, p2, _) -> 
-          pattern p1; pattern p2
-      | Tpat_lazy p -> pattern p
-
-    and type_declaration td = 
-      (* CR jfuruse: parameters now have positions! *)
-      match td.typ_kind with
-      | Ttype_abstract -> ()
-      | Ttype_variant defs ->
-          List.iter (fun (id, {loc}, core_types, _loc') ->
-            record loc (Str (A.AStr_type id));
-            List.iter core_type core_types) defs
-      | Ttype_record defs ->
-          List.iter (fun (id, {loc}, _, coty, _loc') -> 
-            record loc (Str (A.AStr_type id));
-            core_type coty) defs
-
-(*
-and type_declaration =
-  { typ_params: string loc option list;
-    typ_type : Types.type_declaration;
-    typ_cstrs: (core_type * core_type * Location.t) list;
-    typ_kind: type_kind;
-    typ_private: private_flag;
-    typ_manifest: core_type option;
-    typ_variance: (bool * bool) list;
-    typ_loc: Location.t }
-
-and type_kind =
-    Ttype_abstract
-  | Ttype_variant of (Ident.t * string loc * core_type list * Location.t) list
-  | Ttype_record of
-      (Ident.t * string loc * mutable_flag * core_type * Location.t) list
-*)
-    and exception_declaration ed = 
-      List.iter core_type ed.exn_params
-
-    and module_expr mexp = 
-      record mexp.mod_loc (Mod_type mexp.mod_type);
-      module_expr_desc mexp.mod_desc
-
-    and module_expr_desc = function
-      | Tmod_ident (path, {loc}) ->
-          record loc (Use (Kind.Module path))
-      | Tmod_structure str -> structure str
-      | Tmod_functor (id, {loc}, _mty, mexp) -> (* CR jfuruse: _mty *)
-          record loc (Functor_parameter id);
-          module_expr mexp
-      | Tmod_apply (m1, m2, _mcoercion) -> (* CR jfuruse: _mcoercion *)
-          module_expr m1;
-          module_expr m2
-      | Tmod_constraint (m, mty, _mty_c, _m_c) -> (* CR jfuruse: coercions *)
-          module_expr m; module_type mty
-      | Tmod_unpack (e, mty) ->
-          expresion e; module_type mty
-
-    and module_type mty = 
-      record loc (Mod_type mty);
-      match mty.mty_desc with
-      | Tmty_ident (path, {loc}) -> 
-          record loc (Use (Kind.Module_type, path))
-      | Tmty_signature sg -> signature sg
-      | Tmty_functor (id, {loc}, mty, mty') -> 
-          record loc (Functor_parameter id);
-          module_type mty;
-          module_type mty'
-      | Tmty_with (mty, withs) ->
-          module_type mty;
-          List.iter (fun (path, {loc}, with_constraint) ->
-            match with_constraint with
-            | Twith_type td 
-            | Twith_typesubst td -> 
-                record loc (Use (Kind.Type, path));
-                type_declaration td
-            | Twith_module (path', {loc=loc'}) 
-            | Twith_modsubst (path', {loc=loc'}) ->
-                record loc (Use (Kind.Module, path));
-                record loc' (Use (Kind.Module, path'))) withs
-      | Tmty_typeof mexp -> 
-          module_expr mexp
-
-    and class_declaration = class_infos class_expr
-    and class_type_declaration = class_infos class_type 
-
-    and class_infos f ci =
-(*      
-  { ci_virt: virtual_flag;
-    ci_params: string loc list * Location.t;
-    ci_id_name : string loc;
-    ci_id_class: Ident.t;
-    ci_id_class_type : Ident.t;
-    ci_id_object : Ident.t;
-    ci_id_typesharp : Ident.t;
-    ci_expr: 'a;
-    ci_decl: Types.class_declaration;
-    ci_type_decl : Types.class_type_declaration;
-    ci_variance: (bool * bool) list;
-    ci_loc: Location.t }
-*)
-      f ci.ci_expr
-
-    and class_expr ce =  
-      (* CR jfuruse: record ce.cl_loc (Class_type ce.cl_type) *)
-      class_type ce.cl_type;
-      match ce.class_expr_desc with
-      | Tcl_ident (path, {loc}, cotypes) ->
-          record loc (Use (Kind.Class, path));
-          List.iter core_type cotypes
-      | Tcl_structure cstr -> class_structure cstr
-      | Tcl_fun (_, pat, _args, cexp, _) -> 
-          pattern pat; 
-          (* CR jfuruse: args are in pat? *)
-          class_expr cexp
-      | Tcl_apply (cexp, args) -> 
-          class_expr cexp;
-          List.iter (fun (_, eopt, _) -> Option.iter ~f:expression eopt) args
-      | Tcl_let (_, pes, _args, cexp) -> 
-          (* CR jfuruse: args are in pes? *)
-          List.iter (fun (pat, exp) -> pattern pat; expression exp) pes;
-          class_expr cexp
-      | Tcl_constraint (cexp, ctyopt, _ (* string list *), _ (* string list *), _) ->
-          class_expr cexp;
-          Option.iter ~f:class_type ctyopt
-
-    and class_type cty =
-      (* CR jfuruse: record cty.cltyp_loc (Class_type cty.cltyp_type); *)
-      match cty.cltyp_desc with
-      | Tcty_constr (path, {loc}, cotys) -> 
-          record loc (Use (Kind.Class, path));
-          List.iter core_type cotys
-      | Tcty_signature csi -> class_signature csi
-      | Tcty_fun (_, coty, clty) -> core_type coty; class_type clty
-
-    and class_signature csg = 
-(*       CR jfuruse: todo
-      {
-    csig_self : core_type;
-    csig_fields : class_type_field list;
-    csig_type : Types.class_signature;
-    csig_loc : Location.t;
-  }
-*)
-      () 
-
-(*
-and class_type_field = {
-    ctf_desc : class_type_field_desc;
-    ctf_loc : Location.t;
-  }
-
-and class_type_field_desc =
-    Tctf_inher of class_type
-  | Tctf_val of (string * mutable_flag * virtual_flag * core_type)
-  | Tctf_virt  of (string * private_flag * core_type)
-  | Tctf_meth  of (string * private_flag * core_type)
-  | Tctf_cstr  of (core_type * core_type)
-*)
-
-    and core_type coty = match coty.ctyp_desc with
-      | Ttyp_any -> ()
-      | Ttyp_var _var -> () (* CR jfuruse: todo *)
-      | Ttyp_arrow (_, coty1, coty2) -> core_type coty1; core_type coty2
-      | Ttyp_tuple cotys -> List.iter core_type cotys
-      | Ttyp_constr (path, {loc}, cotys) -> 
-          record loc (Use (Kind.Type, path));
-          List.iter core_type cotys
-(*
-      | Ttyp_object of core_field_type list
-      | Ttyp_class of Path.t * Longident.t loc * core_type list * label list
-      | Ttyp_alias of core_type * string
-      | Ttyp_variant of row_field list * bool * label list option
-      | Ttyp_poly of string list * core_type
-      | Ttyp_package of package_type
-*)
-      | _ -> prerr_endline "TODO"; () (* CR jfuruse: todo *)
-
-    and class_structure _cstr = () (* CR jfuruse: todo *)
+      method! pattern p = 
+        record p.pat_loc (Type (p.pat_type, p.pat_env, `Pattern));
+        super#pattern p
+    end
   end
 
-  let recorded () = Hashtbl.fold (fun k (_,vs) st -> 
+  let get_recorded () = Hashtbl.fold (fun k (_,vs) st -> 
     List.map (fun v -> k,v) vs @ st) recorded []
 
+  let record_structure str = 
+    Hashtbl.clear recorded;
+    let o = new Record.fold in
+    ignore (o#structure str);
+    get_recorded ()
+
+  let record_signature sg = 
+    Hashtbl.clear recorded;
+    let o = new Record.fold in
+    ignore (o#signature sg);
+    get_recorded ()
+
   let string_of_at = function
     | `Expr -> "Expr"
     | `Pattern -> "Pattern"
   val structure : Typedtree.structure -> module_expr
   val signature : Typedtree.signature -> module_expr
 
+  val flatten : structure -> structure
+
   open Format
   val format_module_expr : formatter -> module_expr -> unit
   val format_structure : formatter -> structure -> unit
 
 module Annot : sig
   type t =
+    | Use of Kind.t * Path.t
     | Type of Types.type_expr * Env.t * [`Expr | `Pattern | `Val]
+    | Mod_type of Types.module_type
     | Str of Abstraction.structure_item 
-    | Use of Kind.t * Path.t
     | Module of Abstraction.module_expr
     | Functor_parameter of Ident.t
     | Non_expansive of bool
-    | Mod_type of Types.module_type
 
   val record : Location.t -> t -> unit
     
      at the location [loc]. [ty] must be a constructor type, otherwise,
      an error message is printed out. 
   *)
+(*
   val record_constr_type_use : Location.t -> Types.type_expr -> unit
   val record_module_expr_def : Location.t -> Ident.t -> Typedtree.module_expr -> unit
   val record_module_expr_use : Location.t -> Typedtree.module_expr -> unit
+*)
+(*
   val record_include :
     Location.t -> Typedtree.module_expr -> (* Types.signature -> *) unit
-(*
   val record_include_sig :
     Location.t -> Typedtree.module_type -> Types.signature -> unit
+  val record_module_type_def : Location.t -> Ident.t -> Typedtree.module_type -> unit
 *)
-  val record_module_type_def : Location.t -> Ident.t -> Typedtree.module_type -> unit
-  val recorded : unit -> (Location.t * t) list
+
+  val record_structure : Typedtree.structure -> (Location.t * t) list
+  val record_signature : Typedtree.signature -> (Location.t * t) list
 
   val format : Format.formatter -> t -> unit
   val summary : Format.formatter -> t -> unit
 
 open Spot
 open Spoteval
-    
+open Cmt_format
+
+type file = {
+  cmt            : Cmt_format.cmt_infos;
+  path           : string;
+  flat           : Abstraction.structure;
+  top            : Abstraction.structure;
+  id_def_regions : (Ident.t, Region.t) Hashtbl.t;
+}
+
+let source_path_of_cmt file = match file.cmt_sourcefile with 
+  | Some f -> Filename.concat file.cmt_builddir f
+  | None -> assert false
+
+let dump_file file =
+  eprintf "@[<v2>{ module= %S;@ path= %S;@ source= %S;@ builddir= %S;@ loadpath= [ @[%a@] ];@ argv= [| @[%a@] |];@ ... }@]@."
+    file.cmt.cmt_modname
+    file.path
+    (match file.cmt.cmt_sourcefile with Some s -> s | None -> "???")
+    file.cmt.cmt_builddir
+    (Format.list ";@ " (fun ppf s -> fprintf ppf "%S" s)) file.cmt.cmt_loadpath
+    (Format.list ";@ " (fun ppf s -> fprintf ppf "%S" s)) (Array.to_list file.cmt.cmt_args)
+
+(* xxx.{ml,cmo,cmx,spot} => xxx.spot 
+   xxx.{mli,cmi,spit} => xxx.spit *)
+let cmt_of_file file =
+  let dirname, filename =
+    try
+      let slash = String.rindex file '/' in
+      Some (String.sub file 0 slash),
+      String.sub file (slash + 1) (String.length file - slash - 1)
+    with
+    | Not_found -> None, file
+  in
+  let filename =
+    match Filename.split_extension filename with
+    | body, (".cmi" | ".mli" | ".cmti") -> body ^ ".cmti"
+    | body, _ -> body ^ ".cmt"
+  in
+  match dirname with
+  | None -> filename
+  | Some d -> Filename.concat d filename
+
+let abstraction_of_cmt cmt = match cmt.cmt_annots with
+  | Implementation str -> 
+      let loc_annots = Spot.Annot.record_structure str in
+      begin match Abstraction.structure str with
+      | Abstraction.AMod_structure str -> str, loc_annots
+      | _ -> assert false
+      end
+  | Interface sg -> 
+      let loc_annots = Spot.Annot.record_signature sg in
+      begin match Abstraction.signature sg with
+      | Abstraction.AMod_structure str -> str, loc_annots
+      | _ -> assert false
+      end
+  | Partial_implementation _parts | Partial_interface _parts ->
+      assert false
+  | _ -> assert false
+
 module Make(Spotconfig : Spotconfig_intf.S) = struct
-  include Spot.File
-
-  type file = {
-    path : string; (* "" means no source *)
-    cwd : string;
-    load_paths : string list;
-    version : string * string;
-    argv : string array;
-    top : Abstraction.structure;
-    flat : Abstraction.structure;
-    rannots : Annot.t Regioned.t list;
-    tree : Tree.t lazy_t;
-    id_def_regions : (Ident.t, Region.t) Hashtbl.t;
-  }
-
-  let dump_file file =
-    eprintf "@[<2>{ path= %S;@ cwd= %S;@ load_paths= [ @[%a@] ];@ version= %S,%S;@ argv= [| @[%a@] |]; ... }@]@."
-      (match file.path with 
-      | "" -> "NONE"
-      | s -> s)
-      file.cwd
-      (Format.list "; " (fun ppf s -> fprintf ppf "%S" s)) file.load_paths
-      (fst file.version) (snd file.version)
-      (Format.list "; " (fun ppf s -> fprintf ppf "%S" s)) (Array.to_list file.argv)
-
-  (* xxx.{ml,cmo,cmx,spot} => xxx.spot 
-     xxx.{mli,cmi,spit} => xxx.spit
-   *)        
-  let spot_of_file file =
-    let dirname, filename =
-      try
-        let slash = String.rindex file '/' in
-        Some (String.sub file 0 slash),
-        String.sub file (slash + 1) (String.length file - slash - 1)
-      with
-      | Not_found -> None, file
-    in
-    let filename =
-      match Filename.split_extension filename with
-      | body, (".cmi" | ".mli" | ".spit") -> body ^ ".spit"
-      | body, _ -> body ^ ".spot"
-    in
-    match dirname with
-    | None -> filename
-    | Some d -> Filename.concat d filename
-
   open Abstraction
 
   module Load : sig
-    exception Old_spot of string (* spot *) * string (* source *)
+  exception Old_cmt of string (* cmt *) * string (* source *)
     val load : load_paths:string list -> string -> file
     val load_module : ?spit:bool -> load_paths:string list -> string -> file
   end = struct
 
-    let check_time_stamp ~spot source =
-      let stat_spot = Unix.stat spot in
+    let check_time_stamp ~cmt source =
+      let stat_cmt = Unix.stat cmt in
       let stat_source = Unix.stat source in
-        (* Needs = : for packed modules, .spot and the source .cmo are written 
+        (* Needs = : for packed modules, .cmt and the source .cmo are written 
            almost at the same moment. *)
-      stat_spot.Unix.st_mtime >= stat_source.Unix.st_mtime
+      stat_cmt.Unix.st_mtime >= stat_source.Unix.st_mtime
 
-    let find_alternative_source ~spot source =
+    let find_alternative_source ~cmt source =
         (* if [source] is not found, we try finding files with the same basename
            in
-           - the directory of [spot]
-           - the directory of [spot] points to (if [spot] is symlink)
+           - the directory of [cmt]
+           - the directory of [cmt] points to (if [cmt] is symlink)
          *)
-        let source_base = Filename.basename source in
+      let source_base = Filename.basename source in
       let source_dirs =
-          Filename.dirname spot ::
+          Filename.dirname cmt ::
           begin 
-            let stat_spot = Unix.lstat spot in
-            if stat_spot.Unix.st_kind = Unix.S_LNK then
-              [ Filename.dirname (Unix.readlink spot) ]
+            let stat_cmt = Unix.lstat cmt in
+            if stat_cmt.Unix.st_kind = Unix.S_LNK then
+              [ Filename.dirname (Unix.readlink cmt) ]
             else []
           end
         in
           (List.map (fun d -> 
             Filename.concat d source_base) source_dirs)
 
-    let load_spot_file file =
-      let ic = open_in_bin file in
-      let magic_number_in_file = 
-        let length = String.length magic_number in
-        let buffer = String.create length in
-        really_input ic buffer 0 length;
-        buffer
-      in
-      if magic_number_in_file <> magic_number then 
-        failwith (Printf.sprintf "Not a spot file: %s" file);
-      let file_version : string * string = input_value ic in
-      if (Spot.ocaml_version, Spot.version) <> file_version then begin
-        failwith 
-	  (Printf.sprintf "Incompatible spot file version %s for ocaml %s (must be %s for ocaml %s)" 
-              (fst file_version) (snd file_version)
-	      Spot.version Spot.ocaml_version);
-      end;
-      let v : t = input_value ic in
-      close_in ic;
-      file_version, v
-    ;;
+    let load_cmt_file file = snd (Cmt_format.read file)
 
     let load_directly path : file =
-      Debug.format "spot loading from %s@." path;
-      let version, file = load_spot_file path in
-      let rannots = 
-        match 
-          List.find_map_opt 
-            (function Annots v -> Some v | _ -> None) file 
-        with 
-        | Some annots -> annots
-        | None -> failwith "no annotations found"
-      in
-      let rannots = 
-        List.map (fun (r, annot) ->
-          { Regioned.region = Region.of_parsing r;
-            value = annot }) rannots
-      in
-      let source_path =
-        match 
-          List.find_map_opt 
-            (function Source_path v -> Some v | _ -> None) 
-            file 
-        with
-        | Some source_path -> source_path
-        | None -> failwith "no source path found"
-      in
+      Debug.format "cmt loading from %s@." path;
+      match load_cmt_file path with
+      | Some cmt -> 
+          let str, loc_annots = abstraction_of_cmt cmt in
+          let path = source_path_of_cmt cmt in
+          { cmt; path;
+            top = str;
+            flat = Spot.Abstraction.flatten str;
+            id_def_regions = 
+              Hashtbl.of_list 1023 begin
+                List.filter_map (fun (loc, annot) -> match annot with
+                | Annot.Str sitem ->
+                    begin match Abstraction.ident_of_structure_item sitem with
+                    | None -> None
+                    | Some (_kind, id) -> 
+                        Some (id, Region.of_parsing loc)
+                    end
+                | _ -> None) loc_annots
+              end
+          }
+      | None -> failwith (sprintf "load_directly failed: %s" path)
 
-      (* fix source_path *)
-      let source_path =
-        match source_path with
-        | None -> ""
-        | Some source_path ->
-            if Sys.file_exists source_path then source_path
-            else
-              try 
-                let path = find_alternative_source ~spot:path source_path in
-                Debug.format "Found an alternative source: %s@." path;
-                path
-              with
-              | Not_found -> source_path
-      in
-
-      let cwd = 
-        match List.find_map_opt (function Cwd v -> Some v | _ -> None) file with
-        | Some cwd -> cwd
-        | None -> failwith "no cwd found"
-      in
-      let load_paths =
-        match List.find_map_opt (function Load_paths v -> Some v | _ -> None) file with
-        | Some load_paths -> load_paths
-        | None -> failwith "no load paths found"
-      in
-      let top = 
-        match List.find_map_opt (function Top v -> Some v | _ -> None) file with
-        | Some (Some top) -> top
-        | Some None -> [] (* Error before writing any top element *)
-        | None -> failwith "no top structure found"
-      in
-      let argv =
-        match List.find_map_opt (function Argv v -> Some v | _ -> None) file with
-        | Some argv -> argv
-        | None -> failwith "no argv found"
-      in
-      let tree =
-        lazy begin
-          List.fold_left Tree.add Tree.empty rannots
-        end
-      in
-      let id_def_regions = 
-        let tbl = Hashtbl.create 107 in
-        List.iter (fun { Regioned.region = loc; value = annot } ->
-          match annot with
-          | Annot.Str ( Abstraction.Str_value id
-                      | Abstraction.Str_type id
-                      | Abstraction.Str_exception id
-                      | Abstraction.Str_modtype (id, _)
-                      | Abstraction.Str_class id
-                      | Abstraction.Str_cltype id   
-                      | Abstraction.Str_module (id, _) )  ->
-              Hashtbl.add tbl id loc
-          | Annot.Str ( Abstraction.Str_include _ ) -> ()
-          | Annot.Functor_parameter id ->
-              Hashtbl.add tbl id loc
-          | Annot.Type _ | Annot.Use _ | Annot.Module _ 
-          | Annot.Non_expansive _ | Annot.Mod_type _ -> ()) rannots;
-        tbl
-      in
-      let flat = 
-        (* flat is created NOT from top but from rannots, since top
-           may not exist when the compilation fails *)
-        List.fold_left (fun st { Regioned.value = annot; _ } -> 
-          match annot with
-          | Annot.Str sitem -> sitem :: st
-          | Annot.Functor_parameter id ->
-              (* CR: fake a sitem. quite ad-hoc *)
-              Str_module (id, Mod_ident (Path.Pdot (Path.Pident id, 
-                                                    "parameter", 
-                                                    -2))) 
-              :: st
-          | Annot.Type _ 
-          | Annot.Use _
-          | Annot.Module _ 
-          | Annot.Non_expansive _ 
-          | Annot.Mod_type _ -> st ) [] rannots
-      in
-      { version = version;
-        path = source_path;
-        cwd = cwd;
-        load_paths = List.map (fun load_path -> cwd ^/ load_path) load_paths;
-        argv = argv;
-        top = top;
-        flat = flat;
-        rannots = rannots;
-        tree = tree;
-        id_def_regions = id_def_regions;
-      }
-
-    exception Old_spot of string (* spot *) * string (* source *)
+    exception Old_cmt of string (* cmt *) * string (* source *)
 
     (* CR jfuruse: exception *)
     (* CRv2 jfuruse: add and check cache time stamp *)
                 begin match file.path with 
                 | "" -> ()
                 | source -> 
-                    if not (check_time_stamp ~spot:path source) then 
+                    if not (check_time_stamp ~cmt:path source) then 
                       if Spotconfig.strict_time_stamp then 
-                        raise (Old_spot (path, source))
+                        raise (Old_cmt (path, source))
                       else
-                        eprintf "Warning: source %s is newer than the spot@." source
+                        eprintf "Warning: source %s is newer than the cmt@." source
                 end;
                 Hashtbl.replace cache path file;
                 file
               with
               | Not_found ->
-                  failwith (Printf.sprintf "failed to find spot file %s" path)
+                  failwith (Printf.sprintf "failed to find cmt file %s" path)
 
     let find_in_path load_paths body ext =
         let body_ext = body ^ ext in
       in
       try find_in_path load_paths body_ext with Not_found ->
       (* We do not give up yet.
-         .spot file is not found, 
-         but we still find a .cmi which is sym-linked to the original directory with .spot
+         .cmt file is not found, 
+         but we still find a .cmi which is sym-linked to the original directory with .cmt
       *)
       let cminame = body ^ ".cmi" in
         try
         let stat = Unix.lstat cmipath in
         if stat.Unix.st_kind = Unix.S_LNK then begin
           let cmipath = Filename.dirname cmipath ^/ Unix.readlink cmipath in
-          let spotpath = Filename.chop_extension cmipath ^ ext in
-          if Sys.file_exists spotpath then begin
-            Debug.format "Found an alternative %s: %s@." ext spotpath;
-              spotpath 
-            end else failwith (Printf.sprintf "spot file not found: %s, neither in %s" body_ext spotpath)
+          let cmtpath = Filename.chop_extension cmipath ^ ext in
+          if Sys.file_exists cmtpath then begin
+            Debug.format "Found an alternative %s: %s@." ext cmtpath;
+              cmtpath 
+            end else failwith (Printf.sprintf "cmt file not found: %s, neither in %s" body_ext cmtpath)
           end else raise Not_found
         with
         | (Failure _ as e) -> raise e
-        | _ -> failwith (Printf.sprintf "spot file not found: %s" body_ext)
+        | _ -> failwith (Printf.sprintf "cmt file not found: %s" body_ext)
       
 
-    let load ~load_paths spotname : file =
-      Debug.format "@[<2>spot searching %s in@ paths [@[%a@]]@]@." 
-          spotname
+    let load ~load_paths cmtname : file =
+      Debug.format "@[<2>cmt searching %s in@ paths [@[%a@]]@]@." 
+          cmtname
           (Format.list "; " (fun ppf x -> fprintf ppf "%S" x)) 
           load_paths;
-        let body, ext = Filename.split_extension spotname in
+        let body, ext = Filename.split_extension cmtname in
       let path = find_in_path load_paths body ext in
       load_directly_with_cache path
 
-    let load ~load_paths spotname : file =
-      let alternate_spotname = 
-        if Filename.is_relative spotname then None
+    let load ~load_paths cmtname : file =
+      let alternate_cmtname = 
+        if Filename.is_relative cmtname then None
         else
-          Option.bind (Dotfile.find_and_load (Filename.dirname spotname)) 
+          Option.bind (Dotfile.find_and_load (Filename.dirname cmtname)) 
             (fun (found_dir, dotfile) ->
               Option.map dotfile.Dotfile.build_dir ~f:(fun build_dir ->
                 let length_found_dir = String.length found_dir in
                 let found_dir' = 
-                  String.sub spotname 0 length_found_dir
+                  String.sub cmtname 0 length_found_dir
                 in
-                let rel_spotname =
-                  String.sub spotname 
+                let rel_cmtname =
+                  String.sub cmtname 
                     (length_found_dir + 1)
-                    (String.length spotname - length_found_dir - 1)
+                    (String.length cmtname - length_found_dir - 1)
                 in
                 assert (found_dir = found_dir');
                 let dir = 
                     Filename.concat found_dir build_dir
                   else build_dir
                 in
-                Filename.concat dir rel_spotname))
+                Filename.concat dir rel_cmtname))
       in
-      try load ~load_paths spotname with
+      try load ~load_paths cmtname with
       | e -> 
-          match alternate_spotname with
-          | Some spotname -> load ~load_paths spotname
+          match alternate_cmtname with
+          | Some cmtname -> load ~load_paths cmtname
           | None -> raise e
 
     (* CR jfuruse: searching algorithm must be reconsidered *)        
     let load_module ?(spit=false) ~load_paths name =
-      let spotname = name ^ if spit then ".spit" else ".spot" in
+      let cmtname = name ^ if spit then ".spit" else ".cmt" in
       try
-        load ~load_paths spotname
+        load ~load_paths cmtname
       with
       | Failure s ->
-          let spitname = name ^ if spit then ".spot" else ".spit" in
+          let spitname = name ^ if spit then ".cmt" else ".spit" in
           Format.printf "%s load failed. Try to load %s@."
-            spotname spitname;
+            cmtname spitname;
           try
             load ~load_paths spitname
           with
 
   let empty_env file =
     { Env.path = file.path;
-      cwd = file.cwd;
-      load_paths = file.load_paths;
+      cwd = file.cmt.cmt_builddir;
+      load_paths = file.cmt.cmt_loadpath;
       binding = Binding.empty }
 
   let invalid_env file =
     { Env.path = file.path;
-      cwd = file.cwd;
-      load_paths = file.load_paths;
+      cwd = file.cmt.cmt_builddir;
+      load_paths = file.cmt.cmt_loadpath;
       binding = Binding.invalid }
       
   type result =
           (* CR jfuruse: loading twice... *)
           Debug.format "Finding %a@." PIdent.format pid;
           let file = 
-            Load.load ~load_paths:[] (spot_of_file pid.PIdent.path) 
+            Load.load ~load_paths:[] (cmt_of_file pid.PIdent.path) 
           in
           match pid.PIdent.ident with
           | None -> File_itself (* the whole file *)
       | Value.Structure (id, _, _)  -> id, find_loc id
       | Value.Closure (id, _, _, _, _) -> id, find_loc id
       | Value.Error (Failure _ as e) -> raise e
-      | Value.Error (Load.Old_spot _ as exn) -> raise exn
+      | Value.Error (Load.Old_cmt _ as exn) -> raise exn
       | Value.Error exn -> raise exn
     in
     eval_and_find path
   let _ = Eval.str_of_global_ident := str_of_global_ident
 
   let eval_packed env file =
-    let f = Load.load ~load_paths:[""] (spot_of_file (env.Env.cwd ^/ file)) in
+    let f = Load.load ~load_paths:[""] (cmt_of_file (env.Env.cwd ^/ file)) in
     Value.Structure ({ PIdent.path = f.path; ident = None },
                     Eval.structure (empty_env f) f.top,
                     None (* packed has no .mli *))
 
   let _ = Eval.packed := eval_packed
 
+(*
   let dump_elem = function
     | Source_path (Some s) -> eprintf "Source_path: %s@." s
     | Source_path None -> eprintf "Source_path: None@." 
     | Annots _ -> eprintf "Annots [...]@."
 
   let dump_elems elems = List.iter dump_elem elems
+*)
 end
 
 open Spot
 open Spoteval
+open Cmt_format
+open Spoteval
 
+type file = {
+  cmt            : Cmt_format.cmt_infos;
+  path           : string;
+  flat           : Abstraction.structure;
+  top            : Abstraction.structure;
+  id_def_regions : (Ident.t, Region.t) Utils.Hashtbl.t;
+}
+
+val source_path_of_cmt : cmt_infos -> string
+val dump_file : file -> unit
+val cmt_of_file : string -> string
+val abstraction_of_cmt : cmt_infos -> Abstraction.structure * (Location.t * Annot.t) list
+
+module Make(Spotconfig : Spotconfig_intf.S) : sig
+  module Load : sig
+    exception Old_cmt of string * string
+    val load : load_paths:string list -> string -> file
+    val load_module : ?spit:bool -> load_paths:string list -> string -> file (* CR jfuruse: spit *)
+  end
+  exception Old_cmt of string * string
+  val load : load_paths:string list -> string -> file
+  val load_module : ?spit:bool -> load_paths:string list -> string -> file (* CR jfuruse: spit *)
+  val empty_env   : file -> Env.t
+  val invalid_env : file -> Env.t
+  type result = File_itself | Found_at of Region.t | Predefined
+  val find_path_in_flat : file -> Kind.t * Path.t -> PIdent.t * result
+  val str_of_global_ident : load_paths:string list -> Ident.t -> string * Value.structure
+  val eval_packed : Env.t -> string -> Value.t
+end
+
+(*
 module Make( Spotconfig : Spotconfig_intf.S ) : sig
 
   type elem = 
-      Spot.File.elem =
+      File.elem =
     | Argv of string array
     | Source_path of string option
     | Cwd of string
   val dump : source: string option -> string -> unit
   val dump_package : prefix: string -> source: string -> string list -> unit
 
-  (* loaded file *)    
   type file = {
     path : string; (* "" means no source *)
     cwd : string;
   val dump_elem : elem -> unit
   val dump_elems : elem list -> unit
 end
+*)
+open Asttypes
+open Types
+open Typedtree
+  
+class fold =
+  object ((o : 'self_type))
+    method string : string -> 'self_type = o#unknown
+    method ref :
+      'a. ('self_type -> 'a -> 'self_type) -> 'a ref -> 'self_type =
+      fun _f_a { contents = _x } -> let o = _f_a o _x in o
+    method option :
+      'a. ('self_type -> 'a -> 'self_type) -> 'a option -> 'self_type =
+      fun _f_a -> function | None -> o | Some _x -> let o = _f_a o _x in o
+    method list :
+      'a. ('self_type -> 'a -> 'self_type) -> 'a list -> 'self_type =
+      fun _f_a ->
+        function
+        | [] -> o
+        | _x :: _x_i1 -> let o = _f_a o _x in let o = o#list _f_a _x_i1 in o
+    method int : int -> 'self_type = o#unknown
+    method bool : bool -> 'self_type = function | false -> o | true -> o
+    method with_constraint : with_constraint -> 'self_type =
+      function
+      | Twith_type _x -> let o = o#type_declaration _x in o
+      | Twith_module (_x, _x_i1) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#unknown) _x_i1 in o
+      | Twith_typesubst _x -> let o = o#type_declaration _x in o
+      | Twith_modsubst (_x, _x_i1) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#unknown) _x_i1 in o
+    method virtual_flag : virtual_flag -> 'self_type = o#unknown
+    method value_description : value_description -> 'self_type =
+      fun { val_desc = _x; val_val = _x_i1; val_prim = _x_i2; val_loc = _x_i3
+        } ->
+        let o = o#core_type _x in
+        let o = o#unknown _x_i1 in
+        let o = o#list (fun o -> o#string) _x_i2 in
+        let o = o#unknown _x_i3 in o
+    method type_kind : type_kind -> 'self_type =
+      function
+      | Ttype_abstract -> o
+      | Ttype_variant _x ->
+          let o =
+            o#list
+              (fun o (_x, _x_i1, _x_i2, _x_i3) ->
+                 let o = o#unknown _x in
+                 let o = o#loc (fun o -> o#string) _x_i1 in
+                 let o = o#list (fun o -> o#core_type) _x_i2 in
+                 let o = o#unknown _x_i3 in o)
+              _x
+          in o
+      | Ttype_record _x ->
+          let o =
+            o#list
+              (fun o (_x, _x_i1, _x_i2, _x_i3, _x_i4) ->
+                 let o = o#unknown _x in
+                 let o = o#loc (fun o -> o#string) _x_i1 in
+                 let o = o#mutable_flag _x_i2 in
+                 let o = o#core_type _x_i3 in let o = o#unknown _x_i4 in o)
+              _x
+          in o
+    method type_expr : type_expr -> 'self_type = o#unknown
+    method type_declaration : type_declaration -> 'self_type =
+      fun
+        {
+          typ_params = _x;
+          typ_type = _x_i1;
+          typ_cstrs = _x_i2;
+          typ_kind = _x_i3;
+          typ_private = _x_i4;
+          typ_manifest = _x_i5;
+          typ_variance = _x_i6;
+          typ_loc = _x_i7
+        } ->
+        let o =
+          o#list (fun o -> o#option (fun o -> o#loc (fun o -> o#string))) _x in
+        let o = o#unknown _x_i1 in
+        let o =
+          o#list
+            (fun o (_x, _x_i1, _x_i2) ->
+               let o = o#core_type _x in
+               let o = o#core_type _x_i1 in let o = o#unknown _x_i2 in o)
+            _x_i2 in
+        let o = o#type_kind _x_i3 in
+        let o = o#private_flag _x_i4 in
+        let o = o#option (fun o -> o#core_type) _x_i5 in
+        let o =
+          o#list
+            (fun o (_x, _x_i1) ->
+               let o = o#bool _x in let o = o#bool _x_i1 in o)
+            _x_i6 in
+        let o = o#unknown _x_i7 in o
+    method structure_item_desc : structure_item_desc -> 'self_type =
+      function
+      | Tstr_eval _x -> let o = o#expression _x in o
+      | Tstr_value (_x, _x_i1) ->
+          let o = o#rec_flag _x in
+          let o =
+            o#list
+              (fun o (_x, _x_i1) ->
+                 let o = o#pattern _x in let o = o#expression _x_i1 in o)
+              _x_i1
+          in o
+      | Tstr_primitive (_x, _x_i1, _x_i2) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#string) _x_i1 in
+          let o = o#value_description _x_i2 in o
+      | Tstr_type _x ->
+          let o =
+            o#list
+              (fun o (_x, _x_i1, _x_i2) ->
+                 let o = o#unknown _x in
+                 let o = o#loc (fun o -> o#string) _x_i1 in
+                 let o = o#type_declaration _x_i2 in o)
+              _x
+          in o
+      | Tstr_exception (_x, _x_i1, _x_i2) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#string) _x_i1 in
+          let o = o#exception_declaration _x_i2 in o
+      | Tstr_exn_rebind (_x, _x_i1, _x_i2, _x_i3) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#string) _x_i1 in
+          let o = o#unknown _x_i2 in
+          let o = o#loc (fun o -> o#unknown) _x_i3 in o
+      | Tstr_module (_x, _x_i1, _x_i2) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#string) _x_i1 in
+          let o = o#module_expr _x_i2 in o
+      | Tstr_recmodule _x ->
+          let o =
+            o#list
+              (fun o (_x, _x_i1, _x_i2, _x_i3) ->
+                 let o = o#unknown _x in
+                 let o = o#loc (fun o -> o#string) _x_i1 in
+                 let o = o#module_type _x_i2 in
+                 let o = o#module_expr _x_i3 in o)
+              _x
+          in o
+      | Tstr_modtype (_x, _x_i1, _x_i2) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#string) _x_i1 in
+          let o = o#module_type _x_i2 in o
+      | Tstr_open (_x, _x_i1) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#unknown) _x_i1 in o
+      | Tstr_class _x ->
+          let o =
+            o#list
+              (fun o (_x, _x_i1, _x_i2) ->
+                 let o = o#class_declaration _x in
+                 let o = o#list (fun o -> o#string) _x_i1 in
+                 let o = o#virtual_flag _x_i2 in o)
+              _x
+          in o
+      | Tstr_class_type _x ->
+          let o =
+            o#list
+              (fun o (_x, _x_i1, _x_i2) ->
+                 let o = o#unknown _x in
+                 let o = o#loc (fun o -> o#string) _x_i1 in
+                 let o = o#class_type_declaration _x_i2 in o)
+              _x
+          in o
+      | Tstr_include (_x, _x_i1) ->
+          let o = o#module_expr _x in
+          let o = o#list (fun o -> o#unknown) _x_i1 in o
+    method structure_item : structure_item -> 'self_type =
+      fun { str_desc = _x; str_loc = _x_i1; str_env = _x_i2 } ->
+        let o = o#structure_item_desc _x in
+        let o = o#unknown _x_i1 in let o = o#unknown _x_i2 in o
+    method structure : structure -> 'self_type =
+      fun { str_items = _x; str_type = _x_i1; str_final_env = _x_i2 } ->
+        let o = o#list (fun o -> o#structure_item) _x in
+        let o = o#unknown _x_i1 in let o = o#unknown _x_i2 in o
+    method signature_item_desc : signature_item_desc -> 'self_type =
+      function
+      | Tsig_value (_x, _x_i1, _x_i2) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#string) _x_i1 in
+          let o = o#value_description _x_i2 in o
+      | Tsig_type _x ->
+          let o =
+            o#list
+              (fun o (_x, _x_i1, _x_i2) ->
+                 let o = o#unknown _x in
+                 let o = o#loc (fun o -> o#string) _x_i1 in
+                 let o = o#type_declaration _x_i2 in o)
+              _x
+          in o
+      | Tsig_exception (_x, _x_i1, _x_i2) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#string) _x_i1 in
+          let o = o#exception_declaration _x_i2 in o
+      | Tsig_module (_x, _x_i1, _x_i2) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#string) _x_i1 in
+          let o = o#module_type _x_i2 in o
+      | Tsig_recmodule _x ->
+          let o =
+            o#list
+              (fun o (_x, _x_i1, _x_i2) ->
+                 let o = o#unknown _x in
+                 let o = o#loc (fun o -> o#string) _x_i1 in
+                 let o = o#module_type _x_i2 in o)
+              _x
+          in o
+      | Tsig_modtype (_x, _x_i1, _x_i2) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#string) _x_i1 in
+          let o = o#modtype_declaration _x_i2 in o
+      | Tsig_open (_x, _x_i1) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#unknown) _x_i1 in o
+      | Tsig_include (_x, _x_i1) ->
+          let o = o#module_type _x in let o = o#unknown _x_i1 in o
+      | Tsig_class _x ->
+          let o = o#list (fun o -> o#class_description) _x in o
+      | Tsig_class_type _x ->
+          let o = o#list (fun o -> o#class_type_declaration) _x in o
+    method signature_item : signature_item -> 'self_type =
+      fun { sig_desc = _x; sig_env = _x_i1; sig_loc = _x_i2 } ->
+        let o = o#signature_item_desc _x in
+        let o = o#unknown _x_i1 in let o = o#unknown _x_i2 in o
+    method signature : signature -> 'self_type =
+      fun { sig_items = _x; sig_type = _x_i1; sig_final_env = _x_i2 } ->
+        let o = o#list (fun o -> o#signature_item) _x in
+        let o = o#unknown _x_i1 in let o = o#unknown _x_i2 in o
+    method row_field : row_field -> 'self_type =
+      function
+      | Ttag (_x, _x_i1, _x_i2) ->
+          let o = o#label _x in
+          let o = o#bool _x_i1 in
+          let o = o#list (fun o -> o#core_type) _x_i2 in o
+      | Tinherit _x -> let o = o#core_type _x in o
+    method row_desc : row_desc -> 'self_type = o#unknown
+    method rec_flag : rec_flag -> 'self_type = o#unknown
+    method private_flag : private_flag -> 'self_type = o#unknown
+    method pattern_desc : pattern_desc -> 'self_type =
+      function
+      | Tpat_any -> o
+      | Tpat_var (_x, _x_i1) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#string) _x_i1 in o
+      | Tpat_alias (_x, _x_i1, _x_i2) ->
+          let o = o#pattern _x in
+          let o = o#unknown _x_i1 in
+          let o = o#loc (fun o -> o#string) _x_i2 in o
+      | Tpat_constant _x -> let o = o#constant _x in o
+      | Tpat_tuple _x -> let o = o#list (fun o -> o#pattern) _x in o
+      | Tpat_construct (_x, _x_i1, _x_i2, _x_i3, _x_i4) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#unknown) _x_i1 in
+          let o = o#constructor_description _x_i2 in
+          let o = o#list (fun o -> o#pattern) _x_i3 in
+          let o = o#bool _x_i4 in o
+      | Tpat_variant (_x, _x_i1, _x_i2) ->
+          let o = o#label _x in
+          let o = o#option (fun o -> o#pattern) _x_i1 in
+          let o = o#ref (fun o -> o#row_desc) _x_i2 in o
+      | Tpat_record (_x, _x_i1) ->
+          let o =
+            o#list
+              (fun o (_x, _x_i1, _x_i2, _x_i3) ->
+                 let o = o#unknown _x in
+                 let o = o#loc (fun o -> o#unknown) _x_i1 in
+                 let o = o#label_description _x_i2 in
+                 let o = o#pattern _x_i3 in o)
+              _x in
+          let o = o#closed_flag _x_i1 in o
+      | Tpat_array _x -> let o = o#list (fun o -> o#pattern) _x in o
+      | Tpat_or (_x, _x_i1, _x_i2) ->
+          let o = o#pattern _x in
+          let o = o#pattern _x_i1 in
+          let o = o#option (fun o -> o#row_desc) _x_i2 in o
+      | Tpat_lazy _x -> let o = o#pattern _x in o
+    method pattern : pattern -> 'self_type =
+      fun
+        {
+          pat_desc = _x;
+          pat_loc = _x_i1;
+          pat_extra = _x_i2;
+          pat_type = _x_i3;
+          pat_env = _x_i4
+        } ->
+        let o = o#pattern_desc _x in
+        let o = o#unknown _x_i1 in
+        let o =
+          o#list
+            (fun o (_x, _x_i1) ->
+               let o = o#pat_extra _x in let o = o#unknown _x_i1 in o)
+            _x_i2 in
+        let o = o#type_expr _x_i3 in let o = o#unknown _x_i4 in o
+    method pat_extra : pat_extra -> 'self_type =
+      function
+      | Tpat_constraint _x -> let o = o#core_type _x in o
+      | Tpat_type (_x, _x_i1) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#unknown) _x_i1 in o
+      | Tpat_unpack -> o
+    method partial : partial -> 'self_type =
+      function | Partial -> o | Total -> o
+    method package_type : package_type -> 'self_type =
+      fun
+        {
+          pack_name = _x;
+          pack_fields = _x_i1;
+          pack_type = _x_i2;
+          pack_txt = _x_i3
+        } ->
+        let o = o#unknown _x in
+        let o =
+          o#list
+            (fun o (_x, _x_i1) ->
+               let o = o#loc (fun o -> o#unknown) _x in
+               let o = o#core_type _x_i1 in o)
+            _x_i1 in
+        let o = o#unknown _x_i2 in
+        let o = o#loc (fun o -> o#unknown) _x_i3 in o
+    method override_flag : override_flag -> 'self_type = o#unknown
+    method optional : optional -> 'self_type =
+      function | Required -> o | Optional -> o
+    method mutable_flag : mutable_flag -> 'self_type = o#unknown
+    method module_type_desc : module_type_desc -> 'self_type =
+      function
+      | Tmty_ident (_x, _x_i1) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#unknown) _x_i1 in o
+      | Tmty_signature _x -> let o = o#signature _x in o
+      | Tmty_functor (_x, _x_i1, _x_i2, _x_i3) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#string) _x_i1 in
+          let o = o#module_type _x_i2 in let o = o#module_type _x_i3 in o
+      | Tmty_with (_x, _x_i1) ->
+          let o = o#module_type _x in
+          let o =
+            o#list
+              (fun o (_x, _x_i1, _x_i2) ->
+                 let o = o#unknown _x in
+                 let o = o#loc (fun o -> o#unknown) _x_i1 in
+                 let o = o#with_constraint _x_i2 in o)
+              _x_i1
+          in o
+      | Tmty_typeof _x -> let o = o#module_expr _x in o
+    method module_type_constraint : module_type_constraint -> 'self_type =
+      function
+      | Tmodtype_implicit -> o
+      | Tmodtype_explicit _x -> let o = o#module_type _x in o
+    method module_type : module_type -> 'self_type =
+      fun { mty_desc = _x; mty_type = _x_i1; mty_env = _x_i2; mty_loc = _x_i3
+        } ->
+        let o = o#module_type_desc _x in
+        let o = o#unknown _x_i1 in
+        let o = o#unknown _x_i2 in let o = o#unknown _x_i3 in o
+    method module_expr_desc : module_expr_desc -> 'self_type =
+      function
+      | Tmod_ident (_x, _x_i1) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#unknown) _x_i1 in o
+      | Tmod_structure _x -> let o = o#structure _x in o
+      | Tmod_functor (_x, _x_i1, _x_i2, _x_i3) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#string) _x_i1 in
+          let o = o#module_type _x_i2 in let o = o#module_expr _x_i3 in o
+      | Tmod_apply (_x, _x_i1, _x_i2) ->
+          let o = o#module_expr _x in
+          let o = o#module_expr _x_i1 in let o = o#module_coercion _x_i2 in o
+      | Tmod_constraint (_x, _x_i1, _x_i2, _x_i3) ->
+          let o = o#module_expr _x in
+          let o = o#unknown _x_i1 in
+          let o = o#module_type_constraint _x_i2 in
+          let o = o#module_coercion _x_i3 in o
+      | Tmod_unpack (_x, _x_i1) ->
+          let o = o#expression _x in let o = o#unknown _x_i1 in o
+    method module_expr : module_expr -> 'self_type =
+      fun { mod_desc = _x; mod_loc = _x_i1; mod_type = _x_i2; mod_env = _x_i3
+        } ->
+        let o = o#module_expr_desc _x in
+        let o = o#unknown _x_i1 in
+        let o = o#unknown _x_i2 in let o = o#unknown _x_i3 in o
+    method module_coercion : module_coercion -> 'self_type =
+      function
+      | Tcoerce_none -> o
+      | Tcoerce_structure _x ->
+          let o =
+            o#list
+              (fun o (_x, _x_i1) ->
+                 let o = o#int _x in let o = o#module_coercion _x_i1 in o)
+              _x
+          in o
+      | Tcoerce_functor (_x, _x_i1) ->
+          let o = o#module_coercion _x in
+          let o = o#module_coercion _x_i1 in o
+      | Tcoerce_primitive _x -> let o = o#unknown _x in o
+    method modtype_declaration : modtype_declaration -> 'self_type =
+      function
+      | Tmodtype_abstract -> o
+      | Tmodtype_manifest _x -> let o = o#module_type _x in o
+    method meth : meth -> 'self_type =
+      function
+      | Tmeth_name _x -> let o = o#string _x in o
+      | Tmeth_val _x -> let o = o#unknown _x in o
+    method loc :
+      'a. ('self_type -> 'a -> 'self_type) -> 'a loc -> 'self_type =
+      fun _f_a -> o#unknown
+    method label_description : label_description -> 'self_type = o#unknown
+    method label : label -> 'self_type = o#unknown
+    method expression_desc : expression_desc -> 'self_type =
+      function
+      | Texp_ident (_x, _x_i1, _x_i2) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#unknown) _x_i1 in
+          let o = o#unknown _x_i2 in o
+      | Texp_constant _x -> let o = o#constant _x in o
+      | Texp_let (_x, _x_i1, _x_i2) ->
+          let o = o#rec_flag _x in
+          let o =
+            o#list
+              (fun o (_x, _x_i1) ->
+                 let o = o#pattern _x in let o = o#expression _x_i1 in o)
+              _x_i1 in
+          let o = o#expression _x_i2 in o
+      | Texp_function (_x, _x_i1, _x_i2) ->
+          let o = o#label _x in
+          let o =
+            o#list
+              (fun o (_x, _x_i1) ->
+                 let o = o#pattern _x in let o = o#expression _x_i1 in o)
+              _x_i1 in
+          let o = o#partial _x_i2 in o
+      | Texp_apply (_x, _x_i1) ->
+          let o = o#expression _x in
+          let o =
+            o#list
+              (fun o (_x, _x_i1, _x_i2) ->
+                 let o = o#label _x in
+                 let o = o#option (fun o -> o#expression) _x_i1 in
+                 let o = o#optional _x_i2 in o)
+              _x_i1
+          in o
+      | Texp_match (_x, _x_i1, _x_i2) ->
+          let o = o#expression _x in
+          let o =
+            o#list
+              (fun o (_x, _x_i1) ->
+                 let o = o#pattern _x in let o = o#expression _x_i1 in o)
+              _x_i1 in
+          let o = o#partial _x_i2 in o
+      | Texp_try (_x, _x_i1) ->
+          let o = o#expression _x in
+          let o =
+            o#list
+              (fun o (_x, _x_i1) ->
+                 let o = o#pattern _x in let o = o#expression _x_i1 in o)
+              _x_i1
+          in o
+      | Texp_tuple _x -> let o = o#list (fun o -> o#expression) _x in o
+      | Texp_construct (_x, _x_i1, _x_i2, _x_i3, _x_i4) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#unknown) _x_i1 in
+          let o = o#constructor_description _x_i2 in
+          let o = o#list (fun o -> o#expression) _x_i3 in
+          let o = o#bool _x_i4 in o
+      | Texp_variant (_x, _x_i1) ->
+          let o = o#label _x in
+          let o = o#option (fun o -> o#expression) _x_i1 in o
+      | Texp_record (_x, _x_i1) ->
+          let o =
+            o#list
+              (fun o (_x, _x_i1, _x_i2, _x_i3) ->
+                 let o = o#unknown _x in
+                 let o = o#loc (fun o -> o#unknown) _x_i1 in
+                 let o = o#label_description _x_i2 in
+                 let o = o#expression _x_i3 in o)
+              _x in
+          let o = o#option (fun o -> o#expression) _x_i1 in o
+      | Texp_field (_x, _x_i1, _x_i2, _x_i3) ->
+          let o = o#expression _x in
+          let o = o#unknown _x_i1 in
+          let o = o#loc (fun o -> o#unknown) _x_i2 in
+          let o = o#label_description _x_i3 in o
+      | Texp_setfield (_x, _x_i1, _x_i2, _x_i3, _x_i4) ->
+          let o = o#expression _x in
+          let o = o#unknown _x_i1 in
+          let o = o#loc (fun o -> o#unknown) _x_i2 in
+          let o = o#label_description _x_i3 in
+          let o = o#expression _x_i4 in o
+      | Texp_array _x -> let o = o#list (fun o -> o#expression) _x in o
+      | Texp_ifthenelse (_x, _x_i1, _x_i2) ->
+          let o = o#expression _x in
+          let o = o#expression _x_i1 in
+          let o = o#option (fun o -> o#expression) _x_i2 in o
+      | Texp_sequence (_x, _x_i1) ->
+          let o = o#expression _x in let o = o#expression _x_i1 in o
+      | Texp_while (_x, _x_i1) ->
+          let o = o#expression _x in let o = o#expression _x_i1 in o
+      | Texp_for (_x, _x_i1, _x_i2, _x_i3, _x_i4, _x_i5) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#string) _x_i1 in
+          let o = o#expression _x_i2 in
+          let o = o#expression _x_i3 in
+          let o = o#direction_flag _x_i4 in let o = o#expression _x_i5 in o
+      | Texp_when (_x, _x_i1) ->
+          let o = o#expression _x in let o = o#expression _x_i1 in o
+      | Texp_send (_x, _x_i1, _x_i2) ->
+          let o = o#expression _x in
+          let o = o#meth _x_i1 in
+          let o = o#option (fun o -> o#expression) _x_i2 in o
+      | Texp_new (_x, _x_i1, _x_i2) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#unknown) _x_i1 in
+          let o = o#unknown _x_i2 in o
+      | Texp_instvar (_x, _x_i1, _x_i2) ->
+          let o = o#unknown _x in
+          let o = o#unknown _x_i1 in
+          let o = o#loc (fun o -> o#string) _x_i2 in o
+      | Texp_setinstvar (_x, _x_i1, _x_i2, _x_i3) ->
+          let o = o#unknown _x in
+          let o = o#unknown _x_i1 in
+          let o = o#loc (fun o -> o#string) _x_i2 in
+          let o = o#expression _x_i3 in o
+      | Texp_override (_x, _x_i1) ->
+          let o = o#unknown _x in
+          let o =
+            o#list
+              (fun o (_x, _x_i1, _x_i2) ->
+                 let o = o#unknown _x in
+                 let o = o#loc (fun o -> o#string) _x_i1 in
+                 let o = o#expression _x_i2 in o)
+              _x_i1
+          in o
+      | Texp_letmodule (_x, _x_i1, _x_i2, _x_i3) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#string) _x_i1 in
+          let o = o#module_expr _x_i2 in let o = o#expression _x_i3 in o
+      | Texp_assert _x -> let o = o#expression _x in o
+      | Texp_assertfalse -> o
+      | Texp_lazy _x -> let o = o#expression _x in o
+      | Texp_poly (_x, _x_i1) ->
+          let o = o#expression _x in
+          let o = o#option (fun o -> o#core_type) _x_i1 in o
+      | Texp_object (_x, _x_i1) ->
+          let o = o#class_structure _x in
+          let o = o#list (fun o -> o#string) _x_i1 in o
+      | Texp_newtype (_x, _x_i1) ->
+          let o = o#string _x in let o = o#expression _x_i1 in o
+      | Texp_pack _x -> let o = o#module_expr _x in o
+    method expression : expression -> 'self_type =
+      fun
+        {
+          exp_desc = _x;
+          exp_loc = _x_i1;
+          exp_extra = _x_i2;
+          exp_type = _x_i3;
+          exp_env = _x_i4
+        } ->
+        let o = o#expression_desc _x in
+        let o = o#unknown _x_i1 in
+        let o =
+          o#list
+            (fun o (_x, _x_i1) ->
+               let o = o#exp_extra _x in let o = o#unknown _x_i1 in o)
+            _x_i2 in
+        let o = o#type_expr _x_i3 in let o = o#unknown _x_i4 in o
+    method exp_extra : exp_extra -> 'self_type =
+      function
+      | Texp_constraint (_x, _x_i1) ->
+          let o = o#option (fun o -> o#core_type) _x in
+          let o = o#option (fun o -> o#core_type) _x_i1 in o
+      | Texp_open (_x, _x_i1, _x_i2) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#unknown) _x_i1 in
+          let o = o#unknown _x_i2 in o
+    method exception_declaration : exception_declaration -> 'self_type =
+      fun { exn_params = _x; exn_exn = _x_i1; exn_loc = _x_i2 } ->
+        let o = o#list (fun o -> o#core_type) _x in
+        let o = o#unknown _x_i1 in let o = o#unknown _x_i2 in o
+    method direction_flag : direction_flag -> 'self_type = o#unknown
+    method core_type_desc : core_type_desc -> 'self_type =
+      function
+      | Ttyp_any -> o
+      | Ttyp_var _x -> let o = o#string _x in o
+      | Ttyp_arrow (_x, _x_i1, _x_i2) ->
+          let o = o#label _x in
+          let o = o#core_type _x_i1 in let o = o#core_type _x_i2 in o
+      | Ttyp_tuple _x -> let o = o#list (fun o -> o#core_type) _x in o
+      | Ttyp_constr (_x, _x_i1, _x_i2) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#unknown) _x_i1 in
+          let o = o#list (fun o -> o#core_type) _x_i2 in o
+      | Ttyp_object _x -> let o = o#list (fun o -> o#core_field_type) _x in o
+      | Ttyp_class (_x, _x_i1, _x_i2, _x_i3) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#unknown) _x_i1 in
+          let o = o#list (fun o -> o#core_type) _x_i2 in
+          let o = o#list (fun o -> o#label) _x_i3 in o
+      | Ttyp_alias (_x, _x_i1) ->
+          let o = o#core_type _x in let o = o#string _x_i1 in o
+      | Ttyp_variant (_x, _x_i1, _x_i2) ->
+          let o = o#list (fun o -> o#row_field) _x in
+          let o = o#bool _x_i1 in
+          let o = o#option (fun o -> o#list (fun o -> o#label)) _x_i2 in o
+      | Ttyp_poly (_x, _x_i1) ->
+          let o = o#list (fun o -> o#string) _x in
+          let o = o#core_type _x_i1 in o
+      | Ttyp_package _x -> let o = o#package_type _x in o
+    method core_type : core_type -> 'self_type =
+      fun
+        {
+          ctyp_desc = _x;
+          ctyp_type = _x_i1;
+          ctyp_env = _x_i2;
+          ctyp_loc = _x_i3
+        } ->
+        let o = o#core_type_desc _x in
+        let o = o#type_expr _x_i1 in
+        let o = o#unknown _x_i2 in let o = o#unknown _x_i3 in o
+    method core_field_type : core_field_type -> 'self_type =
+      fun { field_desc = _x; field_loc = _x_i1 } ->
+        let o = o#core_field_desc _x in let o = o#unknown _x_i1 in o
+    method core_field_desc : core_field_desc -> 'self_type =
+      function
+      | Tcfield (_x, _x_i1) ->
+          let o = o#string _x in let o = o#core_type _x_i1 in o
+      | Tcfield_var -> o
+    method constructor_description : constructor_description -> 'self_type =
+      o#unknown
+    method constant : constant -> 'self_type = o#unknown
+    method closed_flag : closed_flag -> 'self_type = o#unknown
+    method class_type_field_desc : class_type_field_desc -> 'self_type =
+      function
+      | Tctf_inher _x -> let o = o#class_type _x in o
+      | Tctf_val _x ->
+          let o =
+            (fun (_x, _x_i1, _x_i2, _x_i3) ->
+               let o = o#string _x in
+               let o = o#mutable_flag _x_i1 in
+               let o = o#virtual_flag _x_i2 in let o = o#core_type _x_i3 in o)
+              _x
+          in o
+      | Tctf_virt _x ->
+          let o =
+            (fun (_x, _x_i1, _x_i2) ->
+               let o = o#string _x in
+               let o = o#private_flag _x_i1 in let o = o#core_type _x_i2 in o)
+              _x
+          in o
+      | Tctf_meth _x ->
+          let o =
+            (fun (_x, _x_i1, _x_i2) ->
+               let o = o#string _x in
+               let o = o#private_flag _x_i1 in let o = o#core_type _x_i2 in o)
+              _x
+          in o
+      | Tctf_cstr _x ->
+          let o =
+            (fun (_x, _x_i1) ->
+               let o = o#core_type _x in let o = o#core_type _x_i1 in o)
+              _x
+          in o
+    method class_type_field : class_type_field -> 'self_type =
+      fun { ctf_desc = _x; ctf_loc = _x_i1 } ->
+        let o = o#class_type_field_desc _x in let o = o#unknown _x_i1 in o
+    method class_type_desc : class_type_desc -> 'self_type =
+      function
+      | Tcty_constr (_x, _x_i1, _x_i2) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#unknown) _x_i1 in
+          let o = o#list (fun o -> o#core_type) _x_i2 in o
+      | Tcty_signature _x -> let o = o#class_signature _x in o
+      | Tcty_fun (_x, _x_i1, _x_i2) ->
+          let o = o#label _x in
+          let o = o#core_type _x_i1 in let o = o#class_type _x_i2 in o
+    method class_type_declaration : class_type_declaration -> 'self_type =
+      o#class_infos (fun o -> o#class_type)
+    method class_type : class_type -> 'self_type =
+      fun
+        {
+          cltyp_desc = _x;
+          cltyp_type = _x_i1;
+          cltyp_env = _x_i2;
+          cltyp_loc = _x_i3
+        } ->
+        let o = o#class_type_desc _x in
+        let o = o#unknown _x_i1 in
+        let o = o#unknown _x_i2 in let o = o#unknown _x_i3 in o
+    method class_structure : class_structure -> 'self_type =
+      fun
+        {
+          cstr_pat = _x;
+          cstr_fields = _x_i1;
+          cstr_type = _x_i2;
+          cstr_meths = _x_i3
+        } ->
+        let o = o#pattern _x in
+        let o = o#list (fun o -> o#class_field) _x_i1 in
+        let o = o#unknown _x_i2 in let o = o#unknown _x_i3 in o
+    method class_signature : class_signature -> 'self_type =
+      fun
+        {
+          csig_self = _x;
+          csig_fields = _x_i1;
+          csig_type = _x_i2;
+          csig_loc = _x_i3
+        } ->
+        let o = o#core_type _x in
+        let o = o#list (fun o -> o#class_type_field) _x_i1 in
+        let o = o#unknown _x_i2 in let o = o#unknown _x_i3 in o
+    method class_infos :
+      'a. ('self_type -> 'a -> 'self_type) -> 'a class_infos -> 'self_type =
+      fun _f_a
+        {
+          ci_virt = _x;
+          ci_params = _x_i1;
+          ci_id_name = _x_i2;
+          ci_id_class = _x_i3;
+          ci_id_class_type = _x_i4;
+          ci_id_object = _x_i5;
+          ci_id_typesharp = _x_i6;
+          ci_expr = _x_i7;
+          ci_decl = _x_i8;
+          ci_type_decl = _x_i9;
+          ci_variance = _x_i10;
+          ci_loc = _x_i11
+        } ->
+        let o = o#virtual_flag _x in
+        let o =
+          (fun (_x, _x_i1) ->
+             let o = o#list (fun o -> o#loc (fun o -> o#string)) _x in
+             let o = o#unknown _x_i1 in o)
+            _x_i1 in
+        let o = o#loc (fun o -> o#string) _x_i2 in
+        let o = o#unknown _x_i3 in
+        let o = o#unknown _x_i4 in
+        let o = o#unknown _x_i5 in
+        let o = o#unknown _x_i6 in
+        let o = _f_a o _x_i7 in
+        let o = o#unknown _x_i8 in
+        let o = o#unknown _x_i9 in
+        let o =
+          o#list
+            (fun o (_x, _x_i1) ->
+               let o = o#bool _x in let o = o#bool _x_i1 in o)
+            _x_i10 in
+        let o = o#unknown _x_i11 in o
+    method class_field_kind : class_field_kind -> 'self_type =
+      function
+      | Tcfk_virtual _x -> let o = o#core_type _x in o
+      | Tcfk_concrete _x -> let o = o#expression _x in o
+    method class_field_desc : class_field_desc -> 'self_type =
+      function
+      | Tcf_inher (_x, _x_i1, _x_i2, _x_i3, _x_i4) ->
+          let o = o#override_flag _x in
+          let o = o#class_expr _x_i1 in
+          let o = o#option (fun o -> o#string) _x_i2 in
+          let o =
+            o#list
+              (fun o (_x, _x_i1) ->
+                 let o = o#string _x in let o = o#unknown _x_i1 in o)
+              _x_i3 in
+          let o =
+            o#list
+              (fun o (_x, _x_i1) ->
+                 let o = o#string _x in let o = o#unknown _x_i1 in o)
+              _x_i4
+          in o
+      | Tcf_val (_x, _x_i1, _x_i2, _x_i3, _x_i4, _x_i5) ->
+          let o = o#string _x in
+          let o = o#loc (fun o -> o#string) _x_i1 in
+          let o = o#mutable_flag _x_i2 in
+          let o = o#unknown _x_i3 in
+          let o = o#class_field_kind _x_i4 in let o = o#bool _x_i5 in o
+      | Tcf_meth (_x, _x_i1, _x_i2, _x_i3, _x_i4) ->
+          let o = o#string _x in
+          let o = o#loc (fun o -> o#string) _x_i1 in
+          let o = o#private_flag _x_i2 in
+          let o = o#class_field_kind _x_i3 in let o = o#bool _x_i4 in o
+      | Tcf_constr (_x, _x_i1) ->
+          let o = o#core_type _x in let o = o#core_type _x_i1 in o
+      | Tcf_init _x -> let o = o#expression _x in o
+    method class_field : class_field -> 'self_type =
+      fun { cf_desc = _x; cf_loc = _x_i1 } ->
+        let o = o#class_field_desc _x in let o = o#unknown _x_i1 in o
+    method class_expr_desc : class_expr_desc -> 'self_type =
+      function
+      | Tcl_ident (_x, _x_i1, _x_i2) ->
+          let o = o#unknown _x in
+          let o = o#loc (fun o -> o#unknown) _x_i1 in
+          let o = o#list (fun o -> o#core_type) _x_i2 in o
+      | Tcl_structure _x -> let o = o#class_structure _x in o
+      | Tcl_fun (_x, _x_i1, _x_i2, _x_i3, _x_i4) ->
+          let o = o#label _x in
+          let o = o#pattern _x_i1 in
+          let o =
+            o#list
+              (fun o (_x, _x_i1, _x_i2) ->
+                 let o = o#unknown _x in
+                 let o = o#loc (fun o -> o#string) _x_i1 in
+                 let o = o#expression _x_i2 in o)
+              _x_i2 in
+          let o = o#class_expr _x_i3 in let o = o#partial _x_i4 in o
+      | Tcl_apply (_x, _x_i1) ->
+          let o = o#class_expr _x in
+          let o =
+            o#list
+              (fun o (_x, _x_i1, _x_i2) ->
+                 let o = o#label _x in
+                 let o = o#option (fun o -> o#expression) _x_i1 in
+                 let o = o#optional _x_i2 in o)
+              _x_i1
+          in o
+      | Tcl_let (_x, _x_i1, _x_i2, _x_i3) ->
+          let o = o#rec_flag _x in
+          let o =
+            o#list
+              (fun o (_x, _x_i1) ->
+                 let o = o#pattern _x in let o = o#expression _x_i1 in o)
+              _x_i1 in
+          let o =
+            o#list
+              (fun o (_x, _x_i1, _x_i2) ->
+                 let o = o#unknown _x in
+                 let o = o#loc (fun o -> o#string) _x_i1 in
+                 let o = o#expression _x_i2 in o)
+              _x_i2 in
+          let o = o#class_expr _x_i3 in o
+      | Tcl_constraint (_x, _x_i1, _x_i2, _x_i3, _x_i4) ->
+          let o = o#class_expr _x in
+          let o = o#option (fun o -> o#class_type) _x_i1 in
+          let o = o#list (fun o -> o#string) _x_i2 in
+          let o = o#list (fun o -> o#string) _x_i3 in
+          let o = o#unknown _x_i4 in o
+    method class_expr : class_expr -> 'self_type =
+      fun { cl_desc = _x; cl_loc = _x_i1; cl_type = _x_i2; cl_env = _x_i3 }
+        ->
+        let o = o#class_expr_desc _x in
+        let o = o#unknown _x_i1 in
+        let o = o#unknown _x_i2 in let o = o#unknown _x_i3 in o
+    method class_description : class_description -> 'self_type =
+      o#class_infos (fun o -> o#class_type)
+    method class_declaration : class_declaration -> 'self_type =
+      o#class_infos (fun o -> o#class_expr)
+    method unknown : 'a. 'a -> 'self_type = fun _ -> o
+  end
+  
+
+open Typedtree
+
+class fold : object ('self)
+  method class_declaration      : class_declaration -> 'self
+  method class_description      : class_description -> 'self
+  method class_expr             : class_expr -> 'self
+  method class_expr_desc        : class_expr_desc -> 'self
+  method class_field            : class_field -> 'self
+  method class_field_desc       : class_field_desc -> 'self
+  method class_field_kind       : class_field_kind -> 'self
+  method class_infos            : ('self -> 'a -> 'self) -> 'a class_infos -> 'self
+  method class_signature        : class_signature -> 'self
+  method class_structure        : class_structure -> 'self
+  method class_type             : class_type -> 'self
+  method class_type_declaration : class_type_declaration -> 'self
+  method class_type_desc        : class_type_desc -> 'self
+  method class_type_field       : class_type_field -> 'self
+  method class_type_field_desc  : class_type_field_desc -> 'self
+  method core_field_desc        : core_field_desc -> 'self
+  method core_field_type        : core_field_type -> 'self
+  method core_type              : core_type -> 'self
+  method core_type_desc         : core_type_desc -> 'self
+  method exception_declaration  : exception_declaration -> 'self
+  method exp_extra              : exp_extra -> 'self
+  method expression             : expression -> 'self
+  method expression_desc        : expression_desc -> 'self
+  method meth                   : meth -> 'self
+  method modtype_declaration    : modtype_declaration -> 'self
+  method module_coercion        : module_coercion -> 'self
+  method module_expr            : module_expr -> 'self
+  method module_expr_desc       : module_expr_desc -> 'self
+  method module_type            : module_type -> 'self
+  method module_type_constraint : module_type_constraint -> 'self
+  method module_type_desc       : module_type_desc -> 'self
+  method mutable_flag           : Asttypes.mutable_flag -> 'self
+  method package_type           : package_type -> 'self
+  method partial                : partial -> 'self
+  method pat_extra              : pat_extra -> 'self
+  method pattern                : pattern -> 'self
+  method pattern_desc           : pattern_desc -> 'self
+  method row_field              : row_field -> 'self
+  method signature              : signature -> 'self
+  method signature_item         : signature_item -> 'self
+  method signature_item_desc    : signature_item_desc -> 'self
+  method structure              : structure -> 'self
+  method structure_item         : structure_item -> 'self
+  method structure_item_desc    : structure_item_desc -> 'self
+  method type_declaration       : type_declaration -> 'self
+  method type_kind              : type_kind -> 'self
+  method value_description      : value_description -> 'self
+  method with_constraint        : with_constraint -> 'self
+
+  method unknown : 'a -> 'self
+
+  method direction_flag          : Asttypes.direction_flag -> 'self
+  method string                  : string -> 'self
+  method private_flag            : Asttypes.private_flag -> 'self
+  method option                  : ('self -> 'a -> 'self) -> 'a option -> 'self
+  method optional                : optional -> 'self
+  method override_flag           : Asttypes.override_flag -> 'self
+  method int                     : int -> 'self
+  method loc                     : ('self -> 'a -> 'self) -> 'a Asttypes.loc -> 'self
+  method label                   : Asttypes.label -> 'self
+  method list                    : ('self -> 'a -> 'self) -> 'a list -> 'self
+  method label_description       : Types.label_description -> 'self
+  method rec_flag                : Asttypes.rec_flag -> 'self
+  method ref                     : ('self -> 'a -> 'self) -> 'a ref -> 'self
+  method row_desc                : Types.row_desc -> 'self
+  method bool                    : bool -> 'self
+  method closed_flag             : Asttypes.closed_flag -> 'self
+  method constant                : Asttypes.constant -> 'self
+  method constructor_description : Types.constructor_description -> 'self
+  method type_expr               : Types.type_expr -> 'self
+  method virtual_flag            : Asttypes.virtual_flag -> 'self
+end
+open Misc
+open Asttypes
+open Types
+
+type 'a loc
+
+and rec_flag and label and constant
+and virtual_flag and type_expr and row_desc
+and private_flag and override_flag and mutable_flag and label_description
+and direction_flag and closed_flag
+
+and constructor_description
+
+and partial = Partial | Total
+and optional = Required | Optional
+
+and pattern =
+  { pat_desc: pattern_desc;
+    pat_loc: Location.t;
+    pat_extra : (pat_extra * Location.t) list;
+    pat_type: type_expr;
+    mutable pat_env: Env.t }
+
+and pat_extra =
+  | Tpat_constraint of core_type
+  | Tpat_type of Path.t * Longident.t loc
+  | Tpat_unpack
+
+and pattern_desc =
+    Tpat_any
+  | Tpat_var of Ident.t * string loc
+  | Tpat_alias of pattern * Ident.t * string loc
+  | Tpat_constant of constant
+  | Tpat_tuple of pattern list
+  | Tpat_construct of
+      Path.t * Longident.t loc * constructor_description * pattern list * bool
+  | Tpat_variant of label * pattern option * row_desc ref
+  | Tpat_record of
+      (Path.t * Longident.t loc * label_description * pattern) list *
+        closed_flag
+  | Tpat_array of pattern list
+  | Tpat_or of pattern * pattern * row_desc option
+  | Tpat_lazy of pattern
+
+and expression =
+  { exp_desc: expression_desc;
+    exp_loc: Location.t;
+    exp_extra : (exp_extra * Location.t) list;
+    exp_type: type_expr;
+    exp_env: Env.t }
+
+and exp_extra =
+  | Texp_constraint of core_type option * core_type option
+  | Texp_open of Path.t * Longident.t loc * Env.t
+
+and expression_desc =
+    Texp_ident of Path.t * Longident.t loc * Types.value_description
+  | Texp_constant of constant
+  | Texp_let of rec_flag * (pattern * expression) list * expression
+  | Texp_function of label * (pattern * expression) list * partial
+  | Texp_apply of expression * (label * expression option * optional) list
+  | Texp_match of expression * (pattern * expression) list * partial
+  | Texp_try of expression * (pattern * expression) list
+  | Texp_tuple of expression list
+  | Texp_construct of
+      Path.t * Longident.t loc * constructor_description * expression list *
+        bool
+  | Texp_variant of label * expression option
+  | Texp_record of
+      (Path.t * Longident.t loc * label_description * expression) list *
+        expression option
+  | Texp_field of expression * Path.t * Longident.t loc * label_description
+  | Texp_setfield of
+      expression * Path.t * Longident.t loc * label_description * expression
+  | Texp_array of expression list
+  | Texp_ifthenelse of expression * expression * expression option
+  | Texp_sequence of expression * expression
+  | Texp_while of expression * expression
+  | Texp_for of
+      Ident.t * string loc * expression * expression * direction_flag *
+        expression
+  | Texp_when of expression * expression
+  | Texp_send of expression * meth * expression option
+  | Texp_new of Path.t * Longident.t loc * Types.class_declaration
+  | Texp_instvar of Path.t * Path.t * string loc
+  | Texp_setinstvar of Path.t * Path.t * string loc * expression
+  | Texp_override of Path.t * (Path.t * string loc * expression) list
+  | Texp_letmodule of Ident.t * string loc * module_expr * expression
+  | Texp_assert of expression
+  | Texp_assertfalse
+  | Texp_lazy of expression
+  | Texp_poly of expression * core_type option
+  | Texp_object of class_structure * string list
+  | Texp_newtype of string * expression
+  | Texp_pack of module_expr
+
+and meth =
+    Tmeth_name of string
+  | Tmeth_val of Ident.t
+
+(* Value expressions for the class language *)
+
+and class_expr =
+  { cl_desc: class_expr_desc;
+    cl_loc: Location.t;
+    cl_type: Types.class_type;
+    cl_env: Env.t }
+
+and class_expr_desc =
+    Tcl_ident of Path.t * Longident.t loc * core_type list (* Pcl_constr *)
+  | Tcl_structure of class_structure
+  | Tcl_fun of
+      label * pattern * (Ident.t * string loc * expression) list * class_expr *
+        partial
+  | Tcl_apply of class_expr * (label * expression option * optional) list
+  | Tcl_let of rec_flag *  (pattern * expression) list *
+                  (Ident.t * string loc * expression) list * class_expr
+  | Tcl_constraint of
+      class_expr * class_type option * string list * string list * Concr.t
+    (* Visible instance variables, methods and concretes methods *)
+
+and class_structure =
+  { cstr_pat : pattern;
+    cstr_fields: class_field list;
+    cstr_type : Types.class_signature;
+    cstr_meths: Ident.t Meths.t }
+
+and class_field =
+   {
+    cf_desc : class_field_desc;
+    cf_loc : Location.t;
+  }
+
+and class_field_kind =
+  Tcfk_virtual of core_type
+| Tcfk_concrete of expression
+
+and class_field_desc =
+    Tcf_inher of
+      override_flag * class_expr * string option * (string * Ident.t) list *
+        (string * Ident.t) list
+    (* Inherited instance variables and concrete methods *)
+  | Tcf_val of
+      string * string loc * mutable_flag * Ident.t * class_field_kind * bool
+        (* None = virtual, true = override *)
+  | Tcf_meth of string * string loc * private_flag * class_field_kind * bool
+  | Tcf_constr of core_type * core_type
+(*  | Tcf_let of rec_flag * (pattern * expression) list *
+              (Ident.t * string loc * expression) list *)
+  | Tcf_init of expression
+
+(* Value expressions for the module language *)
+
+and module_expr =
+  { mod_desc: module_expr_desc;
+    mod_loc: Location.t;
+    mod_type: Types.module_type;
+    mod_env: Env.t }
+
+and module_type_constraint =
+  Tmodtype_implicit
+| Tmodtype_explicit of module_type
+
+and module_expr_desc =
+    Tmod_ident of Path.t * Longident.t loc
+  | Tmod_structure of structure
+  | Tmod_functor of Ident.t * string loc * module_type * module_expr
+  | Tmod_apply of module_expr * module_expr * module_coercion
+  | Tmod_constraint of
+      module_expr * Types.module_type * module_type_constraint * module_coercion
+  | Tmod_unpack of expression * Types.module_type
+
+and structure = {
+  str_items : structure_item list;
+  str_type : Types.signature;
+  str_final_env : Env.t;
+}
+
+and structure_item =
+  { str_desc : structure_item_desc;
+    str_loc : Location.t;
+    str_env : Env.t
+  }
+
+and structure_item_desc =
+    Tstr_eval of expression
+  | Tstr_value of rec_flag * (pattern * expression) list
+  | Tstr_primitive of Ident.t * string loc * value_description
+  | Tstr_type of (Ident.t * string loc * type_declaration) list
+  | Tstr_exception of Ident.t * string loc * exception_declaration
+  | Tstr_exn_rebind of Ident.t * string loc * Path.t * Longident.t loc
+  | Tstr_module of Ident.t * string loc * module_expr
+  | Tstr_recmodule of (Ident.t * string loc * module_type * module_expr) list
+  | Tstr_modtype of Ident.t * string loc * module_type
+  | Tstr_open of Path.t * Longident.t loc
+  | Tstr_class of (class_declaration * string list * virtual_flag) list
+  | Tstr_class_type of (Ident.t * string loc * class_type_declaration) list
+  | Tstr_include of module_expr * Ident.t list
+
+and module_coercion =
+    Tcoerce_none
+  | Tcoerce_structure of (int * module_coercion) list
+  | Tcoerce_functor of module_coercion * module_coercion
+  | Tcoerce_primitive of Primitive.description
+
+and module_type =
+  { mty_desc: module_type_desc;
+    mty_type : Types.module_type;
+    mty_env : Env.t; (* BINANNOT ADDED *)
+    mty_loc: Location.t }
+
+and module_type_desc =
+    Tmty_ident of Path.t * Longident.t loc
+  | Tmty_signature of signature
+  | Tmty_functor of Ident.t * string loc * module_type * module_type
+  | Tmty_with of module_type * (Path.t * Longident.t loc * with_constraint) list
+  | Tmty_typeof of module_expr
+
+and signature = {
+  sig_items : signature_item list;
+  sig_type : Types.signature;
+  sig_final_env : Env.t;