text
stringlengths 0
601k
|
---|
module Core_over_monad ( M : Preface_specs . MONAD ) ( Req : Preface_specs . Traversable . CORE with type ' a t = ' a M . t ) = Core ( Req ) |
module Operation ( C : Preface_specs . Traversable . CORE ) = struct type ' a t = ' a C . t type ' a iter = ' a C . iter let sequence x = C . traverse id x end |
module Via ( C : Preface_specs . Traversable . CORE ) ( O : Preface_specs . Traversable . OPERATION with type ' a t = ' a C . t and type ' a iter = ' a C . iter ) = struct include C include O end |
module Over_applicative ( A : Preface_specs . APPLICATIVE ) ( Req : Preface_specs . Traversable . WITH_TRAVERSE with type ' a t = ' a A . t ) = struct module Core = Core_over_applicative ( A ) ( Req ) module Operation = Operation ( Core ) include Core include Operation end |
module Over_monad ( M : Preface_specs . MONAD ) ( Req : Preface_specs . Traversable . WITH_TRAVERSE with type ' a t = ' a M . t ) = struct module Core = Core_over_monad ( M ) ( Req ) module Operation = Operation ( Core ) include Core include Operation end |
module Join_with_monad ( I : Preface_specs . MONAD ) ( T : functor ( M : Preface_specs . MONAD ) -> Preface_specs . TRAVERSABLE with type ' a t = ' a M . t and type ' a iter = ' a I . t ) = struct module Traversable = T include I end |
module Join_with_applicative ( I : Preface_specs . APPLICATIVE ) ( T : functor ( A : Preface_specs . APPLICATIVE ) -> Preface_specs . TRAVERSABLE with type ' a t = ' a A . t and type ' a iter = ' a I . t ) = struct module Traversable = T include I end |
type ctx = { map_loc : source_position * source_position -> Result_structure . loc ; fragments : ( string , Graphql_ast . fragment ) Hashtbl . t ; schema : Schema . t ; errors : ( Result_structure . loc * string ) list ref ; warnings : ( Result_structure . loc * string ) list ref ; type_stack : Schema . type_meta option list ; type_literal_stack : Schema . type_ref option list ; input_type_stack : Schema . type_meta option list ; input_type_literal_stack : Schema . type_ref option list ; parent_type_stack : Schema . type_meta option list ; } |
module type VisitorSig = sig type t val make_self : unit -> t val enter_document : t -> ctx -> document -> unit val exit_document : t -> ctx -> document -> unit val enter_operation_definition : t -> ctx -> operation spanning -> unit val exit_operation_definition : t -> ctx -> operation spanning -> unit val enter_fragment_definition : t -> ctx -> fragment spanning -> unit val exit_fragment_definition : t -> ctx -> fragment spanning -> unit val enter_variable_definition : t -> ctx -> string spanning * variable_definition -> unit val exit_variable_definition : t -> ctx -> string spanning * variable_definition -> unit val enter_directive : t -> ctx -> directive spanning -> unit val exit_directive : t -> ctx -> directive spanning -> unit val enter_argument : t -> ctx -> string spanning * Schema . type_ref option * input_value spanning -> unit val exit_argument : t -> ctx -> string spanning * input_value spanning -> unit val enter_selection_set : t -> ctx -> selection list spanning -> unit val exit_selection_set : t -> ctx -> selection list spanning -> unit val enter_field : t -> ctx -> field spanning -> unit val exit_field : t -> ctx -> field spanning -> unit val enter_fragment_spread : t -> ctx -> fragment_spread spanning -> unit val exit_fragment_spread : t -> ctx -> fragment_spread spanning -> unit val enter_inline_fragment : t -> ctx -> inline_fragment spanning -> unit val exit_inline_fragment : t -> ctx -> inline_fragment spanning -> unit val enter_null_value : t -> ctx -> unit spanning -> unit val exit_null_value : t -> ctx -> unit spanning -> unit val enter_int_value : t -> ctx -> int spanning -> unit val exit_int_value : t -> ctx -> int spanning -> unit val enter_float_value : t -> ctx -> float spanning -> unit val exit_float_value : t -> ctx -> float spanning -> unit val enter_string_value : t -> ctx -> string spanning -> unit val exit_string_value : t -> ctx -> string spanning -> unit val enter_bool_value : t -> ctx -> bool spanning -> unit val exit_bool_value : t -> ctx -> bool spanning -> unit val enter_enum_value : t -> ctx -> string spanning -> unit val exit_enum_value : t -> ctx -> string spanning -> unit val enter_variable_value : t -> ctx -> string spanning -> unit val exit_variable_value : t -> ctx -> string spanning -> unit val enter_list_value : t -> ctx -> input_value spanning list spanning -> unit val exit_list_value : t -> ctx -> input_value spanning list spanning -> unit val enter_object_value : t -> ctx -> ( string spanning * input_value spanning ) list spanning -> unit val exit_object_value : t -> ctx -> ( string spanning * input_value spanning ) list spanning -> unit val enter_object_field : t -> ctx -> string spanning * input_value spanning -> unit val exit_object_field : t -> ctx -> string spanning * input_value spanning -> unit end |
module AbstractVisitor = struct let enter_document _self _ctx _ = ( ) let exit_document _self _ctx _ = ( ) let enter_operation_definition _self _ctx _ = ( ) let exit_operation_definition _self _ctx _ = ( ) let enter_fragment_definition _self _ctx _ = ( ) let exit_fragment_definition _self _ctx _ = ( ) let enter_variable_definition _self _ctx _ = ( ) let exit_variable_definition _self _ctx _ = ( ) let enter_directive _self _ctx _ = ( ) let exit_directive _self _ctx _ = ( ) let enter_argument _self _ctx _ = ( ) let exit_argument _self _ctx _ = ( ) let enter_selection_set _self _ctx _ = ( ) let exit_selection_set _self _ctx _ = ( ) let enter_field _self _ctx _ = ( ) let exit_field _self _ctx _ = ( ) let enter_fragment_spread _self _ctx _ = ( ) let exit_fragment_spread _self _ctx _ = ( ) let enter_inline_fragment _self _ctx _ = ( ) let exit_inline_fragment _self _ctx _ = ( ) let enter_null_value _self _ctx _ = ( ) let exit_null_value _self _ctx _ = ( ) let enter_int_value _self _ctx _ = ( ) let exit_int_value _self _ctx _ = ( ) let enter_float_value _self _ctx _ = ( ) let exit_float_value _self _ctx _ = ( ) let enter_string_value _self _ctx _ = ( ) let exit_string_value _self _ctx _ = ( ) let enter_bool_value _self _ctx _ = ( ) let exit_bool_value _self _ctx _ = ( ) let enter_enum_value _self _ctx _ = ( ) let exit_enum_value _self _ctx _ = ( ) let enter_variable_value _self _ctx _ = ( ) let exit_variable_value _self _ctx _ = ( ) let enter_list_value _self _ctx _ = ( ) let exit_list_value _self _ctx _ = ( ) let enter_object_value _self _ctx _ = ( ) let exit_object_value _self _ctx _ = ( ) let enter_object_field _self _ctx _ = ( ) let exit_object_field _self _ctx _ = ( ) end |
module Context = struct let push_type ctx type_ref = { ctx with type_stack = Option . flat_map ( fun type_ref -> Schema . lookup_type ctx . schema ( Schema . innermost_name type_ref ) ) type_ref :: ctx . type_stack ; type_literal_stack = type_ref :: ctx . type_literal_stack ; } let push_input_type ctx type_ref = { ctx with input_type_stack = Option . flat_map ( fun type_ref -> Schema . lookup_type ctx . schema ( Schema . innermost_name type_ref ) ) type_ref :: ctx . input_type_stack ; input_type_literal_stack = type_ref :: ctx . input_type_literal_stack ; } let push_parent_type ctx = let top = match ctx . type_stack with t :: _ -> t | [ ] -> None in { ctx with parent_type_stack = top :: ctx . parent_type_stack } let parent_type ctx = match ctx . parent_type_stack with t :: _ -> t | [ ] -> None let current_input_type_literal ctx = match ctx . input_type_literal_stack with t :: _ -> t | [ ] -> None let push_error ctx loc msg = ctx . errors := ( ctx . map_loc loc , msg ) :: ( ! ctx . errors ) let push_warning ctx loc msg = ctx . warnings := ( ctx . map_loc loc , msg ) :: ( ! ctx . warnings ) end |
let rec as_schema_type_ref = function | Tr_named { item ; _ } -> Schema . Named item | Tr_list { item ; _ } -> Schema . List ( as_schema_type_ref item ) | Tr_non_null_named { item ; _ } -> Schema . NonNull ( Schema . Named item ) | Tr_non_null_list { item ; _ } -> Schema . NonNull ( Schema . List ( as_schema_type_ref item ) ) |
module Visitor ( V : VisitorSig ) = struct let enter_input_value self ctx value = match value . item with | Iv_null -> V . enter_null_value self ctx ( Source_pos . replace value ( ) ) | Iv_int i -> V . enter_int_value self ctx ( Source_pos . replace value i ) | Iv_float f -> V . enter_float_value self ctx ( Source_pos . replace value f ) | Iv_string s -> V . enter_string_value self ctx ( Source_pos . replace value s ) | Iv_boolean b -> V . enter_bool_value self ctx ( Source_pos . replace value b ) | Iv_enum e -> V . enter_enum_value self ctx ( Source_pos . replace value e ) | Iv_variable v -> V . enter_variable_value self ctx ( Source_pos . replace value v ) | Iv_list l -> V . enter_list_value self ctx ( Source_pos . replace value l ) | Iv_object o -> V . enter_object_value self ctx ( Source_pos . replace value o ) let exit_input_value self ctx value = match value . item with | Iv_null -> V . exit_null_value self ctx ( Source_pos . replace value ( ) ) | Iv_int i -> V . exit_int_value self ctx ( Source_pos . replace value i ) | Iv_float f -> V . exit_float_value self ctx ( Source_pos . replace value f ) | Iv_string s -> V . exit_string_value self ctx ( Source_pos . replace value s ) | Iv_boolean b -> V . exit_bool_value self ctx ( Source_pos . replace value b ) | Iv_enum e -> V . exit_enum_value self ctx ( Source_pos . replace value e ) | Iv_variable v -> V . exit_variable_value self ctx ( Source_pos . replace value v ) | Iv_list l -> V . exit_list_value self ctx ( Source_pos . replace value l ) | Iv_object o -> V . exit_object_value self ctx ( Source_pos . replace value o ) let rec visit_input_value self ctx ( arg_type : Schema . type_ref option ) value = let ( ) = enter_input_value self ctx value in let ( ) = match ( arg_type |> Option . map Schema . innermost_name |> Option . flat_map ( Schema . lookup_type ctx . schema ) , value . item ) with | Some ( Scalar _ as ty ) , _ when ty |> Schema . is_type_default == false -> ( ) | _ , Iv_object fields -> List . iter ( fun ( key , value ) -> let inner_type = Context . current_input_type_literal ctx |> Option . flat_map ( function | Schema . Named name | Schema . NonNull ( Schema . Named name ) -> Schema . lookup_type ctx . schema name | _ -> None ) |> Option . flat_map ( fun t -> try Schema . lookup_input_field t key . item with | Schema . Invalid_type msg -> Context . push_error ctx key . span msg ; None | other -> raise other ) |> Option . map ( fun am -> am . Schema . am_arg_type ) in let ctx = Context . push_input_type ctx inner_type in let ( ) = V . enter_object_field self ctx ( key , value ) in let ( ) = visit_input_value self ctx inner_type value in V . exit_object_field self ctx ( key , value ) ) fields | _ , Iv_list items -> let inner_type = Context . current_input_type_literal ctx |> Option . flat_map ( function | Schema . List inner | Schema . NonNull ( Schema . List inner ) -> Some inner | _ -> None ) in let ctx = Context . push_input_type ctx inner_type in List . iter ( visit_input_value self ctx inner_type ) items | _ -> ( ) in exit_input_value self ctx value let rec visit_inline_fragment self ctx inline_fragment = let ctx = match inline_fragment . item . if_type_condition with | None -> ctx | Some { item ; _ } -> Context . push_type ctx ( Some ( Schema . NonNull ( Schema . Named item ) ) ) in let ( ) = V . enter_inline_fragment self ctx inline_fragment in let ( ) = visit_directives self ctx inline_fragment . item . if_directives in let ( ) = visit_selection_set self ctx inline_fragment . item . if_selection_set in V . exit_inline_fragment self ctx inline_fragment and visit_fragment_spread self ctx fragment_spread = let ( ) = V . enter_fragment_spread self ctx fragment_spread in let ( ) = visit_directives self ctx fragment_spread . item . fs_directives in V . exit_fragment_spread self ctx fragment_spread and visit_field self ctx field = let meta_field = Context . parent_type ctx |> Option . flat_map ( fun t -> Schema . lookup_field t field . item . fd_name . item ) in let field_type = Option . map ( fun fm -> fm . Schema . fm_field_type ) meta_field in let field_args = Option . map ( fun fm -> fm . Schema . fm_arguments ) meta_field in let ctx = Context . push_type ctx field_type in let ( ) = V . enter_field self ctx field in let ( ) = visit_arguments self ctx field_args field . item . fd_arguments in let ( ) = visit_directives self ctx field . item . fd_directives in let ( ) = match field . item . fd_selection_set with | None -> ( ) | Some selection_set -> visit_selection_set self ctx selection_set in V . exit_field self ctx field and visit_selection self ctx = function | Field field -> visit_field self ctx field | FragmentSpread fragment_spread -> visit_fragment_spread self ctx fragment_spread | InlineFragment inline_fragment -> visit_inline_fragment self ctx inline_fragment and visit_selection_set self ctx selection_set = let ctx = Context . push_parent_type ctx in let ( ) = V . enter_selection_set self ctx selection_set in let ( ) = List . iter ( visit_selection self ctx ) selection_set . item in V . exit_selection_set self ctx selection_set and visit_arguments self ctx meta_args = function | None -> ( ) | Some { item ; _ } -> List . iter ( fun ( name , value ) -> let arg_type = meta_args |> Option . flat_map ( fun meta_args -> match List . find ( fun am -> am . Schema . am_name = name . item ) meta_args with | am -> Some am | exception Not_found -> None ) |> Option . map ( fun am -> am . Schema . am_arg_type ) in let ctx = Context . push_input_type ctx arg_type in let ( ) = V . enter_argument self ctx ( name , arg_type , value ) in let ( ) = visit_input_value self ctx arg_type value in V . exit_argument self ctx ( name , value ) ) item and visit_directives self ctx = List . iter ( fun directive -> let meta_args = Schema . lookup_directive ctx . schema directive . item . d_name . item |> Option . map ( fun d -> d . Schema . dm_arguments ) in let ( ) = V . enter_directive self ctx directive in let ( ) = visit_arguments self ctx meta_args directive . item . d_arguments in V . exit_directive self ctx directive ) let visit_variable_definitions self ctx = function | None -> ( ) | Some { item ; _ } -> List . iter ( fun ( name , def ) -> let ctx = Context . push_input_type ctx ( Some ( as_schema_type_ref def . vd_type . item ) ) in let ( ) = V . enter_variable_definition self ctx ( name , def ) in let ( ) = match def . vd_default_value with | None -> ( ) | Some value -> visit_input_value self ctx ( Some ( def . vd_type . item |> Type_utils . to_schema_type_ref ) ) value in V . exit_variable_definition self ctx ( name , def ) ) item let visit_operation_definition self ctx operation = let ( ) = visit_variable_definitions self ctx operation . o_variable_definitions in let ( ) = visit_directives self ctx operation . o_directives in visit_selection_set self ctx operation . o_selection_set let visit_fragment_definition self ctx fragment = let ( ) = visit_directives self ctx fragment . fg_directives in visit_selection_set self ctx fragment . fg_selection_set let visit_definition self ctx def = let def_type = Schema . NonNull ( Schema . Named ( match def with | Operation { item = { o_type = Query ; _ } ; _ } -> Schema . query_type ctx . schema |> Schema . type_name | Operation { item = { o_type = Mutation ; _ } ; _ } -> Schema . mutation_type ctx . schema |> Option . unsafe_unwrap ~ reason " : Can ' t find mutation type " |> Schema . type_name | Operation { item = { o_type = Subscription ; _ } ; _ } -> Schema . subscription_type ctx . schema |> Option . unsafe_unwrap ~ reason " : Can ' t find subscription type " |> Schema . type_name | Fragment { item = { fg_type_condition = { item ; _ } ; _ } ; _ } -> item ) ) in let ctx = Context . push_type ctx ( Some def_type ) in match def with | Operation operation -> let ( ) = V . enter_operation_definition self ctx operation in let ( ) = visit_operation_definition self ctx operation . item in V . exit_operation_definition self ctx operation | Fragment fragment -> let ( ) = V . enter_fragment_definition self ctx fragment in let ( ) = visit_fragment_definition self ctx fragment . item in V . exit_fragment_definition self ctx fragment let visit_document ctx doc = let self = V . make_self ( ) in let ( ) = V . enter_document self ctx doc in let ( ) = List . iter ( visit_definition self ctx ) doc in let ( ) = V . exit_document self ctx doc in self end |
let find_fragments doc = let open Graphql_ast in let open Source_pos in let lookup = Hashtbl . create 1 in let ( ) = List . iter ( function | Fragment fragment -> Hashtbl . add lookup fragment . item . fg_name . item fragment . item | _ -> ( ) ) doc in lookup |
let make_context config document = { map_loc = config . Generator_utils . map_loc ; fragments = find_fragments document ; schema = config . Generator_utils . schema ; errors = ref [ ] ; warnings = ref [ ] ; type_stack = [ ] ; type_literal_stack = [ ] ; input_type_stack = [ ] ; input_type_literal_stack = [ ] ; parent_type_stack = [ ] ; } |
module type G = sig val is_directed : bool type t module V : Sig . COMPARABLE val iter_vertex : ( V . t -> unit ) -> t -> unit val fold_vertex : ( V . t -> ' a -> ' a ) -> t -> ' a -> ' a val iter_succ : ( V . t -> unit ) -> t -> V . t -> unit val fold_succ : ( V . t -> ' a -> ' a ) -> t -> V . t -> ' a -> ' a end |
module Dfs ( G : G ) = struct module H = Hashtbl . Make ( G . V ) let fold f i g = let h = H . create 97 in let s = Stack . create ( ) in let push v = if not ( H . mem h v ) then begin H . add h v ( ) ; Stack . push v s end in let rec loop acc = if not ( Stack . is_empty s ) then let v = Stack . pop s in let ns = f v acc in G . iter_succ push g v ; loop ns else acc in G . fold_vertex ( fun v s -> push v ; loop s ) g i let iter ( ? pre = fun _ -> ( ) ) ( ? post = fun _ -> ( ) ) g = let h = H . create 97 in let rec visit v = if not ( H . mem h v ) then begin H . add h v ( ) ; pre v ; G . iter_succ visit g v ; post v end in G . iter_vertex visit g let postfix post g = iter ~ post g let fold_component f i g v0 = let h = H . create 97 in let s = Stack . create ( ) in let push v = if not ( H . mem h v ) then begin H . add h v ( ) ; Stack . push v s end in push v0 ; let rec loop acc = if not ( Stack . is_empty s ) then let v = Stack . pop s in let ns = f v acc in G . iter_succ push g v ; loop ns else acc in loop i let iter_component ( ? pre = fun _ -> ( ) ) ( ? post = fun _ -> ( ) ) g v = let h = H . create 97 in let rec visit v = H . add h v ( ) ; pre v ; G . iter_succ ( fun w -> if not ( H . mem h w ) then visit w ) g v ; post v in visit v let postfix_component post g = iter_component ~ post g module Tail = struct let has_cycle g = let h = H . create 97 in let stack = Stack . create ( ) in let loop ( ) = while not ( Stack . is_empty stack ) do let v = Stack . top stack in if H . mem h v then begin H . replace h v false ; ignore ( Stack . pop stack ) end else begin H . add h v true ; G . iter_succ ( fun w -> try if H . find h w then raise Exit with Not_found -> Stack . push w stack ) g v ; end done in try G . iter_vertex ( fun v -> if not ( H . mem h v ) then begin Stack . push v stack ; loop ( ) end ) g ; false with Exit -> true let has_cycle_undirected g = let h = H . create 97 in let father = H . create 97 in let is_father u v = try G . V . equal ( H . find father v ) u with Not_found -> false in let stack = Stack . create ( ) in let loop ( ) = while not ( Stack . is_empty stack ) do let v = Stack . top stack in if H . mem h v then begin H . remove father v ; H . replace h v false ; ignore ( Stack . pop stack ) end else begin H . add h v true ; G . iter_succ ( fun w -> try if H . find h w && not ( is_father w v ) then raise Exit with Not_found -> H . add father w v ; Stack . push w stack ) g v ; end done in try G . iter_vertex ( fun v -> if not ( H . mem h v ) then begin Stack . push v stack ; loop ( ) end ) g ; false with Exit -> true let has_cycle g = if G . is_directed then has_cycle g else has_cycle_undirected g let iter f g = let h = H . create 97 in let stack = Stack . create ( ) in let loop ( ) = while not ( Stack . is_empty stack ) do let v = Stack . pop stack in if not ( H . mem h v ) then begin H . add h v ( ) ; f v ; G . iter_succ ( fun w -> if not ( H . mem h w ) then Stack . push w stack ) g v end done in G . iter_vertex ( fun v -> if not ( H . mem h v ) then begin Stack . push v stack ; loop ( ) end ) g let iter_component f g v0 = let h = H . create 97 in let stack = Stack . create ( ) in Stack . push v0 stack ; while not ( Stack . is_empty stack ) do let v = Stack . pop stack in if not ( H . mem h v ) then begin H . add h v ( ) ; f v ; G . iter_succ ( fun w -> if not ( H . mem h w ) then Stack . push w stack ) g v end done end let prefix = Tail . iter let has_cycle = Tail . has_cycle let prefix_component = Tail . iter_component module S = Set . Make ( G . V ) type iterator = S . t * G . V . t list * G . t let start g = let st = G . fold_vertex ( fun v st -> v :: st ) g [ ] in S . empty , st , g let get ( _ , st , _ ) = match st with | [ ] -> raise Exit | v :: _ -> v let step ( s , st , g ) = match st with | [ ] -> raise Exit | v :: st -> let s ' = S . add v s in let st ' = G . fold_succ ( fun w st -> w :: st ) g v st in let rec clean = function | w :: st when S . mem w s ' -> clean st | st -> st in ( s ' , clean st ' , g ) end |
module Bfs ( G : G ) = struct module H = Hashtbl . Make ( G . V ) let fold f i ( g : G . t ) = let h = H . create 97 in let q = Queue . create ( ) in let push v = if not ( H . mem h v ) then begin H . add h v ( ) ; Queue . add v q end in let rec loop s = if not ( Queue . is_empty q ) then let v = Queue . pop q in let ns = f v s in G . iter_succ push g v ; loop ns else s in G . fold_vertex ( fun v s -> push v ; loop s ) g i let iter f = fold ( fun v ( ) -> f v ) ( ) let fold_component f i g v0 = let h = H . create 97 in let q = Queue . create ( ) in let push v = if not ( H . mem h v ) then begin H . add h v ( ) ; Queue . add v q end in push v0 ; let rec loop s = if not ( Queue . is_empty q ) then let v = Queue . pop q in let ns = f v s in G . iter_succ push g v ; loop ns else s in loop i let iter_component f = fold_component ( fun v ( ) -> f v ) ( ) module Q = struct type ' a t = ' a list * ' a list exception Empty let empty = [ ] , [ ] let is_empty = function [ ] , [ ] -> true | _ -> false let push x ( i , o ) = ( x :: i , o ) let pop = function | i , y :: o -> y , ( i , o ) | [ ] , [ ] -> raise Empty | i , [ ] -> match List . rev i with | x :: o -> x , ( [ ] , o ) | [ ] -> assert false let peek q = fst ( pop q ) end module S = Set . Make ( G . V ) type iterator = S . t * G . V . t Q . t * G . t let start g = let s = G . fold_vertex S . add g S . empty in s , Q . empty , g let get ( s , q , _ ) = if Q . is_empty q then if S . is_empty s then raise Exit else S . choose s else Q . peek q let step ( s , q , g ) = let push v ( s , q as acc ) = if S . mem v s then S . remove v s , Q . push v q else acc in let v , s ' , q ' = if Q . is_empty q then begin if S . is_empty s then raise Exit ; let v = S . choose s in v , S . remove v s , q end else let v , q ' = Q . pop q in v , s , q ' in let s ' ' , q ' ' = G . fold_succ push g v ( s ' , q ' ) in ( s ' ' , q ' ' , g ) end |
module type GM = sig type t module V : sig type t end val iter_vertex : ( V . t -> unit ) -> t -> unit val iter_succ : ( V . t -> unit ) -> t -> V . t -> unit module Mark : sig val clear : t -> unit val get : V . t -> int val set : V . t -> int -> unit end end |
module Mark ( G : GM ) = struct let dfs g = G . Mark . clear g ; let n = ref 0 in let rec visit v = if G . Mark . get v = 0 then begin incr n ; G . Mark . set v ! n ; G . iter_succ visit g v end in G . iter_vertex visit g let has_cycle g = G . Mark . clear g ; let rec visit v = G . Mark . set v 1 ; G . iter_succ ( fun w -> let m = G . Mark . get w in if m = 1 then raise Exit ; if m = 0 then visit w ) g v ; G . Mark . set v 2 in try G . iter_vertex ( fun v -> if G . Mark . get v = 0 then visit v ) g ; false with Exit -> true end |
object ( self ) method virtual record : string -> ( string * ' res ) list -> ' res method virtual constr : string -> ( string * ' res ) list -> ' res method virtual tuple : ( string * ' res ) list -> ' res method virtual bool : bool -> ' res method virtual char : char -> ' res method virtual int : int -> ' res method virtual list : ' a . ( ' a -> ' res ) -> ' a list -> ' res method virtual option : ' a . ( ' a -> ' res ) -> ' a option -> ' res method virtual string : string -> ' res method position : position -> ' res = fun { pos_fname ; pos_lnum ; pos_bol ; pos_cnum } -> let pos_fname = self # string pos_fname in let pos_lnum = self # int pos_lnum in let pos_bol = self # int pos_bol in let pos_cnum = self # int pos_cnum in self # record " Lexing . position " [ ( " pos_fname " , pos_fname ) ; ( " pos_lnum " , pos_lnum ) ; ( " pos_bol " , pos_bol ) ; ( " pos_cnum " , pos_cnum ) ] method location : location -> ' res = fun { loc_start ; loc_end ; loc_ghost } -> let loc_start = self # position loc_start in let loc_end = self # position loc_end in let loc_ghost = self # bool loc_ghost in self # record " Location . t " [ ( " loc_start " , loc_start ) ; ( " loc_end " , loc_end ) ; ( " loc_ghost " , loc_ghost ) ] method location_stack : location_stack -> ' res = self # list self # location method loc : ' a . ( ' a -> ' res ) -> ' a loc -> ' res = fun _a { txt ; loc } -> let txt = _a txt in let loc = self # location loc in self # record " loc " [ ( " txt " , txt ) ; ( " loc " , loc ) ] method longident : longident -> ' res = fun x -> match x with | Lident a -> let a = self # string a in self # constr " Lident " [ ( " label " , a ) ] | Ldot ( a , b ) -> let a = self # longident a in let b = self # string b in self # constr " Ldot " [ ( " longident " , a ) ; ( " label " , b ) ] | Lapply ( a , b ) -> let a = self # longident a in let b = self # longident b in self # constr " Lapply " [ ( " longident1 " , a ) ; ( " longident2 " , b ) ] method longident_loc : longident_loc -> ' res = self # loc self # longident method rec_flag : rec_flag -> ' res = fun x -> match x with | Nonrecursive -> self # constr " Nonrecursive " [ ] | Recursive -> self # constr " Recursive " [ ] method direction_flag : direction_flag -> ' res = fun x -> match x with | Upto -> self # constr " Upto " [ ] | Downto -> self # constr " Downto " [ ] method private_flag : private_flag -> ' res = fun x -> match x with | Private -> self # constr " Private " [ ] | Public -> self # constr " Public " [ ] method mutable_flag : mutable_flag -> ' res = fun x -> match x with | Immutable -> self # constr " Immutable " [ ] | Mutable -> self # constr " Mutable " [ ] method virtual_flag : virtual_flag -> ' res = fun x -> match x with | Virtual -> self # constr " Virtual " [ ] | Concrete -> self # constr " Concrete " [ ] method override_flag : override_flag -> ' res = fun x -> match x with | Override -> self # constr " Override " [ ] | Fresh -> self # constr " Fresh " [ ] method closed_flag : closed_flag -> ' res = fun x -> match x with | Closed -> self # constr " Closed " [ ] | Open -> self # constr " Open " [ ] method label : label -> ' res = self # string method arg_label : arg_label -> ' res = fun x -> match x with | Nolabel -> self # constr " Nolabel " [ ] | Labelled a -> let a = self # string a in self # constr " Labelled " [ ( " label " , a ) ] | Optional a -> let a = self # string a in self # constr " Optional " [ ( " label " , a ) ] method variance : variance -> ' res = fun x -> match x with | Covariant -> self # constr " Covariant " [ ] | Contravariant -> self # constr " Contravariant " [ ] | NoVariance -> self # constr " NoVariance " [ ] method injectivity : injectivity -> ' res = fun x -> match x with | Injective -> self # constr " Injective " [ ] | NoInjectivity -> self # constr " NoInjectivity " [ ] method constant : constant -> ' res = fun x -> match x with | Pconst_integer ( a , b ) -> let a = self # string a in let b = self # option self # char b in self # constr " Pconst_integer " [ ( " label " , a ) ; ( " char option " , b ) ] | Pconst_char a -> let a = self # char a in self # constr " Pconst_char " [ ( " char " , a ) ] | Pconst_string ( a , b , c ) -> let a = self # string a in let b = self # location b in let c = self # option self # string c in self # constr " Pconst_string " [ ( " label " , a ) ; ( " location " , b ) ; ( " label option " , c ) ] | Pconst_float ( a , b ) -> let a = self # string a in let b = self # option self # char b in self # constr " Pconst_float " [ ( " label " , a ) ; ( " char option " , b ) ] method attribute : attribute -> ' res = fun { attr_name ; attr_payload ; attr_loc } -> let attr_name = self # loc self # string attr_name in let attr_payload = self # payload attr_payload in let attr_loc = self # location attr_loc in self # record " attribute " [ ( " attr_name " , attr_name ) ; ( " attr_payload " , attr_payload ) ; ( " attr_loc " , attr_loc ) ] method extension : extension -> ' res = fun ( a , b ) -> let a = self # loc self # string a in let b = self # payload b in self # tuple [ ( " label loc " , a ) ; ( " payload " , b ) ] method attributes : attributes -> ' res = self # list self # attribute method str_loc_lst : string loc list -> ' res = fun lst -> self # list ( self # loc self # string ) lst method existentials = self # str_loc_lst method type_vars = self # str_loc_lst method payload : payload -> ' res = fun x -> match x with | PStr a -> let a = self # structure a in self # constr " PStr " [ ( " structure " , a ) ] | PSig a -> let a = self # signature a in self # constr " PSig " [ ( " signature " , a ) ] | PTyp a -> let a = self # core_type a in self # constr " PTyp " [ ( " core_type " , a ) ] | PPat ( a , b ) -> let a = self # pattern a in let b = self # option self # expression b in self # constr " PPat " [ ( " pattern " , a ) ; ( " expression option " , b ) ] method core_type : core_type -> ' res = fun { ptyp_desc ; ptyp_loc ; ptyp_loc_stack ; ptyp_attributes } -> let ptyp_desc = self # core_type_desc ptyp_desc in let ptyp_loc = self # location ptyp_loc in let ptyp_loc_stack = self # location_stack ptyp_loc_stack in let ptyp_attributes = self # attributes ptyp_attributes in self # record " core_type " [ ( " ptyp_desc " , ptyp_desc ) ; ( " ptyp_loc " , ptyp_loc ) ; ( " ptyp_loc_stack " , ptyp_loc_stack ) ; ( " ptyp_attributes " , ptyp_attributes ) ] method core_type_desc : core_type_desc -> ' res = fun x -> match x with | Ptyp_any -> self # constr " Ptyp_any " [ ] | Ptyp_var a -> let a = self # string a in self # constr " Ptyp_var " [ ( " label " , a ) ] | Ptyp_arrow ( a , b , c ) -> let a = self # arg_label a in let b = self # core_type b in let c = self # core_type c in self # constr " Ptyp_arrow " [ ( " arg_label " , a ) ; ( " core_type1 " , b ) ; ( " core_type2 " , c ) ] | Ptyp_tuple a -> let a = self # list self # core_type a in self # constr " Ptyp_tuple " [ ( " core_type list " , a ) ] | Ptyp_constr ( a , b ) -> let a = self # longident_loc a in let b = self # list self # core_type b in self # constr " Ptyp_constr " [ ( " longident_loc " , a ) ; ( " core_type list " , b ) ] | Ptyp_object ( a , b ) -> let a = self # list self # object_field a in let b = self # closed_flag b in self # constr " Ptyp_object " [ ( " object_field list " , a ) ; ( " closed_flag " , b ) ] | Ptyp_class ( a , b ) -> let a = self # longident_loc a in let b = self # list self # core_type b in self # constr " Ptyp_class " [ ( " longident_loc " , a ) ; ( " core_type list " , b ) ] | Ptyp_alias ( a , b ) -> let a = self # core_type a in let b = self # string b in self # constr " Ptyp_alias " [ ( " core_type " , a ) ; ( " label " , b ) ] | Ptyp_variant ( a , b , c ) -> let a = self # list self # row_field a in let b = self # closed_flag b in let c = self # option ( self # list self # label ) c in self # constr " Ptyp_variant " [ ( " row_field list " , a ) ; ( " closed_flag " , b ) ; ( " label list option " , c ) ] | Ptyp_poly ( a , b ) -> let a = self # list ( self # loc self # string ) a in let b = self # core_type b in self # constr " Ptyp_poly " [ ( " label loc list " , a ) ; ( " core_type " , b ) ] | Ptyp_package a -> let a = self # package_type a in self # constr " Ptyp_package " [ ( " package_type " , a ) ] | Ptyp_extension a -> let a = self # extension a in self # constr " Ptyp_extension " [ ( " extension " , a ) ] method package_type : package_type -> ' res = fun ( a , b ) -> let a = self # longident_loc a in let b = self # list ( fun ( a , b ) -> let a = self # longident_loc a in let b = self # core_type b in self # tuple [ ( " longident_loc " , a ) ; ( " core_type " , b ) ] ) b in self # tuple [ ( " longident_loc " , a ) ; ( " ( longident_loc * core_type ) list " , b ) ] method row_field : row_field -> ' res = fun { prf_desc ; prf_loc ; prf_attributes } -> let prf_desc = self # row_field_desc prf_desc in let prf_loc = self # location prf_loc in let prf_attributes = self # attributes prf_attributes in self # record " row_field " [ ( " prf_desc " , prf_desc ) ; ( " prf_loc " , prf_loc ) ; ( " prf_attributes " , prf_attributes ) ] method row_field_desc : row_field_desc -> ' res = fun x -> match x with | Rtag ( a , b , c ) -> let a = self # loc self # label a in let b = self # bool b in let c = self # list self # core_type c in self # constr " Rtag " [ ( " label loc " , a ) ; ( " bool " , b ) ; ( " core_type list " , c ) ] | Rinherit a -> let a = self # core_type a in self # constr " Rinherit " [ ( " core_type " , a ) ] method object_field : object_field -> ' res = fun { pof_desc ; pof_loc ; pof_attributes } -> let pof_desc = self # object_field_desc pof_desc in let pof_loc = self # location pof_loc in let pof_attributes = self # attributes pof_attributes in self # record " object_field " [ ( " pof_desc " , pof_desc ) ; ( " pof_loc " , pof_loc ) ; ( " pof_attributes " , pof_attributes ) ] method object_field_desc : object_field_desc -> ' res = fun x -> match x with | Otag ( a , b ) -> let a = self # loc self # label a in let b = self # core_type b in self # constr " Otag " [ ( " label loc " , a ) ; ( " core_type " , b ) ] | Oinherit a -> let a = self # core_type a in self # constr " Oinherit " [ ( " core_type " , a ) ] method pattern : pattern -> ' res = fun { ppat_desc ; ppat_loc ; ppat_loc_stack ; ppat_attributes } -> let ppat_desc = self # pattern_desc ppat_desc in let ppat_loc = self # location ppat_loc in let ppat_loc_stack = self # location_stack ppat_loc_stack in let ppat_attributes = self # attributes ppat_attributes in self # record " pattern " [ ( " ppat_desc " , ppat_desc ) ; ( " ppat_loc " , ppat_loc ) ; ( " ppat_loc_stack " , ppat_loc_stack ) ; ( " ppat_attributes " , ppat_attributes ) ] method pattern_desc : pattern_desc -> ' res = fun x -> match x with | Ppat_any -> self # constr " Ppat_any " [ ] | Ppat_var a -> let a = self # loc self # string a in self # constr " Ppat_var " [ ( " label loc " , a ) ] | Ppat_alias ( a , b ) -> let a = self # pattern a in let b = self # loc self # string b in self # constr " Ppat_alias " [ ( " pattern " , a ) ; ( " label loc " , b ) ] | Ppat_constant a -> let a = self # constant a in self # constr " Ppat_constant " [ ( " constant " , a ) ] | Ppat_interval ( a , b ) -> let a = self # constant a in let b = self # constant b in self # constr " Ppat_interval " [ ( " constant1 " , a ) ; ( " constant2 " , b ) ] | Ppat_tuple a -> let a = self # list self # pattern a in self # constr " Ppat_tuple " [ ( " pattern list " , a ) ] | Ppat_construct ( a , b ) -> let a = self # longident_loc a in let b = self # option ( fun ( existentials , patt ) -> let existentials = self # existentials existentials in let patt = self # pattern patt in self # tuple [ ( " existentials " , existentials ) ; ( " pattern " , patt ) ] ) b in self # constr " Ppat_construct " [ ( " longident_loc " , a ) ; ( " args " , b ) ] | Ppat_variant ( a , b ) -> let a = self # label a in let b = self # option self # pattern b in self # constr " Ppat_variant " [ ( " label " , a ) ; ( " pattern option " , b ) ] | Ppat_record ( a , b ) -> let a = self # list ( fun ( a , b ) -> let a = self # longident_loc a in let b = self # pattern b in self # tuple [ ( " longident_loc " , a ) ; ( " pattern " , b ) ] ) a in let b = self # closed_flag b in self # constr " Ppat_record " [ ( " ( longident_loc * pattern ) list " , a ) ; ( " closed_flag " , b ) ] | Ppat_array a -> let a = self # list self # pattern a in self # constr " Ppat_array " [ ( " pattern list " , a ) ] | Ppat_or ( a , b ) -> let a = self # pattern a in let b = self # pattern b in self # constr " Ppat_or " [ ( " pattern1 " , a ) ; ( " pattern2 " , b ) ] | Ppat_constraint ( a , b ) -> let a = self # pattern a in let b = self # core_type b in self # constr " Ppat_constraint " [ ( " pattern " , a ) ; ( " core_type " , b ) ] | Ppat_type a -> let a = self # longident_loc a in self # constr " Ppat_type " [ ( " longident_loc " , a ) ] | Ppat_lazy a -> let a = self # pattern a in self # constr " Ppat_lazy " [ ( " pattern " , a ) ] | Ppat_unpack a -> let a = self # loc ( self # option self # string ) a in self # constr " Ppat_unpack " [ ( " label option loc " , a ) ] | Ppat_exception a -> let a = self # pattern a in self # constr " Ppat_exception " [ ( " pattern " , a ) ] | Ppat_extension a -> let a = self # extension a in self # constr " Ppat_extension " [ ( " extension " , a ) ] | Ppat_open ( a , b ) -> let a = self # longident_loc a in let b = self # pattern b in self # constr " Ppat_open " [ ( " longident_loc " , a ) ; ( " pattern " , b ) ] method expression : expression -> ' res = fun { pexp_desc ; pexp_loc ; pexp_loc_stack ; pexp_attributes } -> let pexp_desc = self # expression_desc pexp_desc in let pexp_loc = self # location pexp_loc in let pexp_loc_stack = self # location_stack pexp_loc_stack in let pexp_attributes = self # attributes pexp_attributes in self # record " expression " [ ( " pexp_desc " , pexp_desc ) ; ( " pexp_loc " , pexp_loc ) ; ( " pexp_loc_stack " , pexp_loc_stack ) ; ( " pexp_attributes " , pexp_attributes ) ] method expression_desc : expression_desc -> ' res = fun x -> match x with | Pexp_ident a -> let a = self # longident_loc a in self # constr " Pexp_ident " [ ( " longident_loc " , a ) ] | Pexp_constant a -> let a = self # constant a in self # constr " Pexp_constant " [ ( " constant " , a ) ] | Pexp_let ( a , b , c ) -> let a = self # rec_flag a in let b = self # list self # value_binding b in let c = self # expression c in self # constr " Pexp_let " [ ( " rec_flag " , a ) ; ( " value_binding list " , b ) ; ( " expression " , c ) ] | Pexp_function a -> let a = self # cases a in self # constr " Pexp_function " [ ( " cases " , a ) ] | Pexp_fun ( a , b , c , d ) -> let a = self # arg_label a in let b = self # option self # expression b in let c = self # pattern c in let d = self # expression d in self # constr " Pexp_fun " [ ( " arg_label " , a ) ; ( " expression option " , b ) ; ( " pattern " , c ) ; ( " expression " , d ) ] | Pexp_apply ( a , b ) -> let a = self # expression a in let b = self # list ( fun ( a , b ) -> let a = self # arg_label a in let b = self # expression b in self # tuple [ ( " arg_label " , a ) ; ( " expression " , b ) ] ) b in self # constr " Pexp_apply " [ ( " expression " , a ) ; ( " ( arg_label * expression ) list " , b ) ] | Pexp_match ( a , b ) -> let a = self # expression a in let b = self # cases b in self # constr " Pexp_match " [ ( " expression " , a ) ; ( " cases " , b ) ] | Pexp_try ( a , b ) -> let a = self # expression a in let b = self # cases b in self # constr " Pexp_try " [ ( " expression " , a ) ; ( " cases " , b ) ] | Pexp_tuple a -> let a = self # list self # expression a in self # constr " Pexp_tuple " [ ( " expression list " , a ) ] | Pexp_construct ( a , b ) -> let a = self # longident_loc a in let b = self # option self # expression b in self # constr " Pexp_construct " [ ( " longident_loc " , a ) ; ( " expression option " , b ) ] | Pexp_variant ( a , b ) -> let a = self # label a in let b = self # option self # expression b in self # constr " Pexp_variant " [ ( " label " , a ) ; ( " expression option " , b ) ] | Pexp_record ( a , b ) -> let a = self # list ( fun ( a , b ) -> let a = self # longident_loc a in let b = self # expression b in self # tuple [ ( " longident_loc " , a ) ; ( " expression " , b ) ] ) a in let b = self # option self # expression b in self # constr " Pexp_record " [ ( " ( longident_loc * expression ) list " , a ) ; ( " expression option " , b ) ] | Pexp_field ( a , b ) -> let a = self # expression a in let b = self # longident_loc b in self # constr " Pexp_field " [ ( " expression " , a ) ; ( " longident_loc " , b ) ] | Pexp_setfield ( a , b , c ) -> let a = self # expression a in let b = self # longident_loc b in let c = self # expression c in self # constr " Pexp_setfield " [ ( " expression1 " , a ) ; ( " longident_loc " , b ) ; ( " expression2 " , c ) ] | Pexp_array a -> let a = self # list self # expression a in self # constr " Pexp_array " [ ( " expression list " , a ) ] | Pexp_ifthenelse ( a , b , c ) -> let a = self # expression a in let b = self # expression b in let c = self # option self # expression c in self # constr " Pexp_ifthenelse " [ ( " expression1 " , a ) ; ( " expression2 " , b ) ; ( " expression option " , c ) ] | Pexp_sequence ( a , b ) -> let a = self # expression a in let b = self # expression b in self # constr " Pexp_sequence " [ ( " expression1 " , a ) ; ( " expression2 " , b ) ] | Pexp_while ( a , b ) -> let a = self # expression a in let b = self # expression b in self # constr " Pexp_while " [ ( " expression1 " , a ) ; ( " expression2 " , b ) ] | Pexp_for ( a , b , c , d , e ) -> let a = self # pattern a in let b = self # expression b in let c = self # expression c in let d = self # direction_flag d in let e = self # expression e in self # constr " Pexp_for " [ ( " pattern " , a ) ; ( " expression1 " , b ) ; ( " expression2 " , c ) ; ( " direction_flag " , d ) ; ( " expression3 " , e ) ] | Pexp_constraint ( a , b ) -> let a = self # expression a in let b = self # core_type b in self # constr " Pexp_constraint " [ ( " expression " , a ) ; ( " core_type " , b ) ] | Pexp_coerce ( a , b , c ) -> let a = self # expression a in let b = self # option self # core_type b in let c = self # core_type c in self # constr " Pexp_coerce " [ ( " expression " , a ) ; ( " core_type option " , b ) ; ( " core_type " , c ) ] | Pexp_send ( a , b ) -> let a = self # expression a in let b = self # loc self # label b in self # constr " Pexp_send " [ ( " expression " , a ) ; ( " label loc " , b ) ] | Pexp_new a -> let a = self # longident_loc a in self # constr " Pexp_new " [ ( " longident_loc " , a ) ] | Pexp_setinstvar ( a , b ) -> let a = self # loc self # label a in let b = self # expression b in self # constr " Pexp_setinstvar " [ ( " label loc " , a ) ; ( " expression " , b ) ] | Pexp_override a -> let a = self # list ( fun ( a , b ) -> let a = self # loc self # label a in let b = self # expression b in self # tuple [ ( " label loc " , a ) ; ( " expression " , b ) ] ) a in self # constr " Pexp_override " [ ( " ( label loc * expression ) list " , a ) ] | Pexp_letmodule ( a , b , c ) -> let a = self # loc ( self # option self # string ) a in let b = self # module_expr b in let c = self # expression c in self # constr " Pexp_letmodule " [ ( " label option loc " , a ) ; ( " module_expr " , b ) ; ( " expression " , c ) ] | Pexp_letexception ( a , b ) -> let a = self # extension_constructor a in let b = self # expression b in self # constr " Pexp_letexception " [ ( " Parsetree . extension_constructor " , a ) ; ( " expression " , b ) ] | Pexp_assert a -> let a = self # expression a in self # constr " Pexp_assert " [ ( " expression " , a ) ] | Pexp_lazy a -> let a = self # expression a in self # constr " Pexp_lazy " [ ( " expression " , a ) ] | Pexp_poly ( a , b ) -> let a = self # expression a in let b = self # option self # core_type b in self # constr " Pexp_poly " [ ( " expression " , a ) ; ( " core_type option " , b ) ] | Pexp_object a -> let a = self # class_structure a in self # constr " Pexp_object " [ ( " class_structure " , a ) ] | Pexp_newtype ( a , b ) -> let a = self # loc self # string a in let b = self # expression b in self # constr " Pexp_newtype " [ ( " label loc " , a ) ; ( " expression " , b ) ] | Pexp_pack a -> let a = self # module_expr a in self # constr " Pexp_pack " [ ( " module_expr " , a ) ] | Pexp_open ( a , b ) -> let a = self # open_declaration a in let b = self # expression b in self # constr " Pexp_open " [ ( " open_declaration " , a ) ; ( " expression " , b ) ] | Pexp_letop a -> let a = self # letop a in self # constr " Pexp_letop " [ ( " letop " , a ) ] | Pexp_extension a -> let a = self # extension a in self # constr " Pexp_extension " [ ( " extension " , a ) ] | Pexp_unreachable -> self # constr " Pexp_unreachable " [ ] method case : case -> ' res = fun { pc_lhs ; pc_guard ; pc_rhs } -> let pc_lhs = self # pattern pc_lhs in let pc_guard = self # option self # expression pc_guard in let pc_rhs = self # expression pc_rhs in self # record " case " [ ( " pc_lhs " , pc_lhs ) ; ( " pc_guard " , pc_guard ) ; ( " pc_rhs " , pc_rhs ) ] method letop : letop -> ' res = fun { let_ ; ands ; body } -> let let_ = self # binding_op let_ in let ands = self # list self # binding_op ands in let body = self # expression body in self # record " letop " [ ( " let_ " , let_ ) ; ( " ands " , ands ) ; ( " body " , body ) ] method binding_op : binding_op -> ' res = fun { pbop_op ; pbop_pat ; pbop_exp ; pbop_loc } -> let pbop_op = self # loc self # string pbop_op in let pbop_pat = self # pattern pbop_pat in let pbop_exp = self # expression pbop_exp in let pbop_loc = self # location pbop_loc in self # record " binding_op " [ ( " pbop_op " , pbop_op ) ; ( " pbop_pat " , pbop_pat ) ; ( " pbop_exp " , pbop_exp ) ; ( " pbop_loc " , pbop_loc ) ] method value_description : value_description -> ' res = fun { pval_name ; pval_type ; pval_prim ; pval_attributes ; pval_loc } -> let pval_name = self # loc self # string pval_name in let pval_type = self # core_type pval_type in let pval_prim = self # list self # string pval_prim in let pval_attributes = self # attributes pval_attributes in let pval_loc = self # location pval_loc in self # record " value_description " [ ( " pval_name " , pval_name ) ; ( " pval_type " , pval_type ) ; ( " pval_prim " , pval_prim ) ; ( " pval_attributes " , pval_attributes ) ; ( " pval_loc " , pval_loc ) ] method type_declaration : type_declaration -> ' res = fun { ptype_name ; ptype_params ; ptype_cstrs ; ptype_kind ; ptype_private ; ptype_manifest ; ptype_attributes ; ptype_loc } -> let ptype_name = self # loc self # string ptype_name in let ptype_params = self # list ( fun ( a , b ) -> let a = self # core_type a in let b = ( fun ( a , b ) -> let a = self # variance a in let b = self # injectivity b in self # tuple [ ( " variance " , a ) ; ( " injectivity " , b ) ] ) b in self # tuple [ ( " core_type " , a ) ; ( " ( variance * injectivity ) " , b ) ] ) ptype_params in let ptype_cstrs = self # list ( fun ( a , b , c ) -> let a = self # core_type a in let b = self # core_type b in let c = self # location c in self # tuple [ ( " core_type1 " , a ) ; ( " core_type2 " , b ) ; ( " location " , c ) ] ) ptype_cstrs in let ptype_kind = self # type_kind ptype_kind in let ptype_private = self # private_flag ptype_private in let ptype_manifest = self # option self # core_type ptype_manifest in let ptype_attributes = self # attributes ptype_attributes in let ptype_loc = self # location ptype_loc in self # record " type_declaration " [ ( " ptype_name " , ptype_name ) ; ( " ptype_params " , ptype_params ) ; ( " ptype_cstrs " , ptype_cstrs ) ; ( " ptype_kind " , ptype_kind ) ; ( " ptype_private " , ptype_private ) ; ( " ptype_manifest " , ptype_manifest ) ; ( " ptype_attributes " , ptype_attributes ) ; ( " ptype_loc " , ptype_loc ) ] method type_kind : type_kind -> ' res = fun x -> match x with | Ptype_abstract -> self # constr " Ptype_abstract " [ ] | Ptype_variant a -> let a = self # list self # constructor_declaration a in self # constr " Ptype_variant " [ ( " constructor_declaration list " , a ) ] | Ptype_record a -> let a = self # list self # label_declaration a in self # constr " Ptype_record " [ ( " label_declaration list " , a ) ] | Ptype_open -> self # constr " Ptype_open " [ ] method label_declaration : label_declaration -> ' res = fun { pld_name ; pld_mutable ; pld_type ; pld_loc ; pld_attributes } -> let pld_name = self # loc self # string pld_name in let pld_mutable = self # mutable_flag pld_mutable in let pld_type = self # core_type pld_type in let pld_loc = self # location pld_loc in let pld_attributes = self # attributes pld_attributes in self # record " label_declaration " [ ( " pld_name " , pld_name ) ; ( " pld_mutable " , pld_mutable ) ; ( " pld_type " , pld_type ) ; ( " pld_loc " , pld_loc ) ; ( " pld_attributes " , pld_attributes ) ] method constructor_declaration : constructor_declaration -> ' res = fun { pcd_name ; pcd_vars ; pcd_args ; pcd_res ; pcd_loc ; pcd_attributes } -> let pcd_name = self # loc self # string pcd_name in let pcd_vars = self # type_vars pcd_vars in let pcd_args = self # constructor_arguments pcd_args in let pcd_res = self # option self # core_type pcd_res in let pcd_loc = self # location pcd_loc in let pcd_attributes = self # attributes pcd_attributes in self # record " constructor_declaration " [ ( " pcd_name " , pcd_name ) ; ( " pcd_vars " , pcd_vars ) ; ( " pcd_args " , pcd_args ) ; ( " pcd_res " , pcd_res ) ; ( " pcd_loc " , pcd_loc ) ; ( " pcd_attributes " , pcd_attributes ) ] method constructor_arguments : constructor_arguments -> ' res = fun x -> match x with | Pcstr_tuple a -> let a = self # list self # core_type a in self # constr " Pcstr_tuple " [ ( " core_type list " , a ) ] | Pcstr_record a -> let a = self # list self # label_declaration a in self # constr " Pcstr_record " [ ( " label_declaration list " , a ) ] method type_extension : type_extension -> ' res = fun { ptyext_path ; ptyext_params ; ptyext_constructors ; ptyext_private ; ptyext_loc ; ptyext_attributes } -> let ptyext_path = self # longident_loc ptyext_path in let ptyext_params = self # list ( fun ( a , b ) -> let a = self # core_type a in let b = ( fun ( a , b ) -> let a = self # variance a in let b = self # injectivity b in self # tuple [ ( " variance " , a ) ; ( " injectivity " , b ) ] ) b in self # tuple [ ( " core_type " , a ) ; ( " ( variance * injectivity ) " , b ) ] ) ptyext_params in let ptyext_constructors = self # list self # extension_constructor ptyext_constructors in let ptyext_private = self # private_flag ptyext_private in let ptyext_loc = self # location ptyext_loc in let ptyext_attributes = self # attributes ptyext_attributes in self # record " type_extension " [ ( " ptyext_path " , ptyext_path ) ; ( " ptyext_params " , ptyext_params ) ; ( " ptyext_constructors " , ptyext_constructors ) ; ( " ptyext_private " , ptyext_private ) ; ( " ptyext_loc " , ptyext_loc ) ; ( " ptyext_attributes " , ptyext_attributes ) ] method extension_constructor : extension_constructor -> ' res = fun { pext_name ; pext_kind ; pext_loc ; pext_attributes } -> let pext_name = self # loc self # string pext_name in let pext_kind = self # extension_constructor_kind pext_kind in let pext_loc = self # location pext_loc in let pext_attributes = self # attributes pext_attributes in self # record " extension_constructor " [ ( " pext_name " , pext_name ) ; ( " pext_kind " , pext_kind ) ; ( " pext_loc " , pext_loc ) ; ( " pext_attributes " , pext_attributes ) ] method type_exception : type_exception -> ' res = fun { ptyexn_constructor ; ptyexn_loc ; ptyexn_attributes } -> let ptyexn_constructor = self # extension_constructor ptyexn_constructor in let ptyexn_loc = self # location ptyexn_loc in let ptyexn_attributes = self # attributes ptyexn_attributes in self # record " type_exception " [ ( " ptyexn_constructor " , ptyexn_constructor ) ; ( " ptyexn_loc " , ptyexn_loc ) ; ( " ptyexn_attributes " , ptyexn_attributes ) ] method extension_constructor_kind : extension_constructor_kind -> ' res = fun x -> match x with | Pext_decl ( existentials , c_args , t_opt ) -> let existentials = self # existentials existentials in let c_args = self # constructor_arguments c_args in let t_opt = self # option self # core_type t_opt in self # constr " Pext_decl " [ ( " existentials " , existentials ) ; ( " constructor_arguments " , c_args ) ; ( " core_type option " , t_opt ) ] | Pext_rebind a -> let a = self # longident_loc a in self # constr " Pext_rebind " [ ( " longident_loc " , a ) ] method class_type : class_type -> ' res = fun { pcty_desc ; pcty_loc ; pcty_attributes } -> let pcty_desc = self # class_type_desc pcty_desc in let pcty_loc = self # location pcty_loc in let pcty_attributes = self # attributes pcty_attributes in self # record " class_type " [ ( " pcty_desc " , pcty_desc ) ; ( " pcty_loc " , pcty_loc ) ; ( " pcty_attributes " , pcty_attributes ) ] method class_type_desc : class_type_desc -> ' res = fun x -> match x with | Pcty_constr ( a , b ) -> let a = self # longident_loc a in let b = self # list self # core_type b in self # constr " Pcty_constr " [ ( " longident_loc " , a ) ; ( " core_type list " , b ) ] | Pcty_signature a -> let a = self # class_signature a in self # constr " Pcty_signature " [ ( " class_signature " , a ) ] | Pcty_arrow ( a , b , c ) -> let a = self # arg_label a in let b = self # core_type b in let c = self # class_type c in self # constr " Pcty_arrow " [ ( " arg_label " , a ) ; ( " core_type " , b ) ; ( " class_type " , c ) ] | Pcty_extension a -> let a = self # extension a in self # constr " Pcty_extension " [ ( " extension " , a ) ] | Pcty_open ( a , b ) -> let a = self # open_description a in let b = self # class_type b in self # constr " Pcty_open " [ ( " open_description " , a ) ; ( " class_type " , b ) ] method class_signature : class_signature -> ' res = fun { pcsig_self ; pcsig_fields } -> let pcsig_self = self # core_type pcsig_self in let pcsig_fields = self # list self # class_type_field pcsig_fields in self # record " class_signature " [ ( " pcsig_self " , pcsig_self ) ; ( " pcsig_fields " , pcsig_fields ) ] method class_type_field : class_type_field -> ' res = fun { pctf_desc ; pctf_loc ; pctf_attributes } -> let pctf_desc = self # class_type_field_desc pctf_desc in let pctf_loc = self # location pctf_loc in let pctf_attributes = self # attributes pctf_attributes in self # record " class_type_field " [ ( " pctf_desc " , pctf_desc ) ; ( " pctf_loc " , pctf_loc ) ; ( " pctf_attributes " , pctf_attributes ) ] method class_type_field_desc : class_type_field_desc -> ' res = fun x -> match x with | Pctf_inherit a -> let a = self # class_type a in self # constr " Pctf_inherit " [ ( " class_type " , a ) ] | Pctf_val a -> let a = ( fun ( a , b , c , d ) -> let a = self # loc self # label a in let b = self # mutable_flag b in let c = self # virtual_flag c in let d = self # core_type d in self # tuple [ ( " label loc " , a ) ; ( " mutable_flag " , b ) ; ( " virtual_flag " , c ) ; ( " core_type " , d ) ] ) a in self # constr " Pctf_val " [ ( " ( label loc * mutable_flag * virtual_flag * core_type ) " , a ) ] | Pctf_method a -> let a = ( fun ( a , b , c , d ) -> let a = self # loc self # label a in let b = self # private_flag b in let c = self # virtual_flag c in let d = self # core_type d in self # tuple [ ( " label loc " , a ) ; ( " private_flag " , b ) ; ( " virtual_flag " , c ) ; ( " core_type " , d ) ] ) a in self # constr " Pctf_method " [ ( " ( label loc * private_flag * virtual_flag * core_type ) " , a ) ] | Pctf_constraint a -> let a = ( fun ( a , b ) -> let a = self # core_type a in let b = self # core_type b in self # tuple [ ( " core_type1 " , a ) ; ( " core_type2 " , b ) ] ) a in self # constr " Pctf_constraint " [ ( " ( core_type * core_type ) " , a ) ] | Pctf_attribute a -> let a = self # attribute a in self # constr " Pctf_attribute " [ ( " attribute " , a ) ] | Pctf_extension a -> let a = self # extension a in self # constr " Pctf_extension " [ ( " extension " , a ) ] method class_infos : ' a . ( ' a -> ' res ) -> ' a class_infos -> ' res = fun _a { pci_virt ; pci_params ; pci_name ; pci_expr ; pci_loc ; pci_attributes } -> let pci_virt = self # virtual_flag pci_virt in let pci_params = self # list ( fun ( a , b ) -> let a = self # core_type a in let b = ( fun ( a , b ) -> let a = self # variance a in let b = self # injectivity b in self # tuple [ ( " variance " , a ) ; ( " injectivity " , b ) ] ) b in self # tuple [ ( " core_type " , a ) ; ( " ( variance * injectivity ) " , b ) ] ) pci_params in let pci_name = self # loc self # string pci_name in let pci_expr = _a pci_expr in let pci_loc = self # location pci_loc in let pci_attributes = self # attributes pci_attributes in self # record " class_infos " [ ( " pci_virt " , pci_virt ) ; ( " pci_params " , pci_params ) ; ( " pci_name " , pci_name ) ; ( " pci_expr " , pci_expr ) ; ( " pci_loc " , pci_loc ) ; ( " pci_attributes " , pci_attributes ) ] method class_description : class_description -> ' res = self # class_infos self # class_type method class_type_declaration : class_type_declaration -> ' res = self # class_infos self # class_type method class_expr : class_expr -> ' res = fun { pcl_desc ; pcl_loc ; pcl_attributes } -> let pcl_desc = self # class_expr_desc pcl_desc in let pcl_loc = self # location pcl_loc in let pcl_attributes = self # attributes pcl_attributes in self # record " class_expr " [ ( " pcl_desc " , pcl_desc ) ; ( " pcl_loc " , pcl_loc ) ; ( " pcl_attributes " , pcl_attributes ) ] method class_expr_desc : class_expr_desc -> ' res = fun x -> match x with | Pcl_constr ( a , b ) -> let a = self # longident_loc a in let b = self # list self # core_type b in self # constr " Pcl_constr " [ ( " longident_loc " , a ) ; ( " core_type list " , b ) ] | Pcl_structure a -> let a = self # class_structure a in self # constr " Pcl_structure " [ ( " class_structure " , a ) ] | Pcl_fun ( a , b , c , d ) -> let a = self # arg_label a in let b = self # option self # expression b in let c = self # pattern c in let d = self # class_expr d in self # constr " Pcl_fun " [ ( " arg_label " , a ) ; ( " expression option " , b ) ; ( " pattern " , c ) ; ( " class_expr " , d ) ] | Pcl_apply ( a , b ) -> let a = self # class_expr a in let b = self # list ( fun ( a , b ) -> let a = self # arg_label a in let b = self # expression b in self # tuple [ ( " arg_label " , a ) ; ( " expression " , b ) ] ) b in self # constr " Pcl_apply " [ ( " class_expr " , a ) ; ( " ( arg_label * expression ) list " , b ) ] | Pcl_let ( a , b , c ) -> let a = self # rec_flag a in let b = self # list self # value_binding b in let c = self # class_expr c in self # constr " Pcl_let " [ ( " rec_flag " , a ) ; ( " value_binding list " , b ) ; ( " class_expr " , c ) ] | Pcl_constraint ( a , b ) -> let a = self # class_expr a in let b = self # class_type b in self # constr " Pcl_constraint " [ ( " class_expr " , a ) ; ( " class_type " , b ) ] | Pcl_extension a -> let a = self # extension a in self # constr " Pcl_extension " [ ( " extension " , a ) ] | Pcl_open ( a , b ) -> let a = self # open_description a in let b = self # class_expr b in self # constr " Pcl_open " [ ( " open_description " , a ) ; ( " class_expr " , b ) ] method class_structure : class_structure -> ' res = fun { pcstr_self ; pcstr_fields } -> let pcstr_self = self # pattern pcstr_self in let pcstr_fields = self # list self # class_field pcstr_fields in self # record " class_structure " [ ( " pcstr_self " , pcstr_self ) ; ( " pcstr_fields " , pcstr_fields ) ] method class_field : class_field -> ' res = fun { pcf_desc ; pcf_loc ; pcf_attributes } -> let pcf_desc = self # class_field_desc pcf_desc in let pcf_loc = self # location pcf_loc in let pcf_attributes = self # attributes pcf_attributes in self # record " class_field " [ ( " pcf_desc " , pcf_desc ) ; ( " pcf_loc " , pcf_loc ) ; ( " pcf_attributes " , pcf_attributes ) ] method class_field_desc : class_field_desc -> ' res = fun x -> match x with | Pcf_inherit ( a , b , c ) -> let a = self # override_flag a in let b = self # class_expr b in let c = self # option ( self # loc self # string ) c in self # constr " Pcf_inherit " [ ( " override_flag " , a ) ; ( " class_expr " , b ) ; ( " label loc option " , c ) ] | Pcf_val a -> let a = ( fun ( a , b , c ) -> let a = self # loc self # label a in let b = self # mutable_flag b in let c = self # class_field_kind c in self # tuple [ ( " label loc " , a ) ; ( " mutable_flag " , b ) ; ( " class_field_kind " , c ) ] ) a in self # constr " Pcf_val " [ ( " ( label loc * mutable_flag * class_field_kind ) " , a ) ] | Pcf_method a -> let a = ( fun ( a , b , c ) -> let a = self # loc self # label a in let b = self # private_flag b in let c = self # class_field_kind c in self # tuple [ ( " label loc " , a ) ; ( " private_flag " , b ) ; ( " class_field_kind " , c ) ] ) a in self # constr " Pcf_method " [ ( " ( label loc * private_flag * class_field_kind ) " , a ) ] | Pcf_constraint a -> let a = ( fun ( a , b ) -> let a = self # core_type a in let b = self # core_type b in self # tuple [ ( " core_type1 " , a ) ; ( " core_type2 " , b ) ] ) a in self # constr " Pcf_constraint " [ ( " ( core_type * core_type ) " , a ) ] | Pcf_initializer a -> let a = self # expression a in self # constr " Pcf_initializer " [ ( " expression " , a ) ] | Pcf_attribute a -> let a = self # attribute a in self # constr " Pcf_attribute " [ ( " attribute " , a ) ] | Pcf_extension a -> let a = self # extension a in self # constr " Pcf_extension " [ ( " extension " , a ) ] method class_field_kind : class_field_kind -> ' res = fun x -> match x with | Cfk_virtual a -> let a = self # core_type a in self # constr " Cfk_virtual " [ ( " core_type " , a ) ] | Cfk_concrete ( a , b ) -> let a = self # override_flag a in let b = self # expression b in self # constr " Cfk_concrete " [ ( " override_flag " , a ) ; ( " expression " , b ) ] method class_declaration : class_declaration -> ' res = self # class_infos self # class_expr method module_type : module_type -> ' res = fun { pmty_desc ; pmty_loc ; pmty_attributes } -> let pmty_desc = self # module_type_desc pmty_desc in let pmty_loc = self # location pmty_loc in let pmty_attributes = self # attributes pmty_attributes in self # record " module_type " [ ( " pmty_desc " , pmty_desc ) ; ( " pmty_loc " , pmty_loc ) ; ( " pmty_attributes " , pmty_attributes ) ] method module_type_desc : module_type_desc -> ' res = fun x -> match x with | Pmty_ident a -> let a = self # longident_loc a in self # constr " Pmty_ident " [ ( " longident_loc " , a ) ] | Pmty_signature a -> let a = self # signature a in self # constr " Pmty_signature " [ ( " signature " , a ) ] | Pmty_functor ( a , b ) -> let a = self # functor_parameter a in let b = self # module_type b in self # constr " Pmty_functor " [ ( " functor_parameter " , a ) ; ( " module_type " , b ) ] | Pmty_with ( a , b ) -> let a = self # module_type a in let b = self # list self # with_constraint b in self # constr " Pmty_with " [ ( " module_type " , a ) ; ( " with_constraint list " , b ) ] | Pmty_typeof a -> let a = self # module_expr a in self # constr " Pmty_typeof " [ ( " module_expr " , a ) ] | Pmty_extension a -> let a = self # extension a in self # constr " Pmty_extension " [ ( " extension " , a ) ] | Pmty_alias a -> let a = self # longident_loc a in self # constr " Pmty_alias " [ ( " longident_loc " , a ) ] method functor_parameter : functor_parameter -> ' res = fun x -> match x with | Unit -> self # constr " Unit " [ ] | Named ( a , b ) -> let a = self # loc ( self # option self # string ) a in let b = self # module_type b in self # constr " Named " [ ( " label option loc " , a ) ; ( " module_type " , b ) ] method signature : signature -> ' res = self # list self # signature_item method signature_item : signature_item -> ' res = fun { psig_desc ; psig_loc } -> let psig_desc = self # signature_item_desc psig_desc in let psig_loc = self # location psig_loc in self # record " signature_item " [ ( " psig_desc " , psig_desc ) ; ( " psig_loc " , psig_loc ) ] method signature_item_desc : signature_item_desc -> ' res = fun x -> match x with | Psig_value a -> let a = self # value_description a in self # constr " Psig_value " [ ( " value_description " , a ) ] | Psig_type ( a , b ) -> let a = self # rec_flag a in let b = self # list self # type_declaration b in self # constr " Psig_type " [ ( " rec_flag " , a ) ; ( " type_declaration list " , b ) ] | Psig_typesubst a -> let a = self # list self # type_declaration a in self # constr " Psig_typesubst " [ ( " type_declaration list " , a ) ] | Psig_typext a -> let a = self # type_extension a in self # constr " Psig_typext " [ ( " type_extension " , a ) ] | Psig_exception a -> let a = self # type_exception a in self # constr " Psig_exception " [ ( " type_exception " , a ) ] | Psig_module a -> let a = self # module_declaration a in self # constr " Psig_module " [ ( " module_declaration " , a ) ] | Psig_modsubst a -> let a = self # module_substitution a in self # constr " Psig_modsubst " [ ( " module_substitution " , a ) ] | Psig_recmodule a -> let a = self # list self # module_declaration a in self # constr " Psig_recmodule " [ ( " module_declaration list " , a ) ] | Psig_modtype a -> let a = self # module_type_declaration a in self # constr " Psig_modtype " [ ( " module_type_declaration " , a ) ] | Psig_modtypesubst a -> let a = self # module_type_declaration a in self # constr " Psig_modtypesubstr " [ ( " module_type_declaration " , a ) ] | Psig_open a -> let a = self # open_description a in self # constr " Psig_open " [ ( " open_description " , a ) ] | Psig_include a -> let a = self # include_description a in self # constr " Psig_include " [ ( " include_description " , a ) ] | Psig_class a -> let a = self # list self # class_description a in self # constr " Psig_class " [ ( " class_description list " , a ) ] | Psig_class_type a -> let a = self # list self # class_type_declaration a in self # constr " Psig_class_type " [ ( " class_type_declaration list " , a ) ] | Psig_attribute a -> let a = self # attribute a in self # constr " Psig_attribute " [ ( " attribute " , a ) ] | Psig_extension ( a , b ) -> let a = self # extension a in let b = self # attributes b in self # constr " Psig_extension " [ ( " extension " , a ) ; ( " attributes " , b ) ] method module_declaration : module_declaration -> ' res = fun { pmd_name ; pmd_type ; pmd_attributes ; pmd_loc } -> let pmd_name = self # loc ( self # option self # string ) pmd_name in let pmd_type = self # module_type pmd_type in let pmd_attributes = self # attributes pmd_attributes in let pmd_loc = self # location pmd_loc in self # record " module_declaration " [ ( " pmd_name " , pmd_name ) ; ( " pmd_type " , pmd_type ) ; ( " pmd_attributes " , pmd_attributes ) ; ( " pmd_loc " , pmd_loc ) ] method module_substitution : module_substitution -> ' res = fun { pms_name ; pms_manifest ; pms_attributes ; pms_loc } -> let pms_name = self # loc self # string pms_name in let pms_manifest = self # longident_loc pms_manifest in let pms_attributes = self # attributes pms_attributes in let pms_loc = self # location pms_loc in self # record " module_substitution " [ ( " pms_name " , pms_name ) ; ( " pms_manifest " , pms_manifest ) ; ( " pms_attributes " , pms_attributes ) ; ( " pms_loc " , pms_loc ) ] method module_type_declaration : module_type_declaration -> ' res = fun { pmtd_name ; pmtd_type ; pmtd_attributes ; pmtd_loc } -> let pmtd_name = self # loc self # string pmtd_name in let pmtd_type = self # option self # module_type pmtd_type in let pmtd_attributes = self # attributes pmtd_attributes in let pmtd_loc = self # location pmtd_loc in self # record " module_type_declaration " [ ( " pmtd_name " , pmtd_name ) ; ( " pmtd_type " , pmtd_type ) ; ( " pmtd_attributes " , pmtd_attributes ) ; ( " pmtd_loc " , pmtd_loc ) ] method open_infos : ' a . ( ' a -> ' res ) -> ' a open_infos -> ' res = fun _a { popen_expr ; popen_override ; popen_loc ; popen_attributes } -> let popen_expr = _a popen_expr in let popen_override = self # override_flag popen_override in let popen_loc = self # location popen_loc in let popen_attributes = self # attributes popen_attributes in self # record " open_infos " [ ( " popen_expr " , popen_expr ) ; ( " popen_override " , popen_override ) ; ( " popen_loc " , popen_loc ) ; ( " popen_attributes " , popen_attributes ) ] method open_description : open_description -> ' res = self # open_infos self # longident_loc method open_declaration : open_declaration -> ' res = self # open_infos self # module_expr method include_infos : ' a . ( ' a -> ' res ) -> ' a include_infos -> ' res = fun _a { pincl_mod ; pincl_loc ; pincl_attributes } -> let pincl_mod = _a pincl_mod in let pincl_loc = self # location pincl_loc in let pincl_attributes = self # attributes pincl_attributes in self # record " include_infos " [ ( " pincl_mod " , pincl_mod ) ; ( " pincl_loc " , pincl_loc ) ; ( " pincl_attributes " , pincl_attributes ) ] method include_description : include_description -> ' res = self # include_infos self # module_type method include_declaration : include_declaration -> ' res = self # include_infos self # module_expr method with_constraint : with_constraint -> ' res = fun x -> match x with | Pwith_type ( a , b ) -> let a = self # longident_loc a in let b = self # type_declaration b in self # constr " Pwith_type " [ ( " longident_loc " , a ) ; ( " type_declaration " , b ) ] | Pwith_module ( a , b ) -> let a = self # longident_loc a in let b = self # longident_loc b in self # constr " Pwith_module " [ ( " longident_loc1 " , a ) ; ( " longident_loc2 " , b ) ] | Pwith_modtype ( a , b ) -> let a = self # longident_loc a in let b = self # module_type b in self # constr " Pwith_modtype " [ ( " longident_loc " , a ) ; ( " module_type " , b ) ] | Pwith_modtypesubst ( a , b ) -> let a = self # longident_loc a in let b = self # module_type b in self # constr " Pwith_modtypesubstr " [ ( " longident_loc " , a ) ; ( " module_type " , b ) ] | Pwith_typesubst ( a , b ) -> let a = self # longident_loc a in let b = self # type_declaration b in self # constr " Pwith_typesubst " [ ( " longident_loc " , a ) ; ( " type_declaration " , b ) ] | Pwith_modsubst ( a , b ) -> let a = self # longident_loc a in let b = self # longident_loc b in self # constr " Pwith_modsubst " [ ( " longident_loc1 " , a ) ; ( " longident_loc2 " , b ) ] method module_expr : module_expr -> ' res = fun { pmod_desc ; pmod_loc ; pmod_attributes } -> let pmod_desc = self # module_expr_desc pmod_desc in let pmod_loc = self # location pmod_loc in let pmod_attributes = self # attributes pmod_attributes in self # record " module_expr " [ ( " pmod_desc " , pmod_desc ) ; ( " pmod_loc " , pmod_loc ) ; ( " pmod_attributes " , pmod_attributes ) ] method module_expr_desc : module_expr_desc -> ' res = fun x -> match x with | Pmod_ident a -> let a = self # longident_loc a in self # constr " Pmod_ident " [ ( " longident_loc " , a ) ] | Pmod_structure a -> let a = self # structure a in self # constr " Pmod_structure " [ ( " structure " , a ) ] | Pmod_functor ( a , b ) -> let a = self # functor_parameter a in let b = self # module_expr b in self # constr " Pmod_functor " [ ( " functor_parameter " , a ) ; ( " module_expr " , b ) ] | Pmod_apply ( a , b ) -> let a = self # module_expr a in let b = self # module_expr b in self # constr " Pmod_apply " [ ( " module_expr1 " , a ) ; ( " module_expr2 " , b ) ] | Pmod_constraint ( a , b ) -> let a = self # module_expr a in let b = self # module_type b in self # constr " Pmod_constraint " [ ( " module_expr " , a ) ; ( " module_type " , b ) ] | Pmod_unpack a -> let a = self # expression a in self # constr " Pmod_unpack " [ ( " expression " , a ) ] | Pmod_extension a -> let a = self # extension a in self # constr " Pmod_extension " [ ( " extension " , a ) ] method structure : structure -> ' res = self # list self # structure_item method structure_item : structure_item -> ' res = fun { pstr_desc ; pstr_loc } -> let pstr_desc = self # structure_item_desc pstr_desc in let pstr_loc = self # location pstr_loc in self # record " structure_item " [ ( " pstr_desc " , pstr_desc ) ; ( " pstr_loc " , pstr_loc ) ] method structure_item_desc : structure_item_desc -> ' res = fun x -> match x with | Pstr_eval ( a , b ) -> let a = self # expression a in let b = self # attributes b in self # constr " Pstr_eval " [ ( " expression " , a ) ; ( " attributes " , b ) ] | Pstr_value ( a , b ) -> let a = self # rec_flag a in let b = self # list self # value_binding b in self # constr " Pstr_value " [ ( " rec_flag " , a ) ; ( " value_binding list " , b ) ] | Pstr_primitive a -> let a = self # value_description a in self # constr " Pstr_primitive " [ ( " value_description " , a ) ] | Pstr_type ( a , b ) -> let a = self # rec_flag a in let b = self # list self # type_declaration b in self # constr " Pstr_type " [ ( " rec_flag " , a ) ; ( " type_declaration list " , b ) ] | Pstr_typext a -> let a = self # type_extension a in self # constr " Pstr_typext " [ ( " type_extension " , a ) ] | Pstr_exception a -> let a = self # type_exception a in self # constr " Pstr_exception " [ ( " type_exception " , a ) ] | Pstr_module a -> let a = self # module_binding a in self # constr " Pstr_module " [ ( " module_binding " , a ) ] | Pstr_recmodule a -> let a = self # list self # module_binding a in self # constr " Pstr_recmodule " [ ( " module_binding list " , a ) ] | Pstr_modtype a -> let a = self # module_type_declaration a in self # constr " Pstr_modtype " [ ( " module_type_declaration " , a ) ] | Pstr_open a -> let a = self # open_declaration a in self # constr " Pstr_open " [ ( " open_declaration " , a ) ] | Pstr_class a -> let a = self # list self # class_declaration a in self # constr " Pstr_class " [ ( " class_declaration list " , a ) ] | Pstr_class_type a -> let a = self # list self # class_type_declaration a in self # constr " Pstr_class_type " [ ( " class_type_declaration list " , a ) ] | Pstr_include a -> let a = self # include_declaration a in self # constr " Pstr_include " [ ( " include_declaration " , a ) ] | Pstr_attribute a -> let a = self # attribute a in self # constr " Pstr_attribute " [ ( " attribute " , a ) ] | Pstr_extension ( a , b ) -> let a = self # extension a in let b = self # attributes b in self # constr " Pstr_extension " [ ( " extension " , a ) ; ( " attributes " , b ) ] method value_binding : value_binding -> ' res = fun { pvb_pat ; pvb_expr ; pvb_attributes ; pvb_loc } -> let pvb_pat = self # pattern pvb_pat in let pvb_expr = self # expression pvb_expr in let pvb_attributes = self # attributes pvb_attributes in let pvb_loc = self # location pvb_loc in self # record " value_binding " [ ( " pvb_pat " , pvb_pat ) ; ( " pvb_expr " , pvb_expr ) ; ( " pvb_attributes " , pvb_attributes ) ; ( " pvb_loc " , pvb_loc ) ] method module_binding : module_binding -> ' res = fun { pmb_name ; pmb_expr ; pmb_attributes ; pmb_loc } -> let pmb_name = self # loc ( self # option self # string ) pmb_name in let pmb_expr = self # module_expr pmb_expr in let pmb_attributes = self # attributes pmb_attributes in let pmb_loc = self # location pmb_loc in self # record " module_binding " [ ( " pmb_name " , pmb_name ) ; ( " pmb_expr " , pmb_expr ) ; ( " pmb_attributes " , pmb_attributes ) ; ( " pmb_loc " , pmb_loc ) ] method toplevel_phrase : toplevel_phrase -> ' res = fun x -> match x with | Ptop_def a -> let a = self # structure a in self # constr " Ptop_def " [ ( " structure " , a ) ] | Ptop_dir a -> let a = self # toplevel_directive a in self # constr " Ptop_dir " [ ( " toplevel_directive " , a ) ] method toplevel_directive : toplevel_directive -> ' res = fun { pdir_name ; pdir_arg ; pdir_loc } -> let pdir_name = self # loc self # string pdir_name in let pdir_arg = self # option self # directive_argument pdir_arg in let pdir_loc = self # location pdir_loc in self # record " toplevel_directive " [ ( " pdir_name " , pdir_name ) ; ( " pdir_arg " , pdir_arg ) ; ( " pdir_loc " , pdir_loc ) ] method directive_argument : directive_argument -> ' res = fun { pdira_desc ; pdira_loc } -> let pdira_desc = self # directive_argument_desc pdira_desc in let pdira_loc = self # location pdira_loc in self # record " directive_argument " [ ( " pdira_desc " , pdira_desc ) ; ( " pdira_loc " , pdira_loc ) ] method directive_argument_desc : directive_argument_desc -> ' res = fun x -> match x with | Pdir_string a -> let a = self # string a in self # constr " Pdir_string " [ ( " label " , a ) ] | Pdir_int ( a , b ) -> let a = self # string a in let b = self # option self # char b in self # constr " Pdir_int " [ ( " label " , a ) ; ( " char option " , b ) ] | Pdir_ident a -> let a = self # longident a in self # constr " Pdir_ident " [ ( " longident " , a ) ] | Pdir_bool a -> let a = self # bool a in self # constr " Pdir_bool " [ ( " bool " , a ) ] method cases : cases -> ' res = self # list self # case end |
object ( self ) method virtual tuple : ( string * ( ' res , string ) result ) list -> ( ' res , string ) result method virtual option : ' a . ( ' a -> ' a -> ( ' res , string ) result ) -> ' a option -> ' a option -> ( ' res , string ) result method virtual bool : bool -> bool -> ( ' res , string ) result method virtual char : char -> char -> ( ' res , string ) result method virtual constr : string -> ( string * ( ' res , string ) result ) list -> ( ' res , string ) result method virtual int : int -> int -> ( ' res , string ) result method virtual bool : bool -> bool -> ( ' res , string ) result method virtual list : ' a . ( ' a -> ' a -> ( ' res , string ) result ) -> ' a list -> ' a list -> ( ' res , string ) result method virtual record : string -> ( string * ( ' res , string ) result ) list -> ( ' res , string ) result method virtual string : string -> string -> ( ' res , string ) result method position : position -> position -> ( ' res , string ) result = fun { pos_fname ; pos_lnum ; pos_bol ; pos_cnum } { pos_fname = pos_fname ' ; pos_lnum = pos_lnum ' ; pos_bol = pos_bol ' ; pos_cnum = pos_cnum ' } -> let pos_fname = self # string pos_fname pos_fname ' in let pos_lnum = self # int pos_lnum pos_lnum ' in let pos_bol = self # int pos_bol pos_bol ' in let pos_cnum = self # int pos_cnum pos_cnum ' in self # record " Lexing . position " [ ( " pos_fname " , pos_fname ) ; ( " pos_lnum " , pos_lnum ) ; ( " pos_bol " , pos_bol ) ; ( " pos_cnum " , pos_cnum ) ] method location : location -> location -> ( ' res , string ) result = fun { loc_start ; loc_end ; loc_ghost } { loc_start = loc_start ' ; loc_end = loc_end ' ; loc_ghost = loc_ghost ' } -> let loc_start = self # position loc_start loc_start ' in let loc_end = self # position loc_end loc_end ' in let loc_ghost = self # bool loc_ghost loc_ghost ' in self # record " Location . t " [ ( " loc_start " , loc_start ) ; ( " loc_end " , loc_end ) ; ( " loc_ghost " , loc_ghost ) ] method location_stack : location_stack -> location_stack -> ( ' res , string ) result = fun l l ' -> match ( l , l ' ) with | [ ] , _ :: _ -> self # list self # location l ' l ' | _ :: _ , [ ] -> self # list self # location l l | _ -> self # list self # location l l ' method loc : ' a . ( ' a -> ' a -> ( ' res , string ) result ) -> ' a loc -> ' a loc -> ( ' res , string ) result = fun _a { txt ; loc } { txt = txt ' ; loc = loc ' } -> let txt = _a txt txt ' in let loc = self # location loc loc ' in self # record " loc " [ ( " txt " , txt ) ; ( " loc " , loc ) ] method longident : longident -> longident -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Lident a , Lident a ' -> let a = self # string a a ' in self # constr " Lident " [ ( " label " , a ) ] | Ldot ( a , b ) , Ldot ( a ' , b ' ) -> let a = self # longident a a ' in let b = self # string b b ' in self # constr " Ldot " [ ( " longident " , a ) ; ( " label " , b ) ] | Lapply ( a , b ) , Lapply ( a ' , b ' ) -> let a = self # longident a a ' in let b = self # longident b b ' in self # constr " Lapply " [ ( " longident1 " , a ) ; ( " longident2 " , b ) ] | _ -> Error " longident " method longident_loc : longident_loc -> longident_loc -> ( ' res , string ) result = self # loc self # longident method rec_flag : rec_flag -> rec_flag -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Nonrecursive , Nonrecursive -> self # constr " Nonrecursive " [ ] | Recursive , Recursive -> self # constr " Recursive " [ ] | _ -> Error " rec_flag " method direction_flag : direction_flag -> direction_flag -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Upto , Upto -> self # constr " Upto " [ ] | Downto , Downto -> self # constr " Downto " [ ] | _ -> Error " direction_flag " method private_flag : private_flag -> private_flag -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Private , Private -> self # constr " Private " [ ] | Public , Public -> self # constr " Public " [ ] | _ -> Error " private_flag " method mutable_flag : mutable_flag -> mutable_flag -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Immutable , Immutable -> self # constr " Immutable " [ ] | Mutable , Mutable -> self # constr " Mutable " [ ] | _ -> Error " mutable_flag " method virtual_flag : virtual_flag -> virtual_flag -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Virtual , Virtual -> self # constr " Virtual " [ ] | Concrete , Concrete -> self # constr " Concrete " [ ] | _ -> Error " virtual_flag " method override_flag : override_flag -> override_flag -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Override , Override -> self # constr " Override " [ ] | Fresh , Fresh -> self # constr " Fresh " [ ] | _ -> Error " override_flag " method closed_flag : closed_flag -> closed_flag -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Closed , Closed -> self # constr " Closed " [ ] | Open , Open -> self # constr " Open " [ ] | _ -> Error " closed_flag " method label : label -> label -> ( ' res , string ) result = self # string method arg_label : arg_label -> arg_label -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Nolabel , Nolabel -> self # constr " Nolabel " [ ] | Labelled a , Labelled a ' -> let a = self # string a a ' in self # constr " Labelled " [ ( " label " , a ) ] | Optional a , Optional a ' -> let a = self # string a a ' in self # constr " Optional " [ ( " label " , a ) ] | _ -> Error " arg_label " method variance : variance -> variance -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Covariant , Covariant -> self # constr " Covariant " [ ] | Contravariant , Contravariant -> self # constr " Contravariant " [ ] | NoVariance , NoVariance -> self # constr " NoVariance " [ ] | _ -> Error " variance " method injectivity : injectivity -> injectivity -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Injective , Injective -> self # constr " Injective " [ ] | NoInjectivity , NoInjectivity -> self # constr " NoInjectivity " [ ] | _ -> Error " injectivity " method constant : constant -> constant -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Pconst_integer ( a , b ) , Pconst_integer ( a ' , b ' ) -> let a = self # string a a ' in let b = self # option self # char b b ' in self # constr " Pconst_integer " [ ( " label " , a ) ; ( " char option " , b ) ] | Pconst_char a , Pconst_char a ' -> let a = self # char a a ' in self # constr " Pconst_char " [ ( " char " , a ) ] | Pconst_string ( a , b , c ) , Pconst_string ( a ' , b ' , c ' ) -> let a = self # string a a ' in let b = self # location b b ' in let c = self # option self # string c c ' in self # constr " Pconst_string " [ ( " label " , a ) ; ( " location " , b ) ; ( " label option " , c ) ] | Pconst_float ( a , b ) , Pconst_float ( a ' , b ' ) -> let a = self # string a a ' in let b = self # option self # char b b ' in self # constr " Pconst_float " [ ( " label " , a ) ; ( " char option " , b ) ] | _ -> Error " constant " method attribute : attribute -> attribute -> ( ' res , string ) result = fun { attr_name ; attr_payload ; attr_loc } { attr_name = attr_name ' ; attr_payload = attr_payload ' ; attr_loc = attr_loc ' } -> let attr_name = self # loc self # string attr_name attr_name ' in let attr_payload = self # payload attr_payload attr_payload ' in let attr_loc = self # location attr_loc attr_loc ' in self # record " attribute " [ ( " attr_name " , attr_name ) ; ( " attr_payload " , attr_payload ) ; ( " attr_loc " , attr_loc ) ] method extension : extension -> extension -> ( ' res , string ) result = fun ( a , b ) ( a ' , b ' ) -> let a = self # loc self # string a a ' in let b = self # payload b b ' in self # tuple [ ( " label loc " , a ) ; ( " payload " , b ) ] method attributes : attributes -> attributes -> ( ' res , string ) result = self # list self # attribute method str_loc_lst : string loc list -> string loc list -> ( ' res , string ) result = fun lst -> self # list ( self # loc self # string ) lst method existentials = self # str_loc_lst method type_vars = self # str_loc_lst method payload : payload -> payload -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | PStr a , PStr a ' -> let a = self # structure a a ' in self # constr " PStr " [ ( " structure " , a ) ] | PSig a , PSig a ' -> let a = self # signature a a ' in self # constr " PSig " [ ( " signature " , a ) ] | PTyp a , PTyp a ' -> let a = self # core_type a a ' in self # constr " PTyp " [ ( " core_type " , a ) ] | PPat ( a , b ) , PPat ( a ' , b ' ) -> let a = self # pattern a a ' in let b = self # option self # expression b b ' in self # constr " PPat " [ ( " pattern " , a ) ; ( " expression option " , b ) ] | _ -> Error " payload " method core_type : core_type -> core_type -> ( ' res , string ) result = fun { ptyp_desc ; ptyp_loc ; ptyp_loc_stack ; ptyp_attributes } { ptyp_desc = ptyp_desc ' ; ptyp_loc = ptyp_loc ' ; ptyp_loc_stack = ptyp_loc_stack ' ; ptyp_attributes = ptyp_attributes ' } -> let ptyp_desc = self # core_type_desc ptyp_desc ptyp_desc ' in let ptyp_loc = self # location ptyp_loc ptyp_loc ' in let ptyp_loc_stack = self # location_stack ptyp_loc_stack ptyp_loc_stack ' in let ptyp_attributes = self # attributes ptyp_attributes ptyp_attributes ' in self # record " core_type " [ ( " ptyp_desc " , ptyp_desc ) ; ( " ptyp_loc " , ptyp_loc ) ; ( " ptyp_loc_stack " , ptyp_loc_stack ) ; ( " ptyp_attributes " , ptyp_attributes ) ] method core_type_desc : core_type_desc -> core_type_desc -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Ptyp_any , Ptyp_any -> self # constr " Ptyp_any " [ ] | Ptyp_var a , Ptyp_var a ' -> let a = self # string a a ' in self # constr " Ptyp_var " [ ( " label " , a ) ] | Ptyp_arrow ( a , b , c ) , Ptyp_arrow ( a ' , b ' , c ' ) -> let a = self # arg_label a a ' in let b = self # core_type b b ' in let c = self # core_type c c ' in self # constr " Ptyp_arrow " [ ( " arg_label " , a ) ; ( " core_type1 " , b ) ; ( " core_type2 " , c ) ] | Ptyp_tuple a , Ptyp_tuple a ' -> let a = self # list self # core_type a a ' in self # constr " Ptyp_tuple " [ ( " core_type list " , a ) ] | Ptyp_constr ( a , b ) , Ptyp_constr ( a ' , b ' ) -> let a = self # longident_loc a a ' in let b = self # list self # core_type b b ' in self # constr " Ptyp_constr " [ ( " longident_loc " , a ) ; ( " core_type list " , b ) ] | Ptyp_object ( a , b ) , Ptyp_object ( a ' , b ' ) -> let a = self # list self # object_field a a ' in let b = self # closed_flag b b ' in self # constr " Ptyp_object " [ ( " object_field list " , a ) ; ( " closed_flag " , b ) ] | Ptyp_class ( a , b ) , Ptyp_class ( a ' , b ' ) -> let a = self # longident_loc a a ' in let b = self # list self # core_type b b ' in self # constr " Ptyp_class " [ ( " longident_loc " , a ) ; ( " core_type list " , b ) ] | Ptyp_alias ( a , b ) , Ptyp_alias ( a ' , b ' ) -> let a = self # core_type a a ' in let b = self # string b b ' in self # constr " Ptyp_alias " [ ( " core_type " , a ) ; ( " label " , b ) ] | Ptyp_variant ( a , b , c ) , Ptyp_variant ( a ' , b ' , c ' ) -> let a = self # list self # row_field a a ' in let b = self # closed_flag b b ' in let c = self # option ( self # list self # label ) c c ' in self # constr " Ptyp_variant " [ ( " row_field list " , a ) ; ( " closed_flag " , b ) ; ( " label list option " , c ) ] | Ptyp_poly ( a , b ) , Ptyp_poly ( a ' , b ' ) -> let a = self # list ( self # loc self # string ) a a ' in let b = self # core_type b b ' in self # constr " Ptyp_poly " [ ( " label loc list " , a ) ; ( " core_type " , b ) ] | Ptyp_package a , Ptyp_package a ' -> let a = self # package_type a a ' in self # constr " Ptyp_package " [ ( " package_type " , a ) ] | Ptyp_extension a , Ptyp_extension a ' -> let a = self # extension a a ' in self # constr " Ptyp_extension " [ ( " extension " , a ) ] | _ -> Error " core_type_desc " method package_type : package_type -> package_type -> ( ' res , string ) result = fun ( a , b ) ( a ' , b ' ) -> let a = self # longident_loc a a ' in let b = self # list ( fun ( a , b ) ( a ' , b ' ) -> let a = self # longident_loc a a ' in let b = self # core_type b b ' in self # tuple [ ( " longident_loc " , a ) ; ( " core_type " , b ) ] ) b in self # tuple [ ( " longident_loc " , a ) ; ( " ( longident_loc * core_type ) list " , b b ' ) ] method row_field : row_field -> row_field -> ( ' res , string ) result = fun { prf_desc ; prf_loc ; prf_attributes } { prf_desc = prf_desc ' ; prf_loc = prf_loc ' ; prf_attributes = prf_attributes ' } -> let prf_desc = self # row_field_desc prf_desc prf_desc ' in let prf_loc = self # location prf_loc prf_loc ' in let prf_attributes = self # attributes prf_attributes prf_attributes ' in self # record " row_field " [ ( " prf_desc " , prf_desc ) ; ( " prf_loc " , prf_loc ) ; ( " prf_attributes " , prf_attributes ) ] method row_field_desc : row_field_desc -> row_field_desc -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Rtag ( a , b , c ) , Rtag ( a ' , b ' , c ' ) -> let a = self # loc self # label a a ' in let b = self # bool b b ' in let c = self # list self # core_type c c ' in self # constr " Rtag " [ ( " label loc " , a ) ; ( " bool " , b ) ; ( " core_type list " , c ) ] | Rinherit a , Rinherit a ' -> let a = self # core_type a a ' in self # constr " Rinherit " [ ( " core_type " , a ) ] | _ -> Error " row_field_desc " method object_field : object_field -> object_field -> ( ' res , string ) result = fun { pof_desc ; pof_loc ; pof_attributes } { pof_desc = pof_desc ' ; pof_loc = pof_loc ' ; pof_attributes = pof_attributes ' } -> let pof_desc = self # object_field_desc pof_desc pof_desc ' in let pof_loc = self # location pof_loc pof_loc ' in let pof_attributes = self # attributes pof_attributes pof_attributes ' in self # record " object_field " [ ( " pof_desc " , pof_desc ) ; ( " pof_loc " , pof_loc ) ; ( " pof_attributes " , pof_attributes ) ] method object_field_desc : object_field_desc -> object_field_desc -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Otag ( a , b ) , Otag ( a ' , b ' ) -> let a = self # loc self # label a a ' in let b = self # core_type b b ' in self # constr " Otag " [ ( " label loc " , a ) ; ( " core_type " , b ) ] | Oinherit a , Oinherit a ' -> let a = self # core_type a a ' in self # constr " Oinherit " [ ( " core_type " , a ) ] | _ -> Error " object_field_desc " method pattern : pattern -> pattern -> ( ' res , string ) result = fun { ppat_desc ; ppat_loc ; ppat_loc_stack ; ppat_attributes } { ppat_desc = ppat_desc ' ; ppat_loc = ppat_loc ' ; ppat_loc_stack = ppat_loc_stack ' ; ppat_attributes = ppat_attributes ' } -> let ppat_desc = self # pattern_desc ppat_desc ppat_desc ' in let ppat_loc = self # location ppat_loc ppat_loc ' in let ppat_loc_stack = self # location_stack ppat_loc_stack ppat_loc_stack ' in let ppat_attributes = self # attributes ppat_attributes ppat_attributes ' in self # record " pattern " [ ( " ppat_desc " , ppat_desc ) ; ( " ppat_loc " , ppat_loc ) ; ( " ppat_loc_stack " , ppat_loc_stack ) ; ( " ppat_attributes " , ppat_attributes ) ] method pattern_desc : pattern_desc -> pattern_desc -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Ppat_any , Ppat_any -> self # constr " Ppat_any " [ ] | Ppat_var a , Ppat_var a ' -> let a = self # loc self # string a a ' in self # constr " Ppat_var " [ ( " label loc " , a ) ] | Ppat_alias ( a , b ) , Ppat_alias ( a ' , b ' ) -> let a = self # pattern a a ' in let b = self # loc self # string b b ' in self # constr " Ppat_alias " [ ( " pattern " , a ) ; ( " label loc " , b ) ] | Ppat_constant a , Ppat_constant a ' -> let a = self # constant a a ' in self # constr " Ppat_constant " [ ( " constant " , a ) ] | Ppat_interval ( a , b ) , Ppat_interval ( a ' , b ' ) -> let a = self # constant a a ' in let b = self # constant b b ' in self # constr " Ppat_interval " [ ( " constant1 " , a ) ; ( " constant2 " , b ) ] | Ppat_tuple a , Ppat_tuple a ' -> let a = self # list self # pattern a a ' in self # constr " Ppat_tuple " [ ( " pattern list " , a ) ] | Ppat_construct ( a , b ) , Ppat_construct ( a ' , b ' ) -> let a = self # longident_loc a a ' in let b = self # option ( fun ( existentials , patt ) ( existentials ' , patt ' ) -> let existentials = self # existentials existentials existentials ' in let patt = self # pattern patt patt ' in self # tuple [ ( " existentials " , existentials ) ; ( " pattern " , patt ) ] ) b b ' in self # constr " Ppat_construct " [ ( " longident_loc " , a ) ; ( " pattern option " , b ) ] | Ppat_variant ( a , b ) , Ppat_variant ( a ' , b ' ) -> let a = self # label a a ' in let b = self # option self # pattern b b ' in self # constr " Ppat_variant " [ ( " label " , a ) ; ( " pattern option " , b ) ] | Ppat_record ( a , b ) , Ppat_record ( a ' , b ' ) -> let a = self # list ( fun ( a , b ) ( a ' , b ' ) -> let a = self # longident_loc a a ' in let b = self # pattern b b ' in self # tuple [ ( " longident_loc " , a ) ; ( " pattern " , b ) ] ) a in let b = self # closed_flag b b ' in self # constr " Ppat_record " [ ( " ( longident_loc * pattern ) list " , a a ' ) ; ( " closed_flag " , b ) ] | Ppat_array a , Ppat_array a ' -> let a = self # list self # pattern a a ' in self # constr " Ppat_array " [ ( " pattern list " , a ) ] | Ppat_or ( a , b ) , Ppat_or ( a ' , b ' ) -> let a = self # pattern a a ' in let b = self # pattern b b ' in self # constr " Ppat_or " [ ( " pattern1 " , a ) ; ( " pattern2 " , b ) ] | Ppat_constraint ( a , b ) , Ppat_constraint ( a ' , b ' ) -> let a = self # pattern a a ' in let b = self # core_type b b ' in self # constr " Ppat_constraint " [ ( " pattern " , a ) ; ( " core_type " , b ) ] | Ppat_type a , Ppat_type a ' -> let a = self # longident_loc a a ' in self # constr " Ppat_type " [ ( " longident_loc " , a ) ] | Ppat_lazy a , Ppat_lazy a ' -> let a = self # pattern a a ' in self # constr " Ppat_lazy " [ ( " pattern " , a ) ] | Ppat_unpack a , Ppat_unpack a ' -> let a = self # loc ( self # option self # string ) a in self # constr " Ppat_unpack " [ ( " label option loc " , a a ' ) ] | Ppat_exception a , Ppat_exception a ' -> let a = self # pattern a a ' in self # constr " Ppat_exception " [ ( " pattern " , a ) ] | Ppat_extension a , Ppat_extension a ' -> let a = self # extension a a ' in self # constr " Ppat_extension " [ ( " extension " , a ) ] | Ppat_open ( a , b ) , Ppat_open ( a ' , b ' ) -> let a = self # longident_loc a a ' in let b = self # pattern b b ' in self # constr " Ppat_open " [ ( " longident_loc " , a ) ; ( " pattern " , b ) ] | Ppat_var _ , Ppat_any -> self # pattern_desc x x | Ppat_tuple [ exp1 ] , ppat_desc ' -> self # pattern_desc x ( Ppat_tuple [ { exp1 with ppat_desc = ppat_desc ' } ] ) | _ -> Error " pattern_desc " method expression : expression -> expression -> ( ' res , string ) result = fun { pexp_desc ; pexp_loc ; pexp_loc_stack ; pexp_attributes } { pexp_desc = pexp_desc ' ; pexp_loc = pexp_loc ' ; pexp_loc_stack = pexp_loc_stack ' ; pexp_attributes = pexp_attributes ' } -> let pexp_desc = self # expression_desc pexp_desc pexp_desc ' in let pexp_loc = self # location pexp_loc pexp_loc ' in let pexp_loc_stack = self # location_stack pexp_loc_stack pexp_loc_stack ' in let pexp_attributes = self # attributes pexp_attributes pexp_attributes ' in self # record " expression " [ ( " pexp_desc " , pexp_desc ) ; ( " pexp_loc " , pexp_loc ) ; ( " pexp_loc_stack " , pexp_loc_stack ) ; ( " pexp_attributes " , pexp_attributes ) ] method expression_desc : expression_desc -> expression_desc -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Pexp_ident a , Pexp_ident a ' -> let a = self # longident_loc a a ' in self # constr " Pexp_ident " [ ( " longident_loc " , a ) ] | Pexp_constant a , Pexp_constant a ' -> let a = self # constant a a ' in self # constr " Pexp_constant " [ ( " constant " , a ) ] | Pexp_let ( a , b , c ) , Pexp_let ( a ' , b ' , c ' ) -> let a = self # rec_flag a a ' in let b = self # list self # value_binding b b ' in let c = self # expression c c ' in self # constr " Pexp_let " [ ( " rec_flag " , a ) ; ( " value_binding list " , b ) ; ( " expression " , c ) ] | Pexp_function a , Pexp_function a ' -> let a = self # cases a a ' in self # constr " Pexp_function " [ ( " cases " , a ) ] | Pexp_fun ( a , b , c , d ) , Pexp_fun ( a ' , b ' , c ' , d ' ) -> let a = self # arg_label a a ' in let b = self # option self # expression b b ' in let c = self # pattern c c ' in let d = self # expression d d ' in self # constr " Pexp_fun " [ ( " arg_label " , a ) ; ( " expression option " , b ) ; ( " pattern " , c ) ; ( " expression " , d ) ] | Pexp_apply ( a , b ) , Pexp_apply ( a ' , b ' ) -> let a = self # expression a a ' in let b = self # list ( fun ( a , b ) ( a ' , b ' ) -> let a = self # arg_label a a ' in let b = self # expression b b ' in self # tuple [ ( " arg_label " , a ) ; ( " expression " , b ) ] ) b in self # constr " Pexp_apply " [ ( " expression " , a ) ; ( " ( arg_label * expression ) list " , b b ' ) ] | Pexp_match ( a , b ) , Pexp_match ( a ' , b ' ) -> let a = self # expression a a ' in let b = self # cases b b ' in self # constr " Pexp_match " [ ( " expression " , a ) ; ( " cases " , b ) ] | Pexp_try ( a , b ) , Pexp_try ( a ' , b ' ) -> let a = self # expression a a ' in let b = self # cases b b ' in self # constr " Pexp_try " [ ( " expression " , a ) ; ( " cases " , b ) ] | Pexp_tuple a , Pexp_tuple a ' -> let a = self # list self # expression a a ' in self # constr " Pexp_tuple " [ ( " expression list " , a ) ] | Pexp_construct ( a , b ) , Pexp_construct ( a ' , b ' ) -> let a = self # longident_loc a a ' in let b = self # option self # expression b b ' in self # constr " Pexp_construct " [ ( " longident_loc " , a ) ; ( " expression option " , b ) ] | Pexp_variant ( a , b ) , Pexp_variant ( a ' , b ' ) -> let a = self # label a a ' in let b = self # option self # expression b b ' in self # constr " Pexp_variant " [ ( " label " , a ) ; ( " expression option " , b ) ] | Pexp_record ( a , b ) , Pexp_record ( a ' , b ' ) -> let a = self # list ( fun ( a , b ) ( a ' , b ' ) -> let a = self # longident_loc a a ' in let b = self # expression b b ' in self # tuple [ ( " longident_loc " , a ) ; ( " expression " , b ) ] ) a in let b = self # option self # expression b b ' in self # constr " Pexp_record " [ ( " ( longident_loc * expression ) list " , a a ' ) ; ( " expression option " , b ) ] | Pexp_field ( a , b ) , Pexp_field ( a ' , b ' ) -> let a = self # expression a a ' in let b = self # longident_loc b b ' in self # constr " Pexp_field " [ ( " expression " , a ) ; ( " longident_loc " , b ) ] | Pexp_setfield ( a , b , c ) , Pexp_setfield ( a ' , b ' , c ' ) -> let a = self # expression a a ' in let b = self # longident_loc b b ' in let c = self # expression c c ' in self # constr " Pexp_setfield " [ ( " expression1 " , a ) ; ( " longident_loc " , b ) ; ( " expression2 " , c ) ] | Pexp_array a , Pexp_array a ' -> let a = self # list self # expression a a ' in self # constr " Pexp_array " [ ( " expression list " , a ) ] | Pexp_ifthenelse ( a , b , c ) , Pexp_ifthenelse ( a ' , b ' , c ' ) -> let a = self # expression a a ' in let b = self # expression b b ' in let c = self # option self # expression c c ' in self # constr " Pexp_ifthenelse " [ ( " expression1 " , a ) ; ( " expression2 " , b ) ; ( " expression option " , c ) ] | Pexp_sequence ( a , b ) , Pexp_sequence ( a ' , b ' ) -> let a = self # expression a a ' in let b = self # expression b b ' in self # constr " Pexp_sequence " [ ( " expression1 " , a ) ; ( " expression2 " , b ) ] | Pexp_while ( a , b ) , Pexp_while ( a ' , b ' ) -> let a = self # expression a a ' in let b = self # expression b b ' in self # constr " Pexp_while " [ ( " expression1 " , a ) ; ( " expression2 " , b ) ] | Pexp_for ( a , b , c , d , e ) , Pexp_for ( a ' , b ' , c ' , d ' , e ' ) -> let a = self # pattern a a ' in let b = self # expression b b ' in let c = self # expression c c ' in let d = self # direction_flag d d ' in let e = self # expression e e ' in self # constr " Pexp_for " [ ( " pattern " , a ) ; ( " expression1 " , b ) ; ( " expression2 " , c ) ; ( " direction_flag " , d ) ; ( " expression3 " , e ) ] | Pexp_constraint ( a , b ) , Pexp_constraint ( a ' , b ' ) -> let a = self # expression a a ' in let b = self # core_type b b ' in self # constr " Pexp_constraint " [ ( " expression " , a ) ; ( " core_type " , b ) ] | Pexp_coerce ( a , b , c ) , Pexp_coerce ( a ' , b ' , c ' ) -> let a = self # expression a a ' in let b = self # option self # core_type b b ' in let c = self # core_type c c ' in self # constr " Pexp_coerce " [ ( " expression " , a ) ; ( " core_type option " , b ) ; ( " core_type " , c ) ] | Pexp_send ( a , b ) , Pexp_send ( a ' , b ' ) -> let a = self # expression a a ' in let b = self # loc self # label b b ' in self # constr " Pexp_send " [ ( " expression " , a ) ; ( " label loc " , b ) ] | Pexp_new a , Pexp_new a ' -> let a = self # longident_loc a a ' in self # constr " Pexp_new " [ ( " longident_loc " , a ) ] | Pexp_setinstvar ( a , b ) , Pexp_setinstvar ( a ' , b ' ) -> let a = self # loc self # label a a ' in let b = self # expression b b ' in self # constr " Pexp_setinstvar " [ ( " label loc " , a ) ; ( " expression " , b ) ] | Pexp_override a , Pexp_override a ' -> let a = self # list ( fun ( a , b ) ( a ' , b ' ) -> let a = self # loc self # label a a ' in let b = self # expression b b ' in self # tuple [ ( " label loc " , a ) ; ( " expression " , b ) ] ) a in self # constr " Pexp_override " [ ( " ( label loc * expression ) list " , a a ' ) ] | Pexp_letmodule ( a , b , c ) , Pexp_letmodule ( a ' , b ' , c ' ) -> let a = self # loc ( self # option self # string ) a in let b = self # module_expr b b ' in let c = self # expression c c ' in self # constr " Pexp_letmodule " [ ( " label option loc " , a a ' ) ; ( " module_expr " , b ) ; ( " expression " , c ) ] | Pexp_letexception ( a , b ) , Pexp_letexception ( a ' , b ' ) -> let a = self # extension_constructor a a ' in let b = self # expression b b ' in self # constr " Pexp_letexception " [ ( " Parsetree . extension_constructor " , a ) ; ( " expression " , b ) ] | Pexp_assert a , Pexp_assert a ' -> let a = self # expression a a ' in self # constr " Pexp_assert " [ ( " expression " , a ) ] | Pexp_lazy a , Pexp_lazy a ' -> let a = self # expression a a ' in self # constr " Pexp_lazy " [ ( " expression " , a ) ] | Pexp_poly ( a , b ) , Pexp_poly ( a ' , b ' ) -> let a = self # expression a a ' in let b = self # option self # core_type b b ' in self # constr " Pexp_poly " [ ( " expression " , a ) ; ( " core_type option " , b ) ] | Pexp_object a , Pexp_object a ' -> let a = self # class_structure a a ' in self # constr " Pexp_object " [ ( " class_structure " , a ) ] | Pexp_newtype ( a , b ) , Pexp_newtype ( a ' , b ' ) -> let a = self # loc self # string a a ' in let b = self # expression b b ' in self # constr " Pexp_newtype " [ ( " label loc " , a ) ; ( " expression " , b ) ] | Pexp_pack a , Pexp_pack a ' -> let a = self # module_expr a a ' in self # constr " Pexp_pack " [ ( " module_expr " , a ) ] | Pexp_open ( a , b ) , Pexp_open ( a ' , b ' ) -> let a = self # open_declaration a a ' in let b = self # expression b b ' in self # constr " Pexp_open " [ ( " open_declaration " , a ) ; ( " expression " , b ) ] | Pexp_letop a , Pexp_letop a ' -> let a = self # letop a a ' in self # constr " Pexp_letop " [ ( " letop " , a ) ] | Pexp_extension a , Pexp_extension a ' -> let a = self # extension a a ' in self # constr " Pexp_extension " [ ( " extension " , a ) ] | Pexp_unreachable , Pexp_unreachable -> self # constr " Pexp_unreachable " [ ] | ( Pexp_apply ( ( { pexp_desc = Pexp_newtype _ ; _ } as exp1 ) , al_exp_list ) , Pexp_newtype _ ) -> self # expression_desc x ( Pexp_apply ( { exp1 with pexp_desc = x ' } , al_exp_list ) ) | ( Pexp_newtype ( a , b ) , Pexp_apply ( { pexp_desc = Pexp_newtype ( a ' , b ' ) ; _ } , _ ) ) -> let a = self # loc self # string a a ' in let b = self # expression b b ' in self # constr " Pexp_newtype " [ ( " label loc " , a ) ; ( " expression " , b ) ] | ( Pexp_constraint ( a , b ) , Pexp_apply ( { pexp_desc = Pexp_constraint ( a ' , b ' ) ; _ } , _ ) ) -> let a = self # expression a a ' in let b = self # core_type b b ' in self # constr " Pexp_constraint " [ ( " expression " , a ) ; ( " core_type " , b ) ] | ( Pexp_open ( a , b ) , Pexp_constraint ( { pexp_desc = Pexp_open ( a ' , b ' ) ; _ } , _ ) ) -> let a = self # open_declaration a a ' in let b = self # expression b b ' in self # constr " Pexp_open " [ ( " open_declaration " , a ) ; ( " expression " , b ) ] | ( Pexp_let ( a , b , c ) , Pexp_constraint ( { pexp_desc = Pexp_let ( a ' , b ' , c ' ) ; _ } , _ ) ) -> let a = self # rec_flag a a ' in let b = self # list self # value_binding b b ' in let c = self # expression c c ' in self # constr " Pexp_let " [ ( " rec_flag " , a ) ; ( " value_binding list " , b ) ; ( " expression " , c ) ] | ( Pexp_fun ( a , b , c , d ) , Pexp_apply ( { pexp_desc = Pexp_fun ( a ' , b ' , c ' , d ' ) ; _ } , _ ) ) -> let a = self # arg_label a a ' in let b = self # option self # expression b b ' in let c = self # pattern c c ' in let d = self # expression d d ' in self # constr " Pexp_fun " [ ( " arg_label " , a ) ; ( " expression option " , b ) ; ( " pattern " , c ) ; ( " expression " , d ) ] | ( Pexp_fun ( a , b , c , d ) , Pexp_constraint ( { pexp_desc = Pexp_fun ( a ' , b ' , c ' , d ' ) ; _ } , _ ) ) -> let a = self # arg_label a a ' in let b = self # option self # expression b b ' in let c = self # pattern c c ' in let d = self # expression d d ' in self # constr " Pexp_fun " [ ( " arg_label " , a ) ; ( " expression option " , b ) ; ( " pattern " , c ) ; ( " expression " , d ) ] | ( Pexp_fun ( a , b , c , d ) , Pexp_poly ( { pexp_desc = Pexp_fun ( a ' , b ' , c ' , d ' ) ; _ } , _ ) ) -> let a = self # arg_label a a ' in let b = self # option self # expression b b ' in let c = self # pattern c c ' in let d = self # expression d d ' in self # constr " Pexp_fun " [ ( " arg_label " , a ) ; ( " expression option " , b ) ; ( " pattern " , c ) ; ( " expression " , d ) ] | ( oexpr_desc , Pexp_newtype ( lloc1 , ( { pexp_desc = Pexp_newtype ( lloc2 , ( { pexp_desc = Pexp_newtype ( lloc3 , { pexp_desc = Pexp_sequence ( ( { pexp_desc = Pexp_apply ( e1 , arg_lablel_e_list ) ; _ } as seqexp1 ) , e2 ) ; _ } ) ; _ } as ntrec2 ) ) ; _ } as ntrec1 ) ) ) -> let normalized_newtypes = Pexp_newtype ( lloc1 , { ntrec1 with pexp_desc = Pexp_newtype ( lloc2 , { ntrec2 with pexp_desc = Pexp_newtype ( lloc3 , e1 ) } ) } ) in let normalized_apply = Pexp_apply ( { e1 with pexp_desc = normalized_newtypes } , arg_lablel_e_list ) in let normalized_pexp_desc2 = Pexp_sequence ( { seqexp1 with pexp_desc = normalized_apply } , e2 ) in self # expression_desc oexpr_desc normalized_pexp_desc2 | Pexp_tuple [ exp1 ] , pexp_desc ' -> self # expression_desc x ( Pexp_tuple [ { exp1 with pexp_desc = pexp_desc ' } ] ) | _ -> Error " expression_desc " method case : case -> case -> ( ' res , string ) result = fun { pc_lhs ; pc_guard ; pc_rhs } { pc_lhs = pc_lhs ' ; pc_guard = pc_guard ' ; pc_rhs = pc_rhs ' } -> let pc_lhs = self # pattern pc_lhs pc_lhs ' in let pc_guard = self # option self # expression pc_guard pc_guard ' in let pc_rhs = self # expression pc_rhs pc_rhs ' in self # record " case " [ ( " pc_lhs " , pc_lhs ) ; ( " pc_guard " , pc_guard ) ; ( " pc_rhs " , pc_rhs ) ] method letop : letop -> letop -> ( ' res , string ) result = fun { let_ ; ands ; body } { let_ = let_ ' ; ands = ands ' ; body = body ' } -> let let_ = self # binding_op let_ let_ ' in let ands = self # list self # binding_op ands ands ' in let body = self # expression body body ' in self # record " letop " [ ( " let_ " , let_ ) ; ( " ands " , ands ) ; ( " body " , body ) ] method binding_op : binding_op -> binding_op -> ( ' res , string ) result = fun { pbop_op ; pbop_pat ; pbop_exp ; pbop_loc } { pbop_op = pbop_op ' ; pbop_pat = pbop_pat ' ; pbop_exp = pbop_exp ' ; pbop_loc = pbop_loc ' } -> let pbop_op = self # loc self # string pbop_op pbop_op ' in let pbop_pat = self # pattern pbop_pat pbop_pat ' in let pbop_exp = self # expression pbop_exp pbop_exp ' in let pbop_loc = self # location pbop_loc pbop_loc ' in self # record " binding_op " [ ( " pbop_op " , pbop_op ) ; ( " pbop_pat " , pbop_pat ) ; ( " pbop_exp " , pbop_exp ) ; ( " pbop_loc " , pbop_loc ) ] method value_description : value_description -> value_description -> ( ' res , string ) result = fun { pval_name ; pval_type ; pval_prim ; pval_attributes ; pval_loc } { pval_name = pval_name ' ; pval_type = pval_type ' ; pval_prim = pval_prim ' ; pval_attributes = pval_attributes ' ; pval_loc = pval_loc ' } -> let pval_name = self # loc self # string pval_name pval_name ' in let pval_type = self # core_type pval_type pval_type ' in let pval_prim = self # list self # string pval_prim pval_prim ' in let pval_attributes = self # attributes pval_attributes pval_attributes ' in let pval_loc = self # location pval_loc pval_loc ' in self # record " value_description " [ ( " pval_name " , pval_name ) ; ( " pval_type " , pval_type ) ; ( " pval_prim " , pval_prim ) ; ( " pval_attributes " , pval_attributes ) ; ( " pval_loc " , pval_loc ) ] method type_declaration : type_declaration -> type_declaration -> ( ' res , string ) result = fun { ptype_name ; ptype_params ; ptype_cstrs ; ptype_kind ; ptype_private ; ptype_manifest ; ptype_attributes ; ptype_loc } { ptype_name = ptype_name ' ; ptype_params = ptype_params ' ; ptype_cstrs = ptype_cstrs ' ; ptype_kind = ptype_kind ' ; ptype_private = ptype_private ' ; ptype_manifest = ptype_manifest ' ; ptype_attributes = ptype_attributes ' ; ptype_loc = ptype_loc ' } -> let ptype_name = self # loc self # string ptype_name ptype_name ' in let ptype_params = self # list ( fun ( a , b ) ( a ' , b ' ) -> let a = self # core_type a a ' in let b = ( fun ( a , b ) ( a ' , b ' ) -> let a = self # variance a a ' in let b = self # injectivity b b ' in self # tuple [ ( " variance " , a ) ; ( " injectivity " , b ) ] ) b in self # tuple [ ( " core_type " , a ) ; ( " ( variance * injectivity ) " , b b ' ) ] ) ptype_params ptype_params ' in let ptype_cstrs = self # list ( fun ( a , b , c ) ( a ' , b ' , c ' ) -> let a = self # core_type a a ' in let b = self # core_type b b ' in let c = self # location c c ' in self # tuple [ ( " core_type1 " , a ) ; ( " core_type2 " , b ) ; ( " location " , c ) ] ) ptype_cstrs ptype_cstrs ' in let ptype_kind = self # type_kind ptype_kind ptype_kind ' in let ptype_private = self # private_flag ptype_private ptype_private ' in let ptype_manifest = self # option self # core_type ptype_manifest ptype_manifest ' in let ptype_attributes = self # attributes ptype_attributes ptype_attributes ' in let ptype_loc = self # location ptype_loc ptype_loc ' in self # record " type_declaration " [ ( " ptype_name " , ptype_name ) ; ( " ptype_params " , ptype_params ) ; ( " ptype_cstrs " , ptype_cstrs ) ; ( " ptype_kind " , ptype_kind ) ; ( " ptype_private " , ptype_private ) ; ( " ptype_manifest " , ptype_manifest ) ; ( " ptype_attributes " , ptype_attributes ) ; ( " ptype_loc " , ptype_loc ) ] method type_kind : type_kind -> type_kind -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Ptype_abstract , Ptype_abstract -> self # constr " Ptype_abstract " [ ] | Ptype_variant a , Ptype_variant a ' -> let a = self # list self # constructor_declaration a a ' in self # constr " Ptype_variant " [ ( " constructor_declaration list " , a ) ] | Ptype_record a , Ptype_record a ' -> let a = self # list self # label_declaration a a ' in self # constr " Ptype_record " [ ( " label_declaration list " , a ) ] | Ptype_open , Ptype_open -> self # constr " Ptype_open " [ ] | _ -> Error " type_kind " method label_declaration : label_declaration -> label_declaration -> ( ' res , string ) result = fun { pld_name ; pld_mutable ; pld_type ; pld_loc ; pld_attributes } { pld_name = pld_name ' ; pld_mutable = pld_mutable ' ; pld_type = pld_type ' ; pld_loc = pld_loc ' ; pld_attributes = pld_attributes ' } -> let pld_name = self # loc self # string pld_name pld_name ' in let pld_mutable = self # mutable_flag pld_mutable pld_mutable ' in let pld_type = self # core_type pld_type pld_type ' in let pld_loc = self # location pld_loc pld_loc ' in let pld_attributes = self # attributes pld_attributes pld_attributes ' in self # record " label_declaration " [ ( " pld_name " , pld_name ) ; ( " pld_mutable " , pld_mutable ) ; ( " pld_type " , pld_type ) ; ( " pld_loc " , pld_loc ) ; ( " pld_attributes " , pld_attributes ) ] method constructor_declaration : constructor_declaration -> constructor_declaration -> ( ' res , string ) result = fun { pcd_name ; pcd_vars ; pcd_args ; pcd_res ; pcd_loc ; pcd_attributes } { pcd_name = pcd_name ' ; pcd_vars = pcd_vars ' ; pcd_args = pcd_args ' ; pcd_res = pcd_res ' ; pcd_loc = pcd_loc ' ; pcd_attributes = pcd_attributes ' } -> let pcd_name = self # loc self # string pcd_name pcd_name ' in let pcd_vars = self # type_vars pcd_vars pcd_vars ' in let pcd_args = self # constructor_arguments pcd_args pcd_args ' in let pcd_res = self # option self # core_type pcd_res pcd_res ' in let pcd_loc = self # location pcd_loc pcd_loc ' in let pcd_attributes = self # attributes pcd_attributes pcd_attributes ' in self # record " constructor_declaration " [ ( " pcd_name " , pcd_name ) ; ( " pcd_vars " , pcd_vars ) ; ( " pcd_args " , pcd_args ) ; ( " pcd_res " , pcd_res ) ; ( " pcd_loc " , pcd_loc ) ; ( " pcd_attributes " , pcd_attributes ) ] method constructor_arguments : constructor_arguments -> constructor_arguments -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Pcstr_tuple a , Pcstr_tuple a ' -> let a = self # list self # core_type a a ' in self # constr " Pcstr_tuple " [ ( " core_type list " , a ) ] | Pcstr_record a , Pcstr_record a ' -> let a = self # list self # label_declaration a a ' in self # constr " Pcstr_record " [ ( " label_declaration list " , a ) ] | _ -> Error " constructor_arguments " method type_extension : type_extension -> type_extension -> ( ' res , string ) result = fun { ptyext_path ; ptyext_params ; ptyext_constructors ; ptyext_private ; ptyext_loc ; ptyext_attributes } { ptyext_path = ptyext_path ' ; ptyext_params = ptyext_params ' ; ptyext_constructors = ptyext_constructors ' ; ptyext_private = ptyext_private ' ; ptyext_loc = ptyext_loc ' ; ptyext_attributes = ptyext_attributes ' } -> let ptyext_path = self # longident_loc ptyext_path ptyext_path ' in let ptyext_params = self # list ( fun ( a , b ) ( a ' , b ' ) -> let a = self # core_type a a ' in let b = ( fun ( a , b ) ( a ' , b ' ) -> let a = self # variance a a ' in let b = self # injectivity b b ' in self # tuple [ ( " variance " , a ) ; ( " injectivity " , b ) ] ) b in self # tuple [ ( " core_type " , a ) ; ( " ( variance * injectivity ) " , b b ' ) ] ) ptyext_params ptyext_params ' in let ptyext_constructors = self # list self # extension_constructor ptyext_constructors ptyext_constructors ' in let ptyext_private = self # private_flag ptyext_private ptyext_private ' in let ptyext_loc = self # location ptyext_loc ptyext_loc ' in let ptyext_attributes = self # attributes ptyext_attributes ptyext_attributes ' in self # record " type_extension " [ ( " ptyext_path " , ptyext_path ) ; ( " ptyext_params " , ptyext_params ) ; ( " ptyext_constructors " , ptyext_constructors ) ; ( " ptyext_private " , ptyext_private ) ; ( " ptyext_loc " , ptyext_loc ) ; ( " ptyext_attributes " , ptyext_attributes ) ] method extension_constructor : extension_constructor -> extension_constructor -> ( ' res , string ) result = fun { pext_name ; pext_kind ; pext_loc ; pext_attributes } { pext_name = pext_name ' ; pext_kind = pext_kind ' ; pext_loc = pext_loc ' ; pext_attributes = pext_attributes ' } -> let pext_name = self # loc self # string pext_name pext_name ' in let pext_kind = self # extension_constructor_kind pext_kind pext_kind ' in let pext_loc = self # location pext_loc pext_loc ' in let pext_attributes = self # attributes pext_attributes pext_attributes ' in self # record " extension_constructor " [ ( " pext_name " , pext_name ) ; ( " pext_kind " , pext_kind ) ; ( " pext_loc " , pext_loc ) ; ( " pext_attributes " , pext_attributes ) ] method type_exception : type_exception -> type_exception -> ( ' res , string ) result = fun { ptyexn_constructor ; ptyexn_loc ; ptyexn_attributes } { ptyexn_constructor = ptyexn_constructor ' ; ptyexn_loc = ptyexn_loc ' ; ptyexn_attributes = ptyexn_attributes ' } -> let ptyexn_constructor = self # extension_constructor ptyexn_constructor ptyexn_constructor ' in let ptyexn_loc = self # location ptyexn_loc ptyexn_loc ' in let ptyexn_attributes = self # attributes ptyexn_attributes ptyexn_attributes ' in self # record " type_exception " [ ( " ptyexn_constructor " , ptyexn_constructor ) ; ( " ptyexn_loc " , ptyexn_loc ) ; ( " ptyexn_attributes " , ptyexn_attributes ) ] method extension_constructor_kind : extension_constructor_kind -> extension_constructor_kind -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | ( Pext_decl ( existentials , c_args , t_opt ) , Pext_decl ( existentials ' , c_args ' , t_opt ' ) ) -> let existentials = self # existentials existentials existentials ' in let c_args = self # constructor_arguments c_args c_args ' in let t_opt = self # option self # core_type t_opt t_opt ' in self # constr " Pext_decl " [ ( " existentials " , existentials ) ; ( " constructor_arguments " , c_args ) ; ( " core_type option " , t_opt ) ] | Pext_rebind a , Pext_rebind a ' -> let a = self # longident_loc a a ' in self # constr " Pext_rebind " [ ( " longident_loc " , a ) ] | _ -> Error " extension_constructor_kind " method class_type : class_type -> class_type -> ( ' res , string ) result = fun { pcty_desc ; pcty_loc ; pcty_attributes } { pcty_desc = pcty_desc ' ; pcty_loc = pcty_loc ' ; pcty_attributes = pcty_attributes ' } -> let pcty_desc = self # class_type_desc pcty_desc pcty_desc ' in let pcty_loc = self # location pcty_loc pcty_loc ' in let pcty_attributes = self # attributes pcty_attributes pcty_attributes ' in self # record " class_type " [ ( " pcty_desc " , pcty_desc ) ; ( " pcty_loc " , pcty_loc ) ; ( " pcty_attributes " , pcty_attributes ) ] method class_type_desc : class_type_desc -> class_type_desc -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Pcty_constr ( a , b ) , Pcty_constr ( a ' , b ' ) -> let a = self # longident_loc a a ' in let b = self # list self # core_type b b ' in self # constr " Pcty_constr " [ ( " longident_loc " , a ) ; ( " core_type list " , b ) ] | Pcty_signature a , Pcty_signature a ' -> let a = self # class_signature a a ' in self # constr " Pcty_signature " [ ( " class_signature " , a ) ] | Pcty_arrow ( a , b , c ) , Pcty_arrow ( a ' , b ' , c ' ) -> let a = self # arg_label a a ' in let b = self # core_type b b ' in let c = self # class_type c c ' in self # constr " Pcty_arrow " [ ( " arg_label " , a ) ; ( " core_type " , b ) ; ( " class_type " , c ) ] | Pcty_extension a , Pcty_extension a ' -> let a = self # extension a a ' in self # constr " Pcty_extension " [ ( " extension " , a ) ] | Pcty_open ( a , b ) , Pcty_open ( a ' , b ' ) -> let a = self # open_description a a ' in let b = self # class_type b b ' in self # constr " Pcty_open " [ ( " open_description " , a ) ; ( " class_type " , b ) ] | _ -> Error " class_type_desc " method class_signature : class_signature -> class_signature -> ( ' res , string ) result = fun { pcsig_self ; pcsig_fields } { pcsig_self = pcsig_self ' ; pcsig_fields = pcsig_fields ' } -> let pcsig_self = self # core_type pcsig_self pcsig_self ' in let pcsig_fields = self # list self # class_type_field pcsig_fields pcsig_fields ' in self # record " class_signature " [ ( " pcsig_self " , pcsig_self ) ; ( " pcsig_fields " , pcsig_fields ) ] method class_type_field : class_type_field -> class_type_field -> ( ' res , string ) result = fun { pctf_desc ; pctf_loc ; pctf_attributes } { pctf_desc = pctf_desc ' ; pctf_loc = pctf_loc ' ; pctf_attributes = pctf_attributes ' } -> let pctf_desc = self # class_type_field_desc pctf_desc pctf_desc ' in let pctf_loc = self # location pctf_loc pctf_loc ' in let pctf_attributes = self # attributes pctf_attributes pctf_attributes ' in self # record " class_type_field " [ ( " pctf_desc " , pctf_desc ) ; ( " pctf_loc " , pctf_loc ) ; ( " pctf_attributes " , pctf_attributes ) ] method class_type_field_desc : class_type_field_desc -> class_type_field_desc -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Pctf_inherit a , Pctf_inherit a ' -> let a = self # class_type a a ' in self # constr " Pctf_inherit " [ ( " class_type " , a ) ] | Pctf_val a , Pctf_val a ' -> let a = ( fun ( a , b , c , d ) ( a ' , b ' , c ' , d ' ) -> let a = self # loc self # label a a ' in let b = self # mutable_flag b b ' in let c = self # virtual_flag c c ' in let d = self # core_type d d ' in self # tuple [ ( " label loc " , a ) ; ( " mutable_flag " , b ) ; ( " virtual_flag " , c ) ; ( " core_type " , d ) ] ) a in self # constr " Pctf_val " [ ( " ( label loc * mutable_flag * virtual_flag * core_type ) " , a a ' ) ] | Pctf_method a , Pctf_method a ' -> let a = ( fun ( a , b , c , d ) ( a ' , b ' , c ' , d ' ) -> let a = self # loc self # label a a ' in let b = self # private_flag b b ' in let c = self # virtual_flag c c ' in let d = self # core_type d d ' in self # tuple [ ( " label loc " , a ) ; ( " private_flag " , b ) ; ( " virtual_flag " , c ) ; ( " core_type " , d ) ] ) a in self # constr " Pctf_method " [ ( " ( label loc * private_flag * virtual_flag * core_type ) " , a a ' ) ] | Pctf_constraint a , Pctf_constraint a ' -> let a = ( fun ( a , b ) ( a ' , b ' ) -> let a = self # core_type a a ' in let b = self # core_type b b ' in self # tuple [ ( " core_type1 " , a ) ; ( " core_type2 " , b ) ] ) a in self # constr " Pctf_constraint " [ ( " ( core_type * core_type ) " , a a ' ) ] | Pctf_attribute a , Pctf_attribute a ' -> let a = self # attribute a a ' in self # constr " Pctf_attribute " [ ( " attribute " , a ) ] | Pctf_extension a , Pctf_extension a ' -> let a = self # extension a a ' in self # constr " Pctf_extension " [ ( " extension " , a ) ] | _ -> Error " class_type_field_desc " method class_infos : ' a . ( ' a -> ' a -> ( ' res , string ) result ) -> ' a class_infos -> ' a class_infos -> ( ' res , string ) result = fun _a { pci_virt ; pci_params ; pci_name ; pci_expr ; pci_loc ; pci_attributes } { pci_virt = pci_virt ' ; pci_params = pci_params ' ; pci_name = pci_name ' ; pci_expr = pci_expr ' ; pci_loc = pci_loc ' ; pci_attributes = pci_attributes ' } -> let pci_virt = self # virtual_flag pci_virt pci_virt ' in let pci_params = self # list ( fun ( a , b ) ( a ' , b ' ) -> let a = self # core_type a a ' in let b = ( fun ( a , b ) ( a ' , b ' ) -> let a = self # variance a a ' in let b = self # injectivity b b ' in self # tuple [ ( " variance " , a ) ; ( " injectivity " , b ) ] ) b in self # tuple [ ( " core_type " , a ) ; ( " ( variance * injectivity ) " , b b ' ) ] ) pci_params pci_params ' in let pci_name = self # loc self # string pci_name pci_name ' in let pci_expr = _a pci_expr pci_expr ' in let pci_loc = self # location pci_loc pci_loc ' in let pci_attributes = self # attributes pci_attributes pci_attributes ' in self # record " class_infos " [ ( " pci_virt " , pci_virt ) ; ( " pci_params " , pci_params ) ; ( " pci_name " , pci_name ) ; ( " pci_expr " , pci_expr ) ; ( " pci_loc " , pci_loc ) ; ( " pci_attributes " , pci_attributes ) ] method class_description : class_description -> class_description -> ( ' res , string ) result = self # class_infos self # class_type method class_type_declaration : class_type_declaration -> class_type_declaration -> ( ' res , string ) result = self # class_infos self # class_type method class_expr : class_expr -> class_expr -> ( ' res , string ) result = fun { pcl_desc ; pcl_loc ; pcl_attributes } { pcl_desc = pcl_desc ' ; pcl_loc = pcl_loc ' ; pcl_attributes = pcl_attributes ' } -> let pcl_desc = self # class_expr_desc pcl_desc pcl_desc ' in let pcl_loc = self # location pcl_loc pcl_loc ' in let pcl_attributes = self # attributes pcl_attributes pcl_attributes ' in self # record " class_expr " [ ( " pcl_desc " , pcl_desc ) ; ( " pcl_loc " , pcl_loc ) ; ( " pcl_attributes " , pcl_attributes ) ] method class_expr_desc : class_expr_desc -> class_expr_desc -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Pcl_constr ( a , b ) , Pcl_constr ( a ' , b ' ) -> let a = self # longident_loc a a ' in let b = self # list self # core_type b b ' in self # constr " Pcl_constr " [ ( " longident_loc " , a ) ; ( " core_type list " , b ) ] | Pcl_structure a , Pcl_structure a ' -> let a = self # class_structure a a ' in self # constr " Pcl_structure " [ ( " class_structure " , a ) ] | Pcl_fun ( a , b , c , d ) , Pcl_fun ( a ' , b ' , c ' , d ' ) -> let a = self # arg_label a a ' in let b = self # option self # expression b b ' in let c = self # pattern c c ' in let d = self # class_expr d d ' in self # constr " Pcl_fun " [ ( " arg_label " , a ) ; ( " expression option " , b ) ; ( " pattern " , c ) ; ( " class_expr " , d ) ] | Pcl_apply ( a , b ) , Pcl_apply ( a ' , b ' ) -> let a = self # class_expr a a ' in let b = self # list ( fun ( a , b ) ( a ' , b ' ) -> let a = self # arg_label a a ' in let b = self # expression b b ' in self # tuple [ ( " arg_label " , a ) ; ( " expression " , b ) ] ) b in self # constr " Pcl_apply " [ ( " class_expr " , a ) ; ( " ( arg_label * expression ) list " , b b ' ) ] | Pcl_let ( a , b , c ) , Pcl_let ( a ' , b ' , c ' ) -> let a = self # rec_flag a a ' in let b = self # list self # value_binding b b ' in let c = self # class_expr c c ' in self # constr " Pcl_let " [ ( " rec_flag " , a ) ; ( " value_binding list " , b ) ; ( " class_expr " , c ) ] | Pcl_constraint ( a , b ) , Pcl_constraint ( a ' , b ' ) -> let a = self # class_expr a a ' in let b = self # class_type b b ' in self # constr " Pcl_constraint " [ ( " class_expr " , a ) ; ( " class_type " , b ) ] | Pcl_extension a , Pcl_extension a ' -> let a = self # extension a a ' in self # constr " Pcl_extension " [ ( " extension " , a ) ] | Pcl_open ( a , b ) , Pcl_open ( a ' , b ' ) -> let a = self # open_description a a ' in let b = self # class_expr b b ' in self # constr " Pcl_open " [ ( " open_description " , a ) ; ( " class_expr " , b ) ] | _ -> Error " class_expr_desc " method class_structure : class_structure -> class_structure -> ( ' res , string ) result = fun { pcstr_self ; pcstr_fields } { pcstr_self = pcstr_self ' ; pcstr_fields = pcstr_fields ' } -> let pcstr_self = self # pattern pcstr_self pcstr_self ' in let pcstr_fields = self # list self # class_field pcstr_fields pcstr_fields ' in self # record " class_structure " [ ( " pcstr_self " , pcstr_self ) ; ( " pcstr_fields " , pcstr_fields ) ] method class_field : class_field -> class_field -> ( ' res , string ) result = fun { pcf_desc ; pcf_loc ; pcf_attributes } { pcf_desc = pcf_desc ' ; pcf_loc = pcf_loc ' ; pcf_attributes = pcf_attributes ' } -> let pcf_desc = self # class_field_desc pcf_desc pcf_desc ' in let pcf_loc = self # location pcf_loc pcf_loc ' in let pcf_attributes = self # attributes pcf_attributes pcf_attributes ' in self # record " class_field " [ ( " pcf_desc " , pcf_desc ) ; ( " pcf_loc " , pcf_loc ) ; ( " pcf_attributes " , pcf_attributes ) ] method class_field_desc : class_field_desc -> class_field_desc -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Pcf_inherit ( a , b , c ) , Pcf_inherit ( a ' , b ' , c ' ) -> let a = self # override_flag a a ' in let b = self # class_expr b b ' in let c = self # option ( self # loc self # string ) c c ' in self # constr " Pcf_inherit " [ ( " override_flag " , a ) ; ( " class_expr " , b ) ; ( " label loc option " , c ) ] | Pcf_val a , Pcf_val a ' -> let a = ( fun ( a , b , c ) ( a ' , b ' , c ' ) -> let a = self # loc self # label a a ' in let b = self # mutable_flag b b ' in let c = self # class_field_kind c c ' in self # tuple [ ( " label loc " , a ) ; ( " mutable_flag " , b ) ; ( " class_field_kind " , c ) ] ) a in self # constr " Pcf_val " [ ( " ( label loc * mutable_flag * class_field_kind ) " , a a ' ) ] | Pcf_method a , Pcf_method a ' -> let a = ( fun ( a , b , c ) ( a ' , b ' , c ' ) -> let a = self # loc self # label a a ' in let b = self # private_flag b b ' in let c = self # class_field_kind c c ' in self # tuple [ ( " label loc " , a ) ; ( " private_flag " , b ) ; ( " class_field_kind " , c ) ] ) a in self # constr " Pcf_method " [ ( " ( label loc * private_flag * class_field_kind ) " , a a ' ) ] | Pcf_constraint a , Pcf_constraint a ' -> let a = ( fun ( a , b ) ( a ' , b ' ) -> let a = self # core_type a a ' in let b = self # core_type b b ' in self # tuple [ ( " core_type1 " , a ) ; ( " core_type2 " , b ) ] ) a in self # constr " Pcf_constraint " [ ( " ( core_type * core_type ) " , a a ' ) ] | Pcf_initializer a , Pcf_initializer a ' -> let a = self # expression a a ' in self # constr " Pcf_initializer " [ ( " expression " , a ) ] | Pcf_attribute a , Pcf_attribute a ' -> let a = self # attribute a a ' in self # constr " Pcf_attribute " [ ( " attribute " , a ) ] | Pcf_extension a , Pcf_extension a ' -> let a = self # extension a a ' in self # constr " Pcf_extension " [ ( " extension " , a ) ] | _ -> Error " class_field_desc " method class_field_kind : class_field_kind -> class_field_kind -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Cfk_virtual a , Cfk_virtual a ' -> let a = self # core_type a a ' in self # constr " Cfk_virtual " [ ( " core_type " , a ) ] | Cfk_concrete ( a , b ) , Cfk_concrete ( a ' , b ' ) -> let a = self # override_flag a a ' in let b = self # expression b b ' in self # constr " Cfk_concrete " [ ( " override_flag " , a ) ; ( " expression " , b ) ] | _ -> Error " class_field_kind " method class_declaration : class_declaration -> class_declaration -> ( ' res , string ) result = self # class_infos self # class_expr method module_type : module_type -> module_type -> ( ' res , string ) result = fun { pmty_desc ; pmty_loc ; pmty_attributes } { pmty_desc = pmty_desc ' ; pmty_loc = pmty_loc ' ; pmty_attributes = pmty_attributes ' } -> let pmty_desc = self # module_type_desc pmty_desc pmty_desc ' in let pmty_loc = self # location pmty_loc pmty_loc ' in let pmty_attributes = self # attributes pmty_attributes pmty_attributes ' in self # record " module_type " [ ( " pmty_desc " , pmty_desc ) ; ( " pmty_loc " , pmty_loc ) ; ( " pmty_attributes " , pmty_attributes ) ] method module_type_desc : module_type_desc -> module_type_desc -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Pmty_ident a , Pmty_ident a ' -> let a = self # longident_loc a a ' in self # constr " Pmty_ident " [ ( " longident_loc " , a ) ] | Pmty_signature a , Pmty_signature a ' -> let a = self # signature a a ' in self # constr " Pmty_signature " [ ( " signature " , a ) ] | Pmty_functor ( a , b ) , Pmty_functor ( a ' , b ' ) -> let a = self # functor_parameter a a ' in let b = self # module_type b b ' in self # constr " Pmty_functor " [ ( " functor_parameter " , a ) ; ( " module_type " , b ) ] | Pmty_with ( a , b ) , Pmty_with ( a ' , b ' ) -> let a = self # module_type a a ' in let b = self # list self # with_constraint b b ' in self # constr " Pmty_with " [ ( " module_type " , a ) ; ( " with_constraint list " , b ) ] | Pmty_typeof a , Pmty_typeof a ' -> let a = self # module_expr a a ' in self # constr " Pmty_typeof " [ ( " module_expr " , a ) ] | Pmty_extension a , Pmty_extension a ' -> let a = self # extension a a ' in self # constr " Pmty_extension " [ ( " extension " , a ) ] | Pmty_alias a , Pmty_alias a ' -> let a = self # longident_loc a a ' in self # constr " Pmty_alias " [ ( " longident_loc " , a ) ] | _ -> Error " module_type_desc " method functor_parameter : functor_parameter -> functor_parameter -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Unit , Unit -> self # constr " Unit " [ ] | Named ( a , b ) , Named ( a ' , b ' ) -> let a = self # loc ( self # option self # string ) a in let b = self # module_type b b ' in self # constr " Named " [ ( " label option loc " , a a ' ) ; ( " module_type " , b ) ] | _ -> Error " functor_parameter " method signature : signature -> signature -> ( ' res , string ) result = self # list self # signature_item method signature_item : signature_item -> signature_item -> ( ' res , string ) result = fun { psig_desc ; psig_loc } { psig_desc = psig_desc ' ; psig_loc = psig_loc ' } -> let psig_desc = self # signature_item_desc psig_desc psig_desc ' in let psig_loc = self # location psig_loc psig_loc ' in self # record " signature_item " [ ( " psig_desc " , psig_desc ) ; ( " psig_loc " , psig_loc ) ] method signature_item_desc : signature_item_desc -> signature_item_desc -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Psig_value a , Psig_value a ' -> let a = self # value_description a a ' in self # constr " Psig_value " [ ( " value_description " , a ) ] | Psig_type ( a , b ) , Psig_type ( a ' , b ' ) -> let a = self # rec_flag a a ' in let b = self # list self # type_declaration b b ' in self # constr " Psig_type " [ ( " rec_flag " , a ) ; ( " type_declaration list " , b ) ] | Psig_typesubst a , Psig_typesubst a ' -> let a = self # list self # type_declaration a a ' in self # constr " Psig_typesubst " [ ( " type_declaration list " , a ) ] | Psig_typext a , Psig_typext a ' -> let a = self # type_extension a a ' in self # constr " Psig_typext " [ ( " type_extension " , a ) ] | Psig_exception a , Psig_exception a ' -> let a = self # type_exception a a ' in self # constr " Psig_exception " [ ( " type_exception " , a ) ] | Psig_module a , Psig_module a ' -> let a = self # module_declaration a a ' in self # constr " Psig_module " [ ( " module_declaration " , a ) ] | Psig_modsubst a , Psig_modsubst a ' -> let a = self # module_substitution a a ' in self # constr " Psig_modsubst " [ ( " module_substitution " , a ) ] | Psig_recmodule a , Psig_recmodule a ' -> let a = self # list self # module_declaration a a ' in self # constr " Psig_recmodule " [ ( " module_declaration list " , a ) ] | Psig_modtype a , Psig_modtype a ' -> let a = self # module_type_declaration a a ' in self # constr " Psig_modtype " [ ( " module_type_declaration " , a ) ] | Psig_open a , Psig_open a ' -> let a = self # open_description a a ' in self # constr " Psig_open " [ ( " open_description " , a ) ] | Psig_include a , Psig_include a ' -> let a = self # include_description a a ' in self # constr " Psig_include " [ ( " include_description " , a ) ] | Psig_class a , Psig_class a ' -> let a = self # list self # class_description a a ' in self # constr " Psig_class " [ ( " class_description list " , a ) ] | Psig_class_type a , Psig_class_type a ' -> let a = self # list self # class_type_declaration a a ' in self # constr " Psig_class_type " [ ( " class_type_declaration list " , a ) ] | Psig_attribute a , Psig_attribute a ' -> let a = self # attribute a a ' in self # constr " Psig_attribute " [ ( " attribute " , a ) ] | Psig_extension ( a , b ) , Psig_extension ( a ' , b ' ) -> let a = self # extension a a ' in let b = self # attributes b b ' in self # constr " Psig_extension " [ ( " extension " , a ) ; ( " attributes " , b ) ] | _ -> Error " signature_item_desc " method module_declaration : module_declaration -> module_declaration -> ( ' res , string ) result = fun { pmd_name ; pmd_type ; pmd_attributes ; pmd_loc } { pmd_name = pmd_name ' ; pmd_type = pmd_type ' ; pmd_attributes = pmd_attributes ' ; pmd_loc = pmd_loc ' } -> let pmd_name = self # loc ( self # option self # string ) pmd_name pmd_name ' in let pmd_type = self # module_type pmd_type pmd_type ' in let pmd_attributes = self # attributes pmd_attributes pmd_attributes ' in let pmd_loc = self # location pmd_loc pmd_loc ' in self # record " module_declaration " [ ( " pmd_name " , pmd_name ) ; ( " pmd_type " , pmd_type ) ; ( " pmd_attributes " , pmd_attributes ) ; ( " pmd_loc " , pmd_loc ) ] method module_substitution : module_substitution -> module_substitution -> ( ' res , string ) result = fun { pms_name ; pms_manifest ; pms_attributes ; pms_loc } { pms_name = pms_name ' ; pms_manifest = pms_manifest ' ; pms_attributes = pms_attributes ' ; pms_loc = pms_loc ' } -> let pms_name = self # loc self # string pms_name pms_name ' in let pms_manifest = self # longident_loc pms_manifest pms_manifest ' in let pms_attributes = self # attributes pms_attributes pms_attributes ' in let pms_loc = self # location pms_loc pms_loc ' in self # record " module_substitution " [ ( " pms_name " , pms_name ) ; ( " pms_manifest " , pms_manifest ) ; ( " pms_attributes " , pms_attributes ) ; ( " pms_loc " , pms_loc ) ] method module_type_declaration : module_type_declaration -> module_type_declaration -> ( ' res , string ) result = fun { pmtd_name ; pmtd_type ; pmtd_attributes ; pmtd_loc } { pmtd_name = pmtd_name ' ; pmtd_type = pmtd_type ' ; pmtd_attributes = pmtd_attributes ' ; pmtd_loc = pmtd_loc ' } -> let pmtd_name = self # loc self # string pmtd_name pmtd_name ' in let pmtd_type = self # option self # module_type pmtd_type pmtd_type ' in let pmtd_attributes = self # attributes pmtd_attributes pmtd_attributes ' in let pmtd_loc = self # location pmtd_loc pmtd_loc ' in self # record " module_type_declaration " [ ( " pmtd_name " , pmtd_name ) ; ( " pmtd_type " , pmtd_type ) ; ( " pmtd_attributes " , pmtd_attributes ) ; ( " pmtd_loc " , pmtd_loc ) ] method open_infos : ' a . ( ' a -> ' a -> ( ' res , string ) result ) -> ' a open_infos -> ' a open_infos -> ( ' res , string ) result = fun _a { popen_expr ; popen_override ; popen_loc ; popen_attributes } { popen_expr = popen_expr ' ; popen_override = popen_override ' ; popen_loc = popen_loc ' ; popen_attributes = popen_attributes ' } -> let popen_expr = _a popen_expr popen_expr ' in let popen_override = self # override_flag popen_override popen_override ' in let popen_loc = self # location popen_loc popen_loc ' in let popen_attributes = self # attributes popen_attributes popen_attributes ' in self # record " open_infos " [ ( " popen_expr " , popen_expr ) ; ( " popen_override " , popen_override ) ; ( " popen_loc " , popen_loc ) ; ( " popen_attributes " , popen_attributes ) ] method open_description : open_description -> open_description -> ( ' res , string ) result = self # open_infos self # longident_loc method open_declaration : open_declaration -> open_declaration -> ( ' res , string ) result = self # open_infos self # module_expr method include_infos : ' a . ( ' a -> ' a -> ( ' res , string ) result ) -> ' a include_infos -> ' a include_infos -> ( ' res , string ) result = fun _a { pincl_mod ; pincl_loc ; pincl_attributes } { pincl_mod = pincl_mod ' ; pincl_loc = pincl_loc ' ; pincl_attributes = pincl_attributes ' } -> let pincl_mod = _a pincl_mod pincl_mod ' in let pincl_loc = self # location pincl_loc pincl_loc ' in let pincl_attributes = self # attributes pincl_attributes pincl_attributes ' in self # record " include_infos " [ ( " pincl_mod " , pincl_mod ) ; ( " pincl_loc " , pincl_loc ) ; ( " pincl_attributes " , pincl_attributes ) ] method include_description : include_description -> include_description -> ( ' res , string ) result = self # include_infos self # module_type method include_declaration : include_declaration -> include_declaration -> ( ' res , string ) result = self # include_infos self # module_expr method with_constraint : with_constraint -> with_constraint -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Pwith_type ( a , b ) , Pwith_type ( a ' , b ' ) -> let a = self # longident_loc a a ' in let b = self # type_declaration b b ' in self # constr " Pwith_type " [ ( " longident_loc " , a ) ; ( " type_declaration " , b ) ] | Pwith_module ( a , b ) , Pwith_module ( a ' , b ' ) -> let a = self # longident_loc a a ' in let b = self # longident_loc b b ' in self # constr " Pwith_module " [ ( " longident_loc1 " , a ) ; ( " longident_loc2 " , b ) ] | Pwith_typesubst ( a , b ) , Pwith_typesubst ( a ' , b ' ) -> let a = self # longident_loc a a ' in let b = self # type_declaration b b ' in self # constr " Pwith_typesubst " [ ( " longident_loc " , a ) ; ( " type_declaration " , b ) ] | Pwith_modsubst ( a , b ) , Pwith_modsubst ( a ' , b ' ) -> let a = self # longident_loc a a ' in let b = self # longident_loc b b ' in self # constr " Pwith_modsubst " [ ( " longident_loc1 " , a ) ; ( " longident_loc2 " , b ) ] | _ -> Error " with_constraint " method module_expr : module_expr -> module_expr -> ( ' res , string ) result = fun { pmod_desc ; pmod_loc ; pmod_attributes } { pmod_desc = pmod_desc ' ; pmod_loc = pmod_loc ' ; pmod_attributes = pmod_attributes ' } -> let pmod_desc = self # module_expr_desc pmod_desc pmod_desc ' in let pmod_loc = self # location pmod_loc pmod_loc ' in let pmod_attributes = self # attributes pmod_attributes pmod_attributes ' in self # record " module_expr " [ ( " pmod_desc " , pmod_desc ) ; ( " pmod_loc " , pmod_loc ) ; ( " pmod_attributes " , pmod_attributes ) ] method module_expr_desc : module_expr_desc -> module_expr_desc -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Pmod_ident a , Pmod_ident a ' -> let a = self # longident_loc a a ' in self # constr " Pmod_ident " [ ( " longident_loc " , a ) ] | Pmod_structure a , Pmod_structure a ' -> let a = self # structure a a ' in self # constr " Pmod_structure " [ ( " structure " , a ) ] | Pmod_functor ( a , b ) , Pmod_functor ( a ' , b ' ) -> let a = self # functor_parameter a a ' in let b = self # module_expr b b ' in self # constr " Pmod_functor " [ ( " functor_parameter " , a ) ; ( " module_expr " , b ) ] | Pmod_apply ( a , b ) , Pmod_apply ( a ' , b ' ) -> let a = self # module_expr a a ' in let b = self # module_expr b b ' in self # constr " Pmod_apply " [ ( " module_expr1 " , a ) ; ( " module_expr2 " , b ) ] | Pmod_constraint ( a , b ) , Pmod_constraint ( a ' , b ' ) -> let a = self # module_expr a a ' in let b = self # module_type b b ' in self # constr " Pmod_constraint " [ ( " module_expr " , a ) ; ( " module_type " , b ) ] | Pmod_unpack a , Pmod_unpack a ' -> let a = self # expression a a ' in self # constr " Pmod_unpack " [ ( " expression " , a ) ] | Pmod_extension a , Pmod_extension a ' -> let a = self # extension a a ' in self # constr " Pmod_extension " [ ( " extension " , a ) ] | _ -> Error " module_expr_desc " method structure : structure -> structure -> ( ' res , string ) result = fun l l ' -> self # list self # structure_item l l ' method structure_item : structure_item -> structure_item -> ( ' res , string ) result = fun { pstr_desc ; pstr_loc } { pstr_desc = pstr_desc ' ; pstr_loc = pstr_loc ' } -> let pstr_desc = self # structure_item_desc pstr_desc pstr_desc ' in let pstr_loc = self # location pstr_loc pstr_loc ' in self # record " structure_item " [ ( " pstr_desc " , pstr_desc ) ; ( " pstr_loc " , pstr_loc ) ] method structure_item_desc : structure_item_desc -> structure_item_desc -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Pstr_eval ( a , b ) , Pstr_eval ( a ' , b ' ) -> let a = self # expression a a ' in let b = self # attributes b b ' in self # constr " Pstr_eval " [ ( " expression " , a ) ; ( " attributes " , b ) ] | Pstr_value ( a , b ) , Pstr_value ( a ' , b ' ) -> let a = self # rec_flag a a ' in let b = self # list self # value_binding b b ' in self # constr " Pstr_value " [ ( " rec_flag " , a ) ; ( " value_binding list " , b ) ] | Pstr_primitive a , Pstr_primitive a ' -> let a = self # value_description a a ' in self # constr " Pstr_primitive " [ ( " value_description " , a ) ] | Pstr_type ( a , b ) , Pstr_type ( a ' , b ' ) -> let a = self # rec_flag a a ' in let b = self # list self # type_declaration b b ' in self # constr " Pstr_type " [ ( " rec_flag " , a ) ; ( " type_declaration list " , b ) ] | Pstr_typext a , Pstr_typext a ' -> let a = self # type_extension a a ' in self # constr " Pstr_typext " [ ( " type_extension " , a ) ] | Pstr_exception a , Pstr_exception a ' -> let a = self # type_exception a a ' in self # constr " Pstr_exception " [ ( " type_exception " , a ) ] | Pstr_module a , Pstr_module a ' -> let a = self # module_binding a a ' in self # constr " Pstr_module " [ ( " module_binding " , a ) ] | Pstr_recmodule a , Pstr_recmodule a ' -> let a = self # list self # module_binding a a ' in self # constr " Pstr_recmodule " [ ( " module_binding list " , a ) ] | Pstr_modtype a , Pstr_modtype a ' -> let a = self # module_type_declaration a a ' in self # constr " Pstr_modtype " [ ( " module_type_declaration " , a ) ] | Pstr_open a , Pstr_open a ' -> let a = self # open_declaration a a ' in self # constr " Pstr_open " [ ( " open_declaration " , a ) ] | Pstr_class a , Pstr_class a ' -> let a = self # list self # class_declaration a a ' in self # constr " Pstr_class " [ ( " class_declaration list " , a ) ] | Pstr_class_type a , Pstr_class_type a ' -> let a = self # list self # class_type_declaration a a ' in self # constr " Pstr_class_type " [ ( " class_type_declaration list " , a ) ] | Pstr_include a , Pstr_include a ' -> let a = self # include_declaration a a ' in self # constr " Pstr_include " [ ( " include_declaration " , a ) ] | Pstr_attribute a , Pstr_attribute a ' -> let a = self # attribute a a ' in self # constr " Pstr_attribute " [ ( " attribute " , a ) ] | Pstr_extension ( a , b ) , Pstr_extension ( a ' , b ' ) -> let a = self # extension a a ' in let b = self # attributes b b ' in self # constr " Pstr_extension " [ ( " extension " , a ) ; ( " attributes " , b ) ] | _ -> Error " structure_item_desc " method value_binding : value_binding -> value_binding -> ( ' res , string ) result = fun { pvb_pat ; pvb_expr ; pvb_attributes ; pvb_loc } { pvb_pat = pvb_pat ' ; pvb_expr = pvb_expr ' ; pvb_attributes = pvb_attributes ' ; pvb_loc = pvb_loc ' } -> let pvb_pat = self # pattern pvb_pat pvb_pat ' in let pvb_expr = self # expression pvb_expr pvb_expr ' in let pvb_attributes = self # attributes pvb_attributes pvb_attributes ' in let pvb_loc = self # location pvb_loc pvb_loc ' in self # record " value_binding " [ ( " pvb_pat " , pvb_pat ) ; ( " pvb_expr " , pvb_expr ) ; ( " pvb_attributes " , pvb_attributes ) ; ( " pvb_loc " , pvb_loc ) ] method module_binding : module_binding -> module_binding -> ( ' res , string ) result = fun { pmb_name ; pmb_expr ; pmb_attributes ; pmb_loc } { pmb_name = pmb_name ' ; pmb_expr = pmb_expr ' ; pmb_attributes = pmb_attributes ' ; pmb_loc = pmb_loc ' } -> let pmb_name = self # loc ( self # option self # string ) pmb_name pmb_name ' in let pmb_expr = self # module_expr pmb_expr pmb_expr ' in let pmb_attributes = self # attributes pmb_attributes pmb_attributes ' in let pmb_loc = self # location pmb_loc pmb_loc ' in self # record " module_binding " [ ( " pmb_name " , pmb_name ) ; ( " pmb_expr " , pmb_expr ) ; ( " pmb_attributes " , pmb_attributes ) ; ( " pmb_loc " , pmb_loc ) ] method toplevel_phrase : toplevel_phrase -> toplevel_phrase -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Ptop_def a , Ptop_def a ' -> let a = self # structure a a ' in self # constr " Ptop_def " [ ( " structure " , a ) ] | Ptop_dir a , Ptop_dir a ' -> let a = self # toplevel_directive a a ' in self # constr " Ptop_dir " [ ( " toplevel_directive " , a ) ] | _ -> Error " toplevel_phrase " method toplevel_directive : toplevel_directive -> toplevel_directive -> ( ' res , string ) result = fun { pdir_name ; pdir_arg ; pdir_loc } { pdir_name = pdir_name ' ; pdir_arg = pdir_arg ' ; pdir_loc = pdir_loc ' } -> let pdir_name = self # loc self # string pdir_name pdir_name ' in let pdir_arg = self # option self # directive_argument pdir_arg pdir_arg ' in let pdir_loc = self # location pdir_loc pdir_loc ' in self # record " toplevel_directive " [ ( " pdir_name " , pdir_name ) ; ( " pdir_arg " , pdir_arg ) ; ( " pdir_loc " , pdir_loc ) ] method directive_argument : directive_argument -> directive_argument -> ( ' res , string ) result = fun { pdira_desc ; pdira_loc } { pdira_desc = pdira_desc ' ; pdira_loc = pdira_loc ' } -> let pdira_desc = self # directive_argument_desc pdira_desc pdira_desc ' in let pdira_loc = self # location pdira_loc pdira_loc ' in self # record " directive_argument " [ ( " pdira_desc " , pdira_desc ) ; ( " pdira_loc " , pdira_loc ) ] method directive_argument_desc : directive_argument_desc -> directive_argument_desc -> ( ' res , string ) result = fun x x ' -> match ( x , x ' ) with | Pdir_string a , Pdir_string a ' -> let a = self # string a a ' in self # constr " Pdir_string " [ ( " label " , a ) ] | Pdir_int ( a , b ) , Pdir_int ( a ' , b ' ) -> let a = self # string a a ' in let b = self # option self # char b b ' in self # constr " Pdir_int " [ ( " label " , a ) ; ( " char option " , b ) ] | Pdir_ident a , Pdir_ident a ' -> let a = self # longident a a ' in self # constr " Pdir_ident " [ ( " longident " , a ) ] | Pdir_bool a , Pdir_bool a ' -> let a = self # bool a a ' in self # constr " Pdir_bool " [ ( " bool " , a ) ] | _ -> Error " directive_argument_desc " method cases : cases -> cases -> ( ' res , string ) result = self # list self # case end |
let src = Logs . Src . create " git . traverse " ~ doc " : logs git ' s traverse event " |
module Log = ( val Logs . src_log src : Logs . LOG ) |
module type STORE = sig module Hash : S . HASH module Value : Value . S with type hash = Hash . t type t val root : t -> Fpath . t val read_exn : t -> Hash . t -> Value . t Lwt . t val is_shallowed : t -> Hash . t -> bool Lwt . t end |
module Make ( Store : STORE ) = struct let fold t ( f : ' acc -> ? name : Fpath . t -> length : int64 -> Store . Hash . t -> Store . Value . t -> ' acc Lwt . t ) ~ path acc hash = let names = Hashtbl . create 0x100 in let open Lwt . Infix in let rec walk close rest queue acc = match rest with | [ ] -> ( match Queue . pop queue with | rest -> walk close [ rest ] queue acc | exception Queue . Empty -> Lwt . return acc ) | hash :: rest -> ( if Store . Hash . Set . mem hash close then walk close rest queue acc else let close ' = Store . Hash . Set . add hash close in Store . read_exn t hash >>= function | Value . Commit commit as value -> ( let rest ' = Store . Value . Commit . tree commit :: rest in Store . is_shallowed t hash >>= function | true -> f acc ~ length ( : Store . Value . Commit . length commit ) hash value >>= fun acc ' -> walk close ' rest ' queue acc ' | false -> List . iter ( fun x -> Queue . add x queue ) ( Store . Value . Commit . parents commit ) ; f acc ~ length ( : Store . Value . Commit . length commit ) hash value >>= fun acc ' -> walk close ' rest ' queue acc ' ) | Value . Tree tree as value -> let path = try Hashtbl . find names hash with Not_found -> path in Lwt_list . iter_s ( fun { Tree . name ; node ; _ } -> Hashtbl . add names node Fpath . ( path / name ) ; Lwt . return ( ) ) ( Store . Value . Tree . to_list tree ) >>= fun ( ) -> let rest ' = rest @ List . map ( fun { Tree . node ; _ } -> node ) ( Store . Value . Tree . to_list tree ) in f acc ~ name : path ~ length ( : Store . Value . Tree . length tree ) hash value >>= fun acc ' -> walk close ' rest ' queue acc ' | Value . Blob blob as value -> let path = try Hashtbl . find names hash with Not_found -> path in f acc ~ name : path ~ length ( : Store . Value . Blob . length blob ) hash value >>= fun acc ' -> walk close ' rest queue acc ' | Value . Tag tag as value -> Queue . add ( Store . Value . Tag . obj tag ) queue ; f acc ~ length ( : Store . Value . Tag . length tag ) hash value >>= fun acc ' -> walk close ' rest queue acc ' ) in walk Store . Hash . Set . empty [ hash ] ( Queue . create ( ) ) acc let iter t f hash = fold t ( fun ( ) ? name : _ ~ length : _ hash value -> f hash value ) ~ path ( : Store . root t ) ( ) hash end |
type queue_elem = | Q_symbol of Symbol . t | Q_set_of_closures_id of Set_of_closures_id . t | Q_export_id of Export_id . t |
type symbols_to_export = { symbols : Symbol . Set . t ; export_ids : Export_id . Set . t ; set_of_closure_ids : Set_of_closures_id . Set . t ; set_of_closure_ids_keep_declaration : Set_of_closures_id . Set . t ; relevant_imported_closure_ids : Closure_id . Set . t ; relevant_local_closure_ids : Closure_id . Set . t ; relevant_imported_vars_within_closure : Var_within_closure . Set . t ; relevant_local_vars_within_closure : Var_within_closure . Set . t ; } |
let traverse ( ~ sets_of_closures_map : Flambda . set_of_closures Set_of_closures_id . Map . t ) ( ~ closure_id_to_set_of_closures_id : Set_of_closures_id . t Closure_id . Map . t ) ( ~ function_declarations_map : A . function_declarations Set_of_closures_id . Map . t ) ( ~ values : Export_info . descr Export_id . Map . t ) ( ~ symbol_id : Export_id . t Symbol . Map . t ) ( ~ root_symbol : Symbol . t ) = let relevant_set_of_closures_declaration_only = ref Set_of_closures_id . Set . empty in let relevant_symbols = ref ( Symbol . Set . singleton root_symbol ) in let relevant_set_of_closures = ref Set_of_closures_id . Set . empty in let relevant_export_ids = ref Export_id . Set . empty in let relevant_imported_closure_ids = ref Closure_id . Set . empty in let relevant_local_closure_ids = ref Closure_id . Set . empty in let relevant_imported_vars_within_closure = ref Var_within_closure . Set . empty in let relevant_local_vars_with_closure = ref Var_within_closure . Set . empty in let ( queue : queue_elem Queue . t ) = Queue . create ( ) in let conditionally_add_symbol symbol = if not ( Symbol . Set . mem symbol ! relevant_symbols ) then begin relevant_symbols := Symbol . Set . add symbol ! relevant_symbols ; Queue . add ( Q_symbol symbol ) queue end in let conditionally_add_set_of_closures_id set_of_closures_id = if not ( Set_of_closures_id . Set . mem set_of_closures_id ! relevant_set_of_closures ) then begin relevant_set_of_closures := Set_of_closures_id . Set . add set_of_closures_id ! relevant_set_of_closures ; Queue . add ( Q_set_of_closures_id set_of_closures_id ) queue end in let conditionally_add_export_id export_id = if not ( Export_id . Set . mem export_id ! relevant_export_ids ) then begin relevant_export_ids := Export_id . Set . add export_id ! relevant_export_ids ; Queue . add ( Q_export_id export_id ) queue end in let process_approx ( approx : Export_info . approx ) = match approx with | Value_id export_id -> conditionally_add_export_id export_id | Value_symbol symbol -> conditionally_add_symbol symbol | Value_unknown -> ( ) in let process_value_set_of_closures ( soc : Export_info . value_set_of_closures ) = conditionally_add_set_of_closures_id soc . set_of_closures_id ; Var_within_closure . Map . iter ( fun _ value -> process_approx value ) soc . bound_vars ; Closure_id . Map . iter ( fun _ value -> process_approx value ) soc . results ; begin match soc . aliased_symbol with | None -> ( ) | Some symbol -> conditionally_add_symbol symbol end in let process_function_body ( function_body : A . function_body ) = Flambda_iterators . iter ( fun ( term : Flambda . t ) -> match term with | Flambda . Apply { kind ; _ } -> begin match kind with | Indirect -> ( ) | Direct closure_id -> begin match Closure_id . Map . find closure_id closure_id_to_set_of_closures_id with | exception Not_found -> relevant_imported_closure_ids := Closure_id . Set . add closure_id ! relevant_imported_closure_ids | set_of_closures_id -> relevant_local_closure_ids := Closure_id . Set . add closure_id ! relevant_local_closure_ids ; conditionally_add_set_of_closures_id set_of_closures_id end end | _ -> ( ) ) ( fun ( named : Flambda . named ) -> let process_closure_id closure_id = match Closure_id . Map . find closure_id closure_id_to_set_of_closures_id with | exception Not_found -> relevant_imported_closure_ids := Closure_id . Set . add closure_id ! relevant_imported_closure_ids | set_of_closure_id -> relevant_local_closure_ids := Closure_id . Set . add closure_id ! relevant_local_closure_ids ; relevant_set_of_closures_declaration_only := Set_of_closures_id . Set . add set_of_closure_id ! relevant_set_of_closures_declaration_only in match named with | Symbol symbol | Read_symbol_field ( symbol , _ ) -> conditionally_add_symbol symbol | Set_of_closures soc -> conditionally_add_set_of_closures_id soc . function_decls . set_of_closures_id | Project_closure { closure_id ; _ } -> process_closure_id closure_id | Move_within_set_of_closures { start_from ; move_to ; _ } -> process_closure_id start_from ; process_closure_id move_to | Project_var { closure_id ; var ; _ } -> begin match Closure_id . Map . find closure_id closure_id_to_set_of_closures_id with | exception Not_found -> relevant_imported_closure_ids := Closure_id . Set . add closure_id ! relevant_imported_closure_ids ; relevant_imported_vars_within_closure := Var_within_closure . Set . add var ! relevant_imported_vars_within_closure | set_of_closure_id -> relevant_local_closure_ids := Closure_id . Set . add closure_id ! relevant_local_closure_ids ; relevant_local_vars_with_closure := Var_within_closure . Set . add var ! relevant_local_vars_with_closure ; relevant_set_of_closures_declaration_only := Set_of_closures_id . Set . add set_of_closure_id ! relevant_set_of_closures_declaration_only end | Prim _ | Expr _ | Const _ | Allocated_const _ | Read_mutable _ -> ( ) ) function_body . body in let rec loop ( ) = if Queue . is_empty queue then ( ) else begin begin match Queue . pop queue with | Q_export_id export_id -> begin match Export_id . Map . find export_id values with | exception Not_found -> ( ) | Value_block ( _ , approxes ) -> Array . iter process_approx approxes | Value_closure value_closure -> process_value_set_of_closures value_closure . set_of_closures | Value_set_of_closures soc -> process_value_set_of_closures soc | _ -> ( ) end | Q_symbol symbol -> let compilation_unit = Symbol . compilation_unit symbol in if Compilation_unit . is_current compilation_unit then begin match Symbol . Map . find symbol symbol_id with | exception Not_found -> Misc . fatal_errorf " cannot find symbol ' s export id % a \ n " Symbol . print symbol | export_id -> conditionally_add_export_id export_id end | Q_set_of_closures_id set_of_closures_id -> begin match Set_of_closures_id . Map . find set_of_closures_id function_declarations_map with | exception Not_found -> ( ) | function_declarations -> Variable . Map . iter ( fun ( _ : Variable . t ) ( fun_decl : A . function_declaration ) -> match fun_decl . function_body with | None -> ( ) | Some function_body -> process_function_body function_body ) function_declarations . funs end end ; loop ( ) end in Queue . add ( Q_symbol root_symbol ) queue ; loop ( ) ; Closure_id . Map . iter ( fun closure_id set_of_closure_id -> if Set_of_closures_id . Set . mem set_of_closure_id ! relevant_set_of_closures then begin relevant_local_closure_ids := Closure_id . Set . add closure_id ! relevant_local_closure_ids end ) closure_id_to_set_of_closures_id ; Set_of_closures_id . Set . iter ( fun set_of_closures_id -> match Set_of_closures_id . Map . find set_of_closures_id sets_of_closures_map with | exception Not_found -> ( ) | set_of_closures -> Variable . Map . iter ( fun var _ -> relevant_local_vars_with_closure := Var_within_closure . Set . add ( Var_within_closure . wrap var ) ! relevant_local_vars_with_closure ) set_of_closures . free_vars ) ! relevant_set_of_closures ; { symbols = ! relevant_symbols ; export_ids = ! relevant_export_ids ; set_of_closure_ids = ! relevant_set_of_closures ; set_of_closure_ids_keep_declaration = ! relevant_set_of_closures_declaration_only ; relevant_imported_closure_ids = ! relevant_imported_closure_ids ; relevant_local_closure_ids = ! relevant_local_closure_ids ; relevant_imported_vars_within_closure = ! relevant_imported_vars_within_closure ; relevant_local_vars_within_closure = ! relevant_local_vars_with_closure ; } |
let extra_remotes = list ( getenv_default " EXTRA_REMOTES " ) " " |
let pins = list ( getenv_default " PINS " ) " " |
let dir = getenv_default " SRC_DIR " " . " |
let add_remote = let layer = ref 0 in fun remote -> ?|~ " opam remote add extra % d % s " ! layer remote ; incr layer |
let pin pin = match pair pin with | ( pkg , None ) None -> . ?| " opam pin add % s -- dev - repo - n " pkg | ( pkg , Some url ) url -> . ?| " opam pin add % s % s - n " pkg url ; ; |
type ' a tree = Tree of ' a * ' a tree list |
let mkt x ts = Tree ( x , ts ) |
let rec map f ( Tree ( info , children ) ) = Tree ( f info , List . map ( map f ) children ) |
let string_of_tree t = let buf = Buffer . create 16 in let rec to_string indent = let child_to_string continue_indentation mark x = Buffer . add_char buf ' \ n ' ; Buffer . add_string buf indent ; Buffer . add_string buf mark ; to_string ( indent ^ continue_indentation ) x in let rec children_to_string = function | [ x ] -> child_to_string " " " └─ " x | x :: xs -> child_to_string " │ " " ├─ " x ; children_to_string xs | [ ] -> ( ) in function | Tree ( x , children ) -> Buffer . add_string buf x ; children_to_string children in to_string " " t ; Buffer . contents buf |
let asy_of_tree t = let buf = Buffer . create 256 in let rec go root k ( Tree ( x , ts ) ) = let name = if root = " " then " node " else root ^ " _ " ^ string_of_int k in Buffer . add_string buf ( Printf . sprintf " TreeNode % s = nodeGM ( % s " \% s " \% s ) ; \ n " name ( if root = " " then " " else root ^ " , " ) x " " ) ; ignore ( List . fold_left ( fun n t -> go name n t ; n + 1 ) 1 ts ) in go " " 0 t ; Printf . sprintf " import drawtree ; treeLevelStep = 30mm ; treeNodeStep = 2mm ; TreeNode nodeGM ( TreeNode parent = null , Label label , pen coul1 = 1bp + gray , pen coul2 = paleblue ) { frame f ; roundbox ( f , label , xmargin = 1 . 5mm , filltype = FillDraw ( fillpen = coul2 , drawpen = coul1 ) ) ; return makeNode ( parent , f ) ; } % s draw ( node , ( 0 , 0 ) ) ; " ( Buffer . contents buf ) |
let dot_of_tree name t = let buf = Buffer . create 256 in let rec go name ( Tree ( x , ts ) ) = Buffer . add_string buf ( Printf . sprintf " % s [ label " =\% s " ] ; \\ n " name x ) ; ignore ( List . fold_left ( fun n t -> let name ' = name ^ " _ " ^ string_of_int n in go name ' t ; Buffer . add_string buf ( Printf . sprintf " % s -> % s [ arrowhead = none ] ; \ n " name name ' ) ; n + 1 ) 1 ts ) in go " n " t ; Printf . sprintf " digraph % s { % s } " name ( Buffer . contents buf ) |
let str_replace c1 c2 str = try let i = String . index str c1 in let s = Bytes . of_string str in Bytes . set s i c2 ; Bytes . to_string s with Not_found -> str |
let box_node x = Box . frame ( Box . line ( str_replace ' ' : ' \ n ' x ) ) |
let rec box_of_tree = function | Tree ( x , [ ] ) -> box_node x | Tree ( x , ts ) -> Box . connect ( box_node x ) ( List . map box_of_tree ts ) |
module type ATOM = sig type t val t : t Irmin . Type . t val compare : t -> t -> int val to_string : t -> string val of_string : string -> t end |
module Make ( Atom : ATOM ) = struct type atom = Atom . t type node = { l : t ; v : atom ; r : t } and t = | N | B of node type dir = L | R type path = dir list let blank = N let rec insert t path x = match ( path , t ) with | ( [ ] , N ) -> B { l = N ; v = x ; r = N } | ( L :: path ' , B { l = lt ; v = y ; r = rt } ) -> let lt ' = insert lt path ' x in B { l = lt ' ; v = y ; r = rt } | ( R :: path ' , B { l = lt ; v = y ; r = rt } ) -> let rt ' = insert rt path ' x in B { l = lt ; v = y ; r = rt ' } | _ -> failwith " Unexpected path for insertion " let rec insert_left t x = match t with | N -> B { l = N ; v = x ; r = N } | B { l = t1 ; v = v ' ; r = t2 } -> insert_left t1 x let rec update t path x = match ( path , t ) with | ( [ ] , B { l = lt ; v = y ; r = rt } ) -> B { l = lt ; v = x ; r = rt } | ( L :: path ' , B { l = lt ; v = y ; r = rt } ) -> let lt ' = update lt path ' x in B { l = lt ' ; v = y ; r = rt } | ( R :: path ' , B { l = lt ; v = y ; r = rt } ) -> let rt ' = update rt path ' x in B { l = lt ; v = y ; r = rt ' } | _ -> failwith " Unexpected path for modification " let rec in_order_iter f = function | N -> ( ) | B { l = lt ; v = y ; r = rt } -> ( in_order_iter f lt ; f y ; in_order_iter f rt ) let rec of_array arr low high = if low > high then N else let mid = low + ( ( high - low + 1 ) / 2 ) in let lt = of_array arr low ( mid - 1 ) in let rt = of_array arr ( mid + 1 ) high in B { l = lt ; v = arr . ( mid ) ; r = rt } let of_list = function | [ ] -> N | l -> of_array ( Array . of_list l ) 0 @@ ( List . length l ) - 1 exception MergeConflict let rec merge3 old v1 v2 = if v1 = v2 then v1 else if v1 = old then v2 else if v2 = old then v1 else match ( old , v1 , v2 ) with | ( N , B _ , N ) -> v1 | ( N , N , B _ ) -> v2 | ( N , B { l = lt1 ; v = x1 ; r = rt1 } , B { l = lt2 ; v = x2 ; r = rt2 } ) -> if x1 = x2 then B { l = merge3 N lt1 lt2 ; v = x1 ; r = merge3 N rt1 rt2 } else raise MergeConflict | ( B { l = lt ; v = x ; r = rt } , B { l = lt1 ; v = x1 ; r = rt1 } , B { l = lt2 ; v = x2 ; r = rt2 } ) -> let lt ' ( ) = merge3 lt lt1 lt2 in let rt ' ( ) = merge3 rt rt1 rt2 in if ( x1 = x2 ) then B { l = lt ' ( ) ; v = x1 ; r = rt ' ( ) } else if ( x1 = x ) then B { l = lt ' ( ) ; v = x2 ; r = rt ' ( ) } else if ( x2 = x ) then B { l = lt ' ( ) ; v = x1 ; r = rt ' ( ) } else raise MergeConflict | ( B _ , N , _ ) | ( B _ , _ , N ) -> failwith " Impossible ; with tombstones , branch cannot be deleted . " | ( N , N , N ) -> N end |
let select_sandbox_item = let icon = ` LightDark Vscode . TreeItem . LightDarkIcon . { light = ` String ( Path . asset " collection - light . svg " |> Path . to_string ) ; dark = ` String ( Path . asset " collection - dark . svg " |> Path . to_string ) } in let label = ` TreeItemLabel ( Vscode . TreeItemLabel . create ~ label " : Select a Sandbox " ( ) ) in let item = Vscode . TreeItem . make_label ~ label ( ) in let command = Vscode . Command . create ~ title " : Select a Sandbox " ~ command " : ocaml . select - sandbox " ( ) in Vscode . TreeItem . set_iconPath item icon ; Vscode . TreeItem . set_command item command ; item |
let terminal_item = let icon = ` LightDark Vscode . TreeItem . LightDarkIcon . { light = ` String ( Path . asset " terminal - light . svg " |> Path . to_string ) ; dark = ` String ( Path . asset " terminal - dark . svg " |> Path . to_string ) } in let label = ` TreeItemLabel ( Vscode . TreeItemLabel . create ~ label " : Open a sandboxed terminal " ( ) ) in let item = Vscode . TreeItem . make_label ~ label ( ) in let command = Vscode . Command . create ~ title " : Open a sandboxed terminal " ~ command " : ocaml . open - terminal " ( ) in Vscode . TreeItem . set_iconPath item icon ; Vscode . TreeItem . set_command item command ; item |
let items = [ select_sandbox_item ; terminal_item ] |
let getTreeItem ~ element = ` Value element |
let getChildren ? element ( ) = match element with | None -> ` Value ( Some items ) | Some _ -> ` Value ( Some [ ] ) |
let register extension = let module TreeDataProvider = Vscode . TreeDataProvider . Make ( Vscode . TreeItem ) in let treeDataProvider = TreeDataProvider . create ~ getTreeItem ~ getChildren ( ) in let disposable = Vscode . Window . registerTreeDataProvider ( module Vscode . TreeItem ) ~ viewId " : ocaml - commands " ~ treeDataProvider in Vscode . ExtensionContext . subscribe extension ~ disposable |
let discord_item = let icon = ` LightDark Vscode . TreeItem . LightDarkIcon . { light = ` String ( Path . asset " discord - light . svg " |> Path . to_string ) ; dark = ` String ( Path . asset " discord - dark . svg " |> Path . to_string ) } in let label = ` TreeItemLabel ( Vscode . TreeItemLabel . create ~ label " : Chat on Discord " ( ) ) in let item = Vscode . TreeItem . make_label ~ label ( ) in let command = Vscode . Command . create ~ title " : Open " ~ command " : vscode . open " ~ arguments : [ Vscode . Uri . parse " https :// discord . gg / cCYQbqN " ( ) |> Vscode . Uri . t_to_js ] ( ) in Vscode . TreeItem . set_iconPath item icon ; Vscode . TreeItem . set_command item command ; item |
let discuss_item = let icon = ` LightDark Vscode . TreeItem . LightDarkIcon . { light = ` String ( Path . asset " chat - light . svg " |> Path . to_string ) ; dark = ` String ( Path . asset " chat - dark . svg " |> Path . to_string ) } in let label = ` TreeItemLabel ( Vscode . TreeItemLabel . create ~ label " : Ask a question on Discuss " ( ) ) in let item = Vscode . TreeItem . make_label ~ label ( ) in let command = Vscode . Command . create ~ title " : Open " ~ command " : vscode . open " ~ arguments : [ Vscode . Uri . parse " https :// discuss . ocaml . org " / ( ) |> Vscode . Uri . t_to_js ] ( ) in Vscode . TreeItem . set_iconPath item icon ; Vscode . TreeItem . set_command item command ; item |
let github_item = let icon = ` LightDark Vscode . TreeItem . LightDarkIcon . { light = ` String ( Path . asset " github - light . svg " |> Path . to_string ) ; dark = ` String ( Path . asset " github - dark . svg " |> Path . to_string ) } in let label = ` TreeItemLabel ( Vscode . TreeItemLabel . create ~ label " : Open an issue on Github " ( ) ) in let item = Vscode . TreeItem . make_label ~ label ( ) in let command = Vscode . Command . create ~ title " : Open " ~ command " : vscode . open " ~ arguments : [ Vscode . Uri . parse " https :// github . com / ocamllabs / vscode - ocaml - platform " ( ) |> Vscode . Uri . t_to_js ] ( ) in Vscode . TreeItem . set_iconPath item icon ; Vscode . TreeItem . set_command item command ; item |
let items = [ discord_item ; discuss_item ; github_item ] |
let getTreeItem ~ element = ` Value element |
let getChildren ? element ( ) = match element with | None -> ` Value ( Some items ) | Some _ -> ` Value ( Some [ ] ) |
let register extension = let module TreeDataProvider = Vscode . TreeDataProvider . Make ( Vscode . TreeItem ) in let treeDataProvider = TreeDataProvider . create ~ getTreeItem ~ getChildren ( ) in let disposable = Vscode . Window . registerTreeDataProvider ( module Vscode . TreeItem ) ~ viewId " : ocaml - help " ~ treeDataProvider in Vscode . ExtensionContext . subscribe extension ~ disposable |
module Dependency = struct type t = Sandbox . Package . t let t_of_js : Ojs . t -> t = Stdlib . Obj . magic let t_to_js : t -> Ojs . t = Stdlib . Obj . magic let label t = Sandbox . Package . name t let description t = Promise . return ( Some ( Sandbox . Package . version t ) ) let tooltip t = Sandbox . Package . synopsis t let context_value t = match Sandbox . Package . documentation t with | Some _ -> " package - with - doc " | None -> " package " let icon _ = TreeItem . LightDarkIcon . { light = ` String ( Path . asset " number - light . svg " |> Path . to_string ) ; dark = ` String ( Path . asset " number - dark . svg " |> Path . to_string ) } let collapsible_state t = if Sandbox . Package . has_dependencies t then TreeItemCollapsibleState . Collapsed else TreeItemCollapsibleState . None let to_treeitem dependency = let open Promise . Syntax in let icon = ` LightDark ( icon dependency ) in let collapsibleState = collapsible_state dependency in let label = ` TreeItemLabel ( Vscode . TreeItemLabel . create ~ label ( : label dependency ) ( ) ) in let item = Vscode . TreeItem . make_label ~ label ~ collapsibleState ( ) in Vscode . TreeItem . set_iconPath item icon ; TreeItem . set_contextValue item ( context_value dependency ) ; let + _ = Promise . Option . iter ( fun desc -> TreeItem . set_description item ( ` String desc ) ) ( description dependency ) in Option . iter ( tooltip dependency ) ~ f ( : fun desc -> TreeItem . set_tooltip item ( ` String desc ) ) ; item let get_dependencies t = let open Promise . Syntax in let + deps = Sandbox . Package . dependencies t in match deps with | Error _ -> None | Ok packages -> Some packages end |
module Command = struct let _open_documentation = let handler ( _ : Extension_instance . t ) ~ args = let ( _ : unit Promise . t ) = let arg = List . hd_exn args in let dep = Dependency . t_of_js arg in let open Promise . Syntax in let doc = Sandbox . Package . documentation dep in match doc with | None -> Promise . return ( ) | Some doc -> let + _ = Vscode . Commands . executeCommand ~ command " : vscode . open " ~ args [ : Vscode . Uri . parse doc ( ) |> Vscode . Uri . t_to_js ] in ( ) in ( ) in Extension_commands . register ~ id : Extension_consts . Commands . open_sandbox_documentation handler let _generate_documentation = let handler ( instance : Extension_instance . t ) ~ args = let ( _ : unit Promise . t ) = let open Promise . Syntax in let sandbox = Extension_instance . sandbox instance in let * odig = Odig . of_sandbox sandbox in match odig with | Error error -> show_message ` Error " % s " error ; Promise . resolve ( ) | Ok odig -> ( let arg = List . hd_exn args in let dep = Dependency . t_of_js arg in let package_name = Sandbox . Package . name dep in let options = ProgressOptions . create ~ location ( ` : ProgressLocation Notification ) ~ title : ( Printf . sprintf " Generating documentation for % s " package_name ) ~ cancellable : false ( ) in let task ~ progress : _ ~ token : _ = Odig . odoc_exec odig ~ sandbox ~ package_name in let * result = Vscode . Window . withProgress ( module Interop . Js . Result ( Interop . Js . Unit ) ( Interop . Js . String ) ) ~ options ~ task in match result with | Error _ -> show_message ` Error " Documentation could not be generated for % s . It might be \ because this package has no documentation . " package_name ; Promise . resolve ( ) | Ok _ -> ( let + server = let html_dir = Odig . html_dir odig in Extension_instance . start_documentation_server instance ~ path : html_dir in match server with | Error ( ) -> ( ) | Ok server -> let ( _ : Ojs . t option Promise . t ) = let port = Documentation_server . port server in let host = Documentation_server . host server in Vscode . Commands . executeCommand ~ command " : simpleBrowser . show " ~ args : [ Ojs . string_to_js ( Printf . sprintf " http ://% s :% i /% s / index . html " host port package_name ) ] in ( ) ) ) in ( ) in Extension_commands . register ~ id : Extension_consts . Commands . generate_sandbox_documentation handler let _uninstall = let handler ( instance : Extension_instance . t ) ~ args = let ( _ : unit Promise . t ) = let arg = List . hd_exn args in let dep = Dependency . t_of_js arg in let message = Printf . sprintf " Are you sure you want to uninstall package % s " ? ( Dependency . label dep ) in with_confirmation message ~ yes " : Uninstall package " @@ fun ( ) -> let open Promise . Syntax in let sandbox = Extension_instance . sandbox instance in Sandbox . focus_on_package_command ~ sandbox ( ) ; let + ( ) = Sandbox . uninstall_packages sandbox [ dep ] in let ( _ : Ojs . t option Promise . t ) = Vscode . Commands . executeCommand ~ command : Extension_consts . Commands . refresh_switches ~ args [ ] : in let ( _ : Ojs . t option Promise . t ) = Vscode . Commands . executeCommand ~ command : Extension_consts . Commands . refresh_sandbox ~ args [ ] : in ( ) in ( ) in Extension_commands . register ~ id : Extension_consts . Commands . uninstall_sandbox_package handler let _upgrade = let handler ( instance : Extension_instance . t ) ~ args : _ = let ( _ : unit Promise . t ) = let open Promise . Syntax in let sandbox = Extension_instance . sandbox instance in Sandbox . focus_on_package_command ~ sandbox ( ) ; let + ( ) = Sandbox . upgrade_packages sandbox in let ( _ : Ojs . t option Promise . t ) = Vscode . Commands . executeCommand ~ command : Extension_consts . Commands . refresh_switches ~ args [ ] : in let ( _ : Ojs . t option Promise . t ) = Vscode . Commands . executeCommand ~ command : Extension_consts . Commands . refresh_sandbox ~ args [ ] : in ( ) in ( ) in Extension_commands . register ~ id : Extension_consts . Commands . upgrade_sandbox handler let ask_packages ( ) = let options = InputBoxOptions . create ~ prompt " : Install Packages " ~ placeHolder " : Type the packages names , separated with a space " ( ) in Window . showInputBox ~ options ( ) let _install = let handler ( instance : Extension_instance . t ) ~ args : _ = let ( _ : unit Promise . t ) = let open Promise . Syntax in let * package_str_opt = ask_packages ( ) in match package_str_opt with | None -> Promise . return ( ) | Some package_str -> let sandbox = Extension_instance . sandbox instance in let packages = String . split package_str ~ on ' : ' in Sandbox . focus_on_package_command ~ sandbox ( ) ; let + ( ) = Sandbox . install_packages sandbox packages in let ( _ : Ojs . t option Promise . t ) = Vscode . Commands . executeCommand ~ command : Extension_consts . Commands . refresh_switches ~ args [ ] : in let ( _ : Ojs . t option Promise . t ) = Vscode . Commands . executeCommand ~ command : Extension_consts . Commands . refresh_sandbox ~ args [ ] : in ( ) in ( ) in Extension_commands . register ~ id : Extension_consts . Commands . install_sandbox handler end |
let getTreeItem ~ element = ` Promise ( Dependency . to_treeitem element ) |
let getChildren ~ instance ? element ( ) = let sandbox = Extension_instance . sandbox instance in match element with | Some element -> ` Promise ( Dependency . get_dependencies element ) | None -> let open Promise . Syntax in let items = let + packages = Sandbox . root_packages sandbox in match packages with | Ok packages -> Some packages | Error _ -> None in ` Promise items |
let register extension instance = let getChildren = getChildren ~ instance in let module EventEmitter = Vscode . EventEmitter . Make ( Interop . Js . Or_undefined ( Dependency ) ) in let event_emitter = EventEmitter . make ( ) in let event = EventEmitter . event event_emitter in let module TreeDataProvider = Vscode . TreeDataProvider . Make ( Dependency ) in let treeDataProvider = TreeDataProvider . create ~ getTreeItem ~ getChildren ~ onDidChangeTreeData : event ( ) in let disposable = Vscode . Window . registerTreeDataProvider ( module Dependency ) ~ viewId " : ocaml - sandbox " ~ treeDataProvider in ExtensionContext . subscribe extension ~ disposable ; let disposable = Commands . registerCommand ~ command : Extension_consts . Commands . refresh_sandbox ~ callback ( : fun ~ args : _ -> EventEmitter . fire event_emitter None ) in ExtensionContext . subscribe extension ~ disposable |
module Dependency = struct type t = | Package : Opam . Package . t -> t | Switch : Opam . t * Opam . Switch . t -> t let equals_opam_sandbox t sandbox = match ( t , sandbox ) with | Switch ( opam , switch ) , Sandbox . Opam ( opam_ , switch_ ) -> Opam . equal opam opam_ && Opam . Switch . equal switch switch_ | _ -> false let t_of_js : Ojs . t -> t = Stdlib . Obj . magic let t_to_js : t -> Ojs . t = Stdlib . Obj . magic let label = function | Switch ( _ , Named name ) -> name | Switch ( _ , Local path ) -> let name = Path . to_string path in name | Package dep -> Opam . Package . name dep let description = function | Switch ( opam , switch ) -> Opam . switch_compiler opam switch | Package dep -> Promise . return ( Some ( Opam . Package . version dep ) ) let tooltip = function | Switch ( _ , Named _ ) -> None | Switch ( _ , Local _ ) -> None | Package dep -> Opam . Package . synopsis dep let context_value = function | Switch _ -> " opam - switch " | Package dep -> ( match Opam . Package . documentation dep with | Some _ -> " package - with - doc " | None -> " package " ) let icon dependency is_current_sandbox = match dependency with | Switch _ -> let selected = if is_current_sandbox then " - selected " else " " in TreeItem . LightDarkIcon . { light = ` String ( Path . asset @@ " dependency - light " ^ selected ^ " . svg " |> Path . to_string ) ; dark = ` String ( Path . asset @@ " dependency - dark " ^ selected ^ " . svg " |> Path . to_string ) } | Package _ -> TreeItem . LightDarkIcon . { light = ` String ( Path . asset " number - light . svg " |> Path . to_string ) ; dark = ` String ( Path . asset " number - dark . svg " |> Path . to_string ) } let collapsible_state = let open Promise . Syntax in function | Switch ( opam , switch ) -> ( let + packages = Opam . switch_compiler opam switch in match packages with | None -> TreeItemCollapsibleState . None | Some ( _ : string ) -> Collapsed ) | Package dep -> Promise . return ( if Opam . Package . has_dependencies dep then TreeItemCollapsibleState . Collapsed else None ) let to_treeitem instance dependency = let open Promise . Syntax in let current_sandbox = Extension_instance . sandbox instance in let is_current_sandbox = equals_opam_sandbox dependency current_sandbox in let icon = ` LightDark ( icon dependency is_current_sandbox ) in let * collapsibleState = collapsible_state dependency in let label = ` TreeItemLabel ( Vscode . TreeItemLabel . create ~ label ( : label dependency ) ( ) ) in let item = Vscode . TreeItem . make_label ~ label ~ collapsibleState ( ) in Vscode . TreeItem . set_iconPath item icon ; TreeItem . set_contextValue item ( context_value dependency ) ; let + ( ) = Promise . Option . iter ( fun desc -> TreeItem . set_description item ( ` String desc ) ) ( description dependency ) in Option . iter ( tooltip dependency ) ~ f ( : fun desc -> TreeItem . set_tooltip item ( ` String desc ) ) ; item let get_dependencies = let open Promise . Syntax in function | Switch ( opam , switch ) -> ( let * packages = Opam . root_packages opam switch in match packages with | Ok packages -> let names = packages |> List . map ~ f ( : fun n -> Package n ) in Promise . return ( Some names ) | Error err -> show_message ` Info " An error occurred while reading the switch dependencies : % s " err ; Promise . return None ) | Package pkg -> ( let + deps = Opam . Package . dependencies pkg in match deps with | Ok packages -> Some ( List . map ~ f ( : fun x -> Package x ) packages ) | Error e -> log " An error occurred while getting package dependencies . Package % s . \ Error % s " ( Opam . Package . name pkg ) e ; None ) end |
module Command = struct let _remove_switch = let handler ( _ : Extension_instance . t ) ~ args = let ( _ : unit Promise . t ) = let arg = List . hd_exn args in let dep = Dependency . t_of_js arg in match dep with | Package _ -> Promise . return @@ show_message ` Warn " The selected item is not an opam switch . " | Switch ( opam , switch ) -> ( let message = Printf . sprintf " Are you sure you want to remove switch % s " ? ( Dependency . label dep ) in with_confirmation message ~ yes " : Remove switch " @@ fun ( ) -> let open Promise . Syntax in Sandbox . focus_on_package_command ( ) ; let + result = Opam . switch_remove opam switch |> Cmd . output in match result with | Error err -> show_message ` Error " % s " err | Ok _ -> let ( _ : Ojs . t option Promise . t ) = Vscode . Commands . executeCommand ~ command : Extension_consts . Commands . refresh_switches ~ args [ ] : in let ( _ : Ojs . t option Promise . t ) = Vscode . Commands . executeCommand ~ command : Extension_consts . Commands . refresh_sandbox ~ args [ ] : in show_message ` Info " The switch has been removed successfully . " ) in ( ) in Extension_commands . register ~ id : Extension_consts . Commands . remove_switch handler let _open_documentation = let handler ( _ : Extension_instance . t ) ~ args = let ( _ : unit Promise . t ) = let arg = List . hd_exn args in let dep = Dependency . t_of_js arg in match dep with | Switch _ -> Promise . return @@ show_message ` Warn " Cannot open documentation of a switch . " | Package pkg -> ( let open Promise . Syntax in let doc = Opam . Package . documentation pkg in match doc with | None -> Promise . return ( ) | Some doc -> let + ( _ : Ojs . t option ) = Vscode . Commands . executeCommand ~ command " : vscode . open " ~ args [ : Vscode . Uri . parse doc ( ) |> Vscode . Uri . t_to_js ] in ( ) ) in ( ) in Extension_commands . register ~ id : Extension_consts . Commands . open_switches_documentation handler end |
let getTreeItem instance ~ element = ` Promise ( Dependency . to_treeitem instance element ) |
let getChildren ? opam ? element ( ) = match ( opam , element ) with | None , _ -> ` Value None | Some _ , Some element -> ` Promise ( Dependency . get_dependencies element ) | Some opam , None -> let open Promise . Syntax in let items = let + switches = Opam . switch_list opam in let items = List . map ~ f ( : fun switch -> Dependency . Switch ( opam , switch ) ) switches in Some items in ` Promise items |
let register extension instance = let ( _ : unit Promise . t ) = let open Promise . Syntax in let + opam = Opam . make ( ) in let getChildren = getChildren ? opam in let getTreeItem = getTreeItem instance in let module EventEmitter = Vscode . EventEmitter . Make ( Interop . Js . Or_undefined ( Dependency ) ) in let event_emitter = EventEmitter . make ( ) in let event = EventEmitter . event event_emitter in let module TreeDataProvider = Vscode . TreeDataProvider . Make ( Dependency ) in let treeDataProvider = TreeDataProvider . create ~ getTreeItem ~ getChildren ~ onDidChangeTreeData : event ( ) in let disposable = Vscode . Window . registerTreeDataProvider ( module Dependency ) ~ viewId " : ocaml - switches " ~ treeDataProvider in ExtensionContext . subscribe extension ~ disposable ; let disposable = Commands . registerCommand ~ command : Extension_consts . Commands . refresh_switches ~ callback ( : fun ~ args : _ -> EventEmitter . fire event_emitter None ) in ExtensionContext . subscribe extension ~ disposable in ( ) |
module Filesys = struct let join_path path = if path = [ " " ] then " " / else String . concat " " / path let split_re = Str . regexp " " / let split_path s = Str . split split_re s let list path = let path_name = join_path path in let d = Unix . opendir path_name in let l = ref [ ] in try while true do l := e :: ! l done ; assert false with Unix . closedir d ; | err -> let is_directory path = let path_name = join_path path in try ( Unix . lstat path_name ) . Unix . st_kind = Unix . S_DIR with let is_container path = let path_name = join_path path in try ( Unix . stat path_name ) . Unix . st_kind = Unix . S_DIR with end ; ; |
module Filetree_dlg = struct open Lx_tree . Types ; ; open Tk ; ; open Widget ; ; type node = { path : string list ; } let some = function Some x -> x | None -> assert false let selected = ref [ ] let name_tv = lazy ( Textvariable . create ( ) ) let listbox = ref None let dir_label = ref None let ok_button = ref None let cb_enable_ok = ref ( fun _ -> true ) let update_ok_button ( ) = let dir = Filesys . join_path ! selected in let name = Textvariable . get ( Lazy . force name_tv ) in prerr_endline ( " Name : " ^ name ) ; let en = ! selected <> [ ] && name <> " " && Button . configure ~ state ( : if en then ` Normal else ` Disabled ) ( some ! ok_button ) let update_listbox d = let files = Filesys . list [ d ] in let reg_files = List . filter ( fun file -> not ( Filesys . is_container [ d ; file ] ) ) files in Listbox . delete ( some ! listbox ) ~ first ( ` : Num 0 ) ~ last ` : End ; Listbox . insert ( some ! listbox ) ~ index ` : End ~ texts : reg_files ; Label . configure ~ text ( : d ^ " " ) : ( some ! dir_label ) let node_action tw tree ev evinfo = selected := tree . node . path ; Lx_tree . update tw ; let dir = Filesys . join_path tree . node . path in update_listbox dir ; update_ok_button ( ) let display_node tw tree = let ( foreground , background ) = if tree . node . path = ! selected then else in Lx_tree . display_text ? foreground ? background ~ events [ : ` ButtonPress ] ~ action : node_action tree . node . name let rescan_node tw tree = let files = Filesys . list tree . node . path in let subnodes = List . map ) let dirs = List . filter let subtrees = List . map ) tree . children <- subtrees let rec make_tree_from_path ( ? loc = [ ] ) p = match p with | [ ] -> let open_dialog ( ? title = " Browse . . . " ) ( ? enable_ok = fun _ -> true ) parent = selected := [ ] ; Textvariable . set ( Lazy . force name_tv ) " " ; let top = Toplevel . create parent in Wm . transient_set top ~ master : parent ; Wm . title_set top title ; cb_enable_ok := enable_ok ; let l1 = Label . create ~ text " : Directories " : top in pack ~ anchor ` : W [ l1 ] ; let dir_tree = make_tree_from_path ( " " :: Filesys . split_path ( Sys . getcwd ( ) ) ) in dir_tree . node . name <- " < Root " ; > let tframe = Frame . create top in let tw = Lx_tree . create let sbar = Scrollbar . create ~ orient ` : Vertical tframe in let canvas = Lx_tree . canvas tw in Canvas . configure ~ yscrollcommand ( : Scrollbar . set sbar ) ~ relief ` : Sunken ~ borderwidth : 3 canvas ; Scrollbar . configure ~ command ( : Canvas . yview canvas ) sbar ; pack ~ side ` : Left ~ fill ` : Both ~ expand : true [ canvas ] ; pack ~ side ` : Left ~ fill ` : Y [ sbar ] ; pack ~ anchor ` : W ~ fill ` : X [ tframe ] ; let lab = Label . create ~ text ( " : " ) top in let lbf = Frame . create top in let lb = Listbox . create ~ height : 10 ~ font " : fixed " ~ exportselection : false let lbs = Scrollbar . create lbf in Listbox . configure ~ yscrollcommand ( : Scrollbar . set lbs ) lb ; Scrollbar . configure ~ command ( : Listbox . yview lb ) lbs ; pack ~ anchor ` : W [ lab ] ; pack ~ anchor ` : W ~ fill ` : X [ lbf ] ; pack ~ side ` : Left ~ expand : true ~ fill ` : X [ lb ] ; pack ~ side ` : Left ~ fill ` : Y [ lbs ] ; listbox := Some lb ; dir_label := Some lab ; let lab ' = Label . create ~ text " : Filename " : top in let ent = Entry . create ~ font " : fixed " pack ~ anchor ` : W [ lab ' ] ; pack ~ anchor ` : W ~ fill ` : X [ ent ] ; Tk . bind ~ events [ : ` ButtonReleaseDetail 1 ] ~ action ( : fun _ -> lb ; Tk . bind ~ events [ : ` KeyPress ] ~ action ( : fun _ -> ent ; let result = ref None in let buttons = Frame . create top in let ok_b = Button . create ~ text " : OK " let cancel_b = Button . create ~ text " : Cancel " pack ~ expand : true ~ fill ` : X [ buttons ] ; pack ~ side ` : Left [ ok_b ; cancel_b ] ; ok_button := Some ok_b ; Grab . set top ; Tkwait . window top ; ! result end ; ; |
module S = struct type t = string let compare = compare end ; ; |
module StringSet = Set . Make ( S ) ; ; |
type filetype = Regular | Directory | Absent ; ; |
type node = { path : string list ; name : string ; mutable is_dir : bool ; mutable selected : bool ; mutable realtype : filetype ; } ; ; |
type file_tree = node tree ; ; |
type state = { mutable current_directory : string ; mutable list_file : string ; mutable tree_widget : node tree_widget option ; mutable info_widget : label widget option ; mutable dir_context_menu : menu widget option ; mutable dir_context_suffix_menu : menu widget option ; mutable dir_context_unsuffix_menu : menu widget option ; mutable file_context_menu : menu widget option ; mutable context_menu_tree : node tree ; mutable modified : bool ; topwdg : toplevel widget ; workframe : frame widget ; directory_xpm : image ; selected_xpm : image ; unselected_xpm : image ; mutable display : node tree_widget -> file_tree -> node display_item ; } ; ; |
let dummy_tree = { node = { path = [ ] ; children = [ ] ; show = false ; scanned = false ; interactive = false ; } ; ; |
let rescan_node tw tree = let files = Filesys . list tree . node . path in let missing_files = List . map ( fun child -> child . node . name ) ( List . filter ) in let all_files = List . sort compare ( files @ missing_files ) in let old_children = tree . children in let new_children = List . map ( fun filename -> ) all_files in List . iter ( fun child -> child . node . realtype <- if List . mem child . node . name files then ) new_children ; tree . children <- new_children ; ; |
let rec selected_files_exist tree = tree . node . selected || selected_files_exist_in_children tree List . exists selected_files_exist tree . children ; ; |
let rec expand ( ? all = false ) tw tree = let show = tree . node . is_dir && ( all || selected_files_exist_in_children tree ) in tree . show <- tree . show || show ; if show then rescan_node tw tree ; List . iter ( fun child -> expand ~ all tw child ) tree . children ; ; |
let rec collapse tw tree = tree . show <- false ; List . iter ( fun child -> collapse tw child ) tree . children ; ; |
let suffix_re = Str . regexp " . [ . ] " ; ; \\^+$ |
let rec find_suffixes ( ? recursive = false ) tw tree = assert ( tree . node . is_dir ) ; rescan_node tw tree ; tree . show <- true ; let files = List . map ( fun ch -> ch . node . name ) tree . children in let suff = List . filter ( fun s -> ) ( List . map ) in let suff_set = ref ( StringSet . empty ) in List . iter ( fun s -> suff_set := StringSet . add s ! suff_set ) suff ; if recursive then begin List . iter ( fun child -> ) tree . children end ; ! suff_set ; ; |
let rec select_suffixes ( ? recursive = false ) ( ? unselect = false ) suffix tree = prerr_endline " select_suffixes " ; List . iter ( fun child -> let child_suff = in if child_suff = suffix && not ( child . node . is_dir ) then if recursive && child . node . is_dir then ) tree . children ; ; |
let rec select_all ( ? recursive = false ) ( ? unselect = false ) tree = prerr_endline " select_all " ; List . iter ( fun child -> if not ( child . node . is_dir ) then if recursive && child . node . is_dir then ) tree . children ; ; |
let set_suffix_menu ? unselect tw menu tree = Menu . delete menu ~ first ( ` : Num 0 ) ~ last ` : End ; let suffixes = find_suffixes tw tree in StringSet . iter ( fun s -> Menu . add_command ~ label : s ~ command ( : fun ( ) -> ) suffixes ; ; |
let node_action st tw tree ev evinfo = match ( ev : Lx_spots . supported_event ) with ` ButtonPress -> ) end | ` Enter -> end | ` Leave -> end | _ -> ( ) ; ; |
let display_node st = let node_action_st = node_action st in fun tw tree -> let node = tree . node in let image = if node . is_dir then st . directory_xpm else else in let foreground = match ( node . realtype , node . is_dir ) with in let events = [ ` ButtonPress ; ` Enter ; ` Leave ] in Lx_tree . display_text ~ image ~ events ~ action : node_action_st ? foreground node . name ; ; |
let neutral_frame wdg = Frame . create ~ highlightthickness : 0 ~ borderwidth : 0 wdg ; ; |
let save st = let rec write_file file path tree = let full_name = if path = " " then tree . node . name else in if not tree . node . is_dir && tree . node . selected then begin output_string file full_name ; output_string file " \ n " ; end ; List . iter ( fun child -> write_file file full_name child ) tree . children in match st . tree_widget with Some tw -> | None -> ( ) ; ; |
let q_save st = if st . modified then begin let choice = Dialog . create ~ parent : st . topwdg ~ title " : Save " ? ~ message " : The current tree is modified . Save it to disk " ? ~ buttons [ : " Yes " ; " No " ; " Cancel " ] ( ) in match choice with | 1 -> true | 2 -> false end else true ; ; |
let drop st = st . list_file <- " " ; st . modified <- false ; Frame . configure ~ width : 400 ~ height : 600 st . workframe ; List . iter destroy ( Winfo . children st . workframe ) ; st . tree_widget <- None ; ; |
let create_work_tree st top_node = let tree_frame = neutral_frame st . workframe in let info_frame = neutral_frame st . workframe in let sbar = Scrollbar . create ~ orient ` : Vertical tree_frame in let info_label = Label . create ~ highlightthickness : 0 ~ borderwidth : 0 ~ justify ` : Left ~ text " : " info_frame in pack ~ anchor ` : W ~ ipady : 4 ~ ipadx : 4 ~ side ` : Left [ info_label ] ; let width = Winfo . reqwidth st . workframe - Winfo . reqwidth sbar in let height = Winfo . reqheight st . workframe - Winfo . reqwidth info_label - 14 in let tw = Lx_tree . create let canvas = Lx_tree . canvas tw in Canvas . configure ~ yscrollcommand ( : Scrollbar . set sbar ) canvas ; Scrollbar . configure ~ command ( : Canvas . yview canvas ) sbar ; Canvas . configure ~ highlightthickness : 0 canvas ; pack ~ side ` : Left ~ fill ` : Both ~ expand : true [ canvas ] ; pack ~ side ` : Left ~ fill ` : Y [ sbar ] ; pack ~ anchor ` : W [ tree_frame ; info_frame ] ; st . tree_widget <- Some tw ; st . info_widget <- Some info_label ; let dcm = Menu . create ~ tearoff : false st . workframe in let dcm_suffix = Menu . create ~ tearoff : false dcm in let dcm_unsuffix = Menu . create ~ tearoff : false dcm in Menu . add_cascade ~ label " : Select by suffix " ~ menu : dcm_suffix dcm ; Menu . add_cascade ~ label " : Unselect by suffix " ~ menu : dcm_unsuffix dcm ; Menu . add_command ~ label " : Select all files " ~ command ( : fun ( ) -> dcm ; Menu . add_command ~ label " : Unselect all files " ~ command ( : fun ( ) -> dcm ; Menu . add_separator dcm ; Menu . add_command ~ label " : Rescan directory " ~ command ( : fun ( ) -> Menu . add_separator dcm ; Menu . add_command ~ label " : Expand all " ~ command ( : fun ( ) -> Menu . add_command ~ label " : Expand as needed " ~ command ( : fun ( ) -> Menu . add_command ~ label " : Collapse " ~ command ( : fun ( ) -> st . dir_context_menu <- Some dcm ; st . dir_context_suffix_menu <- Some dcm_suffix ; st . dir_context_unsuffix_menu <- Some dcm_unsuffix ; ; ; |
let file_new st ( ) = let enable_ok filename = not ( Sys . file_exists filename ) in if q_save st then begin match Filetree_dlg . open_dialog ~ title " : New tree " ~ enable_ok st . topwdg with | None -> end ; ; |
let strip_ws_re = Str . regexp " [ ^ \ r \ n \ t ] ( . ) [ *\\*\\ \ r \ n \ t ] " ; ; *$ |
let strip_ws s = if Str . string_match strip_ws_re s 0 then Str . matched_group 1 s else assert false ; ; |
let file_open st ( ) = let rec enter_path path node = match path with | [ ] -> in let rec read_file file initial_node = let line = strip_ws ( input_line file ) in if line = " " then read_file file initial_node else begin let path = Filesys . split_path line in enter_path path initial_node ; read_file file initial_node end in let enable_ok filename = Sys . file_exists filename in if q_save st then begin match Filetree_dlg . open_dialog ~ title " : Open tree " ~ enable_ok st . topwdg with | None -> end ; ; |
let file_save st ( ) = save st ; ignore ( Dialog . create ~ parent : st . topwdg ~ title " : Saved " ~ message " : Tree saved . " ; ; |
let file_quit st ( ) = if q_save st then destroy st . topwdg ; ; |
let view_expand ? all st ( ) = match st . tree_widget with Some tw -> | None -> ( ) ; ; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.