text
stringlengths
12
786k
let buffer_add_char buf c = buffer_check_size buf 1 ; Bytes . set buf . bytes buf . ind c ; buf . ind <- buf . ind + 1
let buffer_add_string buf s = let str_len = String . length s in buffer_check_size buf str_len ; String . blit s 0 buf . bytes buf . ind str_len ; buf . ind <- buf . ind + str_len
let buffer_contents buf = Bytes . sub_string buf . bytes 0 buf . ind
let char_of_iconv iconv = match iconv with | Int_d | Int_pd | Int_sd | Int_Cd -> ' d ' | Int_i | Int_pi | Int_si | Int_Ci -> ' i ' | Int_x | Int_Cx -> ' x ' | Int_X | Int_CX -> ' X ' | Int_o | Int_Co -> ' o ' | Int_u | Int_Cu -> ' u '
let char_of_fconv ( ? cF = ' F ' ) fconv = match snd fconv with | Float_f -> ' f ' | Float_e -> ' e ' | Float_E -> ' E ' | Float_g -> ' g ' | Float_G -> ' G ' | Float_F -> cF | Float_h -> ' h ' | Float_H -> ' H '
let char_of_counter counter = match counter with | Line_counter -> ' l ' | Char_counter -> ' n ' | Token_counter -> ' N '
let bprint_char_set buf char_set = let rec print_start set = let is_alone c = let before , after = Char . ( chr ( code c - 1 ) , chr ( code c + 1 ) ) in is_in_char_set set c && not ( is_in_char_set set before && is_in_char_set set after ) in if is_alone ' ] ' then buffer_add_char b...
let bprint_padty buf padty = match padty with | Left -> buffer_add_char buf ' ' - | Right -> ( ) | Zeros -> buffer_add_char buf ' 0 '
let bprint_ignored_flag buf ign_flag = if ign_flag then buffer_add_char buf ' _ '
let bprint_pad_opt buf pad_opt = match pad_opt with | None -> ( ) | Some width -> buffer_add_string buf ( Int . to_string width )
let bprint_padding : type a b . buffer -> ( a , b ) padding -> unit = fun buf pad -> match pad with | No_padding -> ( ) | Lit_padding ( padty , n ) -> bprint_padty buf padty ; buffer_add_string buf ( Int . to_string n ) | Arg_padding padty -> bprint_padty buf padty ; buffer_add_ch...
let bprint_precision : type a b . buffer -> ( a , b ) precision -> unit = fun buf prec -> match prec with | No_precision -> ( ) | Lit_precision n -> buffer_add_char buf ' . ' ; buffer_add_string buf ( Int . to_string n ) | Arg_precision -> buffer_add_string buf " . " *
let bprint_iconv_flag buf iconv = match iconv with | Int_pd | Int_pi -> buffer_add_char buf ' ' + | Int_sd | Int_si -> buffer_add_char buf ' ' | Int_Cx | Int_CX | Int_Co | Int_Cd | Int_Ci | Int_Cu -> buffer_add_char buf ' ' # | Int_d | Int_i | Int_x | Int_X | Int_o | Int_u -> ( )
let bprint_int_fmt buf ign_flag iconv pad prec = buffer_add_char buf ' ' ; % bprint_ignored_flag buf ign_flag ; bprint_iconv_flag buf iconv ; bprint_padding buf pad ; bprint_precision buf prec ; buffer_add_char buf ( char_of_iconv iconv )
let bprint_altint_fmt buf ign_flag iconv pad prec c = buffer_add_char buf ' ' ; % bprint_ignored_flag buf ign_flag ; bprint_iconv_flag buf iconv ; bprint_padding buf pad ; bprint_precision buf prec ; buffer_add_char buf c ; buffer_add_char buf ( char_of_iconv iconv )
let bprint_fconv_flag buf fconv = match fst fconv with | Float_flag_p -> buffer_add_char buf ' ' + | Float_flag_s -> buffer_add_char buf ' ' | Float_flag_ -> ( )
let bprint_float_fmt buf ign_flag fconv pad prec = buffer_add_char buf ' ' ; % bprint_ignored_flag buf ign_flag ; bprint_fconv_flag buf fconv ; bprint_padding buf pad ; bprint_precision buf prec ; buffer_add_char buf ( char_of_fconv fconv )
let string_of_formatting_lit formatting_lit = match formatting_lit with | Close_box -> " ] " @ | Close_tag -> " } " @ | Break ( str , _ , _ ) -> str | FFlush -> " " @? | Force_newline -> " @\ n " | Flush_newline -> " . " @ | Magic_size ( str , _ ) -> str |...
let string_of_formatting_gen : type a b c d e f . ( a , b , c , d , e , f ) formatting_gen -> string = fun formatting_gen -> match formatting_gen with | Open_tag ( Format ( _ , str ) ) -> str | Open_box ( Format ( _ , str ) ) -> str
let bprint_char_literal buf chr = match chr with | ' ' % -> buffer_add_string buf " " %% | _ -> buffer_add_char buf chr
let bprint_string_literal buf str = for i = 0 to String . length str - 1 do bprint_char_literal buf str . [ i ] done
let rec bprint_fmtty : type a b c d e f g h i j k l . buffer -> ( a , b , c , d , e , f , g , h , i , j , k , l ) fmtty_rel -> unit = fun buf fmtty -> match fmtty with | Char_ty rest -> buffer_add_string buf " % c " ; bprint_fmtty buf rest | String_ty rest -> buffer_add_strin...
let rec int_of_custom_arity : type a b c . ( a , b , c ) custom_arity -> int = function | Custom_zero -> 0 | Custom_succ x -> 1 + int_of_custom_arity x
let bprint_fmt buf fmt = let rec fmtiter : type a b c d e f . ( a , b , c , d , e , f ) fmt -> bool -> unit = fun fmt ign_flag -> match fmt with | String ( pad , rest ) -> buffer_add_char buf ' ' ; % bprint_ignored_flag buf ign_flag ; bprint_padding buf pad ; buffer_add_char buf...
let string_of_fmt fmt = let buf = buffer_create 16 in bprint_fmt buf fmt ; buffer_contents buf
type ( _ , _ ) eq = Refl : ( ' a , ' a ) eq
let rec symm : type a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 . ( a1 , b1 , c1 , d1 , e1 , f1 , a2 , b2 , c2 , d2 , e2 , f2 ) fmtty_rel -> ( a2 , b2 , c2 , d2 , e2 , f2 , a1 , b1 , c1 , d1 , e1 , f1 ) fmtty_rel = function | Char_ty rest -> Char_ty ( symm rest ) ...
let rec fmtty_rel_det : type a1 b c d1 e1 f1 a2 d2 e2 f2 . ( a1 , b , c , d1 , e1 , f1 , a2 , b , c , d2 , e2 , f2 ) fmtty_rel -> ( ( f1 , f2 ) eq -> ( a1 , a2 ) eq ) * ( ( a1 , a2 ) eq -> ( f1 , f2 ) eq ) * ( ( e1 , e2 ) eq -> ( d1 , d2 ) ...
let rec fmtty_of_formatting_gen : type a b c d e f . ( a , b , c , d , e , f ) formatting_gen -> ( a , b , c , d , e , f ) fmtty = fun formatting_gen -> match formatting_gen with | Open_tag ( Format ( fmt , _ ) ) -> fmtty_of_fmt fmt | Open_box ( Format ( fmt , _ ) ...
let type_padding : type a b c d e f x y . ( x , y ) padding -> ( a , b , c , d , e , f ) fmtty -> ( a , b , c , d , e , f ) padding_fmtty_ebb = fun pad fmtty -> match pad , fmtty with | No_padding , _ -> Padding_fmtty_EBB ( No_padding , fmtty ) | Lit_padding ( pa...
let type_padprec : type a b c d e f x y z . ( x , y ) padding -> ( y , z ) precision -> ( a , b , c , d , e , f ) fmtty -> ( a , b , c , d , e , f ) padprec_fmtty_ebb = fun pad prec fmtty -> match prec , type_padding pad fmtty with | No_precision , Padding_fmtty_EBB ...
let rec type_format : type a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 . ( a1 , b1 , c1 , d1 , e1 , f1 ) fmt -> ( a2 , b2 , c2 , d2 , e2 , f2 ) fmtty -> ( a2 , b2 , c2 , d2 , e2 , f2 ) fmt = fun fmt fmtty -> match type_format_gen fmt fmtty with | Fmt_fmtty_EBB ( fmt ' , E...
let recast : type a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 . ( a1 , b1 , c1 , d1 , e1 , f1 ) fmt -> ( a1 , b1 , c1 , d1 , e1 , f1 , a2 , b2 , c2 , d2 , e2 , f2 ) fmtty_rel -> ( a2 , b2 , c2 , d2 , e2 , f2 ) fmt = fun fmt fmtty -> type_format fmt ( erase_rel ( ...
let fix_padding padty width str = let len = String . length str in let width , padty = ( abs width , if width < 0 then Left else padty ) in if width <= len then str else let res = Bytes . make width ( if padty = Zeros then ' 0 ' else ' ' ) in begin match padty with | Left -> String . ...
let fix_int_precision prec str = let prec = abs prec in let len = String . length str in match str . [ 0 ] with | ( ' ' + | ' ' - | ' ' ) as c when prec + 1 > len -> let res = Bytes . make ( prec + 1 ) ' 0 ' in Bytes . set res 0 c ; String . blit str 1 res ( ...
let string_to_caml_string str = let str = String . escaped str in let l = String . length str in let res = Bytes . make ( l + 2 ) ' " ' \ in String . unsafe_blit str 0 res 1 l ; Bytes . unsafe_to_string res
let format_of_iconv = function | Int_d | Int_Cd -> " % d " | Int_pd -> " %+ d " | Int_sd -> " % d " | Int_i | Int_Ci -> " % i " | Int_pi -> " %+ i " | Int_si -> " % i " | Int_x -> " % x " | Int_Cx -> " %# x " | Int_X -> " % X " | Int_CX -> " %# X " ...
let format_of_iconvL = function | Int_d | Int_Cd -> " % Ld " | Int_pd -> " %+ Ld " | Int_sd -> " % Ld " | Int_i | Int_Ci -> " % Li " | Int_pi -> " %+ Li " | Int_si -> " % Li " | Int_x -> " % Lx " | Int_Cx -> " %# Lx " | Int_X -> " % LX " | Int_CX -> " ...
let format_of_iconvl = function | Int_d | Int_Cd -> " % ld " | Int_pd -> " %+ ld " | Int_sd -> " % ld " | Int_i | Int_Ci -> " % li " | Int_pi -> " %+ li " | Int_si -> " % li " | Int_x -> " % lx " | Int_Cx -> " %# lx " | Int_X -> " % lX " | Int_CX -> " ...
let format_of_iconvn = function | Int_d | Int_Cd -> " % nd " | Int_pd -> " %+ nd " | Int_sd -> " % nd " | Int_i | Int_Ci -> " % ni " | Int_pi -> " %+ ni " | Int_si -> " % ni " | Int_x -> " % nx " | Int_Cx -> " %# nx " | Int_X -> " % nX " | Int_CX -> " ...
let format_of_fconv fconv prec = let prec = abs prec in let symb = char_of_fconv ~ cF ' : g ' fconv in let buf = buffer_create 16 in buffer_add_char buf ' ' ; % bprint_fconv_flag buf fconv ; buffer_add_char buf ' . ' ; buffer_add_string buf ( Int . to_string prec ) ; buffer_add_char ...
let transform_int_alt iconv s = match iconv with | Int_Cd | Int_Ci | Int_Cu -> let digits = let n = ref 0 in for i = 0 to String . length s - 1 do match String . unsafe_get s i with ' 0 ' . . ' 9 ' -> incr n | _ -> ( ) done ; ! n in let buf = Bytes . create ( String . len...
let convert_int iconv n = transform_int_alt iconv ( format_int ( format_of_iconv iconv ) n )
let convert_int32 iconv n = transform_int_alt iconv ( format_int32 ( format_of_iconvl iconv ) n )
let convert_nativeint iconv n = transform_int_alt iconv ( format_nativeint ( format_of_iconvn iconv ) n )
let convert_int64 iconv n = transform_int_alt iconv ( format_int64 ( format_of_iconvL iconv ) n )
let convert_float fconv prec x = match snd fconv with | Float_h | Float_H -> ( let sign = match fst fconv with | Float_flag_p -> ' ' + | Float_flag_s -> ' ' | _ -> ' ' - in let str = hexstring_of_float x prec sign in match snd fconv with Float_H -> String . uppercase_ascii str | _ -> ...
let format_caml_char c = let str = Char . escaped c in let l = String . length str in let res = Bytes . make ( l + 2 ) ' ' ' \ in String . unsafe_blit str 0 res 1 l ; Bytes . unsafe_to_string res
let string_of_fmtty fmtty = let buf = buffer_create 16 in bprint_fmtty buf fmtty ; buffer_contents buf
let rec make_printf : type a b c d e f . ( ( b , c ) acc -> f ) -> ( b , c ) acc -> ( a , b , c , d , e , f ) fmt -> a = fun k acc fmt -> match fmt with | Bool ( pad , rest ) -> make_padding k acc rest pad string_of_bool | Alpha rest -> fun f x -> make_printf k ( Acc_...
type padty = | Left | Right | Zeros
type int_conv = | Int_d | Int_pd | Int_sd | Int_i | Int_pi | Int_si | Int_x | Int_Cx | Int_X | Int_CX | Int_o | Int_Co | Int_u | Int_Cd | Int_Ci | Int_Cu
type float_flag_conv = | Float_flag_ | Float_flag_p | Float_flag_s
type float_kind_conv = | Float_f | Float_e | Float_E | Float_g | Float_G | Float_F | Float_h | Float_H | Float_CF
type float_conv = float_flag_conv * float_kind_conv
type counter = | Line_counter | Char_counter | Token_counter
type ( ' a , ' b ) padding = | No_padding : ( ' a , ' a ) padding | Lit_padding : padty * int -> ( ' a , ' a ) padding | Arg_padding : padty -> ( int -> ' a , ' a ) padding
type pad_option = int option
type ( ' a , ' b ) precision = | No_precision : ( ' a , ' a ) precision | Lit_precision : int -> ( ' a , ' a ) precision | Arg_precision : ( int -> ' a , ' a ) precision
type prec_option = int option
type ( ' a , ' b , ' c ) custom_arity = | Custom_zero : ( ' a , string , ' a ) custom_arity | Custom_succ : ( ' a , ' b , ' c ) custom_arity -> ( ' a , ' x -> ' b , ' x -> ' c ) custom_arity pad_option * ( ' d1 , ' q1 , ' d2 , ' q2 ) r...
type of the expected format parameter depends of where the ( . . . ) %% # Printf . printf " ( ) " %% - : ( unit , out_channel , unit , ' _a , ' _a , unit ) CamlinternalFormatBasics . format6 -> unit = < fun > # Printf . printf " ( ) %%% d " - : ( int -...
type block_type = | Pp_hbox | Pp_vbox | Pp_hvbox | Pp_hovbox | Pp_box | Pp_fits
type formatting_lit = | Close_box | Close_tag | Break of string * int * int | FFlush | Force_newline | Flush_newline | Magic_size of string * int | Escaped_at | Escaped_percent | Scan_indic of char
type ( ' a , ' b , ' c , ' d , ' e , ' f ) formatting_gen = | Open_tag : ( ' a , ' b , ' c , ' d , ' e , ' f ) format6 -> ( ' a , ' b , ' c , ' d , ' e , ' f ) formatting_gen | Open_box : ( ' a , ' b , ' c , ' d , ' ...
let rec erase_rel : type a b c d e f g h i j k l . ( a , b , c , d , e , f , g , h , i , j , k , l ) fmtty_rel -> ( a , b , c , d , e , f ) fmtty | Char_ty rest -> Char_ty ( erase_rel rest ) | String_ty rest -> String_ty ( erase_rel rest ) | Int_ty rest -> Int_t...
let rec concat_fmtty : type a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 g1 j1 g2 j2 . ( g1 , b1 , c1 , j1 , d1 , a1 , g2 , b2 , c2 , j2 , d2 , a2 ) fmtty_rel -> ( a1 , b1 , c1 , d1 , e1 , f1 , a2 , b2 , c2 , d2 , e2 , f2 ) fmtty_rel -> ( g1 , b1 , c1 , j1 , e1 ...
let rec concat_fmt : type a b c d e f g h . ( a , b , c , d , e , f ) fmt -> ( f , b , c , e , g , h ) fmt -> ( a , b , c , d , g , h ) fmt = | String ( pad , rest ) -> String ( pad , concat_fmt rest fmt2 ) | Caml_string ( pad , rest ) -> Caml_string...
type ' a t = ' a lazy_t
let raise_undefined = Obj . repr ( fun ( ) -> raise Undefined )
let force_lazy_block ( blk : ' arg lazy_t ) = let closure = ( Obj . obj ( Obj . field ( Obj . repr blk ) 0 ) : unit -> ' arg ) in Obj . set_field ( Obj . repr blk ) 0 raise_undefined ; try let result = closure ( ) in make_forward ( Obj . repr blk ) ( Obj . repr ...
let force_val_lazy_block ( blk : ' arg lazy_t ) = let closure = ( Obj . obj ( Obj . field ( Obj . repr blk ) 0 ) : unit -> ' arg ) in Obj . set_field ( Obj . repr blk ) 0 raise_undefined ; let result = closure ( ) in make_forward ( Obj . repr blk ) ( Obj . repr ...
let force ( lzv : ' arg lazy_t ) = let lzv = Sys . opaque_identity lzv in let x = Obj . repr lzv in let t = Obj . tag x in if t = Obj . forward_tag then ( Obj . obj ( Obj . field x 0 ) : ' arg ) else if t <> Obj . lazy_tag then ( Obj . obj x : ' arg ) else force_lazy_bloc...
let force_val ( lzv : ' arg lazy_t ) = let x = Obj . repr lzv in let t = Obj . tag x in if t = Obj . forward_tag then ( Obj . obj ( Obj . field x 0 ) : ' arg ) else if t <> Obj . lazy_tag then ( Obj . obj x : ' arg ) else force_val_lazy_block lzv
type shape = | Function | Lazy | Class | Module of shape array | Value of Obj . t
let rec init_mod_field modu i loc shape = let init = match shape with | Function -> let rec fn ( x : ' a ) = let fn ' : ' a -> ' b = Obj . obj ( Obj . field modu i ) in if fn == fn ' then raise ( Undefined_recursive_module loc ) else fn ' x in Obj . repr fn | Lazy -> let rec l ...
let [ @ inline never ] init_mod loc shape = match shape with | Module comps -> Obj . repr ( init_mod_block loc comps ) | _ -> failwith " CamlinternalMod . init_mod : not a module "
let rec update_mod_field modu i shape n = match shape with | Function | Lazy -> Obj . set_field modu i n | Value _ -> ( ) | Class -> assert ( Obj . tag n = 0 && Obj . size n = 4 ) ; let cl = Obj . field modu i in for j = 0 to 3 do Obj . set_field cl j ( Obj . field n j ) done...
let [ @ inline never ] update_mod shape o n = match shape with | Module comps -> update_mod_block comps o n | _ -> failwith " CamlinternalMod . update_mod : not a module "
let magic x = Sys . opaque_identity ( Obj . magic x )
let of_repr x = Sys . opaque_identity ( Obj . obj x )
let set_object_field ( arr : _ array ) field new_value = Array . unsafe_set ( Sys . opaque_identity arr ) field new_value
let get_object_field ( arr : _ array ) field = Array . unsafe_get ( Sys . opaque_identity arr ) field
let copy o = let o = ( of_repr ( dup ( repr o ) ) ) in set_id o
type params = { mutable compact_table : bool ; mutable copy_parent : bool ; mutable clean_when_copying : bool ; mutable retry_count : int ; mutable bucket_small_size : int }
let params = { compact_table = true ; copy_parent = true ; clean_when_copying = true ; retry_count = 3 ; bucket_small_size = 16 }
type item = DummyA | DummyB | DummyC of int
let _ = [ DummyA ; DummyB ; DummyC 0 ]
let dummy_item = ( magic ( ) : item )
type t = DummyA | DummyB | DummyC of int
let _ = [ DummyA ; DummyB ; DummyC 0 ]
type obj = t array
let public_method_label s : tag = let accu = ref 0 in for i = 0 to String . length s - 1 do accu := 223 * ! accu + Char . code s . [ i ] done ; accu := ! accu land ( 1 lsl 31 - 1 ) ; let tag = if ! accu > 0x3FFFFFFF then ! accu - ( 1 lsl 31 ) else ! accu in magic tag
module Vars = Map . Make ( struct type t = string let compare ( x : t ) y = compare x y end )
type vars = int Vars . t
module Meths = Map . Make ( struct type t = string let compare ( x : t ) y = compare x y end )
type meths = label Meths . t
module Labs = Map . Make ( struct type t = label let compare ( x : t ) y = compare x y end )
type labs = bool Labs . t
type table = { mutable size : int ; mutable methods : closure array ; mutable methods_by_name : meths ; mutable methods_by_label : labs ; mutable previous_states : ( meths * labs * ( label * item ) list * vars * label list * string list ) list ; mutable hidden_meths : ( label * item ...