text
stringlengths 12
786k
|
---|
let ( ) = Location . register_error_of_exn ( function | Error ( loc , err ) -> Some ( Location . error_of_printer ~ loc report_error err ) | _ -> None )
|
let string s = Lconst ( Const_base ( Const_string ( s , None ) ) )
|
let int i = Lconst ( Const_base ( Const_int i ) )
|
let marshal_loc ( x : Location . t ) = let s = Marshal . to_string x [ ] in string s
|
let true_ = Lconst ( Const_pointer 1 )
|
let false_ = Lconst ( Const_pointer 0 )
|
let quote_bool b = if b then true_ else false_
|
let none = Lconst ( Const_pointer 0 )
|
let some x = Lprim ( Pmakeblock ( 0 , Immutable , None ) , [ x ] , Location . none )
|
let option opt = match opt with | None -> none | Some x -> some x
|
let nil = Lconst ( Const_pointer 0 )
|
let cons hd tl = Lprim ( Pmakeblock ( 0 , Immutable , None ) , [ hd ; tl ] , Location . none )
|
let rec list l = match l with | [ ] -> nil | hd :: tl -> cons hd ( list tl )
|
let pair ( x , y ) = Lprim ( Pmakeblock ( 0 , Immutable , None ) , [ x ; y ] , Location . none )
|
module Lam = struct let stdmod_path = Ident . lift_string " CamlinternalQuote " let lambda_mod = " Lambda " let camlinternalQuote = lazy ( match Env . open_pers_signature stdmod_path Env . initial_safe_string with | exception Not_found -> fatal_error @@ " Module " ^ stdmod_path ^ " unavailable . " | env -> env ) let static_pos = function | Path . Uniphase ( Static , i ) -> i | Path . Biphase ( i , _ ) -> i | _ -> fatal_error ( stdmod_path ^ " primitive at unexpected position . " ) let combinator modname field = lazy ( let env = Lazy . force camlinternalQuote in let lid = Longident . Ldot ( Longident . Ldot ( Longident . Lident lambda_mod , modname ) , field ) in match Env . lookup_value lid env with | ( Path . Pdot ( Path . Pdot ( Path . Pdot ( Path . Pident ident , _ , pos1 ) , _ , pos2 ) , _ , pos3 ) , _ ) -> Lprim ( Pfield ( static_pos pos3 ) , [ Lprim ( Pfield ( static_pos pos2 ) , [ Lprim ( Pfield ( static_pos pos1 ) , [ Lprim ( Pgetglobal ident , [ ] , Location . none ) ] , Location . none ) ] , Location . none ) ] , Location . none ) | _ -> fatal_error @@ " Primitive " ^ stdmod_path ^ " . " ^ lambda_mod ^ " . " ^ modname ^ " . " ^ field ^ " not found . " | exception Not_found -> fatal_error @@ " Primitive " ^ stdmod_path ^ " . " ^ lambda_mod ^ " . " ^ modname ^ " . " ^ field " ^ not found . " ) let apply comb args = let comb = Lazy . force comb in Lapply { ap_func = comb ; ap_args = args ; ap_loc = Location . none ; ap_should_be_tailcall = false ; ap_inlined = Default_inline ; ap_specialised = Default_specialise ; } module Loc = struct let unmarshal = combinator " Loc " " unmarshal " end module Constant = struct let unmarshal = combinator " Constant " " unmarshal " end module Identifier = struct let unmarshal = combinator " Identifier " " unmarshal " end module Attribute = struct let unmarshal_inline_attr = combinator " Attribute " " unmarshal_inline_attr " let unmarshal_specialise_attr = combinator " Attribute " " unmarshal_specialise_attr " let unmarshal_function_kind = combinator " Attribute " " unmarshal_function_kind " let unmarshal_function_attr = combinator " Attribute " " unmarshal_function_attr " let unmarshal_let_kind = combinator " Attribute " " unmarshal_let_kind " let unmarshal_value_kind = combinator " Attribute " " unmarshal_value_kind " let unmarshal_direction_flag = combinator " Attribute " " unmarshal_direction_flag " let unmarshal_method_kind = combinator " Attribute " " unmarshal_method_kind " end module Exp = struct let var = combinator " Exp " " var " let constant = combinator " Exp " " constant " let application = combinator " Exp " " application " let function_ = combinator " Exp " " function_ " let let_ = combinator " Exp " " let_ " let letrec = combinator " Exp " " letrec " let primitive = combinator " Exp " " primitive " let switch = combinator " Exp " " switch " let stringswitch = combinator " Exp " " stringswitch " let staticraise = combinator " Exp " " staticraise " let staticcatch = combinator " Exp " " staticcatch " let trywith = combinator " Exp " " trywith " let ifthenelse = combinator " Exp " " ifthenelse " let sequence = combinator " Exp " " sequence " let while_ = combinator " Exp " " while_ " let for_ = combinator " Exp " " for_ " let assign = combinator " Exp " " assign " let send = combinator " Exp " " send " end module Primitive = struct let unmarshal = combinator " Primitive " " unmarshal " end let marshal_constant ( x : Lambda . structured_constant ) = let s = Marshal . to_string x [ ] in string s let quote_loc ( x : Location . t ) = let s = marshal_loc x in apply Loc . unmarshal [ s ] let quote_constant ( x : Lambda . structured_constant ) = let s = marshal_constant x in apply Constant . unmarshal [ s ] let quote_ident ( id : Ident . t ) = let s = string ( Marshal . to_string id [ ] ) in apply Identifier . unmarshal [ s ] let quote_inline_attr ( attr : inline_attribute ) = let s = Marshal . to_string attr [ ] in apply Attribute . unmarshal_inline_attr [ string s ] let quote_specialise_attr ( attr : specialise_attribute ) = let s = Marshal . to_string attr [ ] in apply Attribute . unmarshal_specialise_attr [ string s ] let quote_fn_kind ( k : function_kind ) = let s = Marshal . to_string k [ ] in apply Attribute . unmarshal_function_kind [ string s ] let quote_fn_attr ( attr : function_attribute ) = let s = Marshal . to_string attr [ ] in apply Attribute . unmarshal_function_attr [ string s ] let quote_let_kind ( k : let_kind ) = let s = Marshal . to_string k [ ] in apply Attribute . unmarshal_let_kind [ string s ] let quote_value_kind ( k : value_kind ) = let s = Marshal . to_string k [ ] in apply Attribute . unmarshal_value_kind [ string s ] let quote_prim ( p : primitive ) = let s = Marshal . to_string p [ ] in apply Primitive . unmarshal [ string s ] let quote_direction_flag ( f : direction_flag ) = let s = Marshal . to_string f [ ] in apply Attribute . unmarshal_direction_flag [ string s ] let quote_method_kind ( k : meth_kind ) = let s = Marshal . to_string k [ ] in apply Attribute . unmarshal_method_kind [ string s ] let rec lift_lambda = function | Lvar id -> apply Exp . var [ quote_ident id ] | Lconst cst -> apply Exp . constant [ quote_constant cst ] | Lapply { ap_func ; ap_args ; ap_loc ; ap_should_be_tailcall ; ap_inlined ; ap_specialised ; } -> apply Exp . application [ quote_loc ap_loc ; lift_lambda ap_func ; list ( List . map lift_lambda ap_args ) ; quote_bool ap_should_be_tailcall ; quote_inline_attr ap_inlined ; quote_specialise_attr ap_specialised ; ] | Lfunction { kind ; params ; body ; attr ; loc ; } -> apply Exp . function_ [ quote_loc loc ; quote_fn_kind kind ; list ( List . map quote_ident params ) ; lift_lambda body ; quote_fn_attr attr ; ] | Llet ( lkind , vkind , id , v , body ) -> apply Exp . let_ [ quote_let_kind lkind ; quote_value_kind vkind ; quote_ident id ; lift_lambda v ; lift_lambda body ; ] | Lletrec ( vbs , body ) -> apply Exp . letrec [ list ( List . map quote_vb vbs ) ; lift_lambda body ; ] | Lprim ( prim , args , loc ) -> apply Exp . primitive [ quote_loc loc ; quote_prim prim ; list ( List . map lift_lambda args ) ; ] | Lswitch ( lam , { sw_numconsts ; sw_consts ; sw_numblocks ; sw_blocks ; sw_failaction ; } ) -> apply Exp . switch [ lift_lambda lam ; int sw_numconsts ; list ( List . map ( fun ( i , l ) -> pair ( int i , lift_lambda l ) ) sw_consts ) ; int sw_numblocks ; list ( List . map ( fun ( i , l ) -> pair ( int i , lift_lambda l ) ) sw_blocks ) ; option ( Misc . may_map lift_lambda sw_failaction ) ; ] | Lstringswitch ( lam , cases , lam_opt , loc ) -> apply Exp . stringswitch [ quote_loc loc ; lift_lambda lam ; list ( List . map ( fun ( str , lam ) -> pair ( string str , lift_lambda lam ) ) cases ) ; option ( Misc . may_map lift_lambda lam_opt ) ; ] | Lstaticraise ( i , lams ) -> apply Exp . staticraise [ int i ; list ( List . map lift_lambda lams ) ; ] | Lstaticcatch ( lam , ( i , ids ) , body ) -> apply Exp . staticcatch [ lift_lambda lam ; pair ( int i , list ( List . map quote_ident ids ) ) ; lift_lambda body ; ] | Ltrywith ( lam , id , body ) -> apply Exp . trywith [ lift_lambda lam ; quote_ident id ; lift_lambda body ; ] | Lifthenelse ( cond , ift , iff ) -> apply Exp . ifthenelse [ lift_lambda cond ; lift_lambda ift ; lift_lambda iff ; ] | Lsequence ( l , l ' ) -> apply Exp . sequence [ lift_lambda l ; lift_lambda l ' ; ] | Lwhile ( cond , body ) -> apply Exp . while_ [ lift_lambda cond ; lift_lambda body ; ] | Lfor ( id , init , final , direction , body ) -> apply Exp . for_ [ quote_ident id ; lift_lambda init ; lift_lambda final ; quote_direction_flag direction ; lift_lambda body ; ] | Lassign ( id , lam ) -> apply Exp . assign [ quote_ident id ; lift_lambda lam ; ] | Lsend ( meth_kind , obj , meth , args , loc ) -> apply Exp . send [ quote_method_kind meth_kind ; lift_lambda obj ; lift_lambda meth ; list ( List . map lift_lambda args ) ; quote_loc loc ] | Levent ( e , _ ) -> lift_lambda e | Lifused ( _ , e ) -> lift_lambda e | Lescape lam -> lam and quote_vb ( id , lam ) = let id = quote_ident id in let lam = lift_lambda lam in pair ( id , lam ) let transl_clos_field loc path_id _name idx = apply Exp . primitive [ quote_loc loc ; quote_prim ( Pfield idx ) ; list [ Lvar path_id ] ; ] let quote_expression transl _pclos e = let lam = transl e in lift_lambda lam let path_arg _loc path = lift_lambda path end _ , pos1 ) , _ , pos2 ) , _ , pos3 ) , _ ) -> Lprim ( Pfield ( static_pos pos3 ) , [ Lprim ( Pfield ( static_pos pos2 ) , [ Lprim ( Pfield ( static_pos pos1 ) , [ Lprim ( Pgetglobal ident , [ ] , Location . none ) ] , Location . none ) ] , Location . none ) ] , Location . none ) | _ -> fatal_error @@ " Primitive " ^ stdmod_path ^ " . " ^ parsetree_mod ^ " . " ^ modname ^ " . " ^ field ^ " not found . " | exception Not_found -> fatal_error @@ " Primitive " ^ stdmod_path ^ " . " ^ parsetree_mod ^ " . " ^ modname ^ " . " ^ field " ^ not found . " ) let apply loc comb args = let comb = Lazy . force comb in Lapply { ap_func = comb ; ap_args = args ; ap_loc = loc ; ap_should_be_tailcall = false ; ap_inlined = Default_inline ; ap_specialised = Default_specialise ; } module Loc = struct let none = combinator " Loc " " none " let unmarshal = combinator " Loc " " unmarshal " end module Name = struct let unmarshal = combinator " Name " " unmarshal " end end ) * module Constant = struct let unmarshal = combinator " Constant " " unmarshal " end module Identifier = struct let unmarshal = combinator " Ident " " unmarshal " let lfrommacro = combinator " Ident " " lfrommacro " end module ArgLabel = struct let unmarshal = combinator " ArgLabel " " unmarshal " end module Variant = struct let of_string = combinator " Variant " " of_string " end module Method = struct let of_string = combinator " Method " " of_string " end module Pat = struct let any = combinator " Pat " " any " let var = combinator " Pat " " var " let alias = combinator " Pat " " alias " let constant = combinator " Pat " " constant " let tuple = combinator " Pat " " tuple " let construct = combinator " Pat " " construct " let variant = combinator " Pat " " variant " let record = combinator " Pat " " record " let array = combinator " Pat " " array " let or_ = combinator " Pat " " or_ " let lazy_ = combinator " Pat " " lazy_ " let exception_ = combinator " Pat " " exception_ " end module Case = struct let nonbinding = combinator " Case " " nonbinding " let simple = combinator " Case " " simple " let pattern = combinator " Case " " pattern " let guarded = combinator " Case " " guarded " end module Exp = struct let var = combinator " Exp " " var " let ident = combinator " Exp " " ident " let constant = combinator " Exp " " constant " let local = combinator " Exp " " local " let let_nonbinding = combinator " Exp " " let_nonbinding " let let_simple = combinator " Exp " " let_simple " let let_rec_simple = combinator " Exp " " let_rec_simple " let let_pattern = combinator " Exp " " let_pattern " let fun_nonbinding = combinator " Exp " " fun_nonbinding " let fun_simple = combinator " Exp " " fun_simple " let fun_pattern = combinator " Exp " " fun_pattern " let function_ = combinator " Exp " " function_ " let apply = combinator " Exp " " apply " let match_ = combinator " Exp " " match_ " let try_ = combinator " Exp " " try_ " let tuple = combinator " Exp " " tuple " let construct = combinator " Exp " " construct " let variant = combinator " Exp " " variant " let record = combinator " Exp " " record " let field = combinator " Exp " " field " let setfield = combinator " Exp " " setfield " let array = combinator " Exp " " array " let ifthenelse = combinator " Exp " " ifthenelse " let sequence = combinator " Exp " " sequence " let while_ = combinator " Exp " " while_ " let for_ = combinator " Exp " " for_ " let send = combinator " Exp " " send " let assert_ = combinator " Exp " " assert_ " let lazy_ = combinator " Exp " " lazy_ " let quote = combinator " Exp " " quote " let escape = combinator " Exp " " escape " let to_closed = combinator " Exp " " to_closed " end let marshal_name ( x : string loc ) = let s = Marshal . to_string x [ ] in string s let marshal_constant ( x : CamlinternalAST . constant ) = let s = Marshal . to_string x [ ] in string s let marshal_ident ( x : Longident . t loc ) = let s = Marshal . to_string x [ ] in string s let marshal_arg_label ( x : Asttypes . arg_label ) = let s = Marshal . to_string x [ ] in string s let func id body = Lfunction { kind = Curried ; params = [ id ] ; body = body ; attr = default_function_attribute ; loc = Location . none ; } let list_func ids body = let rec loop list_id = function | [ ] -> body | [ id ] -> Llet ( Alias , Pgenval , id , Lprim ( Pfield 0 , [ Lvar list_id ] , Location . none ) , body ) | id :: ids -> let tail_id = Ident . create " tl " in Llet ( Alias , Pgenval , id , Lprim ( Pfield 0 , [ Lvar list_id ] , Location . none ) , Llet ( Alias , Pgenval , tail_id , Lprim ( Pfield 1 , [ Lvar list_id ] , Location . none ) , loop tail_id ids ) ) in let list_id = Ident . create " list " in let body = loop list_id ids in Lfunction { kind = Curried ; params = [ list_id ] ; body = body ; attr = default_function_attribute ; loc = Location . none ; } let bind id def body = Llet ( Strict , Pgenval , id , def , body ) let quote_loc ( loc : Location . t ) = if loc = Location . none then use Loc . none else apply Location . none Loc . unmarshal [ marshal_loc loc ] let quote_constant loc ( const : Asttypes . constant ) = let const : CamlinternalAST . constant = let open CamlinternalAST in match const with | Const_int x -> Pconst_integer ( string_of_int x , None ) | Const_char x -> Pconst_char x | Const_string ( x , y ) -> Pconst_string ( x , y ) | Const_float x -> Pconst_float ( x , None ) | Const_int32 x -> Pconst_integer ( Int32 . to_string x , Some ' l ' ) | Const_int64 x -> Pconst_integer ( Int64 . to_string x , Some ' L ' ) | Const_nativeint x -> Pconst_integer ( Nativeint . to_string x , Some ' n ' ) in apply loc Constant . unmarshal [ marshal_constant const ] let quote_name loc ( str : string loc ) = apply loc Ident . unmarshal [ marshal_name str ] let quote_variant loc ( variant : label ) = apply loc Variant . of_string [ string variant ] let wrap_local loc id ( name : string loc ) body = let name = quote_name name . loc name in apply loc Exp . local [ quote_loc loc ; name ; func id body ] let quote_method loc ( meth : Typedtree . meth ) = let name = match meth with | Tmeth_name name -> name | Tmeth_val id -> Ident . name id in apply loc Method . of_string [ string name ] let quote_arg_label loc ( lbl : Asttypes . arg_label ) = apply loc ArgLabel . unmarshal [ marshal_arg_label lbl ] let lid_of_path p = let rec loop = function | Path . Pident id -> if Ident . global id then Longident . Lglobal ( Ident . name id ) else Longident . Lident ( Ident . name id ) | Path . Pdot ( p , s , _ ) -> Longident . Ldot ( loop p , s ) | Path . Papply ( p , p ' ) -> Longident . Lapply ( loop p , loop p ' ) in loop p let lid_of_type_path env ty = let desc = ( Ctype . repr ( Ctype . expand_head_opt env ( Ctype . correct_levels ty ) ) ) . desc in match desc with | Tconstr ( p , _ , _ ) -> lid_of_path p | _ -> fatal_error " No path for type " let quote_variant_constructor env loc constr = let lid = match lid_of_type_path env constr . cstr_res with | Longident . Lident _ -> Longident . Lident constr . cstr_name | Longident . Lglobal _ -> Longident . Lglobal constr . cstr_name | Longident . Ldot ( lid , _ ) -> Longident . Ldot ( lid , constr . cstr_name ) | Longident . Lfrommacro _ -> assert false | Longident . Lapply _ -> assert false in let lid = mkloc lid loc in apply loc Identifier . unmarshal [ marshal_ident lid ] let quote_record_label env loc lbl = let lid = match lid_of_type_path env lbl . lbl_res with | Longident . Lident _ -> Longident . Lident lbl . lbl_name | Longident . Lglobal _ -> Longident . Lglobal lbl . lbl_name | Longident . Ldot ( lid , _ ) -> Longident . Ldot ( lid , lbl . lbl_name ) | Longident . Lfrommacro _ -> assert false | Longident . Lapply _ -> assert false in let lid = mkloc lid loc in apply loc Identifier . unmarshal [ marshal_ident lid ] let transl_clos_field loc path_id str index = apply loc Identifier . lfrommacro [ Lvar path_id ; string str ; Lconst ( Const_base ( Const_int index ) ) ] let path_arg loc p = let lid = mkloc ( lid_of_path p ) loc in let lid = marshal_ident lid in apply loc Identifier . unmarshal [ lid ] let rec quote_pattern p = let env = p . pat_env in let loc = p . pat_loc in match p . pat_desc with | Tpat_any -> apply loc Pat . any [ quote_loc loc ] | Tpat_var ( id , _ ) -> apply loc Pat . var [ quote_loc loc ; Lvar id ] | Tpat_alias ( pat , id , _ ) -> let pat = quote_pattern pat in apply loc Pat . alias [ quote_loc loc ; pat ; Lvar id ] | Tpat_constant const -> let const = quote_constant loc const in apply loc Pat . constant [ quote_loc loc ; const ] | Tpat_tuple pats -> let pats = List . map quote_pattern pats in apply loc Pat . tuple [ quote_loc loc ; list pats ] | Tpat_construct ( lid , constr , args ) -> let constr = quote_variant_constructor env lid . loc constr in let args = match args with | [ ] -> None | [ arg ] -> let arg = quote_pattern arg in Some arg | _ :: _ -> let args = List . map quote_pattern args in Some ( apply loc Pat . tuple [ quote_loc loc ; list args ] ) in apply loc Pat . construct [ quote_loc loc ; constr ; option args ] | Tpat_variant ( variant , argo , _ ) -> let variant = quote_variant loc variant in let argo = Misc . may_map quote_pattern argo in apply loc Pat . variant [ quote_loc loc ; variant ; option argo ] | Tpat_record ( lbl_pats , closed ) -> let lbl_pats = List . map ( fun ( lid , lbl , pat ) -> let lbl = quote_record_label env ( lid : Longident . t loc ) . loc lbl in let pat = quote_pattern pat in pair ( lbl , pat ) ) lbl_pats in let closed = match closed with | Asttypes . Closed -> true_ | Asttypes . Open -> false_ in apply loc Pat . record [ quote_loc loc ; list lbl_pats ; closed ] | Tpat_array pats -> let pats = List . map quote_pattern pats in apply loc Pat . array [ quote_loc loc ; list pats ] | Tpat_or ( pat1 , pat2 , _ ) -> let pat1 = quote_pattern pat1 in let pat2 = quote_pattern pat2 in apply loc Pat . or_ [ quote_loc loc ; pat1 ; pat2 ] | Tpat_lazy pat -> let pat = quote_pattern pat in apply loc Pat . lazy_ [ quote_loc loc ; pat ] type case_binding = | Non_binding of lambda * lambda | Simple of lambda * lambda | Pattern of lambda * lambda | Guarded of lambda * lambda let rec case_binding exn transl pclos stage case : case_binding = let pat = case . c_lhs in let pat_loc = pat . pat_loc in match case . c_guard with | None -> begin match pat . pat_desc , exn with | Tpat_var ( id , name ) , false -> let name = quote_name name . loc name in let body = quote_expression transl pclos stage case . c_rhs in Simple ( name , func id body ) | _ -> match pat_bound_idents pat with | [ ] -> let pat = quote_pattern pat in let pat = if exn then apply pat_loc Pat . exception_ [ quote_loc pat_loc ; pat ] else pat in let exp = quote_expression transl pclos stage case . c_rhs in Non_binding ( pat , exp ) | id_names -> let ids = List . map fst id_names in let names = List . map ( fun ( _ , name ) -> quote_name ( name : string loc ) . loc name ) id_names in let pat = quote_pattern pat in let pat = if exn then apply pat_loc Pat . exception_ [ quote_loc pat_loc ; pat ] else pat in let exp = quote_expression transl pclos stage case . c_rhs in let pat_id = Ident . create " pattern " in let exp_id = Ident . create " expression " in let body = bind pat_id pat ( bind exp_id exp ( pair ( Lvar pat_id , Lvar exp_id ) ) ) in Pattern ( list names , list_func ids body ) end | Some guard -> let id_names = pat_bound_idents case . c_lhs in let ids = List . map fst id_names in let names = List . map ( fun ( _ , name ) -> quote_name ( name : string loc ) . loc name ) id_names in let pat = quote_pattern case . c_lhs in let pat = if exn then apply pat_loc Pat . exception_ [ quote_loc pat_loc ; pat ] else pat in let guard = quote_expression transl pclos stage guard in let exp = quote_expression transl pclos stage case . c_rhs in let pat_id = Ident . create " pattern " in let guard_id = Ident . create " guard " in let exp_id = Ident . create " expression " in let body = bind pat_id pat ( bind guard_id guard ( bind exp_id exp ( triple ( Lvar pat_id , Lvar guard_id , Lvar exp_id ) ) ) ) in Guarded ( list names , list_func ids body ) and quote_case_binding loc cb = match cb with | Non_binding ( pat , exp ) -> apply loc Case . nonbinding [ quote_loc loc ; pat ; exp ] | Simple ( name , body ) -> apply loc Case . simple [ quote_loc loc ; name ; body ] | Pattern ( names , body ) -> apply loc Case . pattern [ quote_loc loc ; names ; body ] | Guarded ( names , body ) -> apply loc Case . guarded [ quote_loc loc ; names ; body ] and quote_case exn transl pclos stage loc case = quote_case_binding loc ( case_binding exn transl pclos stage case ) and quote_nonrecursive_let transl pclos stage vbs body = List . fold_right ( fun vb body -> let loc = vb . vb_loc in let pat = vb . vb_pat in let exp = vb . vb_expr in match pat . pat_desc with | Tpat_var ( id , name ) -> let name = quote_name name . loc name in let exp = quote_expression transl pclos stage exp in apply loc Exp . let_simple [ quote_loc loc ; name ; exp ; func id body ] | _ -> match pat_bound_idents pat with | [ ] -> let pat = quote_pattern pat in let exp = quote_expression transl pclos stage exp in apply loc Exp . let_nonbinding [ quote_loc loc ; pat ; exp ; body ] | id_names -> let ids = List . map fst id_names in let names = List . map ( fun ( _ , name ) -> quote_name ( name : string loc ) . loc name ) id_names in let pat = quote_pattern pat in let exp = quote_expression transl pclos stage exp in let pat_id = Ident . create " pattern " in let body_id = Ident . create " body " in let body = bind pat_id pat ( bind body_id body ( pair ( Lvar pat_id , Lvar body_id ) ) ) in apply loc Exp . let_pattern [ quote_loc loc ; list names ; exp ; list_func ids body ] ) vbs ( quote_expression transl pclos stage body ) and quote_recursive_let transl pclos stage loc vbs body = let id_names , exps = List . fold_right ( fun vb ( id_names , exps ) -> let pat = vb . vb_pat in let exp = vb . vb_expr in match pat . pat_desc with | Tpat_var ( id , name ) | Tpat_alias ( { pat_desc = Tpat_any } , id , name ) -> let name = quote_name name . loc name in let exp = quote_expression transl pclos stage exp in ( ( id , name ) :: id_names , exp :: exps ) | _ -> assert false ) vbs ( [ ] , [ ] ) in let ids = List . map fst id_names in let names = List . map snd id_names in let exps_id = Ident . create " exps " in let body_id = Ident . create " body " in let body = bind exps_id ( list exps ) ( bind body_id ( quote_expression transl pclos stage body ) ( pair ( Lvar exps_id , Lvar body_id ) ) ) in apply loc Exp . let_rec_simple [ quote_loc loc ; list names ; list_func ids body ] and quote_expression transl pclos stage e = let env = e . exp_env in let loc = e . exp_loc in match e . exp_desc with | Texp_ident ( path , lid , _ ) -> begin let quote_path path = let env = e . exp_env in if Env . cur_stage env <> Env . find_stage path env then let lid = lid_of_path path in let lid = mkloc lid loc in let lid = apply loc Identifier . unmarshal [ marshal_ident lid ] in apply loc Exp . ident [ quote_loc loc ; lid ] else begin match path with | Path . Pident id -> apply loc Exp . var [ quote_loc loc ; Lvar id ] | _ -> fatal_error " Cross - stage identifier has compound path " end in match pclos with | None -> quote_path path | Some ( path_id , map ) -> try let field_idx = Env . PathMap . find path map in let ppf = Format . str_formatter in let open Parsetree in Pprintast . expression ppf { pexp_desc = ( Pexp_ident lid ) ; pexp_loc = Location . none ; pexp_attributes = [ ] ; } ; let str = Format . flush_str_formatter ( ) in let lid = transl_clos_field loc path_id str field_idx in apply loc Exp . ident [ quote_loc loc ; lid ] with Not_found -> quote_path path end | Texp_constant const -> let const = quote_constant loc const in apply loc Exp . constant [ quote_loc loc ; const ] | Texp_let ( rf , vbs , body ) -> begin match rf with | Nonrecursive -> quote_nonrecursive_let transl pclos stage vbs body | Recursive -> quote_recursive_let transl pclos stage loc vbs body end | Texp_function ( label , cases , _ ) -> begin let cbs = List . map ( case_binding false transl pclos stage ) cases in match cbs with | [ Non_binding ( pat , exp ) ] -> let label = quote_arg_label loc label in apply loc Exp . fun_nonbinding [ quote_loc loc ; label ; pat ; exp ] | [ Simple ( name , body ) ] -> let label = quote_arg_label loc label in apply loc Exp . fun_simple [ quote_loc loc ; name ; label ; none ; body ] | [ Pattern ( names , body ) ] -> let label = quote_arg_label loc label in apply loc Exp . fun_pattern [ quote_loc loc ; names ; label ; none ; body ] | cases -> let cases = List . map ( quote_case_binding loc ) cases in apply loc Exp . function_ [ quote_loc loc ; list cases ] end | Texp_apply ( fn , args ) -> let fn = quote_expression transl pclos stage fn in let args = List . filter ( fun ( _ , exp ) -> exp <> None ) args in let args = List . map ( fun ( lbl , exp ) -> match exp with | None -> assert false | Some exp -> let lbl = quote_arg_label loc lbl in let exp = quote_expression transl pclos stage exp in pair ( lbl , exp ) ) args in apply loc Exp . apply [ quote_loc loc ; fn ; list args ] | Texp_match ( exp , cases , exn_cases , _ ) -> let exp = quote_expression transl pclos stage exp in let cases = List . map ( quote_case false transl pclos stage loc ) cases in let exn_cases = List . map ( quote_case true transl pclos stage loc ) exn_cases in apply loc Exp . match_ [ quote_loc loc ; exp ; list ( cases @ exn_cases ) ] | Texp_try ( exp , cases ) -> let exp = quote_expression transl pclos stage exp in let cases = List . map ( quote_case false transl pclos stage loc ) cases in apply loc Exp . try_ [ quote_loc loc ; exp ; list cases ] | Texp_tuple exps -> let exps = List . map ( quote_expression transl pclos stage ) exps in apply loc Exp . tuple [ quote_loc loc ; list exps ] | Texp_construct ( lid , constr , args ) -> let constr = quote_variant_constructor env lid . loc constr in let args = match args with | [ ] -> None | [ arg ] -> let arg = quote_expression transl pclos stage arg in Some arg | _ :: _ -> let args = List . map ( quote_expression transl pclos stage ) args in Some ( apply loc Exp . tuple [ quote_loc loc ; list args ] ) in apply loc Exp . construct [ quote_loc loc ; constr ; option args ] | Texp_variant ( variant , argo ) -> let variant = quote_variant loc variant in let argo = Misc . may_map ( quote_expression transl pclos stage ) argo in apply loc Exp . variant [ quote_loc loc ; variant ; option argo ] | Texp_record { fields = fields ; extended_expression = base } -> let lbl_exps = List . map ( function | ( lbl , ( Overridden ( lid , exp ) ) ) -> let lbl = quote_record_label env ( lid : Longident . t loc ) . loc lbl in let exp = quote_expression transl pclos stage exp in pair ( lbl , exp ) | _ -> assert false ) @@ List . filter ( function | ( _ , ( Overridden _ ) ) -> true | _ -> false ) @@ Array . to_list fields in let base = Misc . may_map ( quote_expression transl pclos stage ) base in apply loc Exp . record [ quote_loc loc ; list lbl_exps ; option base ] | Texp_field ( rcd , lid , lbl ) -> let rcd = quote_expression transl pclos stage rcd in let lbl = quote_record_label env lid . loc lbl in apply loc Exp . field [ quote_loc loc ; rcd ; lbl ] | Texp_setfield ( rcd , lid , lbl , exp ) -> let rcd = quote_expression transl pclos stage rcd in let lbl = quote_record_label env lid . loc lbl in let exp = quote_expression transl pclos stage exp in apply loc Exp . setfield [ quote_loc loc ; rcd ; lbl ; exp ] | Texp_array exps -> let exps = List . map ( quote_expression transl pclos stage ) exps in apply loc Exp . array [ quote_loc loc ; list exps ] | Texp_ifthenelse ( cond , then_ , else_ ) -> let cond = quote_expression transl pclos stage cond in let then_ = quote_expression transl pclos stage then_ in let else_ = Misc . may_map ( quote_expression transl pclos stage ) else_ in apply loc Exp . ifthenelse [ quote_loc loc ; cond ; then_ ; option else_ ] | Texp_sequence ( exp1 , exp2 ) -> let exp1 = quote_expression transl pclos stage exp1 in let exp2 = quote_expression transl pclos stage exp2 in apply loc Exp . sequence [ quote_loc loc ; exp1 ; exp2 ] | Texp_while ( cond , body ) -> let cond = quote_expression transl pclos stage cond in let body = quote_expression transl pclos stage body in apply loc Exp . while_ [ quote_loc loc ; cond ; body ] | Texp_for ( id , pat , low , high , dir , body ) -> let low = quote_expression transl pclos stage low in let high = quote_expression transl pclos stage high in let dir = match dir with | Asttypes . Upto -> true_ | Asttypes . Downto -> false_ in let name = match pat . Parsetree . ppat_desc with | Parsetree . Ppat_var name -> name | Parsetree . Ppat_any -> Location . mkloc " _ " pat . Parsetree . ppat_loc | _ -> assert false in let name = quote_name name . loc name in let body = quote_expression transl pclos stage body in apply loc Exp . for_ [ quote_loc loc ; name ; low ; high ; dir ; func id body ] | Texp_send ( obj , meth , _ ) -> let obj = quote_expression transl pclos stage obj in let meth = quote_method loc meth in apply loc Exp . send [ quote_loc loc ; obj ; meth ] | Texp_assert exp -> let exp = quote_expression transl pclos stage exp in apply loc Exp . assert_ [ quote_loc loc ; exp ] | Texp_lazy exp -> let exp = quote_expression transl pclos stage exp in apply loc Exp . lazy_ [ quote_loc loc ; exp ] | Texp_quote exp -> let exp = quote_expression transl pclos ( stage + 1 ) exp in apply loc Exp . quote [ quote_loc loc ; exp ] | Texp_escape exp -> if stage > 0 then begin let exp = quote_expression transl pclos ( stage - 1 ) exp in apply loc Exp . escape [ quote_loc loc ; exp ] end else transl exp | Texp_new _ | Texp_instvar _ | Texp_setinstvar _ | Texp_override _ | Texp_letmodule _ | Texp_object _ | Texp_pack _ | Texp_unreachable | Texp_letexception _ | Texp_extension_constructor _ -> fatal_error " Expression cannot be quoted " let quote_expression transl pclos exp = quote_expression transl pclos 0 exp let transl_close_expression loc lam = apply loc Exp . to_closed [ lam ] end ) *
|
let transl_close_expression _loc e = e
|
let wrap_local _loc _id _name lam = lam
|
let check_buflen cs = let cslen = Cstruct . len cs in if cslen < packet_length then invalid_arg ( " HID packets must be 64 bytes long , got " ^ string_of_int cslen )
|
module Status = struct type t = . . type t += | Invalid_pin of int | Incorrect_length | Incorrect_length_for_ins | Incompatible_file_structure | Security_status_unsatisfied | Hid_required | Conditions_of_use_not_satisfied | Incorrect_data | File_not_found | Parse_error | Incorrect_params | Incorrect_class | Ins_not_supported | Memory_error | Referenced_data_not_found | Technical_problem of int | Ok | Unknown of int let of_int = function | 0x6700 -> Incorrect_length | 0x6981 -> Incompatible_file_structure | 0x6982 -> Security_status_unsatisfied | 0x6983 -> Hid_required | 0x6985 -> Conditions_of_use_not_satisfied | 0x6a80 -> Incorrect_data | 0x9404 -> File_not_found | 0x9405 -> Parse_error | 0x6b00 -> Incorrect_params | 0x6c00 -> Incorrect_length | 0x6d00 -> Ins_not_supported | 0x6e00 -> Incorrect_class | 0x9000 -> Ok | 0x917e -> Incorrect_length_for_ins | 0x9200 -> Memory_error | 0x6a88 -> Referenced_data_not_found | v when v >= 0x63c0 && v <= 0x63cf -> Invalid_pin ( v land 0x0f ) | v when v >= 0x6f00 && v <= 0x6fff -> Technical_problem ( v land 0xff ) | v -> Unknown v let string_fs = ref [ ] let register_string_f f = string_fs := f :: ! string_fs let to_string = function | Conditions_of_use_not_satisfied -> " Conditions of use not satisfied " | File_not_found -> " File not found " | Hid_required -> " HID required " | Incompatible_file_structure -> " Incompatible file structure " | Incorrect_class -> " Incorrect class " | Incorrect_data -> " Incorrect data " | Incorrect_length -> " Incorrect length " | Incorrect_length_for_ins -> " Incorrect length for instruction " | Incorrect_params -> " Incorrect parameters " | Ins_not_supported -> " Instruction not supported " | Invalid_pin i -> " Invalid pin " ^ string_of_int i | Memory_error -> " Memory error " | Ok -> " Ok " | Parse_error -> " Parse error " | Referenced_data_not_found -> " Referenced data not found " | Security_status_unsatisfied -> " Security status unsatisfied " | Technical_problem i -> " Technical problem " ^ string_of_int i | Unknown i -> Printf . sprintf " Unknown status code 0x % x " i | t -> try List . fold_left begin fun a f -> match f t with Some s -> failwith s | None -> a end " Unregistered status message " ! string_fs with Failure s -> s let help_suggestor_f = ref ( fun _ -> None ) let register_help_suggestor_f f = help_suggestor_f := f let to_help_suggestion t = ! help_suggestor_f t let show t = to_string t let pp ppf t = Format . fprintf ppf " % s % a " ( to_string t ) ( fun ppf -> function | None -> Format . fprintf ppf " " | Some s -> Format . fprintf ppf " - % a " Format . pp_print_text s ) ( to_help_suggestion t ) end
|
module Header = struct type t = { cmd : cmd ; seq : int ; } and cmd = Ping | Apdu let cmd_of_int = function | 0x05 -> Some Apdu | 0x02 -> Some Ping | _ -> None module Error = struct type t = | Header_too_short of int | Invalid_channel of int | Invalid_command_tag of int | Unexpected_sequence_number of { expected : int ; actual : int } let pp ppf = function | Header_too_short i -> Format . fprintf ppf " Header too short ( got % d bytes ) " i | Invalid_channel i -> Format . fprintf ppf " Invalid channel ( % d ) " i | Invalid_command_tag i -> Format . fprintf ppf " Invalid command tag ( % d ) " i | Unexpected_sequence_number { expected ; actual } -> Format . fprintf ppf " Unexpected sequence number ( expected % d , got % d ) " expected actual end let fail_header_too_short i = R . error ( Error . Header_too_short i ) let fail_invalid_chan i = R . error ( Error . Invalid_channel i ) let fail_invalid_cmd i = R . error ( Error . Invalid_command_tag i ) let fail_unexpected_seqnum ~ expected ~ actual = R . error ( Error . Unexpected_sequence_number { expected ; actual } ) let read cs = let cslen = Cstruct . len cs in begin if cslen < 5 then fail_header_too_short cslen else R . ok ( ) end >>= fun ( ) -> let channel_id = Cstruct . BE . get_uint16 cs 0 in let cmd = Cstruct . get_uint8 cs 2 in let seq = Cstruct . BE . get_uint16 cs 3 in begin if channel_id <> channel then fail_invalid_chan channel_id else R . ok ( ) end >>= fun ( ) -> begin match cmd_of_int cmd with | Some cmd -> R . ok cmd | None -> fail_invalid_cmd cmd end >>= fun cmd -> R . ok ( { cmd ; seq } , Cstruct . shift cs 5 ) let check_seqnum t expected_seq = if expected_seq <> t . seq then fail_unexpected_seqnum ~ actual : t . seq ~ expected : expected_seq else R . ok ( ) end
|
type transport_error = | Hidapi of string | Incomplete_write of int | Incomplete_read of int
|
let pp_transport_error ppf = function | Hidapi s -> Format . pp_print_string ppf s | Incomplete_write i -> Format . fprintf ppf " wrote % d bytes , expected to write 64 \ bytes " i | Incomplete_read i -> Format . fprintf ppf " read % d bytes , expected to read 64 \ bytes " i
|
type error = | AppError of { status : Status . t ; msg : string } | ApduError of Header . Error . t | TransportError of transport_error
|
let app_error ~ msg r = R . reword_error ( fun status -> AppError { status ; msg } ) r
|
let apdu_error r = R . reword_error ( fun e -> ApduError e ) r
|
let pp_error ppf = function | AppError { status ; msg } -> Format . fprintf ppf " Application level error ( % s ) : % a " msg Status . pp status | ApduError e -> Format . fprintf ppf " APDU level error : % a " Header . Error . pp e | TransportError e -> Format . fprintf ppf " Transport level error : % a " pp_transport_error e
|
let check_nbwritten = function | n when n = packet_length -> R . ok ( ) | n -> R . error ( TransportError ( Incomplete_write n ) )
|
let check_nbread = function | n when n = packet_length -> R . ok ( ) | n -> R . error ( TransportError ( Incomplete_read n ) )
|
let write_hidapi h ? len buf = R . reword_error ( fun s -> TransportError ( Hidapi s ) ) ( Hidapi . write h ? len Cstruct . ( to_bigarray ( sub buf 0 packet_length ) ) ) >>= check_nbwritten
|
let read_hidapi ? timeout h buf = R . reword_error ( fun s -> TransportError ( Hidapi s ) ) ( Hidapi . read ? timeout h buf packet_length ) >>= check_nbread
|
let write_ping ( ? buf = Cstruct . create packet_length ) h = check_buflen buf ; let open Cstruct in BE . set_uint16 buf 0 channel ; set_uint8 buf 2 ping ; BE . set_uint16 buf 3 0 ; memset ( sub buf 5 59 ) 0 ; write_hidapi h buf
|
let write_apdu ? pp ( ? buf = Cstruct . create packet_length ) h p = check_buflen buf ; let apdu_len = Apdu . length p in let apdu_buf = Cstruct . create apdu_len in let _nb_written = Apdu . write apdu_buf p in begin match pp with | None -> ( ) | Some pp -> Format . fprintf pp " -> REQ % a . " @ Cstruct . hexdump_pp apdu_buf ; Format . pp_print_flush pp ( ) end ; let apdu_p = ref 0 in let i = ref 0 in let open Cstruct in BE . set_uint16 buf 0 channel ; set_uint8 buf 2 apdu ; BE . set_uint16 buf 3 ! i ; BE . set_uint16 buf 5 apdu_len ; let nb_to_write = ( min apdu_len ( packet_length - 7 ) ) in blit apdu_buf 0 buf 7 nb_to_write ; write_hidapi h buf >>= fun ( ) -> apdu_p := ! apdu_p + nb_to_write ; incr i ; let rec inner apdu_p = if apdu_p >= apdu_len then R . ok ( ) else begin memset buf 0 ; BE . set_uint16 buf 0 channel ; set_uint8 buf 2 apdu ; BE . set_uint16 buf 3 ! i ; let nb_to_write = ( min ( apdu_len - apdu_p ) ( packet_length - 5 ) ) in blit apdu_buf apdu_p buf 5 nb_to_write ; write_hidapi h buf >>= fun ( ) -> incr i ; inner ( apdu_p + nb_to_write ) end in inner ! apdu_p
|
let read ? pp ( ? buf = Cstruct . create packet_length ) h = check_buflen buf ; let expected_seq = ref 0 in let full_payload = ref ( Cstruct . create 0 ) in let payload = ref ( Cstruct . create 0 ) in let rec inner ( ) = read_hidapi ~ timeout : 600_000 h ( Cstruct . to_bigarray buf ) >>= fun ( ) -> begin match pp with | None -> ( ) | Some pp -> Format . fprintf pp " <- RAW PKT % a . " @ Cstruct . hexdump_pp ( Cstruct . sub buf 0 packet_length ) ; Format . pp_print_flush pp ( ) end ; apdu_error ( Header . read buf ) >>= fun ( hdr , buf ) -> apdu_error ( Header . check_seqnum hdr ! expected_seq ) >>= fun ( ) -> if hdr . seq = 0 then begin let len = Cstruct . BE . get_uint16 buf 0 in let cs = Cstruct . shift buf 2 in payload := Cstruct . create len ; full_payload := ! payload ; let nb_to_read = min len ( packet_length - 7 ) in Cstruct . blit cs 0 ! payload 0 nb_to_read ; payload := Cstruct . shift ! payload nb_to_read ; expected_seq := ! expected_seq + 1 ; end else begin let nb_to_read = min ( Cstruct . len ! payload ) ( packet_length - 5 ) in Cstruct . blit buf 0 ! payload 0 nb_to_read ; payload := Cstruct . shift ! payload nb_to_read ; expected_seq := ! expected_seq + 1 end ; match Cstruct . len ! payload , hdr . cmd with | 0 , Ping -> R . ok ( Status . Ok , Cstruct . create 0 ) | 0 , Apdu -> let payload_len = Cstruct . len ! full_payload in let sw = Cstruct . BE . get_uint16 ! full_payload ( payload_len - 2 ) in R . ok ( Status . of_int sw , Cstruct . sub ! full_payload 0 ( payload_len - 2 ) ) | _ -> inner ( ) in inner ( )
|
let ping ? pp ? buf h = write_ping ? buf h >>= fun ( ) -> read ? pp ? buf h >>| ignore
|
let apdu ? pp ( ? msg " " ) = ? buf h apdu = write_apdu ? pp ? buf h apdu >>= fun ( ) -> read ? pp ? buf h >>= fun ( status , payload ) -> begin match pp with | None -> ( ) | Some pp -> Format . fprintf pp " <- RESP [ % a ] % a . " @ Status . pp status Cstruct . hexdump_pp payload ; Format . pp_print_flush pp ( ) end ; match status with | Status . Ok -> R . ok payload | status -> app_error ~ msg ( R . error status )
|
let write_payload ? pp ( ? msg " = write_payload " ) ? buf ( ? mark_last = false ) ~ cmd ? p1 ? p2 h cs = let rec inner cs = let cs_len = Cstruct . len cs in let lc = min Apdu . max_data_length cs_len in let last = lc = cs_len in let p1 = match last , mark_last , p1 with | true , true , None -> Some 0x80 | true , true , Some p1 -> Some ( 0x80 lor p1 ) | _ -> p1 in apdu ? pp ~ msg ? buf h Apdu . ( create ? p1 ? p2 ~ lc ~ data ( : Cstruct . sub cs 0 lc ) cmd ) >>= fun response -> if last then R . ok response else inner ( Cstruct . shift cs lc ) in if Cstruct . len cs = 0 then R . ok cs else inner cs
|
type ' a message_handler = Bigstring . t -> pos : int -> len : int -> ' a
|
module Handler_result = struct type ' a t = | Stop of ' a | Continue | Wait of unit Deferred . t end
|
module type Reader = sig type t [ @@ deriving sexp_of ] val close : t -> unit Deferred . t val is_closed : t -> bool val read_forever : t -> on_message ( : Bigstring . t -> pos : int -> len : int -> ' a Handler_result . t ) -> on_end_of_batch ( : unit -> unit ) -> ( ' a , [ ` Eof | ` Closed ] ) Result . t Deferred . t end
|
module Send_result = struct type message_too_big = { size : int ; max_message_size : int } [ @@ deriving sexp_of ] type ' a t = | Sent of ' a | Closed | Message_too_big of message_too_big [ @@ deriving sexp_of ] end
|
module type Writer = sig type t [ @@ deriving sexp_of ] val close : t -> unit Deferred . t val is_closed : t -> bool val monitor : t -> Monitor . t val bytes_to_write : t -> int val stopped : t -> unit Deferred . t val flushed : t -> unit Deferred . t val ready_to_write : t -> unit Deferred . t val send_bin_prot : t -> ' a Bin_prot . Type_class . writer -> ' a -> unit Send_result . t val send_bin_prot_and_bigstring : t -> ' a Bin_prot . Type_class . writer -> ' a -> buf : Bigstring . t -> pos : int -> len : int -> unit Send_result . t val send_bin_prot_and_bigstring_non_copying : t -> ' a Bin_prot . Type_class . writer -> ' a -> buf : Bigstring . t -> pos : int -> len : int -> unit Deferred . t Send_result . t end
|
let cpt = ref 0
|
let tot_time = ref 0 .
|
let measure_time f s iter = let t0 = Unix . gettimeofday ( ) in let a = f ( ) in let t1 = Unix . gettimeofday ( ) in Printf . printf " % s time % d : % Fs -> average % Fs \ n " %! s ! cpt ( t1 . - t0 ) ( ( t1 . - t0 ) . / ( float iter ) ) ; tot_time := ! tot_time . + ( t1 . - t0 ) ; incr cpt ; a ; ;
|
let devices = measure_time Spoc . Devices . init " init " 1
|
let tile_dim = ref 32l
|
let block_rows = ref 8l
|
let transpose = kern idata odata -> let open Std in let mutable x = thread_idx_x + block_idx_x * @ tile_dim in let mutable y = thread_idx_y + block_idx_y * @ tile_dim in let width = grid_dim_x * @ tile_dim in let ( tile : float32 array ) = create_array ( @ tile_dim * ( @ tile_dim + 1 ) ) in let mutable j = 0 in while j < @ tile_dim do tile . ( ( thread_idx_y + j ) * @ tile_dim + thread_idx_x ) <>- ( idata . [ ( < y + j ) * width + x ] > : float32 ) ; j := j + @ block_rows ; done ; block_barrier ( ) ; x := thread_idx_x + block_idx_y * @ tile_dim ; y := thread_idx_y + block_idx_x * @ tile_dim ; j := 0 ; while j < @ tile_dim do odata . [ ( < y + j ) * width + x ] > <- tile . ( thread_idx_x * @ tile_dim + ( thread_idx_y + j ) ) ; j := j + @ block_rows ; done
|
let _ = let nx = ref 1024 and ny = ref 1024 in let dev_id = ref 0 in let arg0 = ( " - d " , Arg . Int ( fun i -> dev_id := i ) , " Choose the device ( default : 0 ) " ) in let arg1 = ( " - nx " , Arg . Int ( fun i -> nx := i ) , " Matrix width ( default 1024 ) " ) in let arg2 = ( " - ny " , Arg . Int ( fun i -> ny := i ) , " Matrix height ( default 1024 ) " ) in Arg . parse [ arg0 ; arg1 ; arg2 ] ( fun s -> ( ) ) " " ; let m1 = Vector . create Vector . float32 ( ! nx * ! ny ) and m2 = Vector . create Vector . float32 ( ! nx * ! ny ) in let dev = devices . ( ! dev_id ) in measure_time ( fun ( ) -> let kind = match dev . Devices . specific_info with | Devices . OpenCLInfo clI -> Devices . OpenCL | _ -> Devices . Cuda in for i = 1 to 10 do ignore ( Kirc . gen ~ only : kind transpose dev ) ; done ; ) " Code generation " 10 ; for i = 0 to ( ! nx - 1 ) * ( ! ny - 1 ) do Mem . set m1 i ( float i ) ; done ; Mem . to_device m1 dev ; Mem . to_device m2 dev ; let open Kernel in let block = { blockX = Int32 . to_int ! tile_dim ; blockY = Int32 . to_int ! block_rows ; blockZ = 1 } and grid = { gridX = ! nx / ( Int32 . to_int ! tile_dim ) ; gridY = ! ny / ( Int32 . to_int ! tile_dim ) ; gridZ = 1 } in Kirc . run transpose ( m1 , m2 ) ( block , grid ) 0 dev ; Devices . flush dev ( ) ; Printf . printf " Starting iterations \ n " ; %! measure_time ( fun ( ) -> for iter = 1 to 10 do Kirc . run transpose ( m1 , m2 ) ( block , grid ) 0 dev ; Devices . flush ~ queue_id : 0 dev ( ) ; done ; ) " Transposition kernel " 10 ; measure_time ( fun ( ) -> for iter = 1 to ! nIters do ignore ( Kirc . gen ~ only : Devices . OpenCL bodyForce dev ) done ; ) " OpenCL Code generation " ; let tot_time = ref 0 . 0 in for iter = 1 to ! nIters do let t0 = Unix . gettimeofday ( ) in Kirc . run bodyForce ( bodiesPos , bodiesVel , dt , ! nBodies ) ( block , grid ) 0 dev ; for i = 0 to ! nBodies - 1 do let bP , bV = ( Mem . get bodiesPos i ) , ( Mem . get bodiesVel i ) in Mem . set bodiesPos i { x = bP . x . + bV . x . * dt ; y = bP . y . + bV . y . * dt ; z = bP . z . + bV . z . * dt ; w = 0 . } ; done ; let tElapsed = ( Unix . gettimeofday ( ) . - t0 ) in if iter > 1 then tot_time := ! tot_time . + tElapsed ; Printf . printf " Iteration % d : . % 3f seconds \ n " %! iter tElapsed ; Printf . printf " Total time : % f \ n " ! tot_time ; ; ; ) *
|
module type D = sig type t val equal : t -> t -> bool val to_string : t -> string end
|
module type S = sig type d type t exception Unresolved val empty : unit -> t val unknown : unit -> t val pop : t -> t val push : t -> d -> t val to_list_exn : t -> d list val top_exn : t -> d option val unify : t -> t -> unit val print : t -> unit val print_pair : string -> t -> t -> unit end
|
module Make ( D : D ) = struct type d = D . t type t = stack ref and h = handler ref and stack = | Empty | Unknown | Link of t | Push of { h : h ; t : t } and handler = | Unknown | Link of h | Label of d let rec rep ( t : t ) = match ! t with | Link t -> rep t | Empty | Unknown | Push _ -> t let rec rep_h ( h : h ) = match ! h with | Link h -> rep_h h | Unknown | Label _ -> h let empty ( ) = ref Empty let unknown ( ) = ref ( Unknown : stack ) let push t h = ref ( Push { h = ref ( Label h ) ; t = rep t } ) let push_unknown t = ref ( Push { h = ref ( Unknown : handler ) ; t = rep t } ) exception Unresolved let top_exn t = match ( ! rep t ) with | Empty -> None | Push p -> ( match ( ! rep_h p . h ) with | Label l -> Some l | Link _ -> assert false | Unknown -> raise Unresolved ) | Link _ -> assert false | Unknown -> raise Unresolved let rec to_list_exn t = match ( ! rep t ) with | Empty -> [ ] | Push p -> ( match ( ! rep_h p . h ) with | Label l -> l :: to_list_exn p . t | Link _ -> assert false | Unknown -> raise Unresolved ) | Link _ -> assert false | Unknown -> raise Unresolved let rec print_h h = match ! h with | Label l -> Printf . printf " % s " ( D . to_string l ) | Link h ' -> Printf . printf " " ; = print_h h ' | Unknown -> Printf . printf " " ? let rec print t = match ! t with | Empty -> Printf . printf " empty \ n " | Unknown -> Printf . printf " ??\ n " | Link s -> Printf . printf " " ; = print s | Push p -> print_h p . h ; Printf . printf " " ; :: print p . t let print_pair_h msg h1 h2 = Printf . printf " % s \ n " msg ; print_h h1 ; print_h h2 let print_pair msg t1 t2 = Printf . printf " % s \ n " msg ; print t1 ; print t2 let fail ( ) = Misc . fatal_error " Malformed trap stack : mismatched pop / push trap handlers . " let link_h ( ~ src : h ) ( ~ dst : h ) = assert ( ! src = Unknown ) ; let rec loop cur = if cur == src then Misc . fatal_error " Trap_stack . unify created a cycle . " ; match ! cur with | Unknown -> ( ) | Label _ -> ( ) | Link h -> loop h in loop dst ; src := Link dst let rec unify_h ( h1 : h ) ( h2 : h ) = match ( ! h1 , ! h2 ) with | Link h1 , Link h2 -> unify_h h1 h2 | Link h , _ -> unify_h h h2 | _ , Link h -> unify_h h1 h | Unknown , _ -> link_h ~ src : h1 ~ dst : h2 | _ , Unknown -> link_h ~ src : h2 ~ dst : h1 | Label l1 , Label l2 -> if not ( D . equal l1 l2 ) then ( print_pair_h " handler labels disagree " : h1 h2 ; fail ( ) ) let link ( ~ src : t ) ( ~ dst : t ) = assert ( ! src = Unknown ) ; let rec loop cur = if cur == src then Misc . fatal_error " Trap_stack . unify created a cycle . " ; match ! cur with | Unknown -> ( ) | Empty -> ( ) | Link t -> loop t | Push { h = _ ; t } -> loop t in loop dst ; src := Link dst let rec unify s1 s2 = match ( ! s1 , ! s2 ) with | Empty , Empty -> ( ) | Link s1 , Link s2 -> unify s1 s2 | Link s , _ -> unify s s2 | _ , Link s -> unify s1 s | Unknown , _ -> link ~ src : s1 ~ dst : s2 | _ , Unknown -> link ~ src : s2 ~ dst : s1 | Push p1 , Push p2 -> unify_h p1 . h p2 . h ; unify p1 . t p2 . t | Empty , _ | _ , Empty -> print_pair " empty " s1 s2 ; fail ( ) let pop t = let res = unknown ( ) in let t ' = push_unknown res in unify t t ' ; res end
|
let ( ) = try let k = push emp 1 in let t1 = pop k in let t2 = pop ( push k 2 ) in unify t1 t2 ; assert false with _ -> ( )
|
let ( ) = let t1 = unknown ( ) in let t2 = emp in unify t1 t2
|
let ( ) = let t1 = unknown ( ) in let t2 = push emp 1 in unify t1 t2
|
let ( ) = let t1 = push ( unknown ( ) ) 1 in let t2 = push emp 1 in unify t1 t2
|
let ( ) = let t1 = pop ( unknown ( ) ) in let t2 = pop ( push emp 1 ) in unify t1 t2
|
let ( ) = let t1 = pop ( unknown ( ) ) in let t2 = pop ( push ( pop ( unknown ( ) ) ) 1 ) in unify t1 t2 ; unify t2 t1
|
let ( ) = let t1 = pop ( push ( unknown ( ) ) 1 ) in Printf . printf " t1 is " ; print t1 ; Printf . printf " rep t1 is " ; print ( rep t1 )
|
let ( ) = let t1 = pop ( pop ( push ( unknown ( ) ) 1 ) ) in Printf . printf " t1 is " ; print t1 ; Printf . printf " rep t1 is " ; print ( rep t1 )
|
let ( ) = let k = push emp 1 in let t1 = pop k in let t2 = pop ( push k 2 ) in Printf . printf " t2 is " ; print t2 ; Printf . printf " rep of t2 is " ; print t2 ; Printf . printf " t1 is " ; print t1 ; Printf . printf " rep t1 is " ; print ( rep t1 ) ; Printf . printf " now t2 is " ; print t2
|
module Core ( Req : Preface_specs . Traversable . WITH_TRAVERSE ) = Req
|
module Core_over_applicative ( A : Preface_specs . APPLICATIVE ) ( Req : Preface_specs . Traversable . WITH_TRAVERSE with type ' a t = ' a A . t ) = Core ( Req )
|
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 )
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.