2002-03-18 07:08:53 -08:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
2011-07-27 07:17:02 -07:00
|
|
|
(* OCaml *)
|
2002-03-18 07:08:53 -08:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 1999 Institut National de Recherche en Informatique et *)
|
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
2012-05-30 07:52:37 -07:00
|
|
|
open Asttypes
|
2002-03-18 07:08:53 -08:00
|
|
|
open Location
|
|
|
|
open Longident
|
|
|
|
open Parsetree
|
|
|
|
|
|
|
|
module StringSet = Set.Make(struct type t = string let compare = compare end)
|
|
|
|
|
|
|
|
(* Collect free module identifiers in the a.s.t. *)
|
|
|
|
|
|
|
|
let free_structure_names = ref StringSet.empty
|
|
|
|
|
2014-10-03 13:31:34 -07:00
|
|
|
let rec add_path bv = function
|
|
|
|
| Lident s ->
|
2002-03-18 07:08:53 -08:00
|
|
|
if not (StringSet.mem s bv)
|
|
|
|
then free_structure_names := StringSet.add s !free_structure_names
|
2014-10-03 13:31:34 -07:00
|
|
|
| Ldot(l, _s) -> add_path bv l
|
|
|
|
| Lapply(l1, l2) -> add_path bv l1; add_path bv l2
|
|
|
|
|
|
|
|
let open_module bv lid = add_path bv lid
|
2002-03-18 07:08:53 -08:00
|
|
|
|
|
|
|
let add bv lid =
|
2012-05-30 07:52:37 -07:00
|
|
|
match lid.txt with
|
2014-10-03 13:31:34 -07:00
|
|
|
Ldot(l, _s) -> add_path bv l
|
2002-03-18 07:08:53 -08:00
|
|
|
| _ -> ()
|
|
|
|
|
2014-10-03 13:31:34 -07:00
|
|
|
let addmodule bv lid = add_path bv lid.txt
|
2012-05-30 07:52:37 -07:00
|
|
|
|
2002-03-18 07:08:53 -08:00
|
|
|
let rec add_type bv ty =
|
|
|
|
match ty.ptyp_desc with
|
|
|
|
Ptyp_any -> ()
|
2014-05-12 03:41:21 -07:00
|
|
|
| Ptyp_var _ -> ()
|
2002-03-18 07:08:53 -08:00
|
|
|
| Ptyp_arrow(_, t1, t2) -> add_type bv t1; add_type bv t2
|
|
|
|
| Ptyp_tuple tl -> List.iter (add_type bv) tl
|
|
|
|
| Ptyp_constr(c, tl) -> add bv c; List.iter (add_type bv) tl
|
2014-05-05 04:21:45 -07:00
|
|
|
| Ptyp_object (fl, _) -> List.iter (fun (_, _, t) -> add_type bv t) fl
|
2013-04-16 05:17:17 -07:00
|
|
|
| Ptyp_class(c, tl) -> add bv c; List.iter (add_type bv) tl
|
2014-05-12 03:41:21 -07:00
|
|
|
| Ptyp_alias(t, _) -> add_type bv t
|
2002-03-18 07:08:53 -08:00
|
|
|
| Ptyp_variant(fl, _, _) ->
|
|
|
|
List.iter
|
2014-04-30 01:19:55 -07:00
|
|
|
(function Rtag(_,_,_,stl) -> List.iter (add_type bv) stl
|
2002-03-18 07:08:53 -08:00
|
|
|
| Rinherit sty -> add_type bv sty)
|
|
|
|
fl
|
2002-04-18 00:27:47 -07:00
|
|
|
| Ptyp_poly(_, t) -> add_type bv t
|
2010-01-20 04:48:34 -08:00
|
|
|
| Ptyp_package pt -> add_package_type bv pt
|
2013-02-28 08:51:59 -08:00
|
|
|
| Ptyp_extension _ -> ()
|
2010-01-20 04:48:34 -08:00
|
|
|
|
|
|
|
and add_package_type bv (lid, l) =
|
|
|
|
add bv lid;
|
2012-05-30 07:52:37 -07:00
|
|
|
List.iter (add_type bv) (List.map (fun (_, e) -> e) l)
|
2002-03-18 07:08:53 -08:00
|
|
|
|
|
|
|
let add_opt add_fn bv = function
|
|
|
|
None -> ()
|
|
|
|
| Some x -> add_fn bv x
|
|
|
|
|
2013-03-25 08:49:10 -07:00
|
|
|
let add_constructor_decl bv pcd =
|
|
|
|
List.iter (add_type bv) pcd.pcd_args; Misc.may (add_type bv) pcd.pcd_res
|
|
|
|
|
2002-03-18 07:08:53 -08:00
|
|
|
let add_type_declaration bv td =
|
|
|
|
List.iter
|
|
|
|
(fun (ty1, ty2, _) -> add_type bv ty1; add_type bv ty2)
|
|
|
|
td.ptype_cstrs;
|
|
|
|
add_opt add_type bv td.ptype_manifest;
|
2012-12-19 01:25:21 -08:00
|
|
|
let add_tkind = function
|
2007-10-09 03:29:37 -07:00
|
|
|
Ptype_abstract -> ()
|
|
|
|
| Ptype_variant cstrs ->
|
2013-03-25 08:49:10 -07:00
|
|
|
List.iter (add_constructor_decl bv) cstrs
|
2007-10-09 03:29:37 -07:00
|
|
|
| Ptype_record lbls ->
|
2014-05-04 16:08:45 -07:00
|
|
|
List.iter (fun pld -> add_type bv pld.pld_type) lbls
|
|
|
|
| Ptype_open -> () in
|
2003-02-27 22:59:19 -08:00
|
|
|
add_tkind td.ptype_kind
|
2002-03-18 07:08:53 -08:00
|
|
|
|
2014-05-04 16:08:45 -07:00
|
|
|
let add_extension_constructor bv ext =
|
|
|
|
match ext.pext_kind with
|
|
|
|
Pext_decl(args, rty) ->
|
|
|
|
List.iter (add_type bv) args; Misc.may (add_type bv) rty
|
|
|
|
| Pext_rebind lid -> add bv lid
|
|
|
|
|
|
|
|
let add_type_extension bv te =
|
|
|
|
add bv te.ptyext_path;
|
|
|
|
List.iter (add_extension_constructor bv) te.ptyext_constructors
|
|
|
|
|
2002-03-18 07:08:53 -08:00
|
|
|
let rec add_class_type bv cty =
|
|
|
|
match cty.pcty_desc with
|
|
|
|
Pcty_constr(l, tyl) ->
|
|
|
|
add bv l; List.iter (add_type bv) tyl
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pcty_signature { pcsig_self = ty; pcsig_fields = fieldl } ->
|
2002-03-18 07:08:53 -08:00
|
|
|
add_type bv ty;
|
|
|
|
List.iter (add_class_type_field bv) fieldl
|
2013-04-16 01:59:09 -07:00
|
|
|
| Pcty_arrow(_, ty1, cty2) ->
|
2002-03-18 07:08:53 -08:00
|
|
|
add_type bv ty1; add_class_type bv cty2
|
2013-04-10 10:44:15 -07:00
|
|
|
| Pcty_extension _ -> ()
|
2002-03-18 07:08:53 -08:00
|
|
|
|
2012-05-30 07:52:37 -07:00
|
|
|
and add_class_type_field bv pctf =
|
|
|
|
match pctf.pctf_desc with
|
2013-04-10 04:17:41 -07:00
|
|
|
Pctf_inherit cty -> add_class_type bv cty
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pctf_val(_, _, _, ty) -> add_type bv ty
|
2013-04-10 04:17:41 -07:00
|
|
|
| Pctf_method(_, _, _, ty) -> add_type bv ty
|
|
|
|
| Pctf_constraint(ty1, ty2) -> add_type bv ty1; add_type bv ty2
|
2014-05-04 13:42:34 -07:00
|
|
|
| Pctf_attribute _ -> ()
|
2013-04-10 10:54:54 -07:00
|
|
|
| Pctf_extension _ -> ()
|
2002-03-18 07:08:53 -08:00
|
|
|
|
|
|
|
let add_class_description bv infos =
|
|
|
|
add_class_type bv infos.pci_expr
|
|
|
|
|
|
|
|
let add_class_type_declaration = add_class_description
|
|
|
|
|
2012-08-25 04:05:40 -07:00
|
|
|
let pattern_bv = ref StringSet.empty
|
|
|
|
|
2002-03-18 07:08:53 -08:00
|
|
|
let rec add_pattern bv pat =
|
|
|
|
match pat.ppat_desc with
|
|
|
|
Ppat_any -> ()
|
|
|
|
| Ppat_var _ -> ()
|
|
|
|
| Ppat_alias(p, _) -> add_pattern bv p
|
2013-04-16 08:34:09 -07:00
|
|
|
| Ppat_interval _
|
2002-03-18 07:08:53 -08:00
|
|
|
| Ppat_constant _ -> ()
|
|
|
|
| Ppat_tuple pl -> List.iter (add_pattern bv) pl
|
2013-04-17 02:46:52 -07:00
|
|
|
| Ppat_construct(c, op) -> add bv c; add_opt add_pattern bv op
|
2009-09-12 05:41:07 -07:00
|
|
|
| Ppat_record(pl, _) ->
|
2002-03-18 07:08:53 -08:00
|
|
|
List.iter (fun (lbl, p) -> add bv lbl; add_pattern bv p) pl
|
|
|
|
| Ppat_array pl -> List.iter (add_pattern bv) pl
|
|
|
|
| Ppat_or(p1, p2) -> add_pattern bv p1; add_pattern bv p2
|
|
|
|
| Ppat_constraint(p, ty) -> add_pattern bv p; add_type bv ty
|
|
|
|
| Ppat_variant(_, op) -> add_opt add_pattern bv op
|
2012-05-30 07:52:37 -07:00
|
|
|
| Ppat_type li -> add bv li
|
2008-07-09 06:03:38 -07:00
|
|
|
| Ppat_lazy p -> add_pattern bv p
|
2012-08-25 04:05:40 -07:00
|
|
|
| Ppat_unpack id -> pattern_bv := StringSet.add id.txt !pattern_bv
|
2014-05-05 04:49:37 -07:00
|
|
|
| Ppat_exception p -> add_pattern bv p
|
2013-03-04 05:52:23 -08:00
|
|
|
| Ppat_extension _ -> ()
|
2012-08-25 04:05:40 -07:00
|
|
|
|
|
|
|
let add_pattern bv pat =
|
|
|
|
pattern_bv := bv;
|
|
|
|
add_pattern bv pat;
|
|
|
|
!pattern_bv
|
2002-03-18 07:08:53 -08:00
|
|
|
|
|
|
|
let rec add_expr bv exp =
|
|
|
|
match exp.pexp_desc with
|
|
|
|
Pexp_ident l -> add bv l
|
|
|
|
| Pexp_constant _ -> ()
|
2012-08-25 04:05:40 -07:00
|
|
|
| Pexp_let(rf, pel, e) ->
|
|
|
|
let bv = add_bindings rf bv pel in add_expr bv e
|
2013-04-17 04:43:29 -07:00
|
|
|
| Pexp_fun (_, opte, p, e) ->
|
|
|
|
add_opt add_expr bv opte; add_expr (add_pattern bv p) e
|
|
|
|
| Pexp_function pel ->
|
|
|
|
add_cases bv pel
|
2002-03-18 07:08:53 -08:00
|
|
|
| Pexp_apply(e, el) ->
|
|
|
|
add_expr bv e; List.iter (fun (_,e) -> add_expr bv e) el
|
2013-04-15 09:23:22 -07:00
|
|
|
| Pexp_match(e, pel) -> add_expr bv e; add_cases bv pel
|
|
|
|
| Pexp_try(e, pel) -> add_expr bv e; add_cases bv pel
|
2002-03-18 07:08:53 -08:00
|
|
|
| Pexp_tuple el -> List.iter (add_expr bv) el
|
2013-04-17 02:46:52 -07:00
|
|
|
| Pexp_construct(c, opte) -> add bv c; add_opt add_expr bv opte
|
2002-03-18 07:08:53 -08:00
|
|
|
| Pexp_variant(_, opte) -> add_opt add_expr bv opte
|
|
|
|
| Pexp_record(lblel, opte) ->
|
|
|
|
List.iter (fun (lbl, e) -> add bv lbl; add_expr bv e) lblel;
|
|
|
|
add_opt add_expr bv opte
|
|
|
|
| Pexp_field(e, fld) -> add_expr bv e; add bv fld
|
|
|
|
| Pexp_setfield(e1, fld, e2) -> add_expr bv e1; add bv fld; add_expr bv e2
|
|
|
|
| Pexp_array el -> List.iter (add_expr bv) el
|
|
|
|
| Pexp_ifthenelse(e1, e2, opte3) ->
|
|
|
|
add_expr bv e1; add_expr bv e2; add_opt add_expr bv opte3
|
|
|
|
| Pexp_sequence(e1, e2) -> add_expr bv e1; add_expr bv e2
|
|
|
|
| Pexp_while(e1, e2) -> add_expr bv e1; add_expr bv e2
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pexp_for( _, e1, e2, _, e3) ->
|
2002-03-18 07:08:53 -08:00
|
|
|
add_expr bv e1; add_expr bv e2; add_expr bv e3
|
2013-04-17 05:23:44 -07:00
|
|
|
| Pexp_coerce(e1, oty2, ty3) ->
|
2002-03-18 07:08:53 -08:00
|
|
|
add_expr bv e1;
|
|
|
|
add_opt add_type bv oty2;
|
2013-04-17 05:23:44 -07:00
|
|
|
add_type bv ty3
|
|
|
|
| Pexp_constraint(e1, ty2) ->
|
|
|
|
add_expr bv e1;
|
|
|
|
add_type bv ty2
|
2014-05-12 03:41:21 -07:00
|
|
|
| Pexp_send(e, _m) -> add_expr bv e
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pexp_new li -> add bv li
|
2014-05-12 03:41:21 -07:00
|
|
|
| Pexp_setinstvar(_v, e) -> add_expr bv e
|
|
|
|
| Pexp_override sel -> List.iter (fun (_s, e) -> add_expr bv e) sel
|
2002-03-18 07:08:53 -08:00
|
|
|
| Pexp_letmodule(id, m, e) ->
|
2012-05-30 07:52:37 -07:00
|
|
|
add_module bv m; add_expr (StringSet.add id.txt bv) e
|
2002-03-18 07:08:53 -08:00
|
|
|
| Pexp_assert (e) -> add_expr bv e
|
|
|
|
| Pexp_lazy (e) -> add_expr bv e
|
2002-04-18 00:27:47 -07:00
|
|
|
| Pexp_poly (e, t) -> add_expr bv e; add_opt add_type bv t
|
2013-04-10 02:35:09 -07:00
|
|
|
| Pexp_object { pcstr_self = pat; pcstr_fields = fieldl } ->
|
2012-08-25 04:05:40 -07:00
|
|
|
let bv = add_pattern bv pat in List.iter (add_class_field bv) fieldl
|
2009-10-06 05:51:42 -07:00
|
|
|
| Pexp_newtype (_, e) -> add_expr bv e
|
2010-10-21 16:59:33 -07:00
|
|
|
| Pexp_pack m -> add_module bv m
|
2014-10-03 13:31:34 -07:00
|
|
|
| Pexp_open (_ovf, m, e) -> open_module bv m.txt; add_expr bv e
|
2013-02-28 08:51:59 -08:00
|
|
|
| Pexp_extension _ -> ()
|
2012-08-25 04:05:40 -07:00
|
|
|
|
2013-04-15 09:23:22 -07:00
|
|
|
and add_cases bv cases =
|
|
|
|
List.iter (add_case bv) cases
|
|
|
|
|
|
|
|
and add_case bv {pc_lhs; pc_guard; pc_rhs} =
|
|
|
|
let bv = add_pattern bv pc_lhs in
|
|
|
|
add_opt add_expr bv pc_guard;
|
|
|
|
add_expr bv pc_rhs
|
2012-08-25 04:05:40 -07:00
|
|
|
|
|
|
|
and add_bindings recf bv pel =
|
2013-06-03 08:14:19 -07:00
|
|
|
let bv' = List.fold_left (fun bv x -> add_pattern bv x.pvb_pat) bv pel in
|
2012-08-25 04:34:27 -07:00
|
|
|
let bv = if recf = Recursive then bv' else bv in
|
2013-06-03 08:14:19 -07:00
|
|
|
List.iter (fun x -> add_expr bv x.pvb_expr) pel;
|
2012-08-25 04:05:40 -07:00
|
|
|
bv'
|
2002-03-18 07:08:53 -08:00
|
|
|
|
|
|
|
and add_modtype bv mty =
|
|
|
|
match mty.pmty_desc with
|
|
|
|
Pmty_ident l -> add bv l
|
2014-01-21 08:47:05 -08:00
|
|
|
| Pmty_alias l -> addmodule bv l
|
2002-03-18 07:08:53 -08:00
|
|
|
| Pmty_signature s -> add_signature bv s
|
|
|
|
| Pmty_functor(id, mty1, mty2) ->
|
2013-12-16 19:52:50 -08:00
|
|
|
Misc.may (add_modtype bv) mty1;
|
|
|
|
add_modtype (StringSet.add id.txt bv) mty2
|
2002-03-18 07:08:53 -08:00
|
|
|
| Pmty_with(mty, cstrl) ->
|
|
|
|
add_modtype bv mty;
|
|
|
|
List.iter
|
2013-04-16 03:47:45 -07:00
|
|
|
(function
|
|
|
|
| Pwith_type (_, td) -> add_type_declaration bv td
|
|
|
|
| Pwith_module (_, lid) -> addmodule bv lid
|
|
|
|
| Pwith_typesubst td -> add_type_declaration bv td
|
|
|
|
| Pwith_modsubst (_, lid) -> addmodule bv lid
|
|
|
|
)
|
2002-03-18 07:08:53 -08:00
|
|
|
cstrl
|
2010-04-02 05:53:33 -07:00
|
|
|
| Pmty_typeof m -> add_module bv m
|
2013-03-08 06:59:45 -08:00
|
|
|
| Pmty_extension _ -> ()
|
2002-03-18 07:08:53 -08:00
|
|
|
|
|
|
|
and add_signature bv = function
|
|
|
|
[] -> ()
|
|
|
|
| item :: rem -> add_signature (add_sig_item bv item) rem
|
|
|
|
|
|
|
|
and add_sig_item bv item =
|
|
|
|
match item.psig_desc with
|
2013-03-06 04:00:18 -08:00
|
|
|
Psig_value vd ->
|
2002-03-18 07:08:53 -08:00
|
|
|
add_type bv vd.pval_type; bv
|
|
|
|
| Psig_type dcls ->
|
2013-03-06 03:47:59 -08:00
|
|
|
List.iter (add_type_declaration bv) dcls; bv
|
2014-05-04 16:08:45 -07:00
|
|
|
| Psig_typext te ->
|
|
|
|
add_type_extension bv te; bv
|
|
|
|
| Psig_exception pext ->
|
|
|
|
add_extension_constructor bv pext; bv
|
2013-03-04 09:39:07 -08:00
|
|
|
| Psig_module pmd ->
|
|
|
|
add_modtype bv pmd.pmd_type; StringSet.add pmd.pmd_name.txt bv
|
2003-06-19 08:53:53 -07:00
|
|
|
| Psig_recmodule decls ->
|
2013-09-04 08:12:37 -07:00
|
|
|
let bv' =
|
|
|
|
List.fold_right StringSet.add
|
|
|
|
(List.map (fun pmd -> pmd.pmd_name.txt) decls) bv
|
|
|
|
in
|
2013-03-04 09:39:07 -08:00
|
|
|
List.iter (fun pmd -> add_modtype bv' pmd.pmd_type) decls;
|
2003-06-19 08:53:53 -07:00
|
|
|
bv'
|
2013-03-06 04:14:02 -08:00
|
|
|
| Psig_modtype x ->
|
|
|
|
begin match x.pmtd_type with
|
|
|
|
None -> ()
|
|
|
|
| Some mty -> add_modtype bv mty
|
2002-03-18 07:08:53 -08:00
|
|
|
end;
|
|
|
|
bv
|
2014-04-15 04:26:00 -07:00
|
|
|
| Psig_open od ->
|
2014-10-03 13:31:34 -07:00
|
|
|
open_module bv od.popen_lid.txt; bv
|
2014-04-15 04:26:00 -07:00
|
|
|
| Psig_include incl ->
|
|
|
|
add_modtype bv incl.pincl_mod; bv
|
2002-03-18 07:08:53 -08:00
|
|
|
| Psig_class cdl ->
|
|
|
|
List.iter (add_class_description bv) cdl; bv
|
|
|
|
| Psig_class_type cdtl ->
|
|
|
|
List.iter (add_class_type_declaration bv) cdtl; bv
|
2013-03-06 04:27:32 -08:00
|
|
|
| Psig_attribute _ | Psig_extension _ ->
|
2013-03-05 03:46:25 -08:00
|
|
|
bv
|
2002-03-18 07:08:53 -08:00
|
|
|
|
|
|
|
and add_module bv modl =
|
|
|
|
match modl.pmod_desc with
|
|
|
|
Pmod_ident l -> addmodule bv l
|
|
|
|
| Pmod_structure s -> ignore (add_structure bv s)
|
|
|
|
| Pmod_functor(id, mty, modl) ->
|
2013-12-16 19:52:50 -08:00
|
|
|
Misc.may (add_modtype bv) mty;
|
2012-05-30 07:52:37 -07:00
|
|
|
add_module (StringSet.add id.txt bv) modl
|
2002-03-18 07:08:53 -08:00
|
|
|
| Pmod_apply(mod1, mod2) ->
|
|
|
|
add_module bv mod1; add_module bv mod2
|
|
|
|
| Pmod_constraint(modl, mty) ->
|
|
|
|
add_module bv modl; add_modtype bv mty
|
2010-10-21 16:59:33 -07:00
|
|
|
| Pmod_unpack(e) ->
|
2009-10-26 03:53:16 -07:00
|
|
|
add_expr bv e
|
2013-03-04 04:54:57 -08:00
|
|
|
| Pmod_extension _ ->
|
|
|
|
()
|
2002-03-18 07:08:53 -08:00
|
|
|
|
|
|
|
and add_structure bv item_list =
|
2010-01-22 04:48:24 -08:00
|
|
|
List.fold_left add_struct_item bv item_list
|
2002-03-18 07:08:53 -08:00
|
|
|
|
|
|
|
and add_struct_item bv item =
|
|
|
|
match item.pstr_desc with
|
2013-04-11 07:07:32 -07:00
|
|
|
Pstr_eval (e, _attrs) ->
|
2002-03-18 07:08:53 -08:00
|
|
|
add_expr bv e; bv
|
2013-06-03 08:14:19 -07:00
|
|
|
| Pstr_value(rf, pel) ->
|
2012-08-25 04:05:40 -07:00
|
|
|
let bv = add_bindings rf bv pel in bv
|
2013-03-06 04:00:18 -08:00
|
|
|
| Pstr_primitive vd ->
|
2002-03-18 07:08:53 -08:00
|
|
|
add_type bv vd.pval_type; bv
|
|
|
|
| Pstr_type dcls ->
|
2013-03-06 03:47:59 -08:00
|
|
|
List.iter (add_type_declaration bv) dcls; bv
|
2014-05-04 16:08:45 -07:00
|
|
|
| Pstr_typext te ->
|
|
|
|
add_type_extension bv te;
|
|
|
|
bv
|
|
|
|
| Pstr_exception pext ->
|
|
|
|
add_extension_constructor bv pext; bv
|
2013-03-06 02:12:21 -08:00
|
|
|
| Pstr_module x ->
|
|
|
|
add_module bv x.pmb_expr; StringSet.add x.pmb_name.txt bv
|
2003-06-19 08:53:53 -07:00
|
|
|
| Pstr_recmodule bindings ->
|
|
|
|
let bv' =
|
|
|
|
List.fold_right StringSet.add
|
2013-03-06 02:12:21 -08:00
|
|
|
(List.map (fun x -> x.pmb_name.txt) bindings) bv in
|
2003-06-19 08:53:53 -07:00
|
|
|
List.iter
|
2013-03-06 02:12:21 -08:00
|
|
|
(fun x -> add_module bv' x.pmb_expr)
|
2003-06-19 08:53:53 -07:00
|
|
|
bindings;
|
|
|
|
bv'
|
2013-03-06 02:49:44 -08:00
|
|
|
| Pstr_modtype x ->
|
2013-04-18 06:14:53 -07:00
|
|
|
begin match x.pmtd_type with
|
|
|
|
None -> ()
|
|
|
|
| Some mty -> add_modtype bv mty
|
|
|
|
end;
|
|
|
|
bv
|
2014-04-15 04:26:00 -07:00
|
|
|
| Pstr_open od ->
|
2014-10-03 13:31:34 -07:00
|
|
|
open_module bv od.popen_lid.txt; bv
|
2002-03-18 07:08:53 -08:00
|
|
|
| Pstr_class cdl ->
|
|
|
|
List.iter (add_class_declaration bv) cdl; bv
|
|
|
|
| Pstr_class_type cdtl ->
|
|
|
|
List.iter (add_class_type_declaration bv) cdtl; bv
|
2014-04-15 04:26:00 -07:00
|
|
|
| Pstr_include incl ->
|
|
|
|
add_module bv incl.pincl_mod; bv
|
2013-03-06 04:27:32 -08:00
|
|
|
| Pstr_attribute _ | Pstr_extension _ ->
|
2013-03-05 03:46:25 -08:00
|
|
|
bv
|
2002-03-18 07:08:53 -08:00
|
|
|
|
|
|
|
and add_use_file bv top_phrs =
|
|
|
|
ignore (List.fold_left add_top_phrase bv top_phrs)
|
|
|
|
|
2012-07-24 09:24:44 -07:00
|
|
|
and add_implementation bv l =
|
|
|
|
ignore (add_structure bv l)
|
|
|
|
|
2002-03-18 07:08:53 -08:00
|
|
|
and add_top_phrase bv = function
|
|
|
|
| Ptop_def str -> add_structure bv str
|
|
|
|
| Ptop_dir (_, _) -> bv
|
|
|
|
|
|
|
|
and add_class_expr bv ce =
|
|
|
|
match ce.pcl_desc with
|
|
|
|
Pcl_constr(l, tyl) ->
|
|
|
|
add bv l; List.iter (add_type bv) tyl
|
2013-04-10 02:35:09 -07:00
|
|
|
| Pcl_structure { pcstr_self = pat; pcstr_fields = fieldl } ->
|
2012-08-25 04:05:40 -07:00
|
|
|
let bv = add_pattern bv pat in List.iter (add_class_field bv) fieldl
|
2008-01-11 08:13:18 -08:00
|
|
|
| Pcl_fun(_, opte, pat, ce) ->
|
2012-08-25 04:05:40 -07:00
|
|
|
add_opt add_expr bv opte;
|
|
|
|
let bv = add_pattern bv pat in add_class_expr bv ce
|
2002-03-18 07:08:53 -08:00
|
|
|
| Pcl_apply(ce, exprl) ->
|
|
|
|
add_class_expr bv ce; List.iter (fun (_,e) -> add_expr bv e) exprl
|
2012-08-25 04:05:40 -07:00
|
|
|
| Pcl_let(rf, pel, ce) ->
|
|
|
|
let bv = add_bindings rf bv pel in add_class_expr bv ce
|
2002-03-18 07:08:53 -08:00
|
|
|
| Pcl_constraint(ce, ct) ->
|
|
|
|
add_class_expr bv ce; add_class_type bv ct
|
2013-04-10 10:26:55 -07:00
|
|
|
| Pcl_extension _ -> ()
|
2002-03-18 07:08:53 -08:00
|
|
|
|
2012-05-30 07:52:37 -07:00
|
|
|
and add_class_field bv pcf =
|
|
|
|
match pcf.pcf_desc with
|
2013-04-10 04:17:41 -07:00
|
|
|
Pcf_inherit(_, ce, _) -> add_class_expr bv ce
|
|
|
|
| Pcf_val(_, _, Cfk_concrete (_, e))
|
|
|
|
| Pcf_method(_, _, Cfk_concrete (_, e)) -> add_expr bv e
|
|
|
|
| Pcf_val(_, _, Cfk_virtual ty)
|
|
|
|
| Pcf_method(_, _, Cfk_virtual ty) -> add_type bv ty
|
|
|
|
| Pcf_constraint(ty1, ty2) -> add_type bv ty1; add_type bv ty2
|
|
|
|
| Pcf_initializer e -> add_expr bv e
|
2014-05-04 13:42:34 -07:00
|
|
|
| Pcf_attribute _ | Pcf_extension _ -> ()
|
2002-03-18 07:08:53 -08:00
|
|
|
|
|
|
|
and add_class_declaration bv decl =
|
|
|
|
add_class_expr bv decl.pci_expr
|