text
stringlengths
12
786k
module Mtf_table : sig type ' a t val create : unit -> ' a t type index = int val not_found : index val encode : ' a t -> if_absent ( : unit -> ' a ) -> string -> index * ' a val decode : ' a t -> if_absent ( : unit -> string * ' a ) -> index -> string * ' a val last : ' a...
module Location = struct type t = { filename : string ; line : int ; start_char : int ; end_char : int ; defname : string ; } let to_string { filename ; line ; start_char ; end_char ; defname } = Printf . sprintf " % s @% s :% d :% d -% d " defname filename line start_char e...
type state = unit Mtf_table . t Mtf_table . t
module Writer = struct open Buf . Write type t = state let create ( ) = Mtf_table . create ( ) let max_length = 4 * 1024 let put_location ( file_mtf : t ) b ( id , locs ) = let total_size_max = List . fold_left ( fun sz ( loc : Location . t ) -> sz + 6 + ( String . len...
module Reader = struct open Buf . Read type t = state let create ( ) = Mtf_table . create ( ) let get_location ( file_mtf : t ) b = let id = Int64 . to_int ( get_64 b ) in let nlocs = get_8 b in let locs = List . init nlocs ( fun _ -> let low = get_32 b in let high = get_16 b in le...
type ' payload entry = | End_of_list | Base_addressx of Address_index . t | Startx_endx of { start_inclusive : Address_index . t ; end_exclusive : Address_index . t ; payload : ' payload } | Startx_length of { start_inclusive : Address_index . t ; length : Targetint . t ; payload ...
module type S = sig type payload type nonrec entry = payload entry type t val create : entry -> start_of_code_symbol : Asm_symbol . t -> t val section : Asm_section . dwarf_section include Dwarf_emittable . S with type t := t end
module Make ( P : sig module Payload : Dwarf_emittable . S val code_for_entry_kind : _ entry -> int val section : Asm_section . dwarf_section struct module Payload = P . Payload type payload = Payload . t type nonrec entry = Payload . t entry type t = { entry : entry ; start_of_code_symbol :...
module Make ( Location_or_range_list : sig include Dwarf_emittable . S val section : Asm_section . dwarf_section struct type one_list = { list : Location_or_range_list . t ; offset_from_first_list : Dwarf_int . t ; label : Asm_label . t } type t = { base_addr : Asm_label . t ; mutable ...
let mode _ = true end
let level = ref 1
let classic_display = ref false
let internal_display = ref None
let failsafe_display = lazy ( Display . create ~ mode ` : Classic ~ log_level :! level ( ) )
let ( !- ) r = match ! r with | None -> !* failsafe_display | Some x -> x
let init log_file = let mode = if ! classic_display || !* My_unix . is_degraded || ! level <= 0 || not ( My_unix . stdout_isatty ( ) ) then ` Classic else ` Sophisticated in internal_display := Some ( Display . create ~ mode ? log_file ~ log_level :! level ( ) )
let raw_dprintf log_level = Display . dprintf ~ log_level !- internal_display
let dprintf log_level fmt = raw_dprintf log_level ( " [ @< 2 " >^^ fmt " ] . " ) ^^@@
let eprintf fmt = dprintf ( - 1 ) fmt
let update ( ) = Display . update !- internal_display
let event ? pretend x = Display . event !- internal_display ? pretend x
let display x = Display . display !- internal_display x
let finish ? how ( ) = match ! internal_display with | None -> ( ) | Some d -> Display . finish ? how d
let chan = ref Pervasives . stdout
let desired_verbosity = ref normal
let init_logger file verbosity = chan := open_out_gen [ Open_creat ; Open_append ] 0o666 file ; desired_verbosity := verbosity
let fin_logger ( ) = close_out ! chan
let flush ( ) = flush ! chan
let logf format = timeprintf ! chan format
let vlogf verbosity format = timeprintf ~ ignore ( :! desired_verbosity > verbosity ) ! chan format
type t = Lident of string | Ldot of t * string | Lapply of t * t
let rec flat accu = function Lident s -> s :: accu | Ldot ( lid , s ) -> flat ( s :: accu ) lid | Lapply ( _ , _ ) -> Misc . fatal_error " Longident . flat "
let flatten lid = flat [ ] lid
let last = function Lident s -> s | Ldot ( _ , s ) -> s | Lapply ( _ , _ ) -> Misc . fatal_error " Longident . last "
let rec split_at_dots s pos = try let dot = String . index_from s pos ' . ' in String . sub s pos ( dot - pos ) :: split_at_dots s ( dot + 1 ) with Not_found -> [ String . sub s pos ( String . length s - pos ) ]
let unflatten l = match l with | [ ] -> None | hd :: tl -> Some ( List . fold_left ( fun p s -> Ldot ( p , s ) ) ( Lident hd ) tl )
let parse s = match unflatten ( split_at_dots s 0 ) with | None -> Lident " " | Some v -> v
type ' a ref = { mutable contents : ' a }
let failwith s = raise ( Failure s )
let invalid_arg s = raise ( Invalid_argument s )
module type OrderedType = sig type t val compare : t -> t -> int end
module Make ( Ord : OrderedType ) = struct type key = Ord . t type ' a t = | Empty | Node of { l : ' a t ; v : key ; d : ' a ; r : ' a t ; h : int } let [ @ inline never ] bal _ _ _ _ = assert false let [ @ inline never ] min_binding_opt _ = assert false let [ @ ...
let ( ) = register_named_value " Pervasives . array_bound_error " ( Invalid_argument " index out of bounds " )
let failwith s = raise ( Failure s )
let invalid_arg s = raise ( Invalid_argument s )
let min x y = if x <= y then x else y
let max x y = if x >= y then x else y
let abs x = if x >= 0 then x else - x
let lnot x = x lxor - 1
let max_int = - 1 lsr 1
let min_int = max_int + 1 [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ] [ @@ noalloc ] [ @@ unb...
let infinity = float_of_bits 0x7F_F0_00_00_00_00_00_00L
let neg_infinity = float_of_bits 0xFF_F0_00_00_00_00_00_00L
let nan = float_of_bits 0x7F_F8_00_00_00_00_00_01L
let max_float = float_of_bits 0x7F_EF_FF_FF_FF_FF_FF_FFL
let min_float = float_of_bits 0x00_10_00_00_00_00_00_00L
let epsilon_float = float_of_bits 0x3C_B0_00_00_00_00_00_00L
type fpclass = | FP_normal | FP_subnormal | FP_zero | FP_infinite | FP_nan = " caml_classify_float " " caml_classify_float_unboxed " [ @@ noalloc ] = " caml_blit_string " [ @@ noalloc ] = " caml_blit_bytes " [ @@ noalloc ]
let ( ^ ) s1 s2 = let l1 = string_length s1 and l2 = string_length s2 in let s = bytes_create ( l1 + l2 ) in string_blit s1 0 s 0 l1 ; string_blit s2 0 s l1 l2 ; bytes_unsafe_to_string s
let char_of_int n = if n < 0 || n > 255 then invalid_arg " char_of_int " else unsafe_char_of_int n
type ' a ref = { mutable contents : ' a }
type ( ' a , ' b ) result = | Ok of ' a | Error of ' b
let string_of_bool b = if b then " true " else " false "
let bool_of_string = function | " true " -> true | " false " -> false | _ -> invalid_arg " bool_of_string "
let bool_of_string_opt = function | " true " -> Some true | " false " -> Some false | _ -> None
let string_of_int n = format_int " % d " n
let int_of_string_opt s = try Some ( int_of_string s ) with Failure _ -> None
let valid_float_lexem s = let l = string_length s in let rec loop i = if i >= l then s ^ " . " else match string_get s i with ' 0 ' . . ' 9 ' | ' ' - -> loop ( i + 1 ) | _ -> s in loop 0
let string_of_float f = valid_float_lexem ( format_float " . % 12g " f )
let float_of_string_opt s = try Some ( float_of_string s ) with Failure _ -> None
let rec ( @ ) l1 l2 = match l1 with [ ] -> l2 | hd :: tl -> hd :: ( tl @ l2 )
let stdin = open_descriptor_in 0
let stdout = open_descriptor_out 1
let stderr = open_descriptor_out 2
type open_flag = | Open_rdonly | Open_wronly | Open_append | Open_creat | Open_trunc | Open_excl | Open_binary | Open_text | Open_nonblock = " caml_ml_set_channel_name "
let open_out_gen mode perm name = let c = open_descriptor_out ( open_desc name mode perm ) in set_out_channel_name c name ; c
let open_out name = open_out_gen [ Open_wronly ; Open_creat ; Open_trunc ; Open_text ] 0o666 name
let open_out_bin name = open_out_gen [ Open_wronly ; Open_creat ; Open_trunc ; Open_binary ] 0o666 name = " caml_ml_out_channels_list "
let flush_all ( ) = let rec iter = function | [ ] -> ( ) | a :: l -> begin try flush a with Sys_error _ -> ( ) end ; iter l in iter ( out_channels_list ( ) ) = " caml_ml_output_bytes " = " caml_ml_output "
let output_bytes oc s = unsafe_output oc s 0 ( bytes_length s )
let output_string oc s = unsafe_output_string oc s 0 ( string_length s )
let output oc s ofs len = if ofs < 0 || len < 0 || ofs > bytes_length s - len then invalid_arg " output " else unsafe_output oc s ofs len
let output_substring oc s ofs len = if ofs < 0 || len < 0 || ofs > string_length s - len then invalid_arg " output_substring " else unsafe_output_string oc s ofs len = " caml_output_value "
let output_value chan v = marshal_to_channel chan v [ ]
let close_out oc = flush oc ; close_out_channel oc
let close_out_noerr oc = ( try flush oc with _ -> ( ) ) ; try close_out_channel oc with _ -> ( ) = " caml_ml_set_binary_mode " = " caml_ml_set_channel_name "
let open_in_gen mode perm name = let c = open_descriptor_in ( open_desc name mode perm ) in set_in_channel_name c name ; c
let open_in name = open_in_gen [ Open_rdonly ; Open_text ] 0 name
let open_in_bin name = open_in_gen [ Open_rdonly ; Open_binary ] 0 name = " caml_ml_input "
let input ic s ofs len = if ofs < 0 || len < 0 || ofs > bytes_length s - len then invalid_arg " input " else unsafe_input ic s ofs len
let rec unsafe_really_input ic s ofs len = if len <= 0 then ( ) else let r = unsafe_input ic s ofs len in if r = 0 then raise End_of_file else unsafe_really_input ic s ( ofs + r ) ( len - r )
let really_input ic s ofs len = if ofs < 0 || len < 0 || ofs > bytes_length s - len then invalid_arg " really_input " else unsafe_really_input ic s ofs len
let really_input_string ic len = let s = bytes_create len in really_input ic s 0 len ; bytes_unsafe_to_string s
let input_line chan = let rec build_result buf pos = function | [ ] -> buf | hd :: tl -> let len = bytes_length hd in bytes_blit hd 0 buf ( pos - len ) len ; build_result buf ( pos - len ) tl in let rec scan accu len = let n = input_scan_line chan in if n = 0 then match accu with | [ ] ...
let close_in_noerr ic = try close_in ic with _ -> ( ) = " caml_ml_set_binary_mode "
let print_char c = output_char stdout c
let print_string s = output_string stdout s
let print_bytes s = output_bytes stdout s
let print_int i = output_string stdout ( string_of_int i )
let print_float f = output_string stdout ( string_of_float f )