From ff1ecd8fcd2ac92bdd52ad826d1b8798367ef461 Mon Sep 17 00:00:00 2001 From: Nicolas Ojeda Bar Date: Wed, 27 Jan 2016 21:48:56 +0100 Subject: [PATCH 1/3] Add Ast_iterator --- Makefile.shared | 2 +- parsing/ast_iterator.ml | 588 +++++++++++++++++++++++++++++++++++++++ parsing/ast_iterator.mli | 69 +++++ 3 files changed, 658 insertions(+), 1 deletion(-) create mode 100755 parsing/ast_iterator.ml create mode 100755 parsing/ast_iterator.mli diff --git a/Makefile.shared b/Makefile.shared index e3ffa95b6..542ec3569 100755 --- a/Makefile.shared +++ b/Makefile.shared @@ -48,7 +48,7 @@ PARSING=parsing/location.cmo parsing/longident.cmo \ parsing/syntaxerr.cmo parsing/parser.cmo \ parsing/lexer.cmo parsing/parse.cmo parsing/printast.cmo \ parsing/pprintast.cmo \ - parsing/ast_mapper.cmo parsing/attr_helper.cmo \ + parsing/ast_mapper.cmo parsing/ast_iterator.cmo parsing/attr_helper.cmo \ parsing/builtin_attributes.cmo parsing/ast_invariants.cmo TYPING=typing/ident.cmo typing/path.cmo \ diff --git a/parsing/ast_iterator.ml b/parsing/ast_iterator.ml new file mode 100755 index 000000000..22ba96ae6 --- /dev/null +++ b/parsing/ast_iterator.ml @@ -0,0 +1,588 @@ +(***********************************************************************) +(* *) +(* OCaml *) +(* *) +(* Nicolas Ojeda Bar, LexiFi *) +(* *) +(* Copyright 2012 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. *) +(* *) +(***********************************************************************) + +(* A generic Parsetree mapping class *) + +(* +[@@@ocaml.warning "+9"] + (* Ensure that record patterns don't miss any field. *) +*) + + +open Parsetree +open Location + +type iterator = { + attribute: iterator -> attribute -> unit; + attributes: iterator -> attribute list -> unit; + case: iterator -> case -> unit; + cases: iterator -> case list -> unit; + class_declaration: iterator -> class_declaration -> unit; + class_description: iterator -> class_description -> unit; + class_expr: iterator -> class_expr -> unit; + class_field: iterator -> class_field -> unit; + class_signature: iterator -> class_signature -> unit; + class_structure: iterator -> class_structure -> unit; + class_type: iterator -> class_type -> unit; + class_type_declaration: iterator -> class_type_declaration -> unit; + class_type_field: iterator -> class_type_field -> unit; + constructor_declaration: iterator -> constructor_declaration -> unit; + expr: iterator -> expression -> unit; + extension: iterator -> extension -> unit; + extension_constructor: iterator -> extension_constructor -> unit; + include_declaration: iterator -> include_declaration -> unit; + include_description: iterator -> include_description -> unit; + label_declaration: iterator -> label_declaration -> unit; + location: iterator -> Location.t -> unit; + module_binding: iterator -> module_binding -> unit; + module_declaration: iterator -> module_declaration -> unit; + module_expr: iterator -> module_expr -> unit; + module_type: iterator -> module_type -> unit; + module_type_declaration: iterator -> module_type_declaration -> unit; + open_description: iterator -> open_description -> unit; + pat: iterator -> pattern -> unit; + payload: iterator -> payload -> unit; + signature: iterator -> signature -> unit; + signature_item: iterator -> signature_item -> unit; + structure: iterator -> structure -> unit; + structure_item: iterator -> structure_item -> unit; + typ: iterator -> core_type -> unit; + type_declaration: iterator -> type_declaration -> unit; + type_extension: iterator -> type_extension -> unit; + type_kind: iterator -> type_kind -> unit; + value_binding: iterator -> value_binding -> unit; + value_description: iterator -> value_description -> unit; + with_constraint: iterator -> with_constraint -> unit; +} +(** A [iterator] record implements one "method" per syntactic category, + using an open recursion style: each method takes as its first + argument the iterator to be applied to children in the syntax + tree. *) + +let iter_fst f (x, _) = f x +let iter_snd f (_, y) = f y +let iter_tuple f1 f2 (x, y) = f1 x; f2 y +let iter_tuple3 f1 f2 f3 (x, y, z) = f1 x; f2 y; f3 z +let iter_opt f = function None -> () | Some x -> f x + +let iter_loc sub {loc; txt = _} = sub.location sub loc + +module T = struct + (* Type expressions for the core language *) + + let row_field sub = function + | Rtag (_, attrs, _, tl) -> + sub.attributes sub attrs; List.iter (sub.typ sub) tl + | Rinherit t -> sub.typ sub t + + let iter sub {ptyp_desc = desc; ptyp_loc = loc; ptyp_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Ptyp_any + | Ptyp_var _ -> () + | Ptyp_arrow (_lab, t1, t2) -> + sub.typ sub t1; sub.typ sub t2 + | Ptyp_tuple tyl -> List.iter (sub.typ sub) tyl + | Ptyp_constr (lid, tl) -> + iter_loc sub lid; List.iter (sub.typ sub) tl + | Ptyp_object (l, o) -> + let f (_, a, t) = sub.attributes sub a; sub.typ sub t in + List.iter f l + | Ptyp_class (lid, tl) -> + iter_loc sub lid; List.iter (sub.typ sub) tl + | Ptyp_alias (t, _) -> sub.typ sub t + | Ptyp_variant (rl, b, ll) -> + List.iter (row_field sub) rl + | Ptyp_poly (_, t) -> sub.typ sub t + | Ptyp_package (lid, l) -> + iter_loc sub lid; + List.iter (iter_tuple (iter_loc sub) (sub.typ sub)) l + | Ptyp_extension x -> sub.extension sub x + + let iter_type_declaration sub + {ptype_name; ptype_params; ptype_cstrs; + ptype_kind; + ptype_private; + ptype_manifest; + ptype_attributes; + ptype_loc} = + iter_loc sub ptype_name; + List.iter (iter_fst (sub.typ sub)) ptype_params; + List.iter + (iter_tuple3 (sub.typ sub) (sub.typ sub) (sub.location sub)) + ptype_cstrs; + sub.type_kind sub ptype_kind; + iter_opt (sub.typ sub) ptype_manifest; + sub.location sub ptype_loc; + sub.attributes sub ptype_attributes + + let iter_type_kind sub = function + | Ptype_abstract -> () + | Ptype_variant l -> + List.iter (sub.constructor_declaration sub) l + | Ptype_record l -> List.iter (sub.label_declaration sub) l + | Ptype_open -> () + + let iter_constructor_arguments sub = function + | Pcstr_tuple l -> List.iter (sub.typ sub) l + | Pcstr_record l -> + List.iter (sub.label_declaration sub) l + + let iter_type_extension sub + {ptyext_path; ptyext_params; + ptyext_constructors; + ptyext_private; + ptyext_attributes} = + iter_loc sub ptyext_path; + List.iter (sub.extension_constructor sub) ptyext_constructors; + List.iter (iter_fst (sub.typ sub)) ptyext_params; + sub.attributes sub ptyext_attributes + + let iter_extension_constructor_kind sub = function + Pext_decl(ctl, cto) -> + iter_constructor_arguments sub ctl; iter_opt (sub.typ sub) cto + | Pext_rebind li -> + iter_loc sub li + + let iter_extension_constructor sub + {pext_name; + pext_kind; + pext_loc; + pext_attributes} = + iter_loc sub pext_name; + iter_extension_constructor_kind sub pext_kind; + sub.location sub pext_loc; + sub.attributes sub pext_attributes + +end + +module CT = struct + (* Type expressions for the class language *) + + let iter sub {pcty_loc = loc; pcty_desc = desc; pcty_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Pcty_constr (lid, tys) -> + iter_loc sub lid; List.iter (sub.typ sub) tys + | Pcty_signature x -> sub.class_signature sub x + | Pcty_arrow (_lab, t, ct) -> + sub.typ sub t; sub.class_type sub ct + | Pcty_extension x -> sub.extension sub x + + let iter_field sub {pctf_desc = desc; pctf_loc = loc; pctf_attributes = attrs} + = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Pctf_inherit ct -> sub.class_type sub ct + | Pctf_val (s, m, v, t) -> sub.typ sub t + | Pctf_method (s, p, v, t) -> sub.typ sub t + | Pctf_constraint (t1, t2) -> + sub.typ sub t1; sub.typ sub t2 + | Pctf_attribute x -> sub.attribute sub x + | Pctf_extension x -> sub.extension sub x + + let iter_signature sub {pcsig_self; pcsig_fields} = + sub.typ sub pcsig_self; + List.iter (sub.class_type_field sub) pcsig_fields +end + +module MT = struct + (* Type expressions for the module language *) + + let iter sub {pmty_desc = desc; pmty_loc = loc; pmty_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Pmty_ident s -> iter_loc sub s + | Pmty_alias s -> iter_loc sub s + | Pmty_signature sg -> sub.signature sub sg + | Pmty_functor (s, mt1, mt2) -> + iter_loc sub s; + iter_opt (sub.module_type sub) mt1; + sub.module_type sub mt2 + | Pmty_with (mt, l) -> + sub.module_type sub mt; + List.iter (sub.with_constraint sub) l + | Pmty_typeof me -> sub.module_expr sub me + | Pmty_extension x -> sub.extension sub x + + let iter_with_constraint sub = function + | Pwith_type (lid, d) -> + iter_loc sub lid; sub.type_declaration sub d + | Pwith_module (lid, lid2) -> + iter_loc sub lid; iter_loc sub lid2 + | Pwith_typesubst d -> sub.type_declaration sub d + | Pwith_modsubst (s, lid) -> + iter_loc sub s; iter_loc sub lid + + let iter_signature_item sub {psig_desc = desc; psig_loc = loc} = + sub.location sub loc; + match desc with + | Psig_value vd -> sub.value_description sub vd + | Psig_type (rf, l) -> List.iter (sub.type_declaration sub) l + | Psig_typext te -> sub.type_extension sub te + | Psig_exception ed -> sub.extension_constructor sub ed + | Psig_module x -> sub.module_declaration sub x + | Psig_recmodule l -> + List.iter (sub.module_declaration sub) l + | Psig_modtype x -> sub.module_type_declaration sub x + | Psig_open x -> sub.open_description sub x + | Psig_include x -> sub.include_description sub x + | Psig_class l -> List.iter (sub.class_description sub) l + | Psig_class_type l -> + List.iter (sub.class_type_declaration sub) l + | Psig_extension (x, attrs) -> + sub.extension sub x; sub.attributes sub attrs + | Psig_attribute x -> sub.attribute sub x +end + + +module M = struct + (* Value expressions for the module language *) + + let iter sub {pmod_loc = loc; pmod_desc = desc; pmod_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Pmod_ident x -> iter_loc sub x + | Pmod_structure str -> sub.structure sub str + | Pmod_functor (arg, arg_ty, body) -> + iter_loc sub arg; + iter_opt (sub.module_type sub) arg_ty; + sub.module_expr sub body + | Pmod_apply (m1, m2) -> + sub.module_expr sub m1; sub.module_expr sub m2 + | Pmod_constraint (m, mty) -> + sub.module_expr sub m; sub.module_type sub mty + | Pmod_unpack e -> sub.expr sub e + | Pmod_extension x -> sub.extension sub x + + let iter_structure_item sub {pstr_loc = loc; pstr_desc = desc} = + sub.location sub loc; + match desc with + | Pstr_eval (x, attrs) -> + sub.expr sub x; sub.attributes sub attrs + | Pstr_value (r, vbs) -> List.iter (sub.value_binding sub) vbs + | Pstr_primitive vd -> sub.value_description sub vd + | Pstr_type (rf, l) -> List.iter (sub.type_declaration sub) l + | Pstr_typext te -> sub.type_extension sub te + | Pstr_exception ed -> sub.extension_constructor sub ed + | Pstr_module x -> sub.module_binding sub x + | Pstr_recmodule l -> List.iter (sub.module_binding sub) l + | Pstr_modtype x -> sub.module_type_declaration sub x + | Pstr_open x -> sub.open_description sub x + | Pstr_class l -> List.iter (sub.class_declaration sub) l + | Pstr_class_type l -> + List.iter (sub.class_type_declaration sub) l + | Pstr_include x -> sub.include_declaration sub x + | Pstr_extension (x, attrs) -> + sub.extension sub x; sub.attributes sub attrs + | Pstr_attribute x -> sub.attribute sub x +end + +module E = struct + (* Value expressions for the core language *) + + let iter sub {pexp_loc = loc; pexp_desc = desc; pexp_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Pexp_ident x -> iter_loc sub x + | Pexp_constant x -> () + | Pexp_let (r, vbs, e) -> + List.iter (sub.value_binding sub) vbs; + sub.expr sub e + | Pexp_fun (lab, def, p, e) -> + iter_opt (sub.expr sub) def; + sub.pat sub p; + sub.expr sub e + | Pexp_function pel -> sub.cases sub pel + | Pexp_apply (e, l) -> + sub.expr sub e; List.iter (iter_snd (sub.expr sub)) l + | Pexp_match (e, pel) -> + sub.expr sub e; sub.cases sub pel + | Pexp_try (e, pel) -> sub.expr sub e; sub.cases sub pel + | Pexp_tuple el -> List.iter (sub.expr sub) el + | Pexp_construct (lid, arg) -> + iter_loc sub lid; iter_opt (sub.expr sub) arg + | Pexp_variant (lab, eo) -> + iter_opt (sub.expr sub) eo + | Pexp_record (l, eo) -> + List.iter (iter_tuple (iter_loc sub) (sub.expr sub)) l; + iter_opt (sub.expr sub) eo + | Pexp_field (e, lid) -> + sub.expr sub e; iter_loc sub lid + | Pexp_setfield (e1, lid, e2) -> + sub.expr sub e1; iter_loc sub lid; + sub.expr sub e2 + | Pexp_array el -> List.iter (sub.expr sub) el + | Pexp_ifthenelse (e1, e2, e3) -> + sub.expr sub e1; sub.expr sub e2; + iter_opt (sub.expr sub) e3 + | Pexp_sequence (e1, e2) -> + sub.expr sub e1; sub.expr sub e2 + | Pexp_while (e1, e2) -> + sub.expr sub e1; sub.expr sub e2 + | Pexp_for (p, e1, e2, d, e3) -> + sub.pat sub p; sub.expr sub e1; sub.expr sub e2; + sub.expr sub e3 + | Pexp_coerce (e, t1, t2) -> + sub.expr sub e; iter_opt (sub.typ sub) t1; + sub.typ sub t2 + | Pexp_constraint (e, t) -> + sub.expr sub e; sub.typ sub t + | Pexp_send (e, s) -> sub.expr sub e + | Pexp_new lid -> iter_loc sub lid + | Pexp_setinstvar (s, e) -> + iter_loc sub s; sub.expr sub e + | Pexp_override sel -> + List.iter (iter_tuple (iter_loc sub) (sub.expr sub)) sel + | Pexp_letmodule (s, me, e) -> + iter_loc sub s; sub.module_expr sub me; + sub.expr sub e + | Pexp_assert e -> sub.expr sub e + | Pexp_lazy e -> sub.expr sub e + | Pexp_poly (e, t) -> + sub.expr sub e; iter_opt (sub.typ sub) t + | Pexp_object cls -> sub.class_structure sub cls + | Pexp_newtype (s, e) -> sub.expr sub e + | Pexp_pack me -> sub.module_expr sub me + | Pexp_open (ovf, lid, e) -> + iter_loc sub lid; sub.expr sub e + | Pexp_extension x -> sub.extension sub x + | Pexp_unreachable -> () +end + +module P = struct + (* Patterns *) + + let iter sub {ppat_desc = desc; ppat_loc = loc; ppat_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Ppat_any -> () + | Ppat_var s -> iter_loc sub s + | Ppat_alias (p, s) -> sub.pat sub p; iter_loc sub s + | Ppat_constant c -> () + | Ppat_interval (c1, c2) -> () + | Ppat_tuple pl -> List.iter (sub.pat sub) pl + | Ppat_construct (l, p) -> + iter_loc sub l; iter_opt (sub.pat sub) p + | Ppat_variant (l, p) -> iter_opt (sub.pat sub) p + | Ppat_record (lpl, cf) -> + List.iter (iter_tuple (iter_loc sub) (sub.pat sub)) lpl + | Ppat_array pl -> List.iter (sub.pat sub) pl + | Ppat_or (p1, p2) -> sub.pat sub p1; sub.pat sub p2 + | Ppat_constraint (p, t) -> + sub.pat sub p; sub.typ sub t + | Ppat_type s -> iter_loc sub s + | Ppat_lazy p -> sub.pat sub p + | Ppat_unpack s -> iter_loc sub s + | Ppat_exception p -> sub.pat sub p + | Ppat_extension x -> sub.extension sub x +end + +module CE = struct + (* Value expressions for the class language *) + + let iter sub {pcl_loc = loc; pcl_desc = desc; pcl_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Pcl_constr (lid, tys) -> + iter_loc sub lid; List.iter (sub.typ sub) tys + | Pcl_structure s -> + sub.class_structure sub s + | Pcl_fun (lab, e, p, ce) -> + iter_opt (sub.expr sub) e; + sub.pat sub p; + sub.class_expr sub ce + | Pcl_apply (ce, l) -> + sub.class_expr sub ce; + List.iter (iter_snd (sub.expr sub)) l + | Pcl_let (r, vbs, ce) -> + List.iter (sub.value_binding sub) vbs; + sub.class_expr sub ce + | Pcl_constraint (ce, ct) -> + sub.class_expr sub ce; sub.class_type sub ct + | Pcl_extension x -> sub.extension sub x + + let iter_kind sub = function + | Cfk_concrete (o, e) -> sub.expr sub e + | Cfk_virtual t -> sub.typ sub t + + let iter_field sub {pcf_desc = desc; pcf_loc = loc; pcf_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Pcf_inherit (o, ce, s) -> sub.class_expr sub ce + | Pcf_val (s, m, k) -> iter_loc sub s; iter_kind sub k + | Pcf_method (s, p, k) -> + iter_loc sub s; iter_kind sub k + | Pcf_constraint (t1, t2) -> + sub.typ sub t1; sub.typ sub t2 + | Pcf_initializer e -> sub.expr sub e + | Pcf_attribute x -> sub.attribute sub x + | Pcf_extension x -> sub.extension sub x + + let iter_structure sub {pcstr_self; pcstr_fields} = + sub.pat sub pcstr_self; + List.iter (sub.class_field sub) pcstr_fields + + let class_infos sub f {pci_virt; pci_params = pl; pci_name; pci_expr; + pci_loc; pci_attributes} = + List.iter (iter_fst (sub.typ sub)) pl; + iter_loc sub pci_name; + f pci_expr; + sub.location sub pci_loc; + sub.attributes sub pci_attributes +end + +(* Now, a generic AST mapper, to be extended to cover all kinds and + cases of the OCaml grammar. The default behavior of the mapper is + the identity. *) + +let default_iterator = + { + structure = (fun this l -> List.iter (this.structure_item this) l); + structure_item = M.iter_structure_item; + module_expr = M.iter; + signature = (fun this l -> List.iter (this.signature_item this) l); + signature_item = MT.iter_signature_item; + module_type = MT.iter; + with_constraint = MT.iter_with_constraint; + class_declaration = + (fun this -> CE.class_infos this (this.class_expr this)); + class_expr = CE.iter; + class_field = CE.iter_field; + class_structure = CE.iter_structure; + class_type = CT.iter; + class_type_field = CT.iter_field; + class_signature = CT.iter_signature; + class_type_declaration = + (fun this -> CE.class_infos this (this.class_type this)); + class_description = + (fun this -> CE.class_infos this (this.class_type this)); + type_declaration = T.iter_type_declaration; + type_kind = T.iter_type_kind; + typ = T.iter; + type_extension = T.iter_type_extension; + extension_constructor = T.iter_extension_constructor; + value_description = + (fun this {pval_name; pval_type; pval_prim; pval_loc; + pval_attributes} -> + iter_loc this pval_name; + this.typ this pval_type; + this.attributes this pval_attributes; + this.location this pval_loc + ); + + pat = P.iter; + expr = E.iter; + + module_declaration = + (fun this {pmd_name; pmd_type; pmd_attributes; pmd_loc} -> + iter_loc this pmd_name; + this.module_type this pmd_type; + this.attributes this pmd_attributes; + this.location this pmd_loc + ); + + module_type_declaration = + (fun this {pmtd_name; pmtd_type; pmtd_attributes; pmtd_loc} -> + iter_loc this pmtd_name; + iter_opt (this.module_type this) pmtd_type; + this.attributes this pmtd_attributes; + this.location this pmtd_loc + ); + + module_binding = + (fun this {pmb_name; pmb_expr; pmb_attributes; pmb_loc} -> + iter_loc this pmb_name; this.module_expr this pmb_expr; + this.attributes this pmb_attributes; + this.location this pmb_loc + ); + + + open_description = + (fun this {popen_lid; popen_override; popen_attributes; popen_loc} -> + iter_loc this popen_lid; + this.location this popen_loc; + this.attributes this popen_attributes + ); + + + include_description = + (fun this {pincl_mod; pincl_attributes; pincl_loc} -> + this.module_type this pincl_mod; + this.location this pincl_loc; + this.attributes this pincl_attributes + ); + + include_declaration = + (fun this {pincl_mod; pincl_attributes; pincl_loc} -> + this.module_expr this pincl_mod; + this.location this pincl_loc; + this.attributes this pincl_attributes + ); + + + value_binding = + (fun this {pvb_pat; pvb_expr; pvb_attributes; pvb_loc} -> + this.pat this pvb_pat; + this.expr this pvb_expr; + this.location this pvb_loc; + this.attributes this pvb_attributes + ); + + + constructor_declaration = + (fun this {pcd_name; pcd_args; pcd_res; pcd_loc; pcd_attributes} -> + iter_loc this pcd_name; + T.iter_constructor_arguments this pcd_args; + iter_opt (this.typ this) pcd_res; + this.location this pcd_loc; + this.attributes this pcd_attributes + ); + + label_declaration = + (fun this {pld_name; pld_type; pld_loc; pld_mutable; pld_attributes} -> + iter_loc this pld_name; + this.typ this pld_type; + this.location this pld_loc; + this.attributes this pld_attributes + ); + + cases = (fun this l -> List.iter (this.case this) l); + case = + (fun this {pc_lhs; pc_guard; pc_rhs} -> + this.pat this pc_lhs; + iter_opt (this.expr this) pc_guard; + this.expr this pc_rhs + ); + + location = (fun this l -> ()); + + extension = (fun this (s, e) -> iter_loc this s; this.payload this e); + attribute = (fun this (s, e) -> iter_loc this s; this.payload this e); + attributes = (fun this l -> List.iter (this.attribute this) l); + payload = + (fun this -> function + | PStr x -> this.structure this x + | PSig x -> this.signature this x + | PTyp x -> this.typ this x + | PPat (x, g) -> this.pat this x; iter_opt (this.expr this) g + ); + } diff --git a/parsing/ast_iterator.mli b/parsing/ast_iterator.mli new file mode 100755 index 000000000..c8d7dd00e --- /dev/null +++ b/parsing/ast_iterator.mli @@ -0,0 +1,69 @@ +(***********************************************************************) +(* *) +(* OCaml *) +(* *) +(* Nicolas Ojeda Bar, LexiFi *) +(* *) +(* Copyright 2012 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. *) +(* *) +(***********************************************************************) + +(** {!iterator} allows to implement AST inspection using open recursion. A + typical mapper would be based on {!default_iterator}, a trivial iterator, + and will fall back on it for handling the syntax it does not modify. *) + +open Parsetree + +(** {2 A generic Parsetree iterator} *) + +type iterator = { + attribute: iterator -> attribute -> unit; + attributes: iterator -> attribute list -> unit; + case: iterator -> case -> unit; + cases: iterator -> case list -> unit; + class_declaration: iterator -> class_declaration -> unit; + class_description: iterator -> class_description -> unit; + class_expr: iterator -> class_expr -> unit; + class_field: iterator -> class_field -> unit; + class_signature: iterator -> class_signature -> unit; + class_structure: iterator -> class_structure -> unit; + class_type: iterator -> class_type -> unit; + class_type_declaration: iterator -> class_type_declaration -> unit; + class_type_field: iterator -> class_type_field -> unit; + constructor_declaration: iterator -> constructor_declaration -> unit; + expr: iterator -> expression -> unit; + extension: iterator -> extension -> unit; + extension_constructor: iterator -> extension_constructor -> unit; + include_declaration: iterator -> include_declaration -> unit; + include_description: iterator -> include_description -> unit; + label_declaration: iterator -> label_declaration -> unit; + location: iterator -> Location.t -> unit; + module_binding: iterator -> module_binding -> unit; + module_declaration: iterator -> module_declaration -> unit; + module_expr: iterator -> module_expr -> unit; + module_type: iterator -> module_type -> unit; + module_type_declaration: iterator -> module_type_declaration -> unit; + open_description: iterator -> open_description -> unit; + pat: iterator -> pattern -> unit; + payload: iterator -> payload -> unit; + signature: iterator -> signature -> unit; + signature_item: iterator -> signature_item -> unit; + structure: iterator -> structure -> unit; + structure_item: iterator -> structure_item -> unit; + typ: iterator -> core_type -> unit; + type_declaration: iterator -> type_declaration -> unit; + type_extension: iterator -> type_extension -> unit; + type_kind: iterator -> type_kind -> unit; + value_binding: iterator -> value_binding -> unit; + value_description: iterator -> value_description -> unit; + with_constraint: iterator -> with_constraint -> unit; +} +(** A [iterator] record implements one "method" per syntactic category, + using an open recursion style: each method takes as its first + argument the iterator to be applied to children in the syntax + tree. *) + +val default_iterator: iterator +(** A default iterator, which implements a "do not do anything" mapping. *) From 92d679f79114414cdf48bfc140a285c90ad90b9c Mon Sep 17 00:00:00 2001 From: Nicolas Ojeda Bar Date: Wed, 27 Jan 2016 21:48:56 +0100 Subject: [PATCH 2/3] Use Ast_iterator for Ast_invariants --- .depend | 383 +++++++++++++++++++------------------- parsing/ast_invariants.ml | 84 ++++----- tools/Makefile.shared | 2 +- 3 files changed, 235 insertions(+), 234 deletions(-) diff --git a/.depend b/.depend index 8ffdb57f8..aa35979b6 100644 --- a/.depend +++ b/.depend @@ -41,11 +41,12 @@ utils/terminfo.cmo : utils/terminfo.cmi utils/terminfo.cmx : utils/terminfo.cmi utils/timings.cmo : utils/timings.cmi utils/timings.cmx : utils/timings.cmi -utils/warnings.cmo : utils/warnings.cmi -utils/warnings.cmx : utils/warnings.cmi +utils/warnings.cmo : utils/misc.cmi utils/warnings.cmi +utils/warnings.cmx : utils/misc.cmx utils/warnings.cmi parsing/ast_helper.cmi : parsing/parsetree.cmi parsing/longident.cmi \ parsing/location.cmi parsing/docstrings.cmi parsing/asttypes.cmi parsing/ast_invariants.cmi : parsing/parsetree.cmi +parsing/ast_iterator.cmi : parsing/parsetree.cmi parsing/location.cmi parsing/ast_mapper.cmi : parsing/parsetree.cmi parsing/location.cmi parsing/asttypes.cmi : parsing/location.cmi parsing/attr_helper.cmi : parsing/parsetree.cmi parsing/location.cmi \ @@ -72,9 +73,15 @@ parsing/ast_helper.cmx : parsing/parsetree.cmi parsing/longident.cmx \ parsing/location.cmx parsing/docstrings.cmx parsing/asttypes.cmi \ parsing/ast_helper.cmi parsing/ast_invariants.cmo : parsing/syntaxerr.cmi parsing/parsetree.cmi \ - parsing/ast_mapper.cmi parsing/ast_invariants.cmi + parsing/longident.cmi parsing/asttypes.cmi parsing/ast_iterator.cmi \ + parsing/ast_invariants.cmi parsing/ast_invariants.cmx : parsing/syntaxerr.cmx parsing/parsetree.cmi \ - parsing/ast_mapper.cmx parsing/ast_invariants.cmi + parsing/longident.cmx parsing/asttypes.cmi parsing/ast_iterator.cmx \ + parsing/ast_invariants.cmi +parsing/ast_iterator.cmo : parsing/parsetree.cmi parsing/location.cmi \ + parsing/ast_iterator.cmi +parsing/ast_iterator.cmx : parsing/parsetree.cmi parsing/location.cmx \ + parsing/ast_iterator.cmi parsing/ast_mapper.cmo : parsing/parsetree.cmi utils/misc.cmi \ parsing/longident.cmi parsing/location.cmi utils/config.cmi \ utils/clflags.cmi parsing/asttypes.cmi parsing/ast_helper.cmi \ @@ -143,10 +150,10 @@ typing/cmt_format.cmi : typing/types.cmi typing/typedtree.cmi \ typing/ctype.cmi : typing/types.cmi typing/path.cmi parsing/longident.cmi \ typing/ident.cmi typing/env.cmi parsing/asttypes.cmi typing/datarepr.cmi : typing/types.cmi typing/path.cmi typing/ident.cmi -typing/envaux.cmi : typing/subst.cmi typing/path.cmi typing/env.cmi typing/env.cmi : utils/warnings.cmi typing/types.cmi typing/subst.cmi \ typing/path.cmi parsing/longident.cmi parsing/location.cmi \ typing/ident.cmi utils/consistbl.cmi parsing/asttypes.cmi +typing/envaux.cmi : typing/subst.cmi typing/path.cmi typing/env.cmi typing/ident.cmi : utils/identifiable.cmi typing/includeclass.cmi : typing/types.cmi typing/env.cmi typing/ctype.cmi typing/includecore.cmi : typing/types.cmi typing/typedtree.cmi \ @@ -165,10 +172,10 @@ typing/path.cmi : typing/ident.cmi typing/predef.cmi : typing/types.cmi typing/path.cmi typing/ident.cmi typing/primitive.cmi : parsing/parsetree.cmi typing/outcometree.cmi \ parsing/location.cmi -typing/printtyped.cmi : typing/typedtree.cmi typing/printtyp.cmi : typing/types.cmi typing/path.cmi \ typing/outcometree.cmi parsing/longident.cmi typing/ident.cmi \ typing/env.cmi parsing/asttypes.cmi +typing/printtyped.cmi : typing/typedtree.cmi typing/stypes.cmi : typing/typedtree.cmi parsing/location.cmi \ typing/annot.cmi typing/subst.cmi : typing/types.cmi typing/path.cmi typing/ident.cmi @@ -184,11 +191,11 @@ typing/typedecl.cmi : typing/types.cmi typing/typedtree.cmi typing/path.cmi \ parsing/parsetree.cmi parsing/longident.cmi parsing/location.cmi \ typing/includecore.cmi typing/ident.cmi typing/env.cmi \ parsing/asttypes.cmi -typing/typedtreeIter.cmi : typing/typedtree.cmi parsing/asttypes.cmi -typing/typedtreeMap.cmi : typing/typedtree.cmi typing/typedtree.cmi : typing/types.cmi typing/primitive.cmi typing/path.cmi \ parsing/parsetree.cmi parsing/longident.cmi parsing/location.cmi \ typing/ident.cmi typing/env.cmi parsing/asttypes.cmi +typing/typedtreeIter.cmi : typing/typedtree.cmi parsing/asttypes.cmi +typing/typedtreeMap.cmi : typing/typedtree.cmi typing/typemod.cmi : typing/types.cmi typing/typedtree.cmi typing/path.cmi \ parsing/parsetree.cmi parsing/longident.cmi parsing/location.cmi \ typing/includemod.cmi typing/ident.cmi typing/env.cmi \ @@ -232,12 +239,6 @@ typing/datarepr.cmo : typing/types.cmi typing/path.cmi parsing/location.cmi \ typing/datarepr.cmx : typing/types.cmx typing/path.cmx parsing/location.cmx \ typing/ident.cmx typing/btype.cmx parsing/asttypes.cmi \ typing/datarepr.cmi -typing/envaux.cmo : typing/types.cmi typing/subst.cmi typing/printtyp.cmi \ - typing/path.cmi utils/misc.cmi typing/ident.cmi typing/env.cmi \ - parsing/asttypes.cmi typing/envaux.cmi -typing/envaux.cmx : typing/types.cmx typing/subst.cmx typing/printtyp.cmx \ - typing/path.cmx utils/misc.cmx typing/ident.cmx typing/env.cmx \ - parsing/asttypes.cmi typing/envaux.cmi typing/env.cmo : utils/warnings.cmi typing/types.cmi utils/tbl.cmi \ typing/subst.cmi typing/predef.cmi typing/path.cmi utils/misc.cmi \ parsing/longident.cmi parsing/location.cmi typing/ident.cmi \ @@ -250,6 +251,12 @@ typing/env.cmx : utils/warnings.cmx typing/types.cmx utils/tbl.cmx \ typing/datarepr.cmx utils/consistbl.cmx utils/config.cmx \ typing/cmi_format.cmx utils/clflags.cmx parsing/builtin_attributes.cmx \ typing/btype.cmx parsing/asttypes.cmi typing/env.cmi +typing/envaux.cmo : typing/types.cmi typing/subst.cmi typing/printtyp.cmi \ + typing/path.cmi utils/misc.cmi typing/ident.cmi typing/env.cmi \ + parsing/asttypes.cmi typing/envaux.cmi +typing/envaux.cmx : typing/types.cmx typing/subst.cmx typing/printtyp.cmx \ + typing/path.cmx utils/misc.cmx typing/ident.cmx typing/env.cmx \ + parsing/asttypes.cmi typing/envaux.cmi typing/ident.cmo : utils/identifiable.cmi typing/ident.cmi typing/ident.cmx : utils/identifiable.cmx typing/ident.cmi typing/includeclass.cmo : typing/types.cmi typing/printtyp.cmi \ @@ -314,12 +321,6 @@ typing/primitive.cmo : utils/warnings.cmi parsing/parsetree.cmi \ typing/primitive.cmx : utils/warnings.cmx parsing/parsetree.cmi \ typing/outcometree.cmi utils/misc.cmx parsing/location.cmx \ parsing/attr_helper.cmx typing/primitive.cmi -typing/printtyped.cmo : typing/typedtree.cmi parsing/printast.cmi \ - typing/path.cmi utils/misc.cmi parsing/longident.cmi parsing/location.cmi \ - typing/ident.cmi parsing/asttypes.cmi typing/printtyped.cmi -typing/printtyped.cmx : typing/typedtree.cmx parsing/printast.cmx \ - typing/path.cmx utils/misc.cmx parsing/longident.cmx parsing/location.cmx \ - typing/ident.cmx parsing/asttypes.cmi typing/printtyped.cmi typing/printtyp.cmo : typing/types.cmi typing/primitive.cmi \ typing/predef.cmi typing/path.cmi parsing/parsetree.cmi \ typing/outcometree.cmi typing/oprint.cmi utils/misc.cmi \ @@ -332,6 +333,12 @@ typing/printtyp.cmx : typing/types.cmx typing/primitive.cmx \ parsing/longident.cmx parsing/location.cmx typing/ident.cmx \ typing/env.cmx typing/ctype.cmx utils/clflags.cmx typing/btype.cmx \ parsing/asttypes.cmi typing/printtyp.cmi +typing/printtyped.cmo : typing/typedtree.cmi parsing/printast.cmi \ + typing/path.cmi utils/misc.cmi parsing/longident.cmi parsing/location.cmi \ + typing/ident.cmi parsing/asttypes.cmi typing/printtyped.cmi +typing/printtyped.cmx : typing/typedtree.cmx parsing/printast.cmx \ + typing/path.cmx utils/misc.cmx parsing/longident.cmx parsing/location.cmx \ + typing/ident.cmx parsing/asttypes.cmi typing/printtyped.cmi typing/stypes.cmo : typing/typedtree.cmi typing/printtyp.cmi \ parsing/location.cmi utils/clflags.cmi typing/annot.cmi typing/stypes.cmi typing/stypes.cmx : typing/typedtree.cmx typing/printtyp.cmx \ @@ -348,8 +355,8 @@ typing/tast_mapper.cmx : typing/typedtree.cmx typing/env.cmx \ parsing/asttypes.cmi typing/tast_mapper.cmi typing/typeclass.cmo : utils/warnings.cmi typing/typetexp.cmi \ typing/types.cmi typing/typedtree.cmi typing/typedecl.cmi \ - typing/typecore.cmi parsing/syntaxerr.cmi typing/subst.cmi \ - typing/stypes.cmi typing/printtyp.cmi typing/predef.cmi typing/path.cmi \ + typing/typecore.cmi typing/subst.cmi typing/stypes.cmi \ + typing/printtyp.cmi typing/predef.cmi typing/path.cmi \ parsing/parsetree.cmi utils/misc.cmi parsing/longident.cmi \ parsing/location.cmi typing/includeclass.cmi typing/ident.cmi \ typing/env.cmi typing/ctype.cmi typing/cmt_format.cmi utils/clflags.cmi \ @@ -357,59 +364,49 @@ typing/typeclass.cmo : utils/warnings.cmi typing/typetexp.cmi \ parsing/ast_helper.cmi typing/typeclass.cmi typing/typeclass.cmx : utils/warnings.cmx typing/typetexp.cmx \ typing/types.cmx typing/typedtree.cmx typing/typedecl.cmx \ - typing/typecore.cmx parsing/syntaxerr.cmx typing/subst.cmx \ - typing/stypes.cmx typing/printtyp.cmx typing/predef.cmx typing/path.cmx \ + typing/typecore.cmx typing/subst.cmx typing/stypes.cmx \ + typing/printtyp.cmx typing/predef.cmx typing/path.cmx \ parsing/parsetree.cmi utils/misc.cmx parsing/longident.cmx \ parsing/location.cmx typing/includeclass.cmx typing/ident.cmx \ typing/env.cmx typing/ctype.cmx typing/cmt_format.cmx utils/clflags.cmx \ parsing/builtin_attributes.cmx typing/btype.cmx parsing/asttypes.cmi \ parsing/ast_helper.cmx typing/typeclass.cmi typing/typecore.cmo : utils/warnings.cmi typing/typetexp.cmi \ - typing/types.cmi typing/typedtree.cmi parsing/syntaxerr.cmi \ - typing/subst.cmi typing/stypes.cmi typing/printtyp.cmi \ - typing/primitive.cmi typing/predef.cmi typing/path.cmi \ - parsing/parsetree.cmi typing/parmatch.cmi typing/oprint.cmi \ - utils/misc.cmi parsing/longident.cmi parsing/location.cmi \ - typing/ident.cmi typing/env.cmi typing/ctype.cmi typing/cmt_format.cmi \ - utils/clflags.cmi parsing/builtin_attributes.cmi typing/btype.cmi \ - parsing/asttypes.cmi parsing/ast_helper.cmi typing/annot.cmi \ - typing/typecore.cmi + typing/types.cmi typing/typedtree.cmi typing/subst.cmi typing/stypes.cmi \ + typing/printtyp.cmi typing/primitive.cmi typing/predef.cmi \ + typing/path.cmi parsing/parsetree.cmi typing/parmatch.cmi \ + typing/oprint.cmi utils/misc.cmi parsing/longident.cmi \ + parsing/location.cmi typing/ident.cmi typing/env.cmi typing/ctype.cmi \ + typing/cmt_format.cmi utils/clflags.cmi parsing/builtin_attributes.cmi \ + typing/btype.cmi parsing/asttypes.cmi parsing/ast_helper.cmi \ + typing/annot.cmi typing/typecore.cmi typing/typecore.cmx : utils/warnings.cmx typing/typetexp.cmx \ - typing/types.cmx typing/typedtree.cmx parsing/syntaxerr.cmx \ - typing/subst.cmx typing/stypes.cmx typing/printtyp.cmx \ - typing/primitive.cmx typing/predef.cmx typing/path.cmx \ - parsing/parsetree.cmi typing/parmatch.cmx typing/oprint.cmx \ - utils/misc.cmx parsing/longident.cmx parsing/location.cmx \ - typing/ident.cmx typing/env.cmx typing/ctype.cmx typing/cmt_format.cmx \ - utils/clflags.cmx parsing/builtin_attributes.cmx typing/btype.cmx \ - parsing/asttypes.cmi parsing/ast_helper.cmx typing/annot.cmi \ - typing/typecore.cmi + typing/types.cmx typing/typedtree.cmx typing/subst.cmx typing/stypes.cmx \ + typing/printtyp.cmx typing/primitive.cmx typing/predef.cmx \ + typing/path.cmx parsing/parsetree.cmi typing/parmatch.cmx \ + typing/oprint.cmx utils/misc.cmx parsing/longident.cmx \ + parsing/location.cmx typing/ident.cmx typing/env.cmx typing/ctype.cmx \ + typing/cmt_format.cmx utils/clflags.cmx parsing/builtin_attributes.cmx \ + typing/btype.cmx parsing/asttypes.cmi parsing/ast_helper.cmx \ + typing/annot.cmi typing/typecore.cmi typing/typedecl.cmo : utils/warnings.cmi typing/typetexp.cmi \ - typing/types.cmi typing/typedtree.cmi parsing/syntaxerr.cmi \ - typing/subst.cmi typing/printtyp.cmi typing/primitive.cmi \ - typing/predef.cmi typing/path.cmi parsing/parsetree.cmi utils/misc.cmi \ + typing/types.cmi typing/typedtree.cmi typing/subst.cmi \ + typing/printtyp.cmi typing/primitive.cmi typing/predef.cmi \ + typing/path.cmi parsing/parsetree.cmi utils/misc.cmi \ parsing/longident.cmi parsing/location.cmi typing/includecore.cmi \ typing/ident.cmi typing/env.cmi typing/ctype.cmi utils/config.cmi \ utils/clflags.cmi typing/btype.cmi parsing/attr_helper.cmi \ parsing/asttypes.cmi parsing/ast_mapper.cmi parsing/ast_helper.cmi \ typing/typedecl.cmi typing/typedecl.cmx : utils/warnings.cmx typing/typetexp.cmx \ - typing/types.cmx typing/typedtree.cmx parsing/syntaxerr.cmx \ - typing/subst.cmx typing/printtyp.cmx typing/primitive.cmx \ - typing/predef.cmx typing/path.cmx parsing/parsetree.cmi utils/misc.cmx \ + typing/types.cmx typing/typedtree.cmx typing/subst.cmx \ + typing/printtyp.cmx typing/primitive.cmx typing/predef.cmx \ + typing/path.cmx parsing/parsetree.cmi utils/misc.cmx \ parsing/longident.cmx parsing/location.cmx typing/includecore.cmx \ typing/ident.cmx typing/env.cmx typing/ctype.cmx utils/config.cmx \ utils/clflags.cmx typing/btype.cmx parsing/attr_helper.cmx \ parsing/asttypes.cmi parsing/ast_mapper.cmx parsing/ast_helper.cmx \ typing/typedecl.cmi -typing/typedtreeIter.cmo : typing/typedtree.cmi utils/misc.cmi \ - parsing/asttypes.cmi typing/typedtreeIter.cmi -typing/typedtreeIter.cmx : typing/typedtree.cmx utils/misc.cmx \ - parsing/asttypes.cmi typing/typedtreeIter.cmi -typing/typedtreeMap.cmo : typing/typedtree.cmi utils/misc.cmi \ - typing/typedtreeMap.cmi -typing/typedtreeMap.cmx : typing/typedtree.cmx utils/misc.cmx \ - typing/typedtreeMap.cmi typing/typedtree.cmo : typing/types.cmi typing/primitive.cmi typing/path.cmi \ parsing/parsetree.cmi utils/misc.cmi parsing/longident.cmi \ parsing/location.cmi typing/ident.cmi typing/env.cmi parsing/asttypes.cmi \ @@ -418,6 +415,14 @@ typing/typedtree.cmx : typing/types.cmx typing/primitive.cmx typing/path.cmx \ parsing/parsetree.cmi utils/misc.cmx parsing/longident.cmx \ parsing/location.cmx typing/ident.cmx typing/env.cmx parsing/asttypes.cmi \ typing/typedtree.cmi +typing/typedtreeIter.cmo : typing/typedtree.cmi utils/misc.cmi \ + parsing/asttypes.cmi typing/typedtreeIter.cmi +typing/typedtreeIter.cmx : typing/typedtree.cmx utils/misc.cmx \ + parsing/asttypes.cmi typing/typedtreeIter.cmi +typing/typedtreeMap.cmo : typing/typedtree.cmi utils/misc.cmi \ + typing/typedtreeMap.cmi +typing/typedtreeMap.cmx : typing/typedtree.cmx utils/misc.cmx \ + typing/typedtreeMap.cmi typing/typemod.cmo : utils/warnings.cmi typing/typetexp.cmi typing/types.cmi \ typing/typedtree.cmi typing/typedecl.cmi typing/typecore.cmi \ typing/typeclass.cmi typing/subst.cmi typing/stypes.cmi \ @@ -445,19 +450,19 @@ typing/types.cmx : typing/primitive.cmx typing/path.cmx \ parsing/parsetree.cmi parsing/longident.cmx parsing/location.cmx \ typing/ident.cmx parsing/asttypes.cmi typing/types.cmi typing/typetexp.cmo : utils/warnings.cmi typing/types.cmi \ - typing/typedtree.cmi utils/tbl.cmi parsing/syntaxerr.cmi \ - typing/printtyp.cmi typing/predef.cmi typing/path.cmi \ - parsing/parsetree.cmi utils/misc.cmi parsing/longident.cmi \ - parsing/location.cmi typing/env.cmi typing/ctype.cmi utils/clflags.cmi \ - parsing/builtin_attributes.cmi typing/btype.cmi parsing/asttypes.cmi \ - parsing/ast_helper.cmi typing/typetexp.cmi + typing/typedtree.cmi utils/tbl.cmi typing/printtyp.cmi typing/predef.cmi \ + typing/path.cmi parsing/parsetree.cmi utils/misc.cmi \ + parsing/longident.cmi parsing/location.cmi typing/env.cmi \ + typing/ctype.cmi utils/clflags.cmi parsing/builtin_attributes.cmi \ + typing/btype.cmi parsing/asttypes.cmi parsing/ast_helper.cmi \ + typing/typetexp.cmi typing/typetexp.cmx : utils/warnings.cmx typing/types.cmx \ - typing/typedtree.cmx utils/tbl.cmx parsing/syntaxerr.cmx \ - typing/printtyp.cmx typing/predef.cmx typing/path.cmx \ - parsing/parsetree.cmi utils/misc.cmx parsing/longident.cmx \ - parsing/location.cmx typing/env.cmx typing/ctype.cmx utils/clflags.cmx \ - parsing/builtin_attributes.cmx typing/btype.cmx parsing/asttypes.cmi \ - parsing/ast_helper.cmx typing/typetexp.cmi + typing/typedtree.cmx utils/tbl.cmx typing/printtyp.cmx typing/predef.cmx \ + typing/path.cmx parsing/parsetree.cmi utils/misc.cmx \ + parsing/longident.cmx parsing/location.cmx typing/env.cmx \ + typing/ctype.cmx utils/clflags.cmx parsing/builtin_attributes.cmx \ + typing/btype.cmx parsing/asttypes.cmi parsing/ast_helper.cmx \ + typing/typetexp.cmi typing/untypeast.cmo : typing/typedtree.cmi typing/path.cmi \ parsing/parsetree.cmi utils/misc.cmi parsing/longident.cmi \ parsing/location.cmi typing/ident.cmi typing/env.cmi parsing/asttypes.cmi \ @@ -679,6 +684,7 @@ bytecomp/typeopt.cmo : typing/types.cmi typing/typedtree.cmi \ bytecomp/typeopt.cmx : typing/types.cmx typing/typedtree.cmx \ typing/predef.cmx typing/path.cmx bytecomp/lambda.cmx typing/ident.cmx \ typing/env.cmx typing/ctype.cmx typing/btype.cmx bytecomp/typeopt.cmi +asmcomp/CSEgen.cmi : asmcomp/mach.cmi asmcomp/asmgen.cmi : utils/timings.cmi bytecomp/lambda.cmi asmcomp/cmm.cmi asmcomp/asmlibrarian.cmi : asmcomp/asmlink.cmi : asmcomp/cmx_format.cmi @@ -692,10 +698,10 @@ asmcomp/clambda.cmi : bytecomp/lambda.cmi typing/ident.cmi \ asmcomp/closure.cmi : bytecomp/lambda.cmi asmcomp/clambda.cmi asmcomp/closure_offsets.cmi : middle_end/base_types/var_within_closure.cmi \ middle_end/flambda.cmi middle_end/base_types/closure_id.cmi -asmcomp/cmmgen.cmi : asmcomp/cmx_format.cmi asmcomp/cmm.cmi \ - asmcomp/clambda.cmi asmcomp/cmm.cmi : bytecomp/lambda.cmi typing/ident.cmi \ bytecomp/debuginfo.cmi +asmcomp/cmmgen.cmi : asmcomp/cmx_format.cmi asmcomp/cmm.cmi \ + asmcomp/clambda.cmi asmcomp/cmx_format.cmi : asmcomp/clambda.cmi asmcomp/coloring.cmi : asmcomp/comballoc.cmi : asmcomp/mach.cmi @@ -704,12 +710,9 @@ asmcomp/compilenv.cmi : utils/timings.cmi middle_end/base_types/symbol.cmi \ middle_end/flambda.cmi asmcomp/export_info.cmi \ middle_end/base_types/compilation_unit.cmi asmcomp/cmx_format.cmi \ middle_end/base_types/closure_id.cmi asmcomp/clambda.cmi -asmcomp/CSEgen.cmi : asmcomp/mach.cmi asmcomp/deadcode.cmi : asmcomp/mach.cmi -asmcomp/emitaux.cmi : bytecomp/debuginfo.cmi asmcomp/emit.cmi : asmcomp/linearize.cmi asmcomp/cmm.cmi -asmcomp/export_info_for_pack.cmi : asmcomp/export_info.cmi \ - middle_end/base_types/compilation_unit.cmi +asmcomp/emitaux.cmi : bytecomp/debuginfo.cmi asmcomp/export_info.cmi : middle_end/base_types/variable.cmi \ middle_end/base_types/var_within_closure.cmi \ middle_end/base_types/tag.cmi middle_end/base_types/symbol.cmi \ @@ -718,6 +721,8 @@ asmcomp/export_info.cmi : middle_end/base_types/variable.cmi \ middle_end/base_types/export_id.cmi \ middle_end/base_types/compilation_unit.cmi \ middle_end/base_types/closure_id.cmi +asmcomp/export_info_for_pack.cmi : asmcomp/export_info.cmi \ + middle_end/base_types/compilation_unit.cmi asmcomp/flambda_to_clambda.cmi : middle_end/base_types/symbol.cmi \ middle_end/flambda.cmi asmcomp/export_info.cmi asmcomp/clambda.cmi asmcomp/import_approx.cmi : middle_end/base_types/symbol.cmi \ @@ -734,8 +739,8 @@ asmcomp/printlinear.cmi : asmcomp/linearize.cmi asmcomp/printmach.cmi : asmcomp/reg.cmi asmcomp/mach.cmi asmcomp/proc.cmi : asmcomp/reg.cmi asmcomp/mach.cmi asmcomp/reg.cmi : typing/ident.cmi asmcomp/cmm.cmi -asmcomp/reloadgen.cmi : asmcomp/reg.cmi asmcomp/mach.cmi asmcomp/reload.cmi : asmcomp/mach.cmi +asmcomp/reloadgen.cmi : asmcomp/reg.cmi asmcomp/mach.cmi asmcomp/schedgen.cmi : asmcomp/mach.cmi asmcomp/linearize.cmi asmcomp/scheduling.cmi : asmcomp/linearize.cmi asmcomp/selectgen.cmi : utils/tbl.cmi asmcomp/reg.cmi asmcomp/mach.cmi \ @@ -750,6 +755,12 @@ asmcomp/x86_dsl.cmi : asmcomp/x86_ast.cmi asmcomp/x86_gas.cmi : asmcomp/x86_ast.cmi asmcomp/x86_masm.cmi : asmcomp/x86_ast.cmi asmcomp/x86_proc.cmi : asmcomp/x86_ast.cmi +asmcomp/CSE.cmo : asmcomp/mach.cmi asmcomp/CSEgen.cmi asmcomp/arch.cmo +asmcomp/CSE.cmx : asmcomp/mach.cmx asmcomp/CSEgen.cmx asmcomp/arch.cmx +asmcomp/CSEgen.cmo : asmcomp/reg.cmi asmcomp/proc.cmi asmcomp/mach.cmi \ + asmcomp/cmm.cmi asmcomp/CSEgen.cmi +asmcomp/CSEgen.cmx : asmcomp/reg.cmx asmcomp/proc.cmx asmcomp/mach.cmx \ + asmcomp/cmm.cmx asmcomp/CSEgen.cmi asmcomp/arch.cmo : utils/clflags.cmi asmcomp/arch.cmx : utils/clflags.cmx asmcomp/asmgen.cmo : bytecomp/translmod.cmi utils/timings.cmi \ @@ -802,14 +813,14 @@ asmcomp/asmpackager.cmx : typing/typemod.cmx bytecomp/translmod.cmx \ typing/env.cmx utils/config.cmx asmcomp/compilenv.cmx \ asmcomp/cmx_format.cmi utils/clflags.cmx utils/ccomp.cmx \ asmcomp/asmlink.cmx asmcomp/asmgen.cmx asmcomp/asmpackager.cmi -asmcomp/branch_relaxation_intf.cmo : asmcomp/linearize.cmi asmcomp/arch.cmo -asmcomp/branch_relaxation_intf.cmx : asmcomp/linearize.cmx asmcomp/arch.cmx asmcomp/branch_relaxation.cmo : utils/misc.cmi asmcomp/mach.cmi \ asmcomp/linearize.cmi asmcomp/cmm.cmi asmcomp/branch_relaxation_intf.cmo \ asmcomp/branch_relaxation.cmi asmcomp/branch_relaxation.cmx : utils/misc.cmx asmcomp/mach.cmx \ asmcomp/linearize.cmx asmcomp/cmm.cmx asmcomp/branch_relaxation_intf.cmx \ asmcomp/branch_relaxation.cmi +asmcomp/branch_relaxation_intf.cmo : asmcomp/linearize.cmi asmcomp/arch.cmo +asmcomp/branch_relaxation_intf.cmx : asmcomp/linearize.cmx asmcomp/arch.cmx asmcomp/build_export_info.cmo : middle_end/base_types/variable.cmi \ middle_end/base_types/var_within_closure.cmi \ middle_end/base_types/tag.cmi middle_end/base_types/symbol.cmi \ @@ -856,6 +867,10 @@ asmcomp/closure_offsets.cmx : middle_end/base_types/variable.cmx \ middle_end/flambda_utils.cmx middle_end/flambda_iterators.cmx \ middle_end/flambda.cmx middle_end/base_types/closure_id.cmx \ asmcomp/closure_offsets.cmi +asmcomp/cmm.cmo : bytecomp/lambda.cmi typing/ident.cmi \ + bytecomp/debuginfo.cmi asmcomp/arch.cmo asmcomp/cmm.cmi +asmcomp/cmm.cmx : bytecomp/lambda.cmx typing/ident.cmx \ + bytecomp/debuginfo.cmx asmcomp/arch.cmx asmcomp/cmm.cmi asmcomp/cmmgen.cmo : typing/types.cmi bytecomp/switch.cmi \ asmcomp/strmatch.cmi asmcomp/proc.cmi bytecomp/printlambda.cmi \ typing/primitive.cmi utils/misc.cmi bytecomp/lambda.cmi typing/ident.cmi \ @@ -870,10 +885,6 @@ asmcomp/cmmgen.cmx : typing/types.cmx bytecomp/switch.cmx \ asmcomp/cmx_format.cmi asmcomp/cmm.cmx utils/clflags.cmx \ asmcomp/clambda.cmx parsing/asttypes.cmi asmcomp/arch.cmx \ asmcomp/cmmgen.cmi -asmcomp/cmm.cmo : bytecomp/lambda.cmi typing/ident.cmi \ - bytecomp/debuginfo.cmi asmcomp/arch.cmo asmcomp/cmm.cmi -asmcomp/cmm.cmx : bytecomp/lambda.cmx typing/ident.cmx \ - bytecomp/debuginfo.cmx asmcomp/arch.cmx asmcomp/cmm.cmi asmcomp/coloring.cmo : asmcomp/reg.cmi asmcomp/proc.cmi asmcomp/coloring.cmi asmcomp/coloring.cmx : asmcomp/reg.cmx asmcomp/proc.cmx asmcomp/coloring.cmi asmcomp/comballoc.cmo : asmcomp/reg.cmi asmcomp/mach.cmi utils/config.cmi \ @@ -894,20 +905,10 @@ asmcomp/compilenv.cmx : utils/warnings.cmx middle_end/base_types/symbol.cmx \ middle_end/base_types/compilation_unit.cmx asmcomp/cmx_format.cmi \ middle_end/base_types/closure_id.cmx asmcomp/clambda.cmx \ asmcomp/compilenv.cmi -asmcomp/CSEgen.cmo : asmcomp/reg.cmi asmcomp/proc.cmi asmcomp/mach.cmi \ - asmcomp/cmm.cmi asmcomp/CSEgen.cmi -asmcomp/CSEgen.cmx : asmcomp/reg.cmx asmcomp/proc.cmx asmcomp/mach.cmx \ - asmcomp/cmm.cmx asmcomp/CSEgen.cmi -asmcomp/CSE.cmo : asmcomp/mach.cmi asmcomp/CSEgen.cmi asmcomp/arch.cmo -asmcomp/CSE.cmx : asmcomp/mach.cmx asmcomp/CSEgen.cmx asmcomp/arch.cmx asmcomp/deadcode.cmo : asmcomp/reg.cmi asmcomp/proc.cmi asmcomp/mach.cmi \ asmcomp/deadcode.cmi asmcomp/deadcode.cmx : asmcomp/reg.cmx asmcomp/proc.cmx asmcomp/mach.cmx \ asmcomp/deadcode.cmi -asmcomp/emitaux.cmo : asmcomp/linearize.cmi bytecomp/debuginfo.cmi \ - utils/config.cmi utils/clflags.cmi asmcomp/arch.cmo asmcomp/emitaux.cmi -asmcomp/emitaux.cmx : asmcomp/linearize.cmx bytecomp/debuginfo.cmx \ - utils/config.cmx utils/clflags.cmx asmcomp/arch.cmx asmcomp/emitaux.cmi asmcomp/emit.cmo : asmcomp/x86_proc.cmi asmcomp/x86_masm.cmi \ asmcomp/x86_gas.cmi asmcomp/x86_dsl.cmi asmcomp/x86_ast.cmi \ asmcomp/reg.cmi asmcomp/proc.cmi utils/misc.cmi asmcomp/mach.cmi \ @@ -922,6 +923,26 @@ asmcomp/emit.cmx : asmcomp/x86_proc.cmx asmcomp/x86_masm.cmx \ bytecomp/debuginfo.cmx utils/config.cmx asmcomp/compilenv.cmx \ asmcomp/cmm.cmx utils/clflags.cmx asmcomp/branch_relaxation.cmx \ asmcomp/arch.cmx asmcomp/emit.cmi +asmcomp/emitaux.cmo : asmcomp/linearize.cmi bytecomp/debuginfo.cmi \ + utils/config.cmi utils/clflags.cmi asmcomp/arch.cmo asmcomp/emitaux.cmi +asmcomp/emitaux.cmx : asmcomp/linearize.cmx bytecomp/debuginfo.cmx \ + utils/config.cmx utils/clflags.cmx asmcomp/arch.cmx asmcomp/emitaux.cmi +asmcomp/export_info.cmo : middle_end/base_types/variable.cmi \ + middle_end/base_types/var_within_closure.cmi \ + middle_end/base_types/tag.cmi middle_end/base_types/symbol.cmi \ + middle_end/simple_value_approx.cmi \ + middle_end/base_types/set_of_closures_id.cmi middle_end/flambda.cmi \ + middle_end/base_types/export_id.cmi \ + middle_end/base_types/compilation_unit.cmi \ + middle_end/base_types/closure_id.cmi asmcomp/export_info.cmi +asmcomp/export_info.cmx : middle_end/base_types/variable.cmx \ + middle_end/base_types/var_within_closure.cmx \ + middle_end/base_types/tag.cmx middle_end/base_types/symbol.cmx \ + middle_end/simple_value_approx.cmx \ + middle_end/base_types/set_of_closures_id.cmx middle_end/flambda.cmx \ + middle_end/base_types/export_id.cmx \ + middle_end/base_types/compilation_unit.cmx \ + middle_end/base_types/closure_id.cmx asmcomp/export_info.cmi asmcomp/export_info_for_pack.cmo : middle_end/base_types/variable.cmi \ middle_end/base_types/var_within_closure.cmi \ middle_end/base_types/symbol.cmi \ @@ -940,22 +961,6 @@ asmcomp/export_info_for_pack.cmx : middle_end/base_types/variable.cmx \ middle_end/base_types/export_id.cmx \ middle_end/base_types/compilation_unit.cmx \ middle_end/base_types/closure_id.cmx asmcomp/export_info_for_pack.cmi -asmcomp/export_info.cmo : middle_end/base_types/variable.cmi \ - middle_end/base_types/var_within_closure.cmi \ - middle_end/base_types/tag.cmi middle_end/base_types/symbol.cmi \ - middle_end/simple_value_approx.cmi \ - middle_end/base_types/set_of_closures_id.cmi middle_end/flambda.cmi \ - middle_end/base_types/export_id.cmi \ - middle_end/base_types/compilation_unit.cmi \ - middle_end/base_types/closure_id.cmi asmcomp/export_info.cmi -asmcomp/export_info.cmx : middle_end/base_types/variable.cmx \ - middle_end/base_types/var_within_closure.cmx \ - middle_end/base_types/tag.cmx middle_end/base_types/symbol.cmx \ - middle_end/simple_value_approx.cmx \ - middle_end/base_types/set_of_closures_id.cmx middle_end/flambda.cmx \ - middle_end/base_types/export_id.cmx \ - middle_end/base_types/compilation_unit.cmx \ - middle_end/base_types/closure_id.cmx asmcomp/export_info.cmi asmcomp/flambda_to_clambda.cmo : middle_end/base_types/variable.cmi \ middle_end/base_types/var_within_closure.cmi \ middle_end/base_types/tag.cmi middle_end/base_types/symbol.cmi \ @@ -1048,14 +1053,14 @@ asmcomp/proc.cmx : asmcomp/x86_proc.cmx asmcomp/reg.cmx utils/misc.cmx \ asmcomp/proc.cmi asmcomp/reg.cmo : typing/ident.cmi asmcomp/cmm.cmi asmcomp/reg.cmi asmcomp/reg.cmx : typing/ident.cmx asmcomp/cmm.cmx asmcomp/reg.cmi -asmcomp/reloadgen.cmo : asmcomp/reg.cmi utils/misc.cmi asmcomp/mach.cmi \ - asmcomp/reloadgen.cmi -asmcomp/reloadgen.cmx : asmcomp/reg.cmx utils/misc.cmx asmcomp/mach.cmx \ - asmcomp/reloadgen.cmi asmcomp/reload.cmo : asmcomp/reloadgen.cmi asmcomp/reg.cmi asmcomp/mach.cmi \ asmcomp/cmm.cmi utils/clflags.cmi asmcomp/reload.cmi asmcomp/reload.cmx : asmcomp/reloadgen.cmx asmcomp/reg.cmx asmcomp/mach.cmx \ asmcomp/cmm.cmx utils/clflags.cmx asmcomp/reload.cmi +asmcomp/reloadgen.cmo : asmcomp/reg.cmi utils/misc.cmi asmcomp/mach.cmi \ + asmcomp/reloadgen.cmi +asmcomp/reloadgen.cmx : asmcomp/reg.cmx utils/misc.cmx asmcomp/mach.cmx \ + asmcomp/reloadgen.cmi asmcomp/schedgen.cmo : asmcomp/reg.cmi asmcomp/proc.cmi asmcomp/mach.cmi \ asmcomp/linearize.cmi asmcomp/cmm.cmi asmcomp/arch.cmo \ asmcomp/schedgen.cmi @@ -1126,19 +1131,16 @@ middle_end/augment_closures.cmi : middle_end/inline_and_simplify_aux.cmi \ middle_end/backend_intf.cmi : middle_end/base_types/symbol.cmi \ middle_end/simple_value_approx.cmi typing/ident.cmi \ middle_end/base_types/closure_id.cmi +middle_end/closure_conversion.cmi : bytecomp/lambda.cmi typing/ident.cmi \ + middle_end/flambda.cmi middle_end/backend_intf.cmi middle_end/closure_conversion_aux.cmi : middle_end/base_types/variable.cmi \ middle_end/base_types/symbol.cmi \ middle_end/base_types/static_exception.cmi \ middle_end/base_types/mutable_variable.cmi bytecomp/lambda.cmi \ typing/ident.cmi -middle_end/closure_conversion.cmi : bytecomp/lambda.cmi typing/ident.cmi \ - middle_end/flambda.cmi middle_end/backend_intf.cmi middle_end/effect_analysis.cmi : middle_end/flambda.cmi middle_end/find_recursive_functions.cmi : middle_end/base_types/variable.cmi \ middle_end/flambda.cmi middle_end/backend_intf.cmi -middle_end/flambda_invariants.cmi : middle_end/flambda.cmi -middle_end/flambda_iterators.cmi : middle_end/base_types/variable.cmi \ - middle_end/base_types/symbol.cmi middle_end/flambda.cmi middle_end/flambda.cmi : middle_end/base_types/variable.cmi \ middle_end/base_types/var_within_closure.cmi \ middle_end/base_types/tag.cmi middle_end/base_types/symbol.cmi \ @@ -1148,6 +1150,9 @@ middle_end/flambda.cmi : middle_end/base_types/variable.cmi \ utils/identifiable.cmi bytecomp/debuginfo.cmi \ middle_end/base_types/closure_id.cmi parsing/asttypes.cmi \ middle_end/allocated_const.cmi +middle_end/flambda_invariants.cmi : middle_end/flambda.cmi +middle_end/flambda_iterators.cmi : middle_end/base_types/variable.cmi \ + middle_end/base_types/symbol.cmi middle_end/flambda.cmi middle_end/flambda_utils.cmi : middle_end/base_types/variable.cmi \ middle_end/base_types/var_within_closure.cmi \ middle_end/base_types/tag.cmi middle_end/base_types/symbol.cmi \ @@ -1164,6 +1169,8 @@ middle_end/inconstant_idents.cmi : middle_end/base_types/variable.cmi \ middle_end/base_types/set_of_closures_id.cmi middle_end/flambda.cmi \ middle_end/base_types/compilation_unit.cmi middle_end/backend_intf.cmi middle_end/initialize_symbol_to_let_symbol.cmi : middle_end/flambda.cmi +middle_end/inline_and_simplify.cmi : middle_end/flambda.cmi \ + middle_end/backend_intf.cmi middle_end/inline_and_simplify_aux.cmi : middle_end/base_types/variable.cmi \ middle_end/base_types/symbol.cmi \ middle_end/base_types/static_exception.cmi \ @@ -1173,18 +1180,16 @@ middle_end/inline_and_simplify_aux.cmi : middle_end/base_types/variable.cmi \ middle_end/inlining_stats_types.cmi middle_end/inlining_cost.cmi \ middle_end/freshening.cmi bytecomp/debuginfo.cmi \ middle_end/base_types/closure_id.cmi middle_end/backend_intf.cmi -middle_end/inline_and_simplify.cmi : middle_end/flambda.cmi \ - middle_end/backend_intf.cmi middle_end/inlining_cost.cmi : middle_end/flambda.cmi -middle_end/inlining_decision_intf.cmi : middle_end/base_types/variable.cmi \ - middle_end/simple_value_approx.cmi middle_end/inline_and_simplify_aux.cmi \ - middle_end/flambda.cmi bytecomp/debuginfo.cmi \ - middle_end/base_types/closure_id.cmi middle_end/inlining_decision.cmi : middle_end/base_types/variable.cmi \ middle_end/simple_value_approx.cmi bytecomp/lambda.cmi \ middle_end/inlining_decision_intf.cmi \ middle_end/inline_and_simplify_aux.cmi middle_end/flambda.cmi \ bytecomp/debuginfo.cmi middle_end/base_types/closure_id.cmi +middle_end/inlining_decision_intf.cmi : middle_end/base_types/variable.cmi \ + middle_end/simple_value_approx.cmi middle_end/inline_and_simplify_aux.cmi \ + middle_end/flambda.cmi bytecomp/debuginfo.cmi \ + middle_end/base_types/closure_id.cmi middle_end/inlining_stats.cmi : middle_end/inlining_stats_types.cmi \ bytecomp/debuginfo.cmi middle_end/base_types/closure_id.cmi middle_end/inlining_stats_types.cmi : middle_end/inlining_cost.cmi @@ -1215,11 +1220,11 @@ middle_end/simple_value_approx.cmi : middle_end/base_types/variable.cmi \ middle_end/base_types/tag.cmi middle_end/base_types/symbol.cmi \ middle_end/freshening.cmi middle_end/flambda.cmi \ middle_end/base_types/export_id.cmi middle_end/base_types/closure_id.cmi +middle_end/simplify_boxed_integer_ops.cmi : \ + middle_end/simplify_boxed_integer_ops_intf.cmi middle_end/simplify_boxed_integer_ops_intf.cmi : \ middle_end/simple_value_approx.cmi bytecomp/lambda.cmi \ middle_end/inlining_cost.cmi middle_end/flambda.cmi -middle_end/simplify_boxed_integer_ops.cmi : \ - middle_end/simplify_boxed_integer_ops_intf.cmi middle_end/simplify_common.cmi : middle_end/simple_value_approx.cmi \ bytecomp/lambda.cmi middle_end/inlining_cost.cmi middle_end/flambda.cmi middle_end/simplify_primitives.cmi : middle_end/base_types/variable.cmi \ @@ -1258,18 +1263,6 @@ middle_end/augment_closures.cmx : middle_end/base_types/variable.cmx \ middle_end/flambda_iterators.cmx middle_end/flambda.cmx \ bytecomp/debuginfo.cmx middle_end/base_types/closure_id.cmx \ utils/clflags.cmx middle_end/augment_closures.cmi -middle_end/closure_conversion_aux.cmo : middle_end/base_types/variable.cmi \ - middle_end/base_types/symbol.cmi \ - middle_end/base_types/static_exception.cmi typing/primitive.cmi \ - utils/numbers.cmi middle_end/base_types/mutable_variable.cmi \ - utils/misc.cmi bytecomp/lambda.cmi typing/ident.cmi \ - middle_end/closure_conversion_aux.cmi -middle_end/closure_conversion_aux.cmx : middle_end/base_types/variable.cmx \ - middle_end/base_types/symbol.cmx \ - middle_end/base_types/static_exception.cmx typing/primitive.cmx \ - utils/numbers.cmx middle_end/base_types/mutable_variable.cmx \ - utils/misc.cmx bytecomp/lambda.cmx typing/ident.cmx \ - middle_end/closure_conversion_aux.cmi middle_end/closure_conversion.cmo : middle_end/base_types/variable.cmi \ middle_end/base_types/tag.cmi middle_end/base_types/symbol.cmi \ middle_end/base_types/static_exception.cmi bytecomp/simplif.cmi \ @@ -1298,6 +1291,18 @@ middle_end/closure_conversion.cmx : middle_end/base_types/variable.cmx \ middle_end/closure_conversion_aux.cmx utils/clflags.cmx \ middle_end/backend_intf.cmi parsing/asttypes.cmi \ middle_end/closure_conversion.cmi +middle_end/closure_conversion_aux.cmo : middle_end/base_types/variable.cmi \ + middle_end/base_types/symbol.cmi \ + middle_end/base_types/static_exception.cmi typing/primitive.cmi \ + utils/numbers.cmi middle_end/base_types/mutable_variable.cmi \ + utils/misc.cmi bytecomp/lambda.cmi typing/ident.cmi \ + middle_end/closure_conversion_aux.cmi +middle_end/closure_conversion_aux.cmx : middle_end/base_types/variable.cmx \ + middle_end/base_types/symbol.cmx \ + middle_end/base_types/static_exception.cmx typing/primitive.cmx \ + utils/numbers.cmx middle_end/base_types/mutable_variable.cmx \ + utils/misc.cmx bytecomp/lambda.cmx typing/ident.cmx \ + middle_end/closure_conversion_aux.cmi middle_end/effect_analysis.cmo : middle_end/semantics_of_primitives.cmi \ utils/misc.cmi bytecomp/lambda.cmi middle_end/flambda.cmi \ middle_end/effect_analysis.cmi @@ -1310,6 +1315,28 @@ middle_end/find_recursive_functions.cmo : middle_end/base_types/variable.cmi \ middle_end/find_recursive_functions.cmx : middle_end/base_types/variable.cmx \ utils/strongly_connected_components.cmx middle_end/flambda_utils.cmx \ middle_end/flambda.cmx middle_end/find_recursive_functions.cmi +middle_end/flambda.cmo : middle_end/base_types/variable.cmi \ + middle_end/base_types/var_within_closure.cmi \ + middle_end/base_types/tag.cmi middle_end/base_types/symbol.cmi \ + middle_end/base_types/static_exception.cmi \ + middle_end/base_types/set_of_closures_id.cmi bytecomp/printlambda.cmi \ + utils/numbers.cmi middle_end/base_types/mutable_variable.cmi \ + utils/misc.cmi bytecomp/lambda.cmi utils/identifiable.cmi \ + bytecomp/debuginfo.cmi middle_end/base_types/compilation_unit.cmi \ + middle_end/base_types/closure_id.cmi utils/clflags.cmi \ + parsing/asttypes.cmi middle_end/allocated_const.cmi \ + middle_end/flambda.cmi +middle_end/flambda.cmx : middle_end/base_types/variable.cmx \ + middle_end/base_types/var_within_closure.cmx \ + middle_end/base_types/tag.cmx middle_end/base_types/symbol.cmx \ + middle_end/base_types/static_exception.cmx \ + middle_end/base_types/set_of_closures_id.cmx bytecomp/printlambda.cmx \ + utils/numbers.cmx middle_end/base_types/mutable_variable.cmx \ + utils/misc.cmx bytecomp/lambda.cmx utils/identifiable.cmx \ + bytecomp/debuginfo.cmx middle_end/base_types/compilation_unit.cmx \ + middle_end/base_types/closure_id.cmx utils/clflags.cmx \ + parsing/asttypes.cmi middle_end/allocated_const.cmx \ + middle_end/flambda.cmi middle_end/flambda_invariants.cmo : middle_end/base_types/variable.cmi \ middle_end/base_types/var_within_closure.cmi \ middle_end/base_types/tag.cmi middle_end/base_types/symbol.cmi \ @@ -1336,28 +1363,6 @@ middle_end/flambda_iterators.cmo : middle_end/base_types/variable.cmi \ utils/misc.cmi middle_end/flambda.cmi middle_end/flambda_iterators.cmi middle_end/flambda_iterators.cmx : middle_end/base_types/variable.cmx \ utils/misc.cmx middle_end/flambda.cmx middle_end/flambda_iterators.cmi -middle_end/flambda.cmo : middle_end/base_types/variable.cmi \ - middle_end/base_types/var_within_closure.cmi \ - middle_end/base_types/tag.cmi middle_end/base_types/symbol.cmi \ - middle_end/base_types/static_exception.cmi \ - middle_end/base_types/set_of_closures_id.cmi bytecomp/printlambda.cmi \ - utils/numbers.cmi middle_end/base_types/mutable_variable.cmi \ - utils/misc.cmi bytecomp/lambda.cmi utils/identifiable.cmi \ - bytecomp/debuginfo.cmi middle_end/base_types/compilation_unit.cmi \ - middle_end/base_types/closure_id.cmi utils/clflags.cmi \ - parsing/asttypes.cmi middle_end/allocated_const.cmi \ - middle_end/flambda.cmi -middle_end/flambda.cmx : middle_end/base_types/variable.cmx \ - middle_end/base_types/var_within_closure.cmx \ - middle_end/base_types/tag.cmx middle_end/base_types/symbol.cmx \ - middle_end/base_types/static_exception.cmx \ - middle_end/base_types/set_of_closures_id.cmx bytecomp/printlambda.cmx \ - utils/numbers.cmx middle_end/base_types/mutable_variable.cmx \ - utils/misc.cmx bytecomp/lambda.cmx utils/identifiable.cmx \ - bytecomp/debuginfo.cmx middle_end/base_types/compilation_unit.cmx \ - middle_end/base_types/closure_id.cmx utils/clflags.cmx \ - parsing/asttypes.cmi middle_end/allocated_const.cmx \ - middle_end/flambda.cmi middle_end/flambda_utils.cmo : middle_end/base_types/variable.cmi \ middle_end/base_types/var_within_closure.cmi \ middle_end/base_types/symbol.cmi bytecomp/switch.cmi \ @@ -1420,26 +1425,6 @@ middle_end/initialize_symbol_to_let_symbol.cmo : \ middle_end/initialize_symbol_to_let_symbol.cmx : \ middle_end/base_types/variable.cmx utils/misc.cmx middle_end/flambda.cmx \ middle_end/initialize_symbol_to_let_symbol.cmi -middle_end/inline_and_simplify_aux.cmo : middle_end/base_types/variable.cmi \ - middle_end/base_types/symbol.cmi \ - middle_end/base_types/static_exception.cmi \ - middle_end/simple_value_approx.cmi \ - middle_end/base_types/set_of_closures_id.cmi utils/numbers.cmi \ - middle_end/base_types/mutable_variable.cmi utils/misc.cmi \ - middle_end/inlining_stats.cmi middle_end/inlining_cost.cmi \ - middle_end/freshening.cmi middle_end/base_types/compilation_unit.cmi \ - utils/clflags.cmi middle_end/backend_intf.cmi \ - middle_end/inline_and_simplify_aux.cmi -middle_end/inline_and_simplify_aux.cmx : middle_end/base_types/variable.cmx \ - middle_end/base_types/symbol.cmx \ - middle_end/base_types/static_exception.cmx \ - middle_end/simple_value_approx.cmx \ - middle_end/base_types/set_of_closures_id.cmx utils/numbers.cmx \ - middle_end/base_types/mutable_variable.cmx utils/misc.cmx \ - middle_end/inlining_stats.cmx middle_end/inlining_cost.cmx \ - middle_end/freshening.cmx middle_end/base_types/compilation_unit.cmx \ - utils/clflags.cmx middle_end/backend_intf.cmi \ - middle_end/inline_and_simplify_aux.cmi middle_end/inline_and_simplify.cmo : utils/warnings.cmi \ middle_end/base_types/variable.cmi \ middle_end/base_types/var_within_closure.cmi \ @@ -1474,6 +1459,26 @@ middle_end/inline_and_simplify.cmx : utils/warnings.cmx \ utils/clflags.cmx middle_end/backend_intf.cmi \ middle_end/augment_closures.cmx middle_end/allocated_const.cmx \ middle_end/inline_and_simplify.cmi +middle_end/inline_and_simplify_aux.cmo : middle_end/base_types/variable.cmi \ + middle_end/base_types/symbol.cmi \ + middle_end/base_types/static_exception.cmi \ + middle_end/simple_value_approx.cmi \ + middle_end/base_types/set_of_closures_id.cmi utils/numbers.cmi \ + middle_end/base_types/mutable_variable.cmi utils/misc.cmi \ + middle_end/inlining_stats.cmi middle_end/inlining_cost.cmi \ + middle_end/freshening.cmi middle_end/base_types/compilation_unit.cmi \ + utils/clflags.cmi middle_end/backend_intf.cmi \ + middle_end/inline_and_simplify_aux.cmi +middle_end/inline_and_simplify_aux.cmx : middle_end/base_types/variable.cmx \ + middle_end/base_types/symbol.cmx \ + middle_end/base_types/static_exception.cmx \ + middle_end/simple_value_approx.cmx \ + middle_end/base_types/set_of_closures_id.cmx utils/numbers.cmx \ + middle_end/base_types/mutable_variable.cmx utils/misc.cmx \ + middle_end/inlining_stats.cmx middle_end/inlining_cost.cmx \ + middle_end/freshening.cmx middle_end/base_types/compilation_unit.cmx \ + utils/clflags.cmx middle_end/backend_intf.cmi \ + middle_end/inline_and_simplify_aux.cmi middle_end/inlining_cost.cmo : middle_end/base_types/variable.cmi \ typing/primitive.cmi utils/misc.cmi bytecomp/lambda.cmi \ middle_end/flambda_iterators.cmi middle_end/flambda.cmi utils/clflags.cmi \ @@ -1732,10 +1737,10 @@ middle_end/base_types/static_exception.cmi : utils/identifiable.cmi middle_end/base_types/symbol.cmi : middle_end/base_types/linkage_name.cmi \ utils/identifiable.cmi middle_end/base_types/compilation_unit.cmi middle_end/base_types/tag.cmi : utils/identifiable.cmi -middle_end/base_types/variable.cmi : utils/identifiable.cmi typing/ident.cmi \ - middle_end/base_types/compilation_unit.cmi middle_end/base_types/var_within_closure.cmi : \ middle_end/base_types/closure_element.cmi +middle_end/base_types/variable.cmi : utils/identifiable.cmi typing/ident.cmi \ + middle_end/base_types/compilation_unit.cmi middle_end/base_types/closure_element.cmo : \ middle_end/base_types/variable.cmi \ middle_end/base_types/closure_element.cmi @@ -1800,24 +1805,24 @@ middle_end/base_types/tag.cmo : utils/numbers.cmi utils/misc.cmi \ utils/identifiable.cmi middle_end/base_types/tag.cmi middle_end/base_types/tag.cmx : utils/numbers.cmx utils/misc.cmx \ utils/identifiable.cmx middle_end/base_types/tag.cmi -middle_end/base_types/variable.cmo : utils/misc.cmi utils/identifiable.cmi \ - typing/ident.cmi middle_end/base_types/compilation_unit.cmi \ - middle_end/base_types/variable.cmi -middle_end/base_types/variable.cmx : utils/misc.cmx utils/identifiable.cmx \ - typing/ident.cmx middle_end/base_types/compilation_unit.cmx \ - middle_end/base_types/variable.cmi middle_end/base_types/var_within_closure.cmo : \ middle_end/base_types/closure_element.cmi \ middle_end/base_types/var_within_closure.cmi middle_end/base_types/var_within_closure.cmx : \ middle_end/base_types/closure_element.cmx \ middle_end/base_types/var_within_closure.cmi +middle_end/base_types/variable.cmo : utils/misc.cmi utils/identifiable.cmi \ + typing/ident.cmi middle_end/base_types/compilation_unit.cmi \ + middle_end/base_types/variable.cmi +middle_end/base_types/variable.cmx : utils/misc.cmx utils/identifiable.cmx \ + typing/ident.cmx middle_end/base_types/compilation_unit.cmx \ + middle_end/base_types/variable.cmi driver/compenv.cmi : driver/compile.cmi : driver/compmisc.cmi : typing/env.cmi driver/errors.cmi : -driver/main_args.cmi : driver/main.cmi : +driver/main_args.cmi : driver/optcompile.cmi : driver/opterrors.cmi : driver/optmain.cmi : @@ -1854,8 +1859,6 @@ driver/compmisc.cmx : typing/typemod.cmx utils/misc.cmx \ parsing/asttypes.cmi driver/compmisc.cmi driver/errors.cmo : parsing/location.cmi driver/errors.cmi driver/errors.cmx : parsing/location.cmx driver/errors.cmi -driver/main_args.cmo : utils/warnings.cmi driver/main_args.cmi -driver/main_args.cmx : utils/warnings.cmx driver/main_args.cmi driver/main.cmo : utils/warnings.cmi utils/timings.cmi utils/misc.cmi \ driver/main_args.cmi parsing/location.cmi utils/config.cmi \ driver/compmisc.cmi driver/compile.cmi driver/compenv.cmi \ @@ -1866,6 +1869,8 @@ driver/main.cmx : utils/warnings.cmx utils/timings.cmx utils/misc.cmx \ driver/compmisc.cmx driver/compile.cmx driver/compenv.cmx \ utils/clflags.cmx bytecomp/bytepackager.cmx bytecomp/bytelink.cmx \ bytecomp/bytelibrarian.cmx driver/main.cmi +driver/main_args.cmo : utils/warnings.cmi driver/main_args.cmi +driver/main_args.cmx : utils/warnings.cmx driver/main_args.cmi driver/optcompile.cmo : utils/warnings.cmi typing/typemod.cmi \ typing/typedtree.cmi typing/typecore.cmi bytecomp/translmod.cmi \ utils/timings.cmi typing/stypes.cmi bytecomp/simplif.cmi \ diff --git a/parsing/ast_invariants.ml b/parsing/ast_invariants.ml index 5bab8a07d..22cc1282e 100644 --- a/parsing/ast_invariants.ml +++ b/parsing/ast_invariants.ml @@ -14,7 +14,7 @@ open Asttypes open Parsetree -open Ast_mapper +open Ast_iterator let err = Syntaxerr.ill_formed_ast @@ -34,41 +34,39 @@ let simple_longident id = in if not (is_simple id.txt) then complex_id id.loc -let mapper = - let super = Ast_mapper.default_mapper in +let iterator = + let super = Ast_iterator.default_iterator in let type_declaration self td = - let td = super.type_declaration self td in + super.type_declaration self td; let loc = td.ptype_loc in match td.ptype_kind with | Ptype_record [] -> empty_record loc | Ptype_variant [] -> empty_variant loc - | _ -> td + | _ -> () in let typ self ty = - let ty = super.typ self ty in + super.typ self ty; let loc = ty.ptyp_loc in match ty.ptyp_desc with | Ptyp_tuple ([] | [_]) -> invalid_tuple loc - | Ptyp_class (id, _) -> simple_longident id; ty + | Ptyp_class (id, _) -> simple_longident id | Ptyp_package (_, cstrs) -> - List.iter (fun (id, _) -> simple_longident id) cstrs; - ty - | _ -> ty + List.iter (fun (id, _) -> simple_longident id) cstrs + | _ -> () in let pat self pat = - let pat = super.pat self pat in + super.pat self pat; let loc = pat.ppat_loc in match pat.ppat_desc with | Ppat_tuple ([] | [_]) -> invalid_tuple loc | Ppat_record ([], _) -> empty_record loc - | Ppat_construct (id, _) -> simple_longident id; pat + | Ppat_construct (id, _) -> simple_longident id | Ppat_record (fields, _) -> - List.iter (fun (id, _) -> simple_longident id) fields; - pat - | _ -> pat + List.iter (fun (id, _) -> simple_longident id) fields + | _ -> () in let expr self exp = - let exp = super.expr self exp in + super.expr self exp; let loc = exp.pexp_loc in match exp.pexp_desc with | Pexp_tuple ([] | [_]) -> invalid_tuple loc @@ -80,64 +78,62 @@ let mapper = | Pexp_field (_, id) | Pexp_setfield (_, id, _) | Pexp_new id - | Pexp_open (_, id, _) -> simple_longident id; exp + | Pexp_open (_, id, _) -> simple_longident id | Pexp_record (fields, _) -> - List.iter (fun (id, _) -> simple_longident id) fields; - exp - | _ -> exp + List.iter (fun (id, _) -> simple_longident id) fields + | _ -> () in let extension_constructor self ec = - let ec = super.extension_constructor self ec in + super.extension_constructor self ec; match ec.pext_kind with - | Pext_rebind id -> simple_longident id; ec - | _ -> ec + | Pext_rebind id -> simple_longident id + | _ -> () in let class_expr self ce = - let ce = super.class_expr self ce in + super.class_expr self ce; let loc = ce.pcl_loc in match ce.pcl_desc with | Pcl_apply (_, []) -> no_args loc - | Pcl_constr (id, _) -> simple_longident id; ce - | _ -> ce + | Pcl_constr (id, _) -> simple_longident id + | _ -> () in let module_type self mty = - let mty = super.module_type self mty in + super.module_type self mty; match mty.pmty_desc with - | Pmty_alias id -> simple_longident id; mty - | _ -> mty + | Pmty_alias id -> simple_longident id + | _ -> () in let open_description self opn = - let opn = super.open_description self opn in - simple_longident opn.popen_lid; - opn + super.open_description self opn; + simple_longident opn.popen_lid in let with_constraint self wc = - let wc = super.with_constraint self wc in + super.with_constraint self wc; match wc with | Pwith_type (id, _) - | Pwith_module (id, _) -> simple_longident id; wc - | _ -> wc + | Pwith_module (id, _) -> simple_longident id + | _ -> () in let module_expr self me = - let me = super.module_expr self me in + super.module_expr self me; match me.pmod_desc with - | Pmod_ident id -> simple_longident id; me - | _ -> me + | Pmod_ident id -> simple_longident id + | _ -> () in let structure_item self st = - let st = super.structure_item self st in + super.structure_item self st; let loc = st.pstr_loc in match st.pstr_desc with | Pstr_type (_, []) -> empty_type loc | Pstr_value (_, []) -> empty_let loc - | _ -> st + | _ -> () in let signature_item self sg = - let sg = super.signature_item self sg in + super.signature_item self sg; let loc = sg.psig_loc in match sg.psig_desc with | Psig_type (_, []) -> empty_type loc - | _ -> sg + | _ -> () in { super with type_declaration @@ -154,5 +150,5 @@ let mapper = ; signature_item } -let structure st = ignore (mapper.structure mapper st : structure) -let signature sg = ignore (mapper.signature mapper sg : signature) +let structure st = iterator.structure iterator st +let signature sg = iterator.signature iterator sg diff --git a/tools/Makefile.shared b/tools/Makefile.shared index f0074a605..ba50ba662 100644 --- a/tools/Makefile.shared +++ b/tools/Makefile.shared @@ -39,7 +39,7 @@ CAMLDEP_IMPORTS=timings.cmo misc.cmo config.cmo identifiable.cmo numbers.cmo \ arg_helper.cmo clflags.cmo terminfo.cmo \ warnings.cmo location.cmo longident.cmo docstrings.cmo \ syntaxerr.cmo ast_helper.cmo parser.cmo lexer.cmo parse.cmo \ - ccomp.cmo ast_mapper.cmo ast_invariants.cmo pparse.cmo compenv.cmo \ + ccomp.cmo ast_mapper.cmo ast_iterator.cmo ast_invariants.cmo pparse.cmo compenv.cmo \ builtin_attributes.cmo ocamldep: depend.cmi $(CAMLDEP_OBJ) From e343dd0ba6c35a212e4cc82e82c01e4b4325ff18 Mon Sep 17 00:00:00 2001 From: Nicolas Ojeda Bar Date: Wed, 27 Jan 2016 22:53:00 +0100 Subject: [PATCH 3/3] Adapt emit_external_warnings and error_if_has_deep_native_repr_attributes --- .depend | 14 +++++++------- debugger/Makefile.shared | 2 +- otherlibs/dynlink/Makefile | 3 ++- parsing/builtin_attributes.ml | 8 +++----- parsing/builtin_attributes.mli | 2 +- typing/typedecl.ml | 10 +++++----- typing/typemod.ml | 12 ++++++------ 7 files changed, 25 insertions(+), 26 deletions(-) diff --git a/.depend b/.depend index aa35979b6..0137ec0b1 100644 --- a/.depend +++ b/.depend @@ -52,7 +52,7 @@ parsing/asttypes.cmi : parsing/location.cmi parsing/attr_helper.cmi : parsing/parsetree.cmi parsing/location.cmi \ parsing/asttypes.cmi parsing/builtin_attributes.cmi : parsing/parsetree.cmi parsing/location.cmi \ - parsing/ast_mapper.cmi + parsing/ast_iterator.cmi parsing/docstrings.cmi : parsing/parsetree.cmi parsing/location.cmi parsing/lexer.cmi : parsing/parser.cmi parsing/location.cmi parsing/location.cmi : utils/warnings.cmi @@ -95,10 +95,10 @@ parsing/attr_helper.cmo : parsing/parsetree.cmi parsing/location.cmi \ parsing/attr_helper.cmx : parsing/parsetree.cmi parsing/location.cmx \ parsing/asttypes.cmi parsing/attr_helper.cmi parsing/builtin_attributes.cmo : utils/warnings.cmi parsing/parsetree.cmi \ - parsing/location.cmi parsing/asttypes.cmi parsing/ast_mapper.cmi \ + parsing/location.cmi parsing/asttypes.cmi parsing/ast_iterator.cmi \ parsing/builtin_attributes.cmi parsing/builtin_attributes.cmx : utils/warnings.cmx parsing/parsetree.cmi \ - parsing/location.cmx parsing/asttypes.cmi parsing/ast_mapper.cmx \ + parsing/location.cmx parsing/asttypes.cmi parsing/ast_iterator.cmx \ parsing/builtin_attributes.cmi parsing/docstrings.cmo : utils/warnings.cmi parsing/parsetree.cmi \ parsing/location.cmi parsing/docstrings.cmi @@ -396,7 +396,7 @@ typing/typedecl.cmo : utils/warnings.cmi typing/typetexp.cmi \ parsing/longident.cmi parsing/location.cmi typing/includecore.cmi \ typing/ident.cmi typing/env.cmi typing/ctype.cmi utils/config.cmi \ utils/clflags.cmi typing/btype.cmi parsing/attr_helper.cmi \ - parsing/asttypes.cmi parsing/ast_mapper.cmi parsing/ast_helper.cmi \ + parsing/asttypes.cmi parsing/ast_iterator.cmi parsing/ast_helper.cmi \ typing/typedecl.cmi typing/typedecl.cmx : utils/warnings.cmx typing/typetexp.cmx \ typing/types.cmx typing/typedtree.cmx typing/subst.cmx \ @@ -405,7 +405,7 @@ typing/typedecl.cmx : utils/warnings.cmx typing/typetexp.cmx \ parsing/longident.cmx parsing/location.cmx typing/includecore.cmx \ typing/ident.cmx typing/env.cmx typing/ctype.cmx utils/config.cmx \ utils/clflags.cmx typing/btype.cmx parsing/attr_helper.cmx \ - parsing/asttypes.cmi parsing/ast_mapper.cmx parsing/ast_helper.cmx \ + parsing/asttypes.cmi parsing/ast_iterator.cmx parsing/ast_helper.cmx \ typing/typedecl.cmi typing/typedtree.cmo : typing/types.cmi typing/primitive.cmi typing/path.cmi \ parsing/parsetree.cmi utils/misc.cmi parsing/longident.cmi \ @@ -431,7 +431,7 @@ typing/typemod.cmo : utils/warnings.cmi typing/typetexp.cmi typing/types.cmi \ parsing/location.cmi typing/includemod.cmi typing/ident.cmi \ typing/env.cmi typing/ctype.cmi utils/config.cmi typing/cmt_format.cmi \ utils/clflags.cmi parsing/builtin_attributes.cmi typing/btype.cmi \ - parsing/asttypes.cmi parsing/ast_mapper.cmi typing/annot.cmi \ + parsing/asttypes.cmi parsing/ast_iterator.cmi typing/annot.cmi \ typing/typemod.cmi typing/typemod.cmx : utils/warnings.cmx typing/typetexp.cmx typing/types.cmx \ typing/typedtree.cmx typing/typedecl.cmx typing/typecore.cmx \ @@ -441,7 +441,7 @@ typing/typemod.cmx : utils/warnings.cmx typing/typetexp.cmx typing/types.cmx \ parsing/location.cmx typing/includemod.cmx typing/ident.cmx \ typing/env.cmx typing/ctype.cmx utils/config.cmx typing/cmt_format.cmx \ utils/clflags.cmx parsing/builtin_attributes.cmx typing/btype.cmx \ - parsing/asttypes.cmi parsing/ast_mapper.cmx typing/annot.cmi \ + parsing/asttypes.cmi parsing/ast_iterator.cmx typing/annot.cmi \ typing/typemod.cmi typing/types.cmo : typing/primitive.cmi typing/path.cmi \ parsing/parsetree.cmi parsing/longident.cmi parsing/location.cmi \ diff --git a/debugger/Makefile.shared b/debugger/Makefile.shared index a296bf26c..30df6492d 100644 --- a/debugger/Makefile.shared +++ b/debugger/Makefile.shared @@ -37,7 +37,7 @@ OTHEROBJS=\ ../utils/terminfo.cmo \ ../parsing/location.cmo ../parsing/longident.cmo ../parsing/docstrings.cmo \ ../parsing/ast_helper.cmo ../parsing/ast_mapper.cmo \ - ../parsing/attr_helper.cmo \ + ../parsing/ast_iterator.cmo ../parsing/attr_helper.cmo \ ../parsing/builtin_attributes.cmo \ ../typing/ident.cmo ../typing/path.cmo ../typing/types.cmo \ ../typing/btype.cmo ../typing/primitive.cmo ../typing/typedtree.cmo \ diff --git a/otherlibs/dynlink/Makefile b/otherlibs/dynlink/Makefile index e95e76363..26ad34cd1 100644 --- a/otherlibs/dynlink/Makefile +++ b/otherlibs/dynlink/Makefile @@ -38,7 +38,8 @@ COMPILEROBJS=\ ../../parsing/asttypes.cmi \ ../../parsing/location.cmo ../../parsing/longident.cmo \ ../../parsing/docstrings.cmo ../../parsing/ast_helper.cmo \ - ../../parsing/ast_mapper.cmo ../../parsing/attr_helper.cmo \ + ../../parsing/ast_mapper.cmo ../../parsing/ast_iterator.cmo \ + ../../parsing/attr_helper.cmo \ ../../parsing/builtin_attributes.cmo \ ../../typing/ident.cmo ../../typing/path.cmo \ ../../typing/primitive.cmo ../../typing/types.cmo \ diff --git a/parsing/builtin_attributes.ml b/parsing/builtin_attributes.ml index 87d6c7930..e9d0fa916 100755 --- a/parsing/builtin_attributes.ml +++ b/parsing/builtin_attributes.ml @@ -106,19 +106,17 @@ let emit_external_warnings = 'ppwarning' attributes during the actual type-checking, making sure to cover all contexts (easier and more ugly alternative: duplicate here the logic which control warnings locally). *) - let open Ast_mapper in + let open Ast_iterator in { - default_mapper with + default_iterator with attribute = (fun _ a -> - begin match a with + match a with | {txt="ocaml.ppwarning"|"ppwarning"}, PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant (Pconst_string (s, _))},_); pstr_loc}] -> Location.prerr_warning pstr_loc (Warnings.Preprocessor s) | _ -> () - end; - a ) } diff --git a/parsing/builtin_attributes.mli b/parsing/builtin_attributes.mli index 2760bf5f5..ee2be723c 100755 --- a/parsing/builtin_attributes.mli +++ b/parsing/builtin_attributes.mli @@ -37,7 +37,7 @@ val warning_leave_scope: unit -> unit val warning_attribute: Parsetree.attributes -> unit val with_warning_attribute: Parsetree.attributes -> (unit -> 'a) -> 'a -val emit_external_warnings: Ast_mapper.mapper +val emit_external_warnings: Ast_iterator.iterator val warn_on_literal_pattern: Parsetree.attributes -> bool val explicit_arity: Parsetree.attributes -> bool diff --git a/typing/typedecl.ml b/typing/typedecl.ml index 1b9fad07c..15f89d702 100644 --- a/typing/typedecl.ml +++ b/typing/typedecl.ml @@ -1394,9 +1394,9 @@ let native_repr_of_type env kind ty = (* Raises an error when [core_type] contains an [@unboxed] or [@untagged] attribute in a strict sub-term. *) let error_if_has_deep_native_repr_attributes core_type = - let open Ast_mapper in - let this_mapper = - { default_mapper with typ = fun mapper core_type -> + let open Ast_iterator in + let this_iterator = + { default_iterator with typ = fun iterator core_type -> begin match get_native_repr_attribute core_type.ptyp_attributes ~global_repr:None @@ -1405,9 +1405,9 @@ let error_if_has_deep_native_repr_attributes core_type = raise (Error (core_type.ptyp_loc, Deep_unbox_or_untag_attribute kind)) | Native_repr_attr_absent -> () end; - default_mapper.typ mapper core_type } + default_iterator.typ iterator core_type } in - ignore (default_mapper.typ this_mapper core_type : Parsetree.core_type) + default_iterator.typ this_iterator core_type let make_native_repr env core_type ty ~global_repr = error_if_has_deep_native_repr_attributes core_type; diff --git a/typing/typemod.ml b/typing/typemod.ml index a45f8281e..7a81c8343 100644 --- a/typing/typemod.ml +++ b/typing/typemod.ml @@ -1465,8 +1465,8 @@ and type_structure ?(toplevel = false) funct_body anchor env sstr scope = let type_toplevel_phrase env s = Env.reset_required_globals (); begin - let map = Builtin_attributes.emit_external_warnings in - ignore (map.Ast_mapper.structure map s) + let iter = Builtin_attributes.emit_external_warnings in + iter.Ast_iterator.structure iter s end; type_structure ~toplevel:true false None env s Location.none let type_module_alias = type_module ~alias:true true false None @@ -1570,8 +1570,8 @@ let type_implementation sourcefile outputprefix modulename initial_env ast = Typecore.reset_delayed_checks (); Env.reset_required_globals (); begin - let map = Builtin_attributes.emit_external_warnings in - ignore (map.Ast_mapper.structure map ast) + let iter = Builtin_attributes.emit_external_warnings in + iter.Ast_iterator.structure iter ast end; let (str, sg, finalenv) = @@ -1639,8 +1639,8 @@ let save_signature modname tsg outputprefix source_file initial_env cmi = let type_interface env ast = begin - let map = Builtin_attributes.emit_external_warnings in - ignore (map.Ast_mapper.signature map ast) + let iter = Builtin_attributes.emit_external_warnings in + iter.Ast_iterator.signature iter ast end; transl_signature env ast