···99 iOS and other Darwin targets.
1010 (Mark Shinwell, review by Nicolas Ojeda Bar and Xavier Leroy)
11111212+- #7887: ensure frame table is 8-aligned on ARM64 and PPC64
1313+ (Xavier Leroy, report by Mark Hayden, review by Mark Shinwell
1414+ and Gabriel Scherer)
1515+1216- #8507: Shorten symbol names of anonymous functions in Flambda mode
1317 (the directory portions are now hidden)
1418 (Mark Shinwell, review by Nicolás Ojeda Bär)
···8387- #2291: Add [Compute_ranges] pass
8488 (Mark Shinwell, review by Vincent Laviron)
85899090+- #2292: Add [Proc.frame_required] and [Proc.prologue_required].
9191+ Move tail recursion label creation to [Linearize]. Correctly position
9292+ [Lprologue] relative to [Iname_for_debugger] operations.
9393+ (Mark Shinwell, review by Vincent Laviron)
9494+8695- #2308: More debugging information on [Cmm] terms
8796 (Mark Shinwell, review by Stephen Dolan)
9797+9898+- #7878, #8542: Replaced TypedtreeIter with tast_iterator
9999+ (Isaac "Izzy" Avram, review by Gabriel Scherer and Nicolás Ojeda Bär)
8810089101### Runtime system:
901029191-- #1725: Deprecate Obj.set_tag
9292- (Stephen Dolan, review by Gabriel Scherer and Damien Doligez)
103103+- #1725, #2279: Deprecate Obj.set_tag and Obj.truncate
104104+ (Stephen Dolan, review by Gabriel Scherer, Damien Doligez and Xavier Leroy)
9310594106* #2240: Constify "identifier" in struct custom_operations
95107 (Cedric Cellier, review by Xavier Leroy)
···352364- #1525: Make function set_max_indent respect documentation
353365 (Pierre Weis, Richard Bonichon, review by Florian Angeletti)
354366367367+- GPR#2202: Correct Hashtbl.MakeSeeded.{add_seq,replace_seq,of_seq} to use
368368+ functor hash function instead of default hash function. Hashtbl.Make.of_seq
369369+ shouldn't create randomized hash tables.
370370+ (David Allsopp, review by Alain Frisch)
371371+355372### Other libraries:
356373357374- #2222: Set default status in waitpid when pid is zero. Otherwise,
···519536- #1917: comballoc: ensure object allocation order is preserved
520537 (Stephen Dolan)
521538522522-- #6242, #2143: optimize some local functions
539539+- #6242, #2143, #8558, #8559: optimize some local functions
523540 (Alain Frisch, review by Gabriel Scherer)
524541525542- #2082: New options [-insn-sched] and [-no-insn-sched] to control
···5656 fun_fast: bool;
5757 fun_dbg : Debuginfo.t;
5858 fun_spacetime_shape : Mach.spacetime_shape option;
5959+ fun_tailrec_entry_point_label : label;
5960 }
60616162(* Invert a test *)
···314315 copy_instr (Lraise k) i (discard_dead_code n)
315316316317let add_prologue first_insn =
317317- let insn = first_insn in
318318- { desc = Lprologue;
319319- next = insn;
320320- arg = [| |];
321321- res = [| |];
322322- dbg = insn.dbg;
323323- live = insn.live;
324324- }
318318+ (* The prologue needs to come after any [Iname_for_debugger] operations that
319319+ refer to parameters. (Such operations always come in a contiguous
320320+ block, cf. [Selectgen].) *)
321321+ let rec skip_naming_ops (insn : instruction) : label * instruction =
322322+ match insn.desc with
323323+ | Lop (Iname_for_debugger _) ->
324324+ let tailrec_entry_point_label, next = skip_naming_ops insn.next in
325325+ tailrec_entry_point_label, { insn with next; }
326326+ | _ ->
327327+ let tailrec_entry_point_label = Cmm.new_label () in
328328+ let tailrec_entry_point =
329329+ { desc = Llabel tailrec_entry_point_label;
330330+ next = insn;
331331+ arg = [| |];
332332+ res = [| |];
333333+ dbg = insn.dbg;
334334+ live = insn.live;
335335+ }
336336+ in
337337+ (* We expect [Lprologue] to expand to at least one instruction---as such,
338338+ if no prologue is required, we avoid adding the instruction here.
339339+ The reason is subtle: an empty expansion of [Lprologue] can cause
340340+ two labels, one either side of the [Lprologue], to point at the same
341341+ location. This means that we lose the property (cf. [Coalesce_labels])
342342+ that we can check if two labels point at the same location by
343343+ comparing them for equality. This causes trouble when the function
344344+ whose prologue is in question lands at the top of the object file
345345+ and we are emitting DWARF debugging information:
346346+ foo_code_begin:
347347+ foo:
348348+ .L1:
349349+ ; empty prologue
350350+ .L2:
351351+ ...
352352+ If we were to emit a location list entry from L1...L2, not realising
353353+ that they point at the same location, then the beginning and ending
354354+ points of the range would be both equal to each other and (relative to
355355+ "foo_code_begin") equal to zero. This appears to confuse objdump,
356356+ which seemingly misinterprets the entry as an end-of-list entry
357357+ (which is encoded with two zero words), then complaining about a
358358+ "hole in location list" (as it ignores any remaining list entries
359359+ after the misinterpreted entry). *)
360360+ if Proc.prologue_required () then
361361+ let prologue =
362362+ { desc = Lprologue;
363363+ next = tailrec_entry_point;
364364+ arg = [| |];
365365+ res = [| |];
366366+ dbg = tailrec_entry_point.dbg;
367367+ live = Reg.Set.empty; (* will not be used *)
368368+ }
369369+ in
370370+ tailrec_entry_point_label, prologue
371371+ else
372372+ tailrec_entry_point_label, tailrec_entry_point
373373+ in
374374+ skip_naming_ops first_insn
325375326376let fundecl f =
327327- let fun_body = add_prologue (linear f.Mach.fun_body end_instr) in
377377+ let fun_tailrec_entry_point_label, fun_body =
378378+ add_prologue (linear f.Mach.fun_body end_instr)
379379+ in
328380 { fun_name = f.Mach.fun_name;
329381 fun_args = Reg.set_of_array f.Mach.fun_args;
330382 fun_body;
331383 fun_fast = not (List.mem Cmm.Reduce_code_size f.Mach.fun_codegen_options);
332384 fun_dbg = f.Mach.fun_dbg;
333385 fun_spacetime_shape = f.Mach.fun_spacetime_shape;
386386+ fun_tailrec_entry_point_label;
334387 }
···527527 match i.desc with
528528 | Lend -> ()
529529 | Lprologue ->
530530+ assert (Proc.prologue_required ());
530531 let n = frame_size() in
531532 if n > 0 then begin
532533 ` addi 1, 1, {emit_int(-n)}\n`;
···541542 | ELF32 -> ()
542543 | ELF64v1 | ELF64v2 ->
543544 ` std 2, {emit_int(toc_save_offset())}(1)\n`
544544- end;
545545- `{emit_label !tailrec_entry_point}:\n`
545545+ end
546546 | Lop(Imove | Ispill | Ireload) ->
547547 let src = i.arg.(0) and dst = i.res.(0) in
548548 if src.loc <> dst.loc then begin
···1007100710081008let fundecl fundecl =
10091009 function_name := fundecl.fun_name;
10101010- tailrec_entry_point := new_label();
10101010+ tailrec_entry_point := fundecl.fun_tailrec_entry_point_label;
10111011 stack_offset := 0;
10121012 call_gc_label := 0;
10131013 float_literals := [];
···11771177 ` {emit_string datag} 0\n`;
11781178 (* Emit the frame descriptors *)
11791179 emit_string data_space; (* not rodata_space because it contains relocations *)
11801180+ if ppc64 then ` .align 3\n`; (* #7887 *)
11801181 let lbl = Compilenv.make_symbol (Some "frametable") in
11811182 declare_global_data lbl;
11821183 `{emit_symbol lbl}:\n`;
+20
asmcomp/power/proc.ml
···341341let num_stack_slots = [| 0; 0 |]
342342let contains_calls = ref false
343343344344+(* See [reserved_stack_space] in emit.mlp. *)
345345+let reserved_stack_space_required () =
346346+ match abi with
347347+ | ELF32 -> false
348348+ | ELF64v1 | ELF64v2 -> true
349349+350350+let frame_required () =
351351+ let is_elf32 =
352352+ match abi with
353353+ | ELF32 -> true
354354+ | ELF64v1 | ELF64v2 -> false
355355+ in
356356+ reserved_stack_space_required ()
357357+ || num_stack_slots.(0) > 0
358358+ || num_stack_slots.(1) > 0
359359+ || (!contains_calls && is_elf32)
360360+361361+let prologue_required () =
362362+ frame_required ()
363363+344364(* Calling the assembler *)
345365346366let assemble_file infile outfile =
+4
asmcomp/proc.mli
···6767(* Info for laying out the stack frame *)
6868val num_stack_slots: int array
6969val contains_calls: bool ref
7070+val frame_required : unit -> bool
7171+7272+(* Function prologues *)
7373+val prologue_required : unit -> bool
70747175(** For a given register class, the DWARF register numbering for that class.
7276 Given an allocated register with location [Reg n] and class [reg_class], the
+3-3
asmcomp/s390x/emit.mlp
···308308 match i.desc with
309309 Lend -> ()
310310 | Lprologue ->
311311+ assert (Proc.prologue_required ());
311312 let n = frame_size() in
312313 emit_stack_adjust n;
313314 if !contains_calls then
314314- ` stg %r14, {emit_int(n - size_addr)}(%r15)\n`;
315315- `{emit_label !tailrec_entry_point}:\n`;
315315+ ` stg %r14, {emit_int(n - size_addr)}(%r15)\n`
316316 | Lop(Imove | Ispill | Ireload) ->
317317 let src = i.arg.(0) and dst = i.res.(0) in
318318 if src.loc <> dst.loc then begin
···648648649649let fundecl fundecl =
650650 function_name := fundecl.fun_name;
651651- tailrec_entry_point := new_label();
651651+ tailrec_entry_point := fundecl.fun_tailrec_entry_point_label;
652652 stack_offset := 0;
653653 call_gc_sites := [];
654654 bound_error_sites := [];
···1919 dynlink_platform_intf)
2020 ; the -33 is specific to the hackery done with dune.
2121 (flags (:standard -nostdlib -w -33))
2222+ (modules_without_implementation dynlink)
2223 (libraries ocamlcommon stdlib))
23242425(rule
+21
runtime/sys.c
···396396 CAMLreturn(res);
397397}
398398399399+CAMLprim value caml_sys_argv(value unit)
400400+{
401401+ CAMLparam0 (); /* unit is unused */
402402+ CAMLlocal1 (argv);
403403+ argv =
404404+ caml_alloc_array((void *)caml_copy_string_of_os,
405405+ (char const **)caml_params->main_argv);
406406+ CAMLreturn(argv);
407407+}
408408+409409+CAMLprim value caml_sys_modify_argv(value new_argv)
410410+{
411411+ caml_failwith ("caml_sys_modify_argv: not implemented");
412412+ return Val_unit;
413413+}
414414+415415+CAMLprim value caml_sys_executable_name(value unit)
416416+{
417417+ return caml_copy_string_of_os(caml_params->exe_name);
418418+}
419419+399420void caml_sys_init(char_os * exe_name, char_os **argv)
400421{
401422 caml_failwith ("caml_sys_init: not implemented");
···5252let rec update_mod shape o n =
5353 match shape with
5454 | Function ->
5555- assert (Obj.tag n = Obj.closure_tag || Obj.tag n = Obj.infix_tag);
5656- overwrite o (Obj.repr (fun x -> (Obj.obj n : _ -> _) x))
5555+ (* The optimisation below is invalid on bytecode since
5656+ the RESTART instruction checks the length of closures.
5757+ See PR#4008 *)
5858+ if Sys.backend_type = Sys.Native
5959+ && Obj.tag n = Obj.closure_tag
6060+ && Obj.size n <= Obj.size o
6161+ then begin overwrite o n end
6262+ else overwrite o (Obj.repr (fun x -> (Obj.obj n : _ -> _) x))
5763 | Lazy ->
5864 if Obj.tag n = Obj.lazy_tag then
5965 Obj.set_field o 0 (Obj.field n 0)
+12
stdlib/ephemeron.ml
···482482 let hash (_seed: int) x = H.hash x
483483 end)
484484 let create sz = create ~random:false sz
485485+ let of_seq i =
486486+ let tbl = create 16 in
487487+ replace_seq tbl i;
488488+ tbl
485489 end
486490487491end
···570574 let hash (_seed: int) x = H2.hash x
571575 end)
572576 let create sz = create ~random:false sz
577577+ let of_seq i =
578578+ let tbl = create 16 in
579579+ replace_seq tbl i;
580580+ tbl
573581 end
574582575583end
···670678 let hash (_seed: int) x = H.hash x
671679 end)
672680 let create sz = create ~random:false sz
681681+ let of_seq i =
682682+ let tbl = create 16 in
683683+ replace_seq tbl i;
684684+ tbl
673685 end
674686end
+15-3
stdlib/hashtbl.ml
···570570 H.equal k key || mem_in_bucket next in
571571 mem_in_bucket h.data.(key_index h key)
572572573573+ let add_seq tbl i =
574574+ Seq.iter (fun (k,v) -> add tbl k v) i
575575+576576+ let replace_seq tbl i =
577577+ Seq.iter (fun (k,v) -> replace tbl k v) i
578578+579579+ let of_seq i =
580580+ let tbl = create 16 in
581581+ replace_seq tbl i;
582582+ tbl
583583+573584 let iter = iter
574585 let filter_map_inplace = filter_map_inplace
575586 let fold = fold
···578589 let to_seq = to_seq
579590 let to_seq_keys = to_seq_keys
580591 let to_seq_values = to_seq_values
581581- let add_seq = add_seq
582582- let replace_seq = replace_seq
583583- let of_seq = of_seq
584592 end
585593586594module Make(H: HashedType): (S with type key = H.t) =
···591599 let hash (_seed: int) x = H.hash x
592600 end)
593601 let create sz = create ~random:false sz
602602+ let of_seq i =
603603+ let tbl = create 16 in
604604+ replace_seq tbl i;
605605+ tbl
594606 end
+1
stdlib/obj.mli
···6666external new_block : int -> int -> t = "caml_obj_block"
6767external dup : t -> t = "caml_obj_dup"
6868external truncate : t -> int -> unit = "caml_obj_truncate"
6969+ [@@ocaml.deprecated]
6970external add_offset : t -> Int32.t -> t = "caml_obj_add_offset"
7071 (* @since 3.12.0 *)
7172external with_tag : int -> t -> t = "caml_obj_with_tag"
+1-1
stdlib/sys.mli
···2020 an error.
2121*)
22222323-val argv : string array
2323+external argv : string array = "%sys_argv"
2424(** The command line arguments given to the process.
2525 The first element is the command name used to invoke the program.
2626 The following elements are the command-line arguments
+3-2
stdlib/sys.mlp
···2525(* System interface *)
26262727external get_config: unit -> string * int * bool = "caml_sys_get_config"
2828-external get_argv: unit -> string * string array = "caml_sys_get_argv"
2828+external get_executable_name : unit -> string = "caml_sys_executable_name"
2929+external argv : string array = "%sys_argv"
2930external big_endian : unit -> bool = "%big_endian"
3031external word_size : unit -> int = "%word_size"
3132external int_size : unit -> int = "%int_size"
···3536external cygwin : unit -> bool = "%ostype_cygwin"
3637external get_backend_type : unit -> backend_type = "%backend_type"
37383838-let (executable_name, argv) = get_argv()
3939+let executable_name = get_executable_name()
3940let (os_type, _, _) = get_config()
4041let backend_type = get_backend_type ()
4142let big_endian = big_endian ()
+4-2
stdlib/weak.ml
···204204 t.table.(t.rover) <- emptybucket;
205205 t.hashes.(t.rover) <- [| |];
206206 end else begin
207207- Obj.truncate (Obj.repr bucket) (prev_len + additional_values);
208208- Obj.truncate (Obj.repr hbucket) prev_len;
207207+ let newbucket = weak_create prev_len in
208208+ blit bucket 0 newbucket 0 prev_len;
209209+ t.table.(t.rover) <- newbucket;
210210+ t.hashes.(t.rover) <- Array.sub hbucket 0 prev_len
209211 end;
210212 if len > t.limit && prev_len <= t.limit then t.oversize <- t.oversize - 1;
211213 end;
···11+module rec M : sig
22+ val f : int list -> int list
33+end = struct
44+ let f = List.map succ
55+end
66+let v = M.f []
+9
testsuite/tests/basic/localfunction.ml
···2121 Printf.printf "%i\n%!" !r;
2222 assert(x1 -. x0 = x2 -. x1)
2323 (* check that we did not allocated anything between x1 and x2 *)
2424+2525+2626+let () =
2727+ (* #8558 *)
2828+ let f () = () in
2929+ let r = ref 0 in
3030+ let g () = f (incr r) in
3131+ g ();
3232+ assert (!r = 1)
-3
testsuite/tests/misc/sorts.ml
···41644164 done;
41654165;;
4166416641674167-(************************************************************************)
41684168-(* merge sort on lists via arrays *)
41694169-41704167let array_of_list l len =
41714168 match l with
41724169 | [] -> [| |]
···607607 | x -> Location.report_exception ppf x; Btype.backtrack snap
608608 done
609609610610-(* Execute a script. If [name] is "", read the script from stdin. *)
610610+external caml_sys_modify_argv : string array -> unit =
611611+ "caml_sys_modify_argv"
611612612612-let override_sys_argv args =
613613- let len = Array.length args in
614614- if Array.length Sys.argv < len then invalid_arg "Toploop.override_sys_argv";
615615- Array.blit args 0 Sys.argv 0 len;
616616- Obj.truncate (Obj.repr Sys.argv) len;
613613+let override_sys_argv new_argv =
614614+ caml_sys_modify_argv new_argv;
617615 Arg.current := 0
618616619619-module type SYS = module type of Sys
620620-621621-(* The script must see a different value for the "constant" Sys.argv.
622622- So, rewrite the module to claim it was always that way *)
623623-let hack_argv new_argv =
624624- let new_argv = Obj.repr new_argv in
625625- let old_argv = Obj.repr Sys.argv in
626626- let sys_mod = Obj.repr (module Sys : SYS) in
627627- for i = 0 to Obj.size sys_mod - 1 do
628628- if Obj.field sys_mod i == old_argv then
629629- Obj.set_field sys_mod i new_argv
630630- done
617617+(* Execute a script. If [name] is "", read the script from stdin. *)
631618632619let run_script ppf name args =
633633- hack_argv args;
634634- Arg.current := 0;
620620+ override_sys_argv args;
635621 Compmisc.init_path ~dir:(Filename.dirname name) ();
636622 (* Note: would use [Filename.abspath] here, if we had it. *)
637623 toplevel_env := Compmisc.initial_env();
+5-15
toplevel/toploop.ml
···565565 | x -> Location.report_exception ppf x; Btype.backtrack snap
566566 done
567567568568-(* Execute a script. If [name] is "", read the script from stdin. *)
569569-570570-(* The script must see a different value for the "constant" Sys.argv.
571571- So, rewrite the module to claim it was always that way *)
572572-module type SYS = module type of Sys
568568+external caml_sys_modify_argv : string array -> unit =
569569+ "caml_sys_modify_argv"
573570574574-let hack_argv new_argv =
575575- let new_argv = Obj.repr new_argv in
576576- let old_argv = Obj.repr Sys.argv in
577577- let sys_mod = Obj.repr (module Sys : SYS) in
578578- for i = 0 to Obj.size sys_mod - 1 do
579579- if Obj.field sys_mod i == old_argv then
580580- Obj.set_field sys_mod i new_argv
581581- done;
571571+let override_sys_argv new_argv =
572572+ caml_sys_modify_argv new_argv;
582573 Arg.current := 0
583574584584-let override_sys_argv = hack_argv
575575+(* Execute a script. If [name] is "", read the script from stdin. *)
585576586577let run_script ppf name args =
587587-(* override_sys_argv args; *)
588578 override_sys_argv args;
589579 Compmisc.init_path ~dir:(Filename.dirname name) ();
590580 (* Note: would use [Filename.abspath] here, if we had it. *)
+24-26
typing/parmatch.ml
···2440244024412441let all_rhs_idents exp =
24422442 let ids = ref Ident.Set.empty in
24432443- let module Iterator = TypedtreeIter.MakeIterator(struct
24442444- include TypedtreeIter.DefaultIteratorArgument
24452445- let enter_expression exp = match exp.exp_desc with
24462446- | Texp_ident (path, _lid, _descr) ->
24472447- List.iter
24482448- (fun id -> ids := Ident.Set.add id !ids)
24492449- (Path.heads path)
24502450- | _ -> ()
24512451-24522443(* Very hackish, detect unpack pattern compilation
24532444 and perform "indirect check for them" *)
24542454- let is_unpack exp =
24452445+ let is_unpack exp =
24552446 List.exists
24562447 (fun attr -> attr.Parsetree.attr_name.txt = "#modulepat")
24572457- exp.exp_attributes
24482448+ exp.exp_attributes in
24492449+ let open Tast_iterator in
24502450+ let expr_iter iter exp =
24512451+ (match exp.exp_desc with
24522452+ | Texp_ident (path, _lid, _descr) ->
24532453+ List.iter (fun id -> ids := Ident.Set.add id !ids) (Path.heads path)
24542454+ (* Use default iterator methods for rest of match.*)
24552455+ | _ -> Tast_iterator.default_iterator.expr iter exp);
2458245624592459- let leave_expression exp =
24602460- if is_unpack exp then begin match exp.exp_desc with
24612461- | Texp_letmodule
24622462- (id_mod,_,_,
24632463- {mod_desc=
24642464- Tmod_unpack ({exp_desc=Texp_ident (Path.Pident id_exp,_,_)},_)},
24652465- _) ->
24662466- assert (Ident.Set.mem id_exp !ids) ;
24672467- if not (Ident.Set.mem id_mod !ids) then begin
24682468- ids := Ident.Set.remove id_exp !ids
24692469- end
24702470- | _ -> assert false
24712471- end
24722472- end) in
24732473- Iterator.iter_expression exp;
24572457+ if is_unpack exp then begin match exp.exp_desc with
24582458+ | Texp_letmodule
24592459+ (id_mod,_,_,
24602460+ {mod_desc=
24612461+ Tmod_unpack ({exp_desc=Texp_ident (Path.Pident id_exp,_,_)},_)},
24622462+ _) ->
24632463+ assert (Ident.Set.mem id_exp !ids) ;
24642464+ if not (Ident.Set.mem id_mod !ids) then begin
24652465+ ids := Ident.Set.remove id_exp !ids
24662466+ end
24672467+ | _ -> assert false
24682468+ end
24692469+ in
24702470+ let iterator = {Tast_iterator.default_iterator with expr = expr_iter} in
24712471+ iterator.expr iterator exp;
24742472 !ids
2475247324762474let check_ambiguous_bindings =
+510
typing/tast_iterator.ml
···11+(**************************************************************************)
22+(* *)
33+(* OCaml *)
44+(* *)
55+(* Isaac "Izzy" Avram *)
66+(* *)
77+(* Copyright 2019 Institut National de Recherche en Informatique et *)
88+(* en Automatique. *)
99+(* *)
1010+(* All rights reserved. This file is distributed under the terms of *)
1111+(* the GNU Lesser General Public License version 2.1, with the *)
1212+(* special exception on linking described in the file LICENSE. *)
1313+(* *)
1414+(**************************************************************************)
1515+1616+open Asttypes
1717+open Typedtree
1818+1919+type iterator =
2020+ {
2121+ binding_op: iterator -> binding_op -> unit;
2222+ case: iterator -> case -> unit;
2323+ cases: iterator -> case list -> unit;
2424+ class_declaration: iterator -> class_declaration -> unit;
2525+ class_description: iterator -> class_description -> unit;
2626+ class_expr: iterator -> class_expr -> unit;
2727+ class_field: iterator -> class_field -> unit;
2828+ class_signature: iterator -> class_signature -> unit;
2929+ class_structure: iterator -> class_structure -> unit;
3030+ class_type: iterator -> class_type -> unit;
3131+ class_type_declaration: iterator -> class_type_declaration -> unit;
3232+ class_type_field: iterator -> class_type_field -> unit;
3333+ env: iterator -> Env.t -> unit;
3434+ expr: iterator -> expression -> unit;
3535+ extension_constructor: iterator -> extension_constructor -> unit;
3636+ module_binding: iterator -> module_binding -> unit;
3737+ module_coercion: iterator -> module_coercion -> unit;
3838+ module_declaration: iterator -> module_declaration -> unit;
3939+ module_substitution: iterator -> module_substitution -> unit;
4040+ module_expr: iterator -> module_expr -> unit;
4141+ module_type: iterator -> module_type -> unit;
4242+ module_type_declaration: iterator -> module_type_declaration -> unit;
4343+ package_type: iterator -> package_type -> unit;
4444+ pat: iterator -> pattern -> unit;
4545+ row_field: iterator -> row_field -> unit;
4646+ object_field: iterator -> object_field -> unit;
4747+ open_declaration: iterator -> open_declaration -> unit;
4848+ open_description: iterator -> open_description -> unit;
4949+ signature: iterator -> signature -> unit;
5050+ signature_item: iterator -> signature_item -> unit;
5151+ structure: iterator -> structure -> unit;
5252+ structure_item: iterator -> structure_item -> unit;
5353+ typ: iterator -> core_type -> unit;
5454+ type_declaration: iterator -> type_declaration -> unit;
5555+ type_declarations: iterator -> (rec_flag * type_declaration list) -> unit;
5656+ type_extension: iterator -> type_extension -> unit;
5757+ type_exception: iterator -> type_exception -> unit;
5858+ type_kind: iterator -> type_kind -> unit;
5959+ value_binding: iterator -> value_binding -> unit;
6060+ value_bindings: iterator -> (rec_flag * value_binding list) -> unit;
6161+ value_description: iterator -> value_description -> unit;
6262+ with_constraint: iterator -> with_constraint -> unit;
6363+ }
6464+6565+let structure sub {str_items; str_final_env; _} =
6666+ List.iter (sub.structure_item sub) str_items;
6767+ sub.env sub str_final_env
6868+6969+let class_infos sub f x =
7070+ List.iter (fun (ct, _) -> sub.typ sub ct) x.ci_params;
7171+ f x.ci_expr
7272+7373+let module_type_declaration sub {mtd_type; _} =
7474+ Option.iter (sub.module_type sub) mtd_type
7575+7676+let module_declaration sub {md_type; _} =
7777+ sub.module_type sub md_type
7878+let module_substitution _ _ = ()
7979+8080+let include_infos f {incl_mod; _} = f incl_mod
8181+8282+let class_type_declaration sub x =
8383+ class_infos sub (sub.class_type sub) x
8484+8585+let class_declaration sub x =
8686+ class_infos sub (sub.class_expr sub) x
8787+8888+let structure_item sub {str_desc; str_env; _} =
8989+ sub.env sub str_env;
9090+ match str_desc with
9191+ | Tstr_eval (exp, _) -> sub.expr sub exp
9292+ | Tstr_value (rec_flag, list) -> sub.value_bindings sub (rec_flag, list)
9393+ | Tstr_primitive v -> sub.value_description sub v
9494+ | Tstr_type (rec_flag, list) -> sub.type_declarations sub (rec_flag, list)
9595+ | Tstr_typext te -> sub.type_extension sub te
9696+ | Tstr_effect ext -> sub.extension_constructor sub ext
9797+ | Tstr_exception ext -> sub.type_exception sub ext
9898+ | Tstr_module mb -> sub.module_binding sub mb
9999+ | Tstr_recmodule list -> List.iter (sub.module_binding sub) list
100100+ | Tstr_modtype x -> sub.module_type_declaration sub x
101101+ | Tstr_class list ->
102102+ List.iter (fun (cls,_) -> sub.class_declaration sub cls) list
103103+ | Tstr_class_type list ->
104104+ List.iter (fun (_, _, cltd) -> sub.class_type_declaration sub cltd) list
105105+ | Tstr_include incl -> include_infos (sub.module_expr sub) incl
106106+ | Tstr_open od -> sub.open_declaration sub od
107107+ | Tstr_attribute _ -> ()
108108+109109+let value_description sub x = sub.typ sub x.val_desc
110110+111111+let label_decl sub {ld_type; _} = sub.typ sub ld_type
112112+113113+let constructor_args sub = function
114114+ | Cstr_tuple l -> List.iter (sub.typ sub) l
115115+ | Cstr_record l -> List.iter (label_decl sub) l
116116+117117+let constructor_decl sub {cd_args; cd_res; _} =
118118+ constructor_args sub cd_args;
119119+ Option.iter (sub.typ sub) cd_res
120120+121121+let type_kind sub = function
122122+ | Ttype_abstract -> ()
123123+ | Ttype_variant list -> List.iter (constructor_decl sub) list
124124+ | Ttype_record list -> List.iter (label_decl sub) list
125125+ | Ttype_open -> ()
126126+127127+let type_declaration sub {typ_cstrs; typ_kind; typ_manifest; typ_params; _} =
128128+ List.iter
129129+ (fun (c1, c2, _) ->
130130+ sub.typ sub c1;
131131+ sub.typ sub c2)
132132+ typ_cstrs;
133133+ sub.type_kind sub typ_kind;
134134+ Option.iter (sub.typ sub) typ_manifest;
135135+ List.iter (fun (c, _) -> sub.typ sub c) typ_params
136136+137137+let type_declarations sub (_, list) = List.iter (sub.type_declaration sub) list
138138+139139+let type_extension sub {tyext_constructors; tyext_params; _} =
140140+ List.iter (fun (c, _) -> sub.typ sub c) tyext_params;
141141+ List.iter (sub.extension_constructor sub) tyext_constructors
142142+143143+let type_exception sub {tyexn_constructor; _} =
144144+ sub.extension_constructor sub tyexn_constructor
145145+146146+let extension_constructor sub {ext_kind; _} =
147147+ match ext_kind with
148148+ | Text_decl (ctl, cto) ->
149149+ constructor_args sub ctl;
150150+ Option.iter (sub.typ sub) cto
151151+ | Text_rebind _ -> ()
152152+153153+let pat sub {pat_extra; pat_desc; pat_env; _} =
154154+ let extra = function
155155+ | Tpat_type _ -> ()
156156+ | Tpat_unpack -> ()
157157+ | Tpat_open (_, _, env) -> sub.env sub env
158158+ | Tpat_constraint ct -> sub.typ sub ct
159159+ in
160160+ sub.env sub pat_env;
161161+ List.iter (fun (e, _, _) -> extra e) pat_extra;
162162+ match pat_desc with
163163+ | Tpat_any -> ()
164164+ | Tpat_var _ -> ()
165165+ | Tpat_constant _ -> ()
166166+ | Tpat_tuple l -> List.iter (sub.pat sub) l
167167+ | Tpat_construct (_, _, l) -> List.iter (sub.pat sub) l
168168+ | Tpat_variant (_, po, _) -> Option.iter (sub.pat sub) po
169169+ | Tpat_record (l, _) -> List.iter (fun (_, _, i) -> sub.pat sub i) l
170170+ | Tpat_array l -> List.iter (sub.pat sub) l
171171+ | Tpat_or (p1, p2, _) ->
172172+ sub.pat sub p1;
173173+ sub.pat sub p2
174174+ | Tpat_alias (p, _, _) -> sub.pat sub p
175175+ | Tpat_lazy p -> sub.pat sub p
176176+ | Tpat_exception p -> sub.pat sub p
177177+178178+let expr sub {exp_extra; exp_desc; exp_env; _} =
179179+ let extra = function
180180+ | Texp_constraint cty -> sub.typ sub cty
181181+ | Texp_coerce (cty1, cty2) ->
182182+ Option.iter (sub.typ sub) cty1;
183183+ sub.typ sub cty2
184184+ | Texp_newtype _ -> ()
185185+ | Texp_poly cto -> Option.iter (sub.typ sub) cto
186186+ in
187187+ List.iter (fun (e, _, _) -> extra e) exp_extra;
188188+ sub.env sub exp_env;
189189+ match exp_desc with
190190+ | Texp_ident _ -> ()
191191+ | Texp_constant _ -> ()
192192+ | Texp_let (rec_flag, list, exp) ->
193193+ sub.value_bindings sub (rec_flag, list);
194194+ sub.expr sub exp
195195+ | Texp_function {cases; _} -> sub.cases sub cases
196196+ | Texp_apply (exp, list) ->
197197+ sub.expr sub exp;
198198+ List.iter (fun (_, o) -> Option.iter (sub.expr sub) o) list
199199+ | Texp_match (exp, cases, effs, _) ->
200200+ sub.expr sub exp;
201201+ sub.cases sub cases;
202202+ sub.cases sub effs
203203+ | Texp_try (exp, cases, effs) ->
204204+ sub.expr sub exp;
205205+ sub.cases sub cases;
206206+ sub.cases sub effs
207207+ | Texp_tuple list -> List.iter (sub.expr sub) list
208208+ | Texp_construct (_, _, args) -> List.iter (sub.expr sub) args
209209+ | Texp_variant (_, expo) -> Option.iter (sub.expr sub) expo
210210+ | Texp_record { fields; extended_expression; _} ->
211211+ Array.iter (function
212212+ | _, Kept _ -> ()
213213+ | _, Overridden (_, exp) -> sub.expr sub exp)
214214+ fields;
215215+ Option.iter (sub.expr sub) extended_expression;
216216+ | Texp_field (exp, _, _) -> sub.expr sub exp
217217+ | Texp_setfield (exp1, _, _, exp2) ->
218218+ sub.expr sub exp1;
219219+ sub.expr sub exp2
220220+ | Texp_array list -> List.iter (sub.expr sub) list
221221+ | Texp_ifthenelse (exp1, exp2, expo) ->
222222+ sub.expr sub exp1;
223223+ sub.expr sub exp2;
224224+ Option.iter (sub.expr sub) expo
225225+ | Texp_sequence (exp1, exp2) ->
226226+ sub.expr sub exp1;
227227+ sub.expr sub exp2
228228+ | Texp_while (exp1, exp2) ->
229229+ sub.expr sub exp1;
230230+ sub.expr sub exp2
231231+ | Texp_for (_, _, exp1, exp2, _, exp3) ->
232232+ sub.expr sub exp1;
233233+ sub.expr sub exp2;
234234+ sub.expr sub exp3
235235+ | Texp_send (exp, _, expo) ->
236236+ sub.expr sub exp;
237237+ Option.iter (sub.expr sub) expo
238238+ | Texp_new _ -> ()
239239+ | Texp_instvar _ -> ()
240240+ | Texp_setinstvar (_, _, _, exp) ->sub.expr sub exp
241241+ | Texp_override (_, list) ->
242242+ List.iter (fun (_, _, e) -> sub.expr sub e) list
243243+ | Texp_letmodule (_, _, _, mexpr, exp) ->
244244+ sub.module_expr sub mexpr;
245245+ sub.expr sub exp
246246+ | Texp_letexception (cd, exp) ->
247247+ sub.extension_constructor sub cd;
248248+ sub.expr sub exp
249249+ | Texp_assert exp -> sub.expr sub exp
250250+ | Texp_lazy exp -> sub.expr sub exp
251251+ | Texp_object (cl, _) -> sub.class_structure sub cl
252252+ | Texp_pack mexpr -> sub.module_expr sub mexpr
253253+ | Texp_letop {let_ = l; ands; body; _} ->
254254+ sub.binding_op sub l;
255255+ List.iter (sub.binding_op sub) ands;
256256+ sub.case sub body
257257+ | Texp_unreachable -> ()
258258+ | Texp_extension_constructor _ -> ()
259259+ | Texp_open (od, e) ->
260260+ sub.open_declaration sub od;
261261+ sub.expr sub e
262262+263263+264264+let package_type sub {pack_fields; _} =
265265+ List.iter (fun (_, p) -> sub.typ sub p) pack_fields
266266+267267+let binding_op sub {bop_exp; _} = sub.expr sub bop_exp
268268+269269+let signature sub {sig_items; sig_final_env; _} =
270270+ sub.env sub sig_final_env;
271271+ List.iter (sub.signature_item sub) sig_items
272272+273273+let signature_item sub {sig_desc; sig_env; _} =
274274+ sub.env sub sig_env;
275275+ match sig_desc with
276276+ | Tsig_value v -> sub.value_description sub v
277277+ | Tsig_type (rf, tdl) -> sub.type_declarations sub (rf, tdl)
278278+ | Tsig_typesubst list -> sub.type_declarations sub (Nonrecursive, list)
279279+ | Tsig_typext te -> sub.type_extension sub te
280280+ | Tsig_effect ext -> sub.extension_constructor sub ext
281281+ | Tsig_exception ext -> sub.type_exception sub ext
282282+ | Tsig_module x -> sub.module_declaration sub x
283283+ | Tsig_modsubst x -> sub.module_substitution sub x
284284+ | Tsig_recmodule list -> List.iter (sub.module_declaration sub) list
285285+ | Tsig_modtype x -> sub.module_type_declaration sub x
286286+ | Tsig_include incl -> include_infos (sub.module_type sub) incl
287287+ | Tsig_class list -> List.iter (sub.class_description sub) list
288288+ | Tsig_class_type list -> List.iter (sub.class_type_declaration sub) list
289289+ | Tsig_open od -> sub.open_description sub od
290290+ | Tsig_attribute _ -> ()
291291+292292+let class_description sub x =
293293+ class_infos sub (sub.class_type sub) x
294294+295295+let module_type sub {mty_desc; mty_env; _} =
296296+ sub.env sub mty_env;
297297+ match mty_desc with
298298+ | Tmty_ident _ -> ()
299299+ | Tmty_alias _ -> ()
300300+ | Tmty_signature sg -> sub.signature sub sg
301301+ | Tmty_functor (_, _, mtype1, mtype2) ->
302302+ Option.iter (sub.module_type sub) mtype1;
303303+ sub.module_type sub mtype2
304304+ | Tmty_with (mtype, list) ->
305305+ sub.module_type sub mtype;
306306+ List.iter (fun (_, _, e) -> sub.with_constraint sub e) list
307307+ | Tmty_typeof mexpr -> sub.module_expr sub mexpr
308308+309309+let with_constraint sub = function
310310+ | Twith_type decl -> sub.type_declaration sub decl
311311+ | Twith_typesubst decl -> sub.type_declaration sub decl
312312+ | Twith_module _ -> ()
313313+ | Twith_modsubst _ -> ()
314314+315315+let open_description sub {open_env; _} = sub.env sub open_env
316316+317317+let open_declaration sub {open_expr; open_env; _} =
318318+ sub.module_expr sub open_expr;
319319+ sub.env sub open_env
320320+321321+let module_coercion sub = function
322322+ | Tcoerce_none -> ()
323323+ | Tcoerce_functor (c1,c2) ->
324324+ sub.module_coercion sub c1;
325325+ sub.module_coercion sub c2
326326+ | Tcoerce_alias (env, _, c1) ->
327327+ sub.env sub env;
328328+ sub.module_coercion sub c1
329329+ | Tcoerce_structure (l1, l2) ->
330330+ List.iter (fun (_, c) -> sub.module_coercion sub c) l1;
331331+ List.iter (fun (_, _ ,c) -> sub.module_coercion sub c) l2
332332+ | Tcoerce_primitive {pc_env; _} -> sub.env sub pc_env
333333+334334+let module_expr sub {mod_desc; mod_env; _} =
335335+ sub.env sub mod_env;
336336+ match mod_desc with
337337+ | Tmod_ident _ -> ()
338338+ | Tmod_structure st -> sub.structure sub st
339339+ | Tmod_functor (_, _, mtype, mexpr) ->
340340+ Option.iter (sub.module_type sub) mtype;
341341+ sub.module_expr sub mexpr
342342+ | Tmod_apply (mexp1, mexp2, c) ->
343343+ sub.module_expr sub mexp1;
344344+ sub.module_expr sub mexp2;
345345+ sub.module_coercion sub c
346346+ | Tmod_constraint (mexpr, _, Tmodtype_implicit, c) ->
347347+ sub.module_expr sub mexpr;
348348+ sub.module_coercion sub c
349349+ | Tmod_constraint (mexpr, _, Tmodtype_explicit mtype, c) ->
350350+ sub.module_expr sub mexpr;
351351+ sub.module_type sub mtype;
352352+ sub.module_coercion sub c
353353+ | Tmod_unpack (exp, _) -> sub.expr sub exp
354354+355355+let module_binding sub {mb_expr; _} = sub.module_expr sub mb_expr
356356+357357+let class_expr sub {cl_desc; cl_env; _} =
358358+ sub.env sub cl_env;
359359+ match cl_desc with
360360+ | Tcl_constraint (cl, clty, _, _, _) ->
361361+ sub.class_expr sub cl;
362362+ Option.iter (sub.class_type sub) clty
363363+ | Tcl_structure clstr -> sub.class_structure sub clstr
364364+ | Tcl_fun (_, pat, priv, cl, _) ->
365365+ sub.pat sub pat;
366366+ List.iter (fun (_, e) -> sub.expr sub e) priv;
367367+ sub.class_expr sub cl
368368+ | Tcl_apply (cl, args) ->
369369+ sub.class_expr sub cl;
370370+ List.iter (fun (_, e) -> Option.iter (sub.expr sub) e) args
371371+ | Tcl_let (rec_flag, value_bindings, ivars, cl) ->
372372+ sub.value_bindings sub (rec_flag, value_bindings);
373373+ List.iter (fun (_, e) -> sub.expr sub e) ivars;
374374+ sub.class_expr sub cl
375375+ | Tcl_ident (_, _, tyl) -> List.iter (sub.typ sub) tyl
376376+ | Tcl_open (od, e) ->
377377+ sub.open_description sub od;
378378+ sub.class_expr sub e
379379+380380+let class_type sub {cltyp_desc; cltyp_env; _} =
381381+ sub.env sub cltyp_env;
382382+ match cltyp_desc with
383383+ | Tcty_signature csg -> sub.class_signature sub csg
384384+ | Tcty_constr (_, _, list) -> List.iter (sub.typ sub) list
385385+ | Tcty_arrow (_, ct, cl) ->
386386+ sub.typ sub ct;
387387+ sub.class_type sub cl
388388+ | Tcty_open (od, e) ->
389389+ sub.open_description sub od;
390390+ sub.class_type sub e
391391+392392+let class_signature sub {csig_self; csig_fields; _} =
393393+ sub.typ sub csig_self;
394394+ List.iter (sub.class_type_field sub) csig_fields
395395+396396+let class_type_field sub {ctf_desc; _} =
397397+ match ctf_desc with
398398+ | Tctf_inherit ct -> sub.class_type sub ct
399399+ | Tctf_val (_, _, _, ct) -> sub.typ sub ct
400400+ | Tctf_method (_, _, _, ct) -> sub.typ sub ct
401401+ | Tctf_constraint (ct1, ct2) ->
402402+ sub.typ sub ct1;
403403+ sub.typ sub ct2
404404+ | Tctf_attribute _ -> ()
405405+406406+let typ sub {ctyp_desc; ctyp_env; _} =
407407+ sub.env sub ctyp_env;
408408+ match ctyp_desc with
409409+ | Ttyp_any -> ()
410410+ | Ttyp_var _ -> ()
411411+ | Ttyp_arrow (_, ct1, ct2) ->
412412+ sub.typ sub ct1;
413413+ sub.typ sub ct2
414414+ | Ttyp_tuple list -> List.iter (sub.typ sub) list
415415+ | Ttyp_constr (_, _, list) -> List.iter (sub.typ sub) list
416416+ | Ttyp_object (list, _) -> List.iter (sub.object_field sub) list
417417+ | Ttyp_class (_, _, list) -> List.iter (sub.typ sub) list
418418+ | Ttyp_alias (ct, _) -> sub.typ sub ct
419419+ | Ttyp_variant (list, _, _) -> List.iter (sub.row_field sub) list
420420+ | Ttyp_poly (_, ct) -> sub.typ sub ct
421421+ | Ttyp_package pack -> sub.package_type sub pack
422422+423423+let class_structure sub {cstr_self; cstr_fields; _} =
424424+ sub.pat sub cstr_self;
425425+ List.iter (sub.class_field sub) cstr_fields
426426+427427+let row_field sub {rf_desc; _} =
428428+ match rf_desc with
429429+ | Ttag (_, _, list) -> List.iter (sub.typ sub) list
430430+ | Tinherit ct -> sub.typ sub ct
431431+432432+let object_field sub {of_desc; _} =
433433+ match of_desc with
434434+ | OTtag (_, ct) -> sub.typ sub ct
435435+ | OTinherit ct -> sub.typ sub ct
436436+437437+let class_field_kind sub = function
438438+ | Tcfk_virtual ct -> sub.typ sub ct
439439+ | Tcfk_concrete (_, e) -> sub.expr sub e
440440+441441+let class_field sub {cf_desc; _} = match cf_desc with
442442+ | Tcf_inherit (_, cl, _, _, _) -> sub.class_expr sub cl
443443+ | Tcf_constraint (cty1, cty2) ->
444444+ sub.typ sub cty1;
445445+ sub.typ sub cty2
446446+ | Tcf_val (_, _, _, k, _) -> class_field_kind sub k
447447+ | Tcf_method (_, _, k) -> class_field_kind sub k
448448+ | Tcf_initializer exp -> sub.expr sub exp
449449+ | Tcf_attribute _ -> ()
450450+451451+let value_bindings sub (_, list) = List.iter (sub.value_binding sub) list
452452+453453+let cases sub l = List.iter (sub.case sub) l
454454+455455+let case sub {c_lhs; c_guard; c_rhs} =
456456+ sub.pat sub c_lhs;
457457+ Option.iter (sub.expr sub) c_guard;
458458+ sub.expr sub c_rhs
459459+460460+let value_binding sub {vb_pat; vb_expr; _} =
461461+ sub.pat sub vb_pat;
462462+ sub.expr sub vb_expr
463463+464464+let env _sub _ = ()
465465+466466+let default_iterator =
467467+ {
468468+ binding_op;
469469+ case;
470470+ cases;
471471+ class_declaration;
472472+ class_description;
473473+ class_expr;
474474+ class_field;
475475+ class_signature;
476476+ class_structure;
477477+ class_type;
478478+ class_type_declaration;
479479+ class_type_field;
480480+ env;
481481+ expr;
482482+ extension_constructor;
483483+ module_binding;
484484+ module_coercion;
485485+ module_declaration;
486486+ module_substitution;
487487+ module_expr;
488488+ module_type;
489489+ module_type_declaration;
490490+ package_type;
491491+ pat;
492492+ row_field;
493493+ object_field;
494494+ open_declaration;
495495+ open_description;
496496+ signature;
497497+ signature_item;
498498+ structure;
499499+ structure_item;
500500+ typ;
501501+ type_declaration;
502502+ type_declarations;
503503+ type_extension;
504504+ type_exception;
505505+ type_kind;
506506+ value_binding;
507507+ value_bindings;
508508+ value_description;
509509+ with_constraint;
510510+ }
···11-(**************************************************************************)
22-(* *)
33-(* OCaml *)
44-(* *)
55-(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *)
66-(* *)
77-(* Copyright 2007 Institut National de Recherche en Informatique et *)
88-(* en Automatique. *)
99-(* *)
1010-(* All rights reserved. This file is distributed under the terms of *)
1111-(* the GNU Lesser General Public License version 2.1, with the *)
1212-(* special exception on linking described in the file LICENSE. *)
1313-(* *)
1414-(**************************************************************************)
1515-1616-(*
1717-TODO:
1818- - 2012/05/10: Follow camlp4 way of building map and iter using classes
1919- and inheritance ?
2020-*)
2121-2222-open Asttypes
2323-open Typedtree
2424-2525-module type IteratorArgument = sig
2626-2727- val enter_structure : structure -> unit
2828- val enter_value_description : value_description -> unit
2929- val enter_type_extension : type_extension -> unit
3030- val enter_type_exception : type_exception -> unit
3131- val enter_extension_constructor : extension_constructor -> unit
3232- val enter_pattern : pattern -> unit
3333- val enter_expression : expression -> unit
3434- val enter_package_type : package_type -> unit
3535- val enter_signature : signature -> unit
3636- val enter_signature_item : signature_item -> unit
3737- val enter_module_type_declaration : module_type_declaration -> unit
3838- val enter_module_type : module_type -> unit
3939- val enter_module_expr : module_expr -> unit
4040- val enter_with_constraint : with_constraint -> unit
4141- val enter_class_expr : class_expr -> unit
4242- val enter_class_signature : class_signature -> unit
4343- val enter_class_declaration : class_declaration -> unit
4444- val enter_class_description : class_description -> unit
4545- val enter_class_type_declaration : class_type_declaration -> unit
4646- val enter_class_type : class_type -> unit
4747- val enter_class_type_field : class_type_field -> unit
4848- val enter_core_type : core_type -> unit
4949- val enter_class_structure : class_structure -> unit
5050- val enter_class_field : class_field -> unit
5151- val enter_structure_item : structure_item -> unit
5252-5353-5454- val leave_structure : structure -> unit
5555- val leave_value_description : value_description -> unit
5656- val leave_type_extension : type_extension -> unit
5757- val leave_type_exception : type_exception -> unit
5858- val leave_extension_constructor : extension_constructor -> unit
5959- val leave_pattern : pattern -> unit
6060- val leave_expression : expression -> unit
6161- val leave_package_type : package_type -> unit
6262- val leave_signature : signature -> unit
6363- val leave_signature_item : signature_item -> unit
6464- val leave_module_type_declaration : module_type_declaration -> unit
6565- val leave_module_type : module_type -> unit
6666- val leave_module_expr : module_expr -> unit
6767- val leave_with_constraint : with_constraint -> unit
6868- val leave_class_expr : class_expr -> unit
6969- val leave_class_signature : class_signature -> unit
7070- val leave_class_declaration : class_declaration -> unit
7171- val leave_class_description : class_description -> unit
7272- val leave_class_type_declaration : class_type_declaration -> unit
7373- val leave_class_type : class_type -> unit
7474- val leave_class_type_field : class_type_field -> unit
7575- val leave_core_type : core_type -> unit
7676- val leave_class_structure : class_structure -> unit
7777- val leave_class_field : class_field -> unit
7878- val leave_structure_item : structure_item -> unit
7979-8080- val enter_bindings : rec_flag -> unit
8181- val enter_binding : value_binding -> unit
8282- val leave_binding : value_binding -> unit
8383- val leave_bindings : rec_flag -> unit
8484-8585- val enter_type_declarations : rec_flag -> unit
8686- val enter_type_declaration : type_declaration -> unit
8787- val leave_type_declaration : type_declaration -> unit
8888- val leave_type_declarations : rec_flag -> unit
8989-9090- end
9191-9292-module MakeIterator(Iter : IteratorArgument) : sig
9393-9494- val iter_structure : structure -> unit
9595- val iter_signature : signature -> unit
9696- val iter_structure_item : structure_item -> unit
9797- val iter_signature_item : signature_item -> unit
9898- val iter_expression : expression -> unit
9999- val iter_module_type : module_type -> unit
100100- val iter_pattern : pattern -> unit
101101- val iter_class_expr : class_expr -> unit
102102-103103- end = struct
104104-105105- let may_iter f v =
106106- match v with
107107- None -> ()
108108- | Some x -> f x
109109-110110-111111- let rec iter_structure str =
112112- Iter.enter_structure str;
113113- List.iter iter_structure_item str.str_items;
114114- Iter.leave_structure str
115115-116116-117117- and iter_binding vb =
118118- Iter.enter_binding vb;
119119- iter_pattern vb.vb_pat;
120120- iter_expression vb.vb_expr;
121121- Iter.leave_binding vb
122122-123123- and iter_bindings rec_flag list =
124124- Iter.enter_bindings rec_flag;
125125- List.iter iter_binding list;
126126- Iter.leave_bindings rec_flag
127127-128128- and iter_case {c_lhs; c_guard; c_rhs; _} =
129129- iter_pattern c_lhs;
130130- may_iter iter_expression c_guard;
131131- iter_expression c_rhs
132132-133133- and iter_cases cases =
134134- List.iter iter_case cases
135135-136136- and iter_structure_item item =
137137- Iter.enter_structure_item item;
138138- begin
139139- match item.str_desc with
140140- Tstr_eval (exp, _attrs) -> iter_expression exp
141141- | Tstr_value (rec_flag, list) ->
142142- iter_bindings rec_flag list
143143- | Tstr_primitive vd -> iter_value_description vd
144144- | Tstr_type (rf, list) -> iter_type_declarations rf list
145145- | Tstr_typext tyext -> iter_type_extension tyext
146146- | Tstr_effect ext -> iter_extension_constructor ext
147147- | Tstr_exception ext -> iter_type_exception ext
148148- | Tstr_module x -> iter_module_binding x
149149- | Tstr_recmodule list -> List.iter iter_module_binding list
150150- | Tstr_modtype mtd -> iter_module_type_declaration mtd
151151- | Tstr_open od -> iter_module_expr od.open_expr
152152- | Tstr_class list ->
153153- List.iter (fun (ci, _) -> iter_class_declaration ci) list
154154- | Tstr_class_type list ->
155155- List.iter
156156- (fun (_, _, ct) -> iter_class_type_declaration ct)
157157- list
158158- | Tstr_include incl -> iter_module_expr incl.incl_mod
159159- | Tstr_attribute _ ->
160160- ()
161161- end;
162162- Iter.leave_structure_item item
163163-164164- and iter_module_binding x =
165165- iter_module_expr x.mb_expr
166166-167167- and iter_value_description v =
168168- Iter.enter_value_description v;
169169- iter_core_type v.val_desc;
170170- Iter.leave_value_description v
171171-172172- and iter_constructor_arguments = function
173173- | Cstr_tuple l -> List.iter iter_core_type l
174174- | Cstr_record l -> List.iter (fun ld -> iter_core_type ld.ld_type) l
175175-176176- and iter_constructor_declaration cd =
177177- iter_constructor_arguments cd.cd_args;
178178- option iter_core_type cd.cd_res;
179179-180180- and iter_type_parameter (ct, _v) =
181181- iter_core_type ct
182182-183183- and iter_type_declaration decl =
184184- Iter.enter_type_declaration decl;
185185- List.iter iter_type_parameter decl.typ_params;
186186- List.iter (fun (ct1, ct2, _loc) ->
187187- iter_core_type ct1;
188188- iter_core_type ct2
189189- ) decl.typ_cstrs;
190190- begin match decl.typ_kind with
191191- Ttype_abstract -> ()
192192- | Ttype_variant list ->
193193- List.iter iter_constructor_declaration list
194194- | Ttype_record list ->
195195- List.iter
196196- (fun ld ->
197197- iter_core_type ld.ld_type
198198- ) list
199199- | Ttype_open -> ()
200200- end;
201201- option iter_core_type decl.typ_manifest;
202202- Iter.leave_type_declaration decl
203203-204204- and iter_type_declarations rec_flag decls =
205205- Iter.enter_type_declarations rec_flag;
206206- List.iter iter_type_declaration decls;
207207- Iter.leave_type_declarations rec_flag
208208-209209- and iter_extension_constructor ext =
210210- Iter.enter_extension_constructor ext;
211211- begin match ext.ext_kind with
212212- Text_decl(args, ret) ->
213213- iter_constructor_arguments args;
214214- option iter_core_type ret
215215- | Text_rebind _ -> ()
216216- end;
217217- Iter.leave_extension_constructor ext;
218218-219219- and iter_type_extension tyext =
220220- Iter.enter_type_extension tyext;
221221- List.iter iter_type_parameter tyext.tyext_params;
222222- List.iter iter_extension_constructor tyext.tyext_constructors;
223223- Iter.leave_type_extension tyext
224224-225225- and iter_type_exception tyexn =
226226- Iter.enter_type_exception tyexn;
227227- iter_extension_constructor tyexn.tyexn_constructor;
228228- Iter.leave_type_exception tyexn
229229-230230- and iter_pattern pat =
231231- Iter.enter_pattern pat;
232232- List.iter (fun (cstr, _, _attrs) -> match cstr with
233233- | Tpat_type _ -> ()
234234- | Tpat_unpack -> ()
235235- | Tpat_open _ -> ()
236236- | Tpat_constraint ct -> iter_core_type ct) pat.pat_extra;
237237- begin
238238- match pat.pat_desc with
239239- Tpat_any -> ()
240240- | Tpat_var _ -> ()
241241- | Tpat_alias (pat1, _, _) -> iter_pattern pat1
242242- | Tpat_constant _ -> ()
243243- | Tpat_tuple list ->
244244- List.iter iter_pattern list
245245- | Tpat_construct (_, _, args) ->
246246- List.iter iter_pattern args
247247- | Tpat_variant (_, pato, _) ->
248248- begin match pato with
249249- None -> ()
250250- | Some pat -> iter_pattern pat
251251- end
252252- | Tpat_record (list, _closed) ->
253253- List.iter (fun (_, _, pat) -> iter_pattern pat) list
254254- | Tpat_array list -> List.iter iter_pattern list
255255- | Tpat_or (p1, p2, _) -> iter_pattern p1; iter_pattern p2
256256- | Tpat_lazy p
257257- | Tpat_exception p -> iter_pattern p
258258- end;
259259- Iter.leave_pattern pat
260260-261261- and option f x = match x with None -> () | Some e -> f e
262262-263263- and iter_expression exp =
264264- Iter.enter_expression exp;
265265- List.iter (function (cstr, _, _attrs) ->
266266- match cstr with
267267- Texp_constraint ct ->
268268- iter_core_type ct
269269- | Texp_coerce (cty1, cty2) ->
270270- option iter_core_type cty1; iter_core_type cty2
271271- | Texp_poly cto -> option iter_core_type cto
272272- | Texp_newtype _ -> ())
273273- exp.exp_extra;
274274- begin
275275- match exp.exp_desc with
276276- Texp_ident _ -> ()
277277- | Texp_constant _ -> ()
278278- | Texp_let (rec_flag, list, exp) ->
279279- iter_bindings rec_flag list;
280280- iter_expression exp
281281- | Texp_function { cases; _ } ->
282282- iter_cases cases
283283- | Texp_apply (exp, list) ->
284284- iter_expression exp;
285285- List.iter (fun (_label, expo) ->
286286- match expo with
287287- None -> ()
288288- | Some exp -> iter_expression exp
289289- ) list
290290- | Texp_match (exp, list1, list2, _) ->
291291- iter_expression exp;
292292- iter_cases list1;
293293- iter_cases list2
294294- | Texp_try (exp, list1, list2) ->
295295- iter_expression exp;
296296- iter_cases list1;
297297- iter_cases list2
298298- | Texp_tuple list ->
299299- List.iter iter_expression list
300300- | Texp_construct (_, _, args) ->
301301- List.iter iter_expression args
302302- | Texp_variant (_label, expo) ->
303303- begin match expo with
304304- None -> ()
305305- | Some exp -> iter_expression exp
306306- end
307307- | Texp_record { fields; extended_expression; _ } ->
308308- Array.iter (function
309309- | _, Kept _ -> ()
310310- | _, Overridden (_, exp) -> iter_expression exp)
311311- fields;
312312- begin match extended_expression with
313313- None -> ()
314314- | Some exp -> iter_expression exp
315315- end
316316- | Texp_field (exp, _, _label) ->
317317- iter_expression exp
318318- | Texp_setfield (exp1, _, _label, exp2) ->
319319- iter_expression exp1;
320320- iter_expression exp2
321321- | Texp_array list ->
322322- List.iter iter_expression list
323323- | Texp_ifthenelse (exp1, exp2, expo) ->
324324- iter_expression exp1;
325325- iter_expression exp2;
326326- begin match expo with
327327- None -> ()
328328- | Some exp -> iter_expression exp
329329- end
330330- | Texp_sequence (exp1, exp2) ->
331331- iter_expression exp1;
332332- iter_expression exp2
333333- | Texp_while (exp1, exp2) ->
334334- iter_expression exp1;
335335- iter_expression exp2
336336- | Texp_for (_id, _, exp1, exp2, _dir, exp3) ->
337337- iter_expression exp1;
338338- iter_expression exp2;
339339- iter_expression exp3
340340- | Texp_send (exp, _meth, expo) ->
341341- iter_expression exp;
342342- begin
343343- match expo with
344344- None -> ()
345345- | Some exp -> iter_expression exp
346346- end
347347- | Texp_new _ -> ()
348348- | Texp_instvar _ -> ()
349349- | Texp_setinstvar (_, _, _, exp) ->
350350- iter_expression exp
351351- | Texp_override (_, list) ->
352352- List.iter (fun (_path, _, exp) ->
353353- iter_expression exp
354354- ) list
355355- | Texp_letmodule (_id, _, _, mexpr, exp) ->
356356- iter_module_expr mexpr;
357357- iter_expression exp
358358- | Texp_letexception (cd, exp) ->
359359- iter_extension_constructor cd;
360360- iter_expression exp
361361- | Texp_assert exp -> iter_expression exp
362362- | Texp_lazy exp -> iter_expression exp
363363- | Texp_object (cl, _) ->
364364- iter_class_structure cl
365365- | Texp_pack (mexpr) ->
366366- iter_module_expr mexpr
367367- | Texp_letop{let_; ands; param = _; body; partial = _} ->
368368- iter_binding_op let_;
369369- List.iter iter_binding_op ands;
370370- iter_case body
371371- | Texp_unreachable ->
372372- ()
373373- | Texp_extension_constructor _ ->
374374- ()
375375- | Texp_open (od, e) ->
376376- iter_module_expr od.open_expr;
377377- iter_expression e
378378- end;
379379- Iter.leave_expression exp;
380380-381381- and iter_binding_op bop =
382382- iter_expression bop.bop_exp
383383-384384- and iter_package_type pack =
385385- Iter.enter_package_type pack;
386386- List.iter (fun (_s, ct) -> iter_core_type ct) pack.pack_fields;
387387- Iter.leave_package_type pack;
388388-389389- and iter_signature sg =
390390- Iter.enter_signature sg;
391391- List.iter iter_signature_item sg.sig_items;
392392- Iter.leave_signature sg;
393393-394394- and iter_signature_item item =
395395- Iter.enter_signature_item item;
396396- begin
397397- match item.sig_desc with
398398- Tsig_value vd ->
399399- iter_value_description vd
400400- | Tsig_type (rf, list) ->
401401- iter_type_declarations rf list
402402- | Tsig_effect ext ->
403403- iter_extension_constructor ext
404404- | Tsig_typesubst list ->
405405- iter_type_declarations Nonrecursive list
406406- | Tsig_exception ext ->
407407- iter_type_exception ext
408408- | Tsig_typext tyext ->
409409- iter_type_extension tyext
410410- | Tsig_module md ->
411411- iter_module_type md.md_type
412412- | Tsig_modsubst _ -> ()
413413- | Tsig_recmodule list ->
414414- List.iter (fun md -> iter_module_type md.md_type) list
415415- | Tsig_modtype mtd ->
416416- iter_module_type_declaration mtd
417417- | Tsig_open _ -> ()
418418- | Tsig_include incl -> iter_module_type incl.incl_mod
419419- | Tsig_class list ->
420420- List.iter iter_class_description list
421421- | Tsig_class_type list ->
422422- List.iter iter_class_type_declaration list
423423- | Tsig_attribute _ -> ()
424424- end;
425425- Iter.leave_signature_item item;
426426-427427- and iter_module_type_declaration mtd =
428428- Iter.enter_module_type_declaration mtd;
429429- begin
430430- match mtd.mtd_type with
431431- | None -> ()
432432- | Some mtype -> iter_module_type mtype
433433- end;
434434- Iter.leave_module_type_declaration mtd
435435-436436- and iter_class_declaration cd =
437437- Iter.enter_class_declaration cd;
438438- List.iter iter_type_parameter cd.ci_params;
439439- iter_class_expr cd.ci_expr;
440440- Iter.leave_class_declaration cd;
441441-442442- and iter_class_description cd =
443443- Iter.enter_class_description cd;
444444- List.iter iter_type_parameter cd.ci_params;
445445- iter_class_type cd.ci_expr;
446446- Iter.leave_class_description cd;
447447-448448- and iter_class_type_declaration cd =
449449- Iter.enter_class_type_declaration cd;
450450- List.iter iter_type_parameter cd.ci_params;
451451- iter_class_type cd.ci_expr;
452452- Iter.leave_class_type_declaration cd;
453453-454454- and iter_module_type mty =
455455- Iter.enter_module_type mty;
456456- begin
457457- match mty.mty_desc with
458458- Tmty_ident _ -> ()
459459- | Tmty_alias _ -> ()
460460- | Tmty_signature sg -> iter_signature sg
461461- | Tmty_functor (_, _, mtype1, mtype2) ->
462462- Misc.may iter_module_type mtype1; iter_module_type mtype2
463463- | Tmty_with (mtype, list) ->
464464- iter_module_type mtype;
465465- List.iter (fun (_path, _, withc) ->
466466- iter_with_constraint withc
467467- ) list
468468- | Tmty_typeof mexpr ->
469469- iter_module_expr mexpr
470470- end;
471471- Iter.leave_module_type mty;
472472-473473- and iter_with_constraint cstr =
474474- Iter.enter_with_constraint cstr;
475475- begin
476476- match cstr with
477477- Twith_type decl -> iter_type_declaration decl
478478- | Twith_module _ -> ()
479479- | Twith_typesubst decl -> iter_type_declaration decl
480480- | Twith_modsubst _ -> ()
481481- end;
482482- Iter.leave_with_constraint cstr;
483483-484484- and iter_module_expr mexpr =
485485- Iter.enter_module_expr mexpr;
486486- begin
487487- match mexpr.mod_desc with
488488- Tmod_ident _ -> ()
489489- | Tmod_structure st -> iter_structure st
490490- | Tmod_functor (_, _, mtype, mexpr) ->
491491- Misc.may iter_module_type mtype;
492492- iter_module_expr mexpr
493493- | Tmod_apply (mexp1, mexp2, _) ->
494494- iter_module_expr mexp1;
495495- iter_module_expr mexp2
496496- | Tmod_constraint (mexpr, _, Tmodtype_implicit, _ ) ->
497497- iter_module_expr mexpr
498498- | Tmod_constraint (mexpr, _, Tmodtype_explicit mtype, _) ->
499499- iter_module_expr mexpr;
500500- iter_module_type mtype
501501- | Tmod_unpack (exp, _mty) ->
502502- iter_expression exp
503503-(* iter_module_type mty *)
504504- end;
505505- Iter.leave_module_expr mexpr;
506506-507507- and iter_class_expr cexpr =
508508- Iter.enter_class_expr cexpr;
509509- begin
510510- match cexpr.cl_desc with
511511- | Tcl_constraint (cl, None, _, _, _ ) ->
512512- iter_class_expr cl;
513513- | Tcl_structure clstr -> iter_class_structure clstr
514514- | Tcl_fun (_label, pat, priv, cl, _partial) ->
515515- iter_pattern pat;
516516- List.iter (fun (_id, exp) -> iter_expression exp) priv;
517517- iter_class_expr cl
518518-519519- | Tcl_apply (cl, args) ->
520520- iter_class_expr cl;
521521- List.iter (fun (_label, expo) ->
522522- match expo with
523523- None -> ()
524524- | Some exp -> iter_expression exp
525525- ) args
526526-527527- | Tcl_let (rec_flat, bindings, ivars, cl) ->
528528- iter_bindings rec_flat bindings;
529529- List.iter (fun (_id, exp) -> iter_expression exp) ivars;
530530- iter_class_expr cl
531531-532532- | Tcl_constraint (cl, Some clty, _vals, _meths, _concrs) ->
533533- iter_class_expr cl;
534534- iter_class_type clty
535535-536536- | Tcl_ident (_, _, tyl) ->
537537- List.iter iter_core_type tyl
538538-539539- | Tcl_open (_, e) ->
540540- iter_class_expr e
541541- end;
542542- Iter.leave_class_expr cexpr;
543543-544544- and iter_class_type ct =
545545- Iter.enter_class_type ct;
546546- begin
547547- match ct.cltyp_desc with
548548- Tcty_signature csg -> iter_class_signature csg
549549- | Tcty_constr (_path, _, list) ->
550550- List.iter iter_core_type list
551551- | Tcty_arrow (_label, ct, cl) ->
552552- iter_core_type ct;
553553- iter_class_type cl
554554- | Tcty_open (_, e) ->
555555- iter_class_type e
556556- end;
557557- Iter.leave_class_type ct;
558558-559559- and iter_class_signature cs =
560560- Iter.enter_class_signature cs;
561561- iter_core_type cs.csig_self;
562562- List.iter iter_class_type_field cs.csig_fields;
563563- Iter.leave_class_signature cs
564564-565565-566566- and iter_class_type_field ctf =
567567- Iter.enter_class_type_field ctf;
568568- begin
569569- match ctf.ctf_desc with
570570- Tctf_inherit ct -> iter_class_type ct
571571- | Tctf_val (_s, _mut, _virt, ct) ->
572572- iter_core_type ct
573573- | Tctf_method (_s, _priv, _virt, ct) ->
574574- iter_core_type ct
575575- | Tctf_constraint (ct1, ct2) ->
576576- iter_core_type ct1;
577577- iter_core_type ct2
578578- | Tctf_attribute _ -> ()
579579- end;
580580- Iter.leave_class_type_field ctf
581581-582582- and iter_core_type ct =
583583- Iter.enter_core_type ct;
584584- begin
585585- match ct.ctyp_desc with
586586- Ttyp_any -> ()
587587- | Ttyp_var _ -> ()
588588- | Ttyp_arrow (_label, ct1, ct2) ->
589589- iter_core_type ct1;
590590- iter_core_type ct2
591591- | Ttyp_tuple list -> List.iter iter_core_type list
592592- | Ttyp_constr (_path, _, list) ->
593593- List.iter iter_core_type list
594594- | Ttyp_object (list, _o) ->
595595- List.iter iter_object_field list
596596- | Ttyp_class (_path, _, list) ->
597597- List.iter iter_core_type list
598598- | Ttyp_alias (ct, _s) ->
599599- iter_core_type ct
600600- | Ttyp_variant (list, _bool, _labels) ->
601601- List.iter iter_row_field list
602602- | Ttyp_poly (_list, ct) -> iter_core_type ct
603603- | Ttyp_package pack -> iter_package_type pack
604604- end;
605605- Iter.leave_core_type ct
606606-607607- and iter_class_structure cs =
608608- Iter.enter_class_structure cs;
609609- iter_pattern cs.cstr_self;
610610- List.iter iter_class_field cs.cstr_fields;
611611- Iter.leave_class_structure cs;
612612-613613-614614- and iter_row_field rf =
615615- match rf.rf_desc with
616616- | Ttag (_label, _bool, list) ->
617617- List.iter iter_core_type list
618618- | Tinherit ct -> iter_core_type ct
619619-620620- and iter_object_field ofield =
621621- match ofield.of_desc with
622622- | OTtag (_, ct) | OTinherit ct -> iter_core_type ct
623623-624624- and iter_class_field cf =
625625- Iter.enter_class_field cf;
626626- begin
627627- match cf.cf_desc with
628628- Tcf_inherit (_ovf, cl, _super, _vals, _meths) ->
629629- iter_class_expr cl
630630- | Tcf_constraint (cty, cty') ->
631631- iter_core_type cty;
632632- iter_core_type cty'
633633- | Tcf_val (_lab, _, _, Tcfk_virtual cty, _) ->
634634- iter_core_type cty
635635- | Tcf_val (_lab, _, _, Tcfk_concrete (_, exp), _) ->
636636- iter_expression exp
637637- | Tcf_method (_lab, _, Tcfk_virtual cty) ->
638638- iter_core_type cty
639639- | Tcf_method (_lab, _, Tcfk_concrete (_, exp)) ->
640640- iter_expression exp
641641- | Tcf_initializer exp ->
642642- iter_expression exp
643643- | Tcf_attribute _ -> ()
644644- end;
645645- Iter.leave_class_field cf;
646646- end
647647-648648-module DefaultIteratorArgument = struct
649649-650650- let enter_structure _ = ()
651651- let enter_value_description _ = ()
652652- let enter_type_extension _ = ()
653653- let enter_type_exception _ = ()
654654- let enter_extension_constructor _ = ()
655655- let enter_pattern _ = ()
656656- let enter_expression _ = ()
657657- let enter_package_type _ = ()
658658- let enter_signature _ = ()
659659- let enter_signature_item _ = ()
660660- let enter_module_type_declaration _ = ()
661661- let enter_module_type _ = ()
662662- let enter_module_expr _ = ()
663663- let enter_with_constraint _ = ()
664664- let enter_class_expr _ = ()
665665- let enter_class_signature _ = ()
666666- let enter_class_declaration _ = ()
667667- let enter_class_description _ = ()
668668- let enter_class_type_declaration _ = ()
669669- let enter_class_type _ = ()
670670- let enter_class_type_field _ = ()
671671- let enter_core_type _ = ()
672672- let enter_class_structure _ = ()
673673- let enter_class_field _ = ()
674674- let enter_structure_item _ = ()
675675-676676-677677- let leave_structure _ = ()
678678- let leave_value_description _ = ()
679679- let leave_type_extension _ = ()
680680- let leave_type_exception _ = ()
681681- let leave_extension_constructor _ = ()
682682- let leave_pattern _ = ()
683683- let leave_expression _ = ()
684684- let leave_package_type _ = ()
685685- let leave_signature _ = ()
686686- let leave_signature_item _ = ()
687687- let leave_module_type_declaration _ = ()
688688- let leave_module_type _ = ()
689689- let leave_module_expr _ = ()
690690- let leave_with_constraint _ = ()
691691- let leave_class_expr _ = ()
692692- let leave_class_signature _ = ()
693693- let leave_class_declaration _ = ()
694694- let leave_class_description _ = ()
695695- let leave_class_type_declaration _ = ()
696696- let leave_class_type _ = ()
697697- let leave_class_type_field _ = ()
698698- let leave_core_type _ = ()
699699- let leave_class_structure _ = ()
700700- let leave_class_field _ = ()
701701- let leave_structure_item _ = ()
702702-703703- let enter_binding _ = ()
704704- let leave_binding _ = ()
705705-706706- let enter_bindings _ = ()
707707- let leave_bindings _ = ()
708708-709709- let enter_type_declaration _ = ()
710710- let leave_type_declaration _ = ()
711711-712712- let enter_type_declarations _ = ()
713713- let leave_type_declarations _ = ()
714714-end
-99
typing/typedtreeIter.mli
···11-(**************************************************************************)
22-(* *)
33-(* OCaml *)
44-(* *)
55-(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *)
66-(* *)
77-(* Copyright 2007 Institut National de Recherche en Informatique et *)
88-(* en Automatique. *)
99-(* *)
1010-(* All rights reserved. This file is distributed under the terms of *)
1111-(* the GNU Lesser General Public License version 2.1, with the *)
1212-(* special exception on linking described in the file LICENSE. *)
1313-(* *)
1414-(**************************************************************************)
1515-1616-open Asttypes
1717-open Typedtree
1818-1919-2020-module type IteratorArgument = sig
2121- val enter_structure : structure -> unit
2222- val enter_value_description : value_description -> unit
2323- val enter_type_extension : type_extension -> unit
2424- val enter_type_exception : type_exception -> unit
2525- val enter_extension_constructor : extension_constructor -> unit
2626- val enter_pattern : pattern -> unit
2727- val enter_expression : expression -> unit
2828- val enter_package_type : package_type -> unit
2929- val enter_signature : signature -> unit
3030- val enter_signature_item : signature_item -> unit
3131- val enter_module_type_declaration : module_type_declaration -> unit
3232- val enter_module_type : module_type -> unit
3333- val enter_module_expr : module_expr -> unit
3434- val enter_with_constraint : with_constraint -> unit
3535- val enter_class_expr : class_expr -> unit
3636- val enter_class_signature : class_signature -> unit
3737- val enter_class_declaration : class_declaration -> unit
3838- val enter_class_description : class_description -> unit
3939- val enter_class_type_declaration : class_type_declaration -> unit
4040- val enter_class_type : class_type -> unit
4141- val enter_class_type_field : class_type_field -> unit
4242- val enter_core_type : core_type -> unit
4343- val enter_class_structure : class_structure -> unit
4444- val enter_class_field : class_field -> unit
4545- val enter_structure_item : structure_item -> unit
4646-4747-4848- val leave_structure : structure -> unit
4949- val leave_value_description : value_description -> unit
5050- val leave_type_extension : type_extension -> unit
5151- val leave_type_exception : type_exception -> unit
5252- val leave_extension_constructor : extension_constructor -> unit
5353- val leave_pattern : pattern -> unit
5454- val leave_expression : expression -> unit
5555- val leave_package_type : package_type -> unit
5656- val leave_signature : signature -> unit
5757- val leave_signature_item : signature_item -> unit
5858- val leave_module_type_declaration : module_type_declaration -> unit
5959- val leave_module_type : module_type -> unit
6060- val leave_module_expr : module_expr -> unit
6161- val leave_with_constraint : with_constraint -> unit
6262- val leave_class_expr : class_expr -> unit
6363- val leave_class_signature : class_signature -> unit
6464- val leave_class_declaration : class_declaration -> unit
6565- val leave_class_description : class_description -> unit
6666- val leave_class_type_declaration : class_type_declaration -> unit
6767- val leave_class_type : class_type -> unit
6868- val leave_class_type_field : class_type_field -> unit
6969- val leave_core_type : core_type -> unit
7070- val leave_class_structure : class_structure -> unit
7171- val leave_class_field : class_field -> unit
7272- val leave_structure_item : structure_item -> unit
7373-7474- val enter_bindings : rec_flag -> unit
7575- val enter_binding : value_binding -> unit
7676- val leave_binding : value_binding -> unit
7777- val leave_bindings : rec_flag -> unit
7878-7979- val enter_type_declarations : rec_flag -> unit
8080- val enter_type_declaration : type_declaration -> unit
8181- val leave_type_declaration : type_declaration -> unit
8282- val leave_type_declarations : rec_flag -> unit
8383-8484-end
8585-8686-module MakeIterator :
8787- functor (Iter : IteratorArgument) ->
8888- sig
8989- val iter_structure : structure -> unit
9090- val iter_signature : signature -> unit
9191- val iter_structure_item : structure_item -> unit
9292- val iter_signature_item : signature_item -> unit
9393- val iter_expression : expression -> unit
9494- val iter_module_type : module_type -> unit
9595- val iter_pattern : pattern -> unit
9696- val iter_class_expr : class_expr -> unit
9797- end
9898-9999-module DefaultIteratorArgument : IteratorArgument