text stringlengths 12 786k |
|---|
module UInt16 : S with type t = private int = struct module B = struct type t = int let max_int = 65535 let add : t -> t -> t = fun x y -> ( x + y ) land max_int let sub : t -> t -> t = fun x y -> ( x - y ) land max_int let mul : t -> t -> t = fun x y -> ( x * y ) land max_int let d... |
module UInt32 : sig include S val of_int32 : int32 -> t val to_int32 : t -> int32 struct module B = struct type t external add : t -> t -> t = " integers_uint32_add " external sub : t -> t -> t = " integers_uint32_sub " external mul : t -> t -> t = " integers_uint32_mul " external div : t... |
module UInt64 : sig include S external of_uint32 : UInt32 . t -> t = " integers_uint64_of_uint32 " external to_uint32 : t -> UInt32 . t = " integers_uint32_of_uint64 " struct module B = struct type t external add : t -> t -> t = " integers_uint64_add " external sub : t -> t -> t = " in... |
let of_byte_size : int -> ( module S ) = function | 1 -> ( module UInt8 ) | 2 -> ( module UInt16 ) | 4 -> ( module UInt32 ) | 8 -> ( module UInt64 ) | _ -> invalid_arg " Unsigned . of_byte_size " |
module Size_t : S = ( val of_byte_size ( size_t_size ( ) ) ) |
module UShort : S = ( val of_byte_size ( ushort_size ( ) ) ) |
module UInt : S = ( val of_byte_size ( uint_size ( ) ) ) |
module ULong : S = ( val of_byte_size ( ulong_size ( ) ) ) |
module ULLong : S = ( val of_byte_size ( ulonglong_size ( ) ) ) |
module type Unsigned_intf = Unsigned . S |
module Extend ( Unsigned : Unsigned . S ) S ( M : sig val length : int end ) end : S with type t = Unsigned . t = struct assert ( M . length < Field . size_in_bits - 3 ) 3 let length_in_bits = M . length module T = struct include Sexpable . Of_stringable ( Unsigned ) Unsigned type t ... |
module UInt64 = struct module M = Extend ( Unsigned . UInt64 ) UInt64 ( struct let length = 64 end ) end [ %% versioned_binable module Stable = struct [ @@@ no_toplevel_latest_type ] no_toplevel_latest_type module V1 = struct type t = Unsigned . UInt64 . t let to_latest = Fn . id [ %% def... |
module UInt32 = struct module M = Extend ( Unsigned . UInt32 ) UInt32 ( struct let length = 32 end ) end [ %% versioned_binable module Stable = struct [ @@@ no_toplevel_latest_type ] no_toplevel_latest_type module V1 = struct type t = Unsigned . UInt32 . t let to_latest = Fn . id [ %% def... |
type mapper = { attribute : mapper -> T . attribute -> attribute ; attributes : mapper -> T . attribute list -> attribute list ; binding_op : mapper -> T . binding_op -> T . pattern -> binding_op ; case : mapper -> T . case -> case ; cases : mapper -> T . case list -> case list ; ... |
let string_is_prefix sub str = let sublen = String . length sub in String . length str >= sublen && String . sub str 0 sublen = sub |
let rec lident_of_path = function | Path . Pident id -> Longident . Lident ( Ident . name id ) | Path . Pdot ( p , s ) -> Longident . Ldot ( lident_of_path p , s ) | Path . Papply ( p1 , p2 ) -> Longident . Lapply ( lident_of_path p1 , lident_of_path p2 ) |
let map_loc sub { loc ; txt } = { loc = sub . location sub loc ; txt } |
let fresh_name s env = let rec aux i = let name = s ^ Int . to_string i in if Env . bound_value name env then aux ( i + 1 ) else name in aux 0 |
let rec extract_letop_patterns n pat = if n = 0 then pat , [ ] else begin match pat . pat_desc with | Tpat_tuple ( [ first ; rest ] ) -> let next , others = extract_letop_patterns ( n - 1 ) rest in first , next :: others | _ -> let rec anys n = if n = 0 then [ ] else { pat... |
let constant = function | Const_char c -> Pconst_char c | Const_string ( s , d ) -> Pconst_string ( s , d ) | Const_int i -> Pconst_integer ( Int . to_string i , None ) | Const_int32 i -> Pconst_integer ( Int32 . to_string i , Some ' l ' ) | Const_int64 i -> Pconst_integer ( ... |
let attribute sub a = { attr_name = map_loc sub a . attr_name ; attr_payload = a . attr_payload ; attr_loc = a . attr_loc } |
let attributes sub l = List . map ( sub . attribute sub ) l |
let structure sub str = List . map ( sub . structure_item sub ) str . str_items |
let open_description sub od = let loc = sub . location sub od . open_loc in let attrs = sub . attributes sub od . open_attributes in Opn . mk ~ loc ~ attrs ~ override : od . open_override ( snd od . open_expr ) |
let open_declaration sub od = let loc = sub . location sub od . open_loc in let attrs = sub . attributes sub od . open_attributes in Opn . mk ~ loc ~ attrs ~ override : od . open_override ( sub . module_expr sub od . open_expr ) |
let structure_item sub item = let loc = sub . location sub item . str_loc in let desc = match item . str_desc with Tstr_eval ( exp , attrs ) -> Pstr_eval ( sub . expr sub exp , attrs ) | Tstr_value ( rec_flag , list ) -> Pstr_value ( rec_flag , List . map ( sub . value_binding ... |
let value_description sub v = let loc = sub . location sub v . val_loc in let attrs = sub . attributes sub v . val_attributes in Val . mk ~ loc ~ attrs ~ prim : v . val_prim ( map_loc sub v . val_name ) ( sub . typ sub v . val_desc ) |
let module_binding sub mb = let loc = sub . location sub mb . mb_loc in let attrs = sub . attributes sub mb . mb_attributes in Mb . mk ~ loc ~ attrs ( map_loc sub mb . mb_name ) ( sub . module_expr sub mb . mb_expr ) |
let type_parameter sub ( ct , v ) = ( sub . typ sub ct , v ) |
let type_declaration sub decl = let loc = sub . location sub decl . typ_loc in let attrs = sub . attributes sub decl . typ_attributes in Type . mk ~ loc ~ attrs ~ params ( : List . map ( type_parameter sub ) decl . typ_params ) ~ cstrs ( : List . map ( fun ( ct1 , ct2 , loc ) ... |
let type_kind sub tk = match tk with | Ttype_abstract -> Ptype_abstract | Ttype_variant list -> Ptype_variant ( List . map ( sub . constructor_declaration sub ) list ) | Ttype_record list -> Ptype_record ( List . map ( sub . label_declaration sub ) list ) | Ttype_open -> Ptype_open |
let constructor_arguments sub = function | Cstr_tuple l -> Pcstr_tuple ( List . map ( sub . typ sub ) l ) | Cstr_record l -> Pcstr_record ( List . map ( sub . label_declaration sub ) l ) |
let constructor_declaration sub cd = let loc = sub . location sub cd . cd_loc in let attrs = sub . attributes sub cd . cd_attributes in Type . constructor ~ loc ~ attrs ~ args ( : constructor_arguments sub cd . cd_args ) ? res ( : Option . map ( sub . typ sub ) cd . cd_res ) ( m... |
let label_declaration sub ld = let loc = sub . location sub ld . ld_loc in let attrs = sub . attributes sub ld . ld_attributes in Type . field ~ loc ~ attrs ~ mut : ld . ld_mutable ( map_loc sub ld . ld_name ) ( sub . typ sub ld . ld_type ) |
let type_extension sub tyext = let attrs = sub . attributes sub tyext . tyext_attributes in Te . mk ~ attrs ~ params ( : List . map ( type_parameter sub ) tyext . tyext_params ) ~ priv : tyext . tyext_private ( map_loc sub tyext . tyext_txt ) ( List . map ( sub . extension_const... |
let type_exception sub tyexn = let attrs = sub . attributes sub tyexn . tyexn_attributes in Te . mk_exception ~ attrs ( sub . extension_constructor sub tyexn . tyexn_constructor ) |
let extension_constructor sub ext = let loc = sub . location sub ext . ext_loc in let attrs = sub . attributes sub ext . ext_attributes in Te . constructor ~ loc ~ attrs ( map_loc sub ext . ext_name ) ( match ext . ext_kind with | Text_decl ( args , ret ) -> Pext_decl ( constructor_ar... |
let pattern sub pat = let loc = sub . location sub pat . pat_loc in let attrs = sub . attributes sub pat . pat_attributes in let desc = match pat with { pat_extra [ = Tpat_unpack , loc , _attrs ] ; pat_desc = Tpat_any ; _ } -> Ppat_unpack { txt = None ; loc } | { pat_extra [ ... |
let exp_extra sub ( extra , loc , attrs ) sexp = let loc = sub . location sub loc in let attrs = sub . attributes sub attrs in let desc = match extra with Texp_coerce ( cty1 , cty2 ) -> Pexp_coerce ( sexp , Option . map ( sub . typ sub ) cty1 , sub . typ sub cty2 ) | Texp_const... |
let cases sub l = List . map ( sub . case sub ) l |
let case sub { c_lhs ; c_guard ; c_rhs } = { pc_lhs = sub . pat sub c_lhs ; pc_guard = Option . map ( sub . expr sub ) c_guard ; pc_rhs = sub . expr sub c_rhs ; } |
let value_binding sub vb = let loc = sub . location sub vb . vb_loc in let attrs = sub . attributes sub vb . vb_attributes in Vb . mk ~ loc ~ attrs ( sub . pat sub vb . vb_pat ) ( sub . expr sub vb . vb_expr ) |
let expression sub exp = let loc = sub . location sub exp . exp_loc in let attrs = sub . attributes sub exp . exp_attributes in let desc = match exp . exp_desc with Texp_ident ( _path , lid , _ ) -> Pexp_ident ( map_loc sub lid ) | Texp_constant cst -> Pexp_constant ( constant cst ) ... |
let binding_op sub bop pat = let pbop_op = bop . bop_op_name in let pbop_pat = sub . pat sub pat in let pbop_exp = sub . expr sub bop . bop_exp in let pbop_loc = bop . bop_loc in { pbop_op ; pbop_pat ; pbop_exp ; pbop_loc } |
let package_type sub pack = ( map_loc sub pack . pack_txt , List . map ( fun ( s , ct ) -> ( s , sub . typ sub ct ) ) pack . pack_fields ) |
let module_type_declaration sub mtd = let loc = sub . location sub mtd . mtd_loc in let attrs = sub . attributes sub mtd . mtd_attributes in Mtd . mk ~ loc ~ attrs ? typ ( : Option . map ( sub . module_type sub ) mtd . mtd_type ) ( map_loc sub mtd . mtd_name ) |
let signature sub sg = List . map ( sub . signature_item sub ) sg . sig_items |
let signature_item sub item = let loc = sub . location sub item . sig_loc in let desc = match item . sig_desc with Tsig_value v -> Psig_value ( sub . value_description sub v ) | Tsig_type ( rec_flag , list ) -> Psig_type ( rec_flag , List . map ( sub . type_declaration sub ) list ) ... |
let module_declaration sub md = let loc = sub . location sub md . md_loc in let attrs = sub . attributes sub md . md_attributes in Md . mk ~ loc ~ attrs ( map_loc sub md . md_name ) ( sub . module_type sub md . md_type ) |
let module_substitution sub ms = let loc = sub . location sub ms . ms_loc in let attrs = sub . attributes sub ms . ms_attributes in Ms . mk ~ loc ~ attrs ( map_loc sub ms . ms_name ) ( map_loc sub ms . ms_txt ) |
let include_infos f sub incl = let loc = sub . location sub incl . incl_loc in let attrs = sub . attributes sub incl . incl_attributes in Incl . mk ~ loc ~ attrs ( f sub incl . incl_mod ) |
let include_declaration sub = include_infos sub . module_expr sub |
let include_description sub = include_infos sub . module_type sub |
let class_infos f sub ci = let loc = sub . location sub ci . ci_loc in let attrs = sub . attributes sub ci . ci_attributes in Ci . mk ~ loc ~ attrs ~ virt : ci . ci_virt ~ params ( : List . map ( type_parameter sub ) ci . ci_params ) ( map_loc sub ci . ci_id_name ) ( f sub ci . ... |
let class_declaration sub = class_infos sub . class_expr sub |
let class_description sub = class_infos sub . class_type sub |
let class_type_declaration sub = class_infos sub . class_type sub |
let functor_parameter sub : functor_parameter -> Parsetree . functor_parameter = function | Unit -> Unit | Named ( _ , name , mtype ) -> Named ( name , sub . module_type sub mtype ) |
let module_type sub mty = let loc = sub . location sub mty . mty_loc in let attrs = sub . attributes sub mty . mty_attributes in let desc = match mty . mty_desc with Tmty_ident ( _path , lid ) -> Pmty_ident ( map_loc sub lid ) | Tmty_alias ( _path , lid ) -> Pmty_alias ( map_loc sub... |
let with_constraint sub ( _path , lid , cstr ) = match cstr with | Twith_type decl -> Pwith_type ( map_loc sub lid , sub . type_declaration sub decl ) | Twith_module ( _path , lid2 ) -> Pwith_module ( map_loc sub lid , map_loc sub lid2 ) | Twith_typesubst decl -> Pwith_typesubst ( ... |
let module_expr sub mexpr = let loc = sub . location sub mexpr . mod_loc in let attrs = sub . attributes sub mexpr . mod_attributes in match mexpr . mod_desc with Tmod_constraint ( m , _ , Tmodtype_implicit , _ ) -> sub . module_expr sub m | _ -> let desc = match mexpr . mod_desc with ... |
let class_expr sub cexpr = let loc = sub . location sub cexpr . cl_loc in let attrs = sub . attributes sub cexpr . cl_attributes in let desc = match cexpr . cl_desc with | Tcl_constraint ( { cl_desc = Tcl_ident ( _path , lid , tyl ) ; _ } , None , _ , _ , _ ) -> Pcl_const... |
let class_type sub ct = let loc = sub . location sub ct . cltyp_loc in let attrs = sub . attributes sub ct . cltyp_attributes in let desc = match ct . cltyp_desc with Tcty_signature csg -> Pcty_signature ( sub . class_signature sub csg ) | Tcty_constr ( _path , lid , list ) -> Pcty_const... |
let class_signature sub cs = { pcsig_self = sub . typ sub cs . csig_self ; pcsig_fields = List . map ( sub . class_type_field sub ) cs . csig_fields ; } |
let class_type_field sub ctf = let loc = sub . location sub ctf . ctf_loc in let attrs = sub . attributes sub ctf . ctf_attributes in let desc = match ctf . ctf_desc with Tctf_inherit ct -> Pctf_inherit ( sub . class_type sub ct ) | Tctf_val ( s , mut , virt , ct ) -> Pctf_val ( mkloc... |
let core_type sub ct = let loc = sub . location sub ct . ctyp_loc in let attrs = sub . attributes sub ct . ctyp_attributes in let desc = match ct . ctyp_desc with Ttyp_any -> Ptyp_any | Ttyp_var s -> Ptyp_var s | Ttyp_arrow ( label , ct1 , ct2 ) -> Ptyp_arrow ( label , sub . typ sub ct1... |
let class_structure sub cs = let rec remove_self = function | { pat_desc = Tpat_alias ( p , id , _s ) } when string_is_prefix " selfpat " - ( Ident . name id ) -> remove_self p | p -> p in { pcstr_self = sub . pat sub ( remove_self cs . cstr_self ) ; pcstr_fields = List . ... |
let row_field sub { rf_loc ; rf_desc ; rf_attributes ; } = let loc = sub . location sub rf_loc in let attrs = sub . attributes sub rf_attributes in let desc = match rf_desc with | Ttag ( label , bool , list ) -> Rtag ( label , bool , List . map ( sub . typ sub ) list ) | Tin... |
let object_field sub { of_loc ; of_desc ; of_attributes ; } = let loc = sub . location sub of_loc in let attrs = sub . attributes sub of_attributes in let desc = match of_desc with | OTtag ( label , ct ) -> Otag ( label , sub . typ sub ct ) | OTinherit ct -> Oinherit ( sub . typ ... |
let class_field sub cf = let loc = sub . location sub cf . cf_loc in let attrs = sub . attributes sub cf . cf_attributes in let desc = match cf . cf_desc with Tcf_inherit ( ovf , cl , super , _vals , _meths ) -> Pcf_inherit ( ovf , sub . class_expr sub cl , Option . map ( fun v ... |
let location _sub l = l |
let default_mapper = { attribute = attribute ; attributes = attributes ; binding_op = binding_op ; structure = structure ; structure_item = structure_item ; module_expr = module_expr ; signature = signature ; signature_item = signature_item ; module_type = module_type ; with_constraint = ... |
let untype_structure ( ? mapper = default_mapper ) structure = mapper . structure mapper structure |
let untype_signature ( ? mapper = default_mapper ) signature = mapper . signature mapper signature |
type info = { line : int ; col : int } |
type expr = Var of int * int | Abs of string * t | App of t * t |
type ctx = ( string * binding ) list |
let with_info t = { info = { line = 0 ; col = 0 } ; expr = t } |
let rec is_bound : ctx -> string -> bool = fun ctx x -> match ctx with | [ ] -> false | ( y , _ ) :: rest -> if x = y then true else is_bound rest x |
let rec fresh_name ctx x = if is_bound ctx x then fresh_name ctx ( x ^ " ' " ) else ( ( x , Name_bind ) :: ctx , x ) |
let rec index_to_name : ctx -> int -> string option = fun ctx n -> match ctx with | [ ] -> None | ( x , _ ) :: xs -> if n = 0 then Some x else index_to_name xs ( n - 1 ) |
let rec pp_term ctx { expr ; info } = match expr with | Abs ( name , term ) -> let ctx2 , name2 = fresh_name ctx name in Io . format " ( lambda ~ p . \ n \ t " [ name2 ] ; pp_term ctx term ; Io . format " ) " [ ] | App ( fn , arg ) -> Io . format " ( " ... |
let sample ( ) = with_info ( Abs ( " sample " , with_info ( App ( with_info ( Abs ( " f " , with_info ( Var ( 0 , 0 ) ) ) ) , with_info ( Var ( 0 , 1 ) ) ) ) ) ) |
let rec longident_of_path = function | Path . Pident ident -> Longident . Lident ( Ident . name ident ) | Pdot ( path , _mode , name ) | Pocamldot ( path , _mode , name , _ ) -> Ldot ( longident_of_path path , name ) | Papply ( path1 , path2 ) -> Lapply ( longident_o... |
module Type0 = struct open Type0 let rec type_desc ~ mode ? loc = function | Tvar None -> Type . none ? loc ( ) | Tvar ( Some name ) -> Type . var ? loc name | Ttuple typs -> Type . tuple ? loc ( List . map ~ f ( : type_expr ? loc ) typs ) | Tarrow ( typ1 , typ2 , explicit... |
let rec type_desc = function | Typedast . Ttyp_var name -> Parsetypes . Ptyp_var name | Ttyp_tuple typs -> Ptyp_tuple ( List . map ~ f : type_expr typs ) | Ttyp_arrow ( typ1 , typ2 , explicit , label ) -> Ptyp_arrow ( type_expr typ1 , type_expr typ2 , explicit , label ) | Ttyp_ct... |
let field_decl { Typedast . fld_ident ; fld_type ; fld_loc ; fld_fld = _ } = { Parsetypes . fld_ident = map_loc ~ f : Ident . name fld_ident ; fld_type = type_expr fld_type ; fld_loc } |
let ctor_args = function | Typedast . Tctor_tuple typs -> Parsetypes . Ctor_tuple ( List . map ~ f : type_expr typs ) | Tctor_record fld -> Ctor_record ( List . map ~ f : field_decl fld ) |
let ctor_decl { Typedast . ctor_ident ; ctor_args = args ; ctor_ret ; ctor_loc ; ctor_ctor = _ } = { Parsetypes . ctor_ident = map_loc ~ f : Ident . name ctor_ident ; ctor_args = ctor_args args ; ctor_ret = Option . map ~ f : type_expr ctor_ret ; ctor_loc } |
let type_decl_desc = function | Typedast . Tdec_abstract -> Parsetypes . Pdec_abstract | Tdec_alias typ -> Pdec_alias ( type_expr typ ) | Tdec_record fields -> Pdec_record ( List . map ~ f : field_decl fields ) | Tdec_variant ctors -> Pdec_variant ( List . map ~ f : ctor_decl ctors ) |... |
let type_decl { Typedast . tdec_ident ; tdec_params ; tdec_desc ; tdec_loc ; tdec_tdec = _ } = { Parsetypes . tdec_ident = map_loc ~ f : Ident . name tdec_ident ; tdec_params = List . map ~ f : type_expr tdec_params ; tdec_desc = type_decl_desc tdec_desc ; tdec_loc } |
let rec pattern_desc = function | Typedast . Tpat_any -> Parsetypes . Ppat_any | Tpat_variable str -> Ppat_variable ( map_loc ~ f : Ident . name str ) | Tpat_constraint ( p , typ ) -> Ppat_constraint ( pattern p , type_expr typ ) | Tpat_tuple ps -> Ppat_tuple ( List . map ~ f : pa... |
let rec expression_desc = function | Typedast . Texp_apply ( e , args ) -> Parsetypes . Pexp_apply ( expression e , List . filter_map args ~ f ( : fun ( explicit , label , e ) -> match explicit with | Explicit -> Some ( label , expression e ) | Implicit -> None ) ) | Texp_... |
let conv_type = function | Typedast . Ttconv_with ( mode , decl ) -> Parsetypes . Ptconv_with ( mode , type_decl decl ) | Ttconv_to typ -> Ptconv_to ( type_expr typ ) |
let rec signature_desc = function | Typedast . Tsig_value ( name , typ ) -> Parsetypes . Psig_value ( map_loc ~ f : Ident . name name , type_expr typ ) | Tsig_instance ( name , typ ) -> Psig_instance ( map_loc ~ f : Ident . name name , type_expr typ ) | Tsig_type decl -> Psig_... |
let rec statement_desc = function | Typedast . Tstmt_value ( p , e ) -> Parsetypes . Pstmt_value ( pattern p , expression e ) | Tstmt_instance ( name , e ) -> Pstmt_instance ( map_loc ~ f : Ident . name name , expression e ) | Tstmt_type decl -> Pstmt_type ( type_decl decl ) ... |
let vds = ref [ ] |
let references = Hashtbl . create 256 |
let unit fn = Filename . chop_extension ( Filename . basename fn ) |
let rec collect_export fn = function | Sig_value ( _ , { Types . val_loc ; _ } ) when not val_loc . Location . loc_ghost -> if unit fn = unit val_loc . Location . loc_start . Lexing . pos_fname then vds := val_loc :: ! vds | Sig_module ( _ , { Types . md_type = Mty_signatur... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.