text stringlengths 0 601k |
|---|
type raw_backtrace unit -> raw_backtrace = " caml_get_exception_raw_backtrace " = " % raise_with_backtrace " |
type backtrace_slot = | Known_location of { is_raise : bool ; filename : string ; line_number : int ; start_char : int ; end_char : int ; is_inline : bool ; } | Unknown_location of { is_raise : bool } |
let _ = [ Known_location { is_raise = false ; filename = " " ; line_number = 0 ; start_char = 0 ; end_char = 0 ; is_inline = false } ; Unknown_location { is_raise = false } ] raw_backtrace_slot -> backtrace_slot = " caml_convert_raw_backtrace_slot " raw_backtrace -> backtrace_slot array = " caml_convert_raw_backtrace " |
let convert_raw_backtrace bt = try Some ( convert_raw_backtrace bt ) with Failure _ -> None |
let format_backtrace_slot pos slot = let info is_raise = if is_raise then if pos = 0 then " Raised at " else " Re - raised at " else if pos = 0 then " Raised by primitive operation at " else " Called from " in match slot with | Unknown_location l -> if l . is_raise then None else Some ( sprintf " % s unknown location "... |
let print_exception_backtrace outchan backtrace = match backtrace with | None -> fprintf outchan " ( Program not linked with - g , cannot print stack backtrace ) \ n " | Some a -> for i = 0 to Array . length a - 1 do match format_backtrace_slot i a . ( i ) with | None -> ( ) | Some str -> fprintf outchan " % s \ n " st... |
let print_raw_backtrace outchan raw_backtrace = print_exception_backtrace outchan ( convert_raw_backtrace raw_backtrace ) |
let print_backtrace outchan = print_raw_backtrace outchan ( get_raw_backtrace ( ) ) |
let backtrace_to_string backtrace = match backtrace with | None -> " ( Program not linked with - g , cannot print stack backtrace ) \ n " | Some a -> let b = Buffer . create 1024 in for i = 0 to Array . length a - 1 do match format_backtrace_slot i a . ( i ) with | None -> ( ) | Some str -> bprintf b " % s \ n " str do... |
let raw_backtrace_to_string raw_backtrace = backtrace_to_string ( convert_raw_backtrace raw_backtrace ) |
let backtrace_slot_is_raise = function | Known_location l -> l . is_raise | Unknown_location l -> l . is_raise |
let backtrace_slot_is_inline = function | Known_location l -> l . is_inline | Unknown_location _ -> false |
type location = { filename : string ; line_number : int ; start_char : int ; end_char : int ; } |
let backtrace_slot_location = function | Unknown_location _ -> None | Known_location l -> Some { filename = l . filename ; line_number = l . line_number ; start_char = l . start_char ; end_char = l . end_char ; } |
let backtrace_slots raw_backtrace = match convert_raw_backtrace raw_backtrace with | None -> None | Some backtrace -> let usable_slot = function | Unknown_location _ -> false | Known_location _ -> true in let rec exists_usable = function | ( - 1 ) -> false | i -> usable_slot backtrace . ( i ) || exists_usable ( i - 1 )... |
module Slot = struct type t = backtrace_slot let format = format_backtrace_slot let is_raise = backtrace_slot_is_raise let is_inline = backtrace_slot_is_inline let location = backtrace_slot_location end raw_backtrace -> int = " caml_raw_backtrace_length " [ @@ noalloc ] raw_backtrace -> int -> raw_backtrace_slot = " ca... |
let get_backtrace ( ) = raw_backtrace_to_string ( get_raw_backtrace ( ) ) |
let register_printer fn = printers := fn :: ! printers |
let exn_slot x = let x = Obj . repr x in if Obj . tag x = 0 then Obj . field x 0 else x |
let exn_slot_id x = let slot = exn_slot x in ( Obj . obj ( Obj . field slot 1 ) : int ) |
let exn_slot_name x = let slot = exn_slot x in ( Obj . obj ( Obj . field slot 0 ) : string ) |
let uncaught_exception_handler = ref None |
let set_uncaught_exception_handler fn = uncaught_exception_handler := Some fn |
let empty_backtrace : raw_backtrace = Obj . obj ( Obj . new_block Obj . abstract_tag 0 ) |
let try_get_raw_backtrace ( ) = try get_raw_backtrace ( ) with _ -> empty_backtrace |
let handle_uncaught_exception ' exn debugger_in_use = try let raw_backtrace = if debugger_in_use then empty_backtrace else try_get_raw_backtrace ( ) in ( try Stdlib . do_at_exit ( ) with _ -> ( ) ) ; match ! uncaught_exception_handler with | None -> eprintf " Fatal error : exception % s \ n " ( to_string exn ) ; print_... |
let handle_uncaught_exception exn debugger_in_use = try handle_uncaught_exception ' exn debugger_in_use with _ -> ( ) = " caml_register_named_value " |
let ( ) = register_named_value " Printexc . handle_uncaught_exception " handle_uncaught_exception |
= " caml_format_float " = " caml_format_int " = " caml_int32_format " = " caml_nativeint_format " = " caml_int64_format " |
module Sformat = struct type index ; ; external unsafe_index_of_int : int -> index = " % identity " ; ; let index_of_int i = if i >= 0 then unsafe_index_of_int i else failwith ( " Sformat . index_of_int : negative argument " ^ string_of_int i ) ; ; external int_of_index : index -> int = " % identity " ; ; let add_int_i... |
let bad_conversion sfmt i c = invalid_arg ( " Printf : bad conversion " % ^ String . make 1 c ^ " , at char number " ^ string_of_int i ^ " in format string ` ` " ^ sfmt ^ " ' ' " ) ; ; |
let bad_conversion_format fmt i c = bad_conversion ( Sformat . to_string fmt ) i c ; ; |
let incomplete_format fmt = invalid_arg ( " Printf : premature end of format string ` ` " ^ Sformat . to_string fmt ^ " ' ' " ) ; ; |
let parse_string_conversion sfmt = let rec parse neg i = if i >= String . length sfmt then ( 0 , neg ) else match String . unsafe_get sfmt i with | ' 1 ' . . ' 9 ' -> ( int_of_string ( String . sub sfmt i ( String . length sfmt - i - 1 ) ) , neg ) | ' ' - -> parse true ( succ i ) | _ -> parse neg ( succ i ) in try pars... |
let pad_string pad_char p neg s i len = if p = len && i = 0 then s else if p <= len then String . sub s i len else let res = String . make p pad_char in if neg then String . blit s i res 0 len else String . blit s i res ( p - len ) len ; res |
let format_string sfmt s = let ( p , neg ) = parse_string_conversion sfmt in pad_string ' ' p neg s 0 ( String . length s ) ; ; |
let extract_format fmt start stop widths = let skip_positional_spec start = match Sformat . unsafe_get fmt start with | ' 0 ' . . ' 9 ' -> let rec skip_int_litteral i = match Sformat . unsafe_get fmt i with | ' 0 ' . . ' 9 ' -> skip_int_litteral ( succ i ) | ' ' $ -> succ i | _ -> start in skip_int_litteral ( succ star... |
let extract_format_int conv fmt start stop widths = let sfmt = extract_format fmt start stop widths in match conv with | ' n ' | ' N ' -> sfmt . [ String . length sfmt - 1 ] <- ' u ' ; sfmt | _ -> sfmt ; ; |
let sub_format incomplete_format bad_conversion_format conv fmt i = let len = Sformat . length fmt in let rec sub_fmt c i = let close = if c = ' ( ' then ' ) ' else ' } ' in let rec sub j = if j >= len then incomplete_format fmt else match Sformat . get fmt j with | ' ' % -> sub_sub ( succ j ) | _ -> sub ( succ j ) and... |
let sub_format_for_printf conv = sub_format incomplete_format bad_conversion_format conv ; ; |
let iter_on_format_args fmt add_conv add_char = let lim = Sformat . length fmt - 1 in let rec scan_flags skip i = if i > lim then incomplete_format fmt else match Sformat . unsafe_get fmt i with | ' ' * -> scan_flags skip ( add_conv skip i ' i ' ) | ' ' # | ' ' - | ' ' | ' ' + -> scan_flags skip ( succ i ) | ' _ ' -> s... |
let summarize_format_type fmt = let len = Sformat . length fmt in let b = Buffer . create len in let add_char i c = Buffer . add_char b c ; succ i in let add_conv skip i c = if skip then Buffer . add_string b " % _ " else Buffer . add_char b ' ' ; % add_char i c in iter_on_format_args fmt add_conv add_char ; Buffer . c... |
module Ac = struct type ac = { mutable ac_rglr : int ; mutable ac_skip : int ; mutable ac_rdrs : int ; } end ; ; |
let ac_of_format fmt = let ac = { ac_rglr = 0 ; ac_skip = 0 ; ac_rdrs = 0 ; } in let incr_ac skip c = let inc = if c = ' a ' then 2 else 1 in if c = ' r ' then ac . ac_rdrs <- ac . ac_rdrs + 1 ; if skip then ac . ac_skip <- ac . ac_skip + inc else ac . ac_rglr <- ac . ac_rglr + inc in let add_conv skip i c = if c <> ' ... |
let count_arguments_of_format fmt = let ac = ac_of_format fmt in ac . ac_rglr + ac . ac_skip + ac . ac_rdrs ; ; |
let list_iter_i f l = let rec loop i = function | [ ] -> ( ) | [ x ] -> f i x | x :: xs -> f i x ; loop ( succ i ) xs in loop 0 l ; ; |
let kapr kpr fmt = match count_arguments_of_format fmt with | 0 -> kpr fmt [ ] || | 1 -> Obj . magic ( fun x -> let a = Array . make 1 ( Obj . repr 0 ) in a . ( 0 ) <- x ; kpr fmt a ) | 2 -> Obj . magic ( fun x y -> let a = Array . make 2 ( Obj . repr 0 ) in a . ( 0 ) <- x ; a . ( 1 ) <- y ; kpr fmt a ) | 3 -> Obj . ma... |
type positional_specification = | Spec_none | Spec_index of Sformat . index ; ; |
let scan_positional_spec fmt got_spec n i = match Sformat . unsafe_get fmt i with | ' 0 ' . . ' 9 ' as d -> let rec get_int_litteral accu j = match Sformat . unsafe_get fmt j with | ' 0 ' . . ' 9 ' as d -> get_int_litteral ( 10 * accu + ( int_of_char d - 48 ) ) ( succ j ) | ' ' $ -> if accu = 0 then failwith " printf :... |
let next_index spec n = match spec with | Spec_none -> Sformat . succ_index n | Spec_index _ -> n ; ; |
let get_index spec n = match spec with | Spec_none -> n | Spec_index p -> p ; ; |
let scan_format fmt args n pos cont_s cont_a cont_t cont_f cont_m = let get_arg spec n = Obj . magic ( args . ( Sformat . int_of_index ( get_index spec n ) ) ) in let rec scan_positional n widths i = let got_spec spec i = scan_flags spec n widths i in scan_positional_spec fmt got_spec n i and scan_flags spec n widths i... |
let mkprintf to_s get_out outc outs flush k fmt = let out = get_out fmt in let rec pr k n fmt v = let len = Sformat . length fmt in let rec doprn n i = if i >= len then Obj . magic ( k out ) else match Sformat . unsafe_get fmt i with | ' ' % -> scan_format fmt v n i cont_s cont_a cont_t cont_f cont_m | c -> outc out c ... |
let kfprintf k oc = mkprintf false ( fun _ -> oc ) output_char output_string flush k ; ; |
let ifprintf oc = kapr ( fun _ -> Obj . magic ignore ) ; ; |
let fprintf oc = kfprintf ignore oc ; ; |
let printf fmt = fprintf stdout fmt ; ; |
let eprintf fmt = fprintf stderr fmt ; ; |
let kbprintf k b = mkprintf false ( fun _ -> b ) Buffer . add_char Buffer . add_string ignore k ; ; |
let bprintf b = kbprintf ignore b ; ; |
let get_buff fmt = let len = 2 * Sformat . length fmt in Buffer . create len ; ; |
let get_contents b = let s = Buffer . contents b in Buffer . clear b ; s ; ; |
let get_cont k b = k ( get_contents b ) ; ; |
let ksprintf k = mkprintf true get_buff Buffer . add_char Buffer . add_string ignore ( get_cont k ) ; ; |
let sprintf fmt = ksprintf ( fun s -> s ) fmt ; ; |
module CamlinternalPr = struct module Sformat = Sformat ; ; module Tformat = struct type ac = Ac . ac = { mutable ac_rglr : int ; mutable ac_skip : int ; mutable ac_rdrs : int ; } ; ; let ac_of_format = ac_of_format ; ; let sub_format = sub_format ; ; let summarize_format_type = summarize_format_type ; ; let scan_forma... |
module type S = sig class type c = object method m : int end module M : sig class type d = c end end ; ; |
module F ( X : S ) = X . M ; ; [ %% expect { | |
module type S = sig class type c = object method m : int end module M : sig class type d = c end end |
module F : functor ( X : S ) -> sig class type d = X . c end } ] ; ; | |
module M = struct module N = struct let x = 1 end end ; ; [ %% expect { | |
module M : sig module N : sig val x : int end end |
module M : sig module N : sig . . . end end } ] ; ; | |
module Test ( X : ( ( A ( -> B -> C ) -> D ) -> ( E -> F ) ) ) = struct end |
module Test : functor ( X : ( A -> ( B -> C ) -> D ) -> E -> F ) -> sig end } ] | |
module type LongFunctor1 = functor ( X : A ) ( ) ( _ : B ) ( ) -> C -> D -> sig end |
module type LongFunctor1 = functor ( X : A ) ( ) ( _ : B ) ( ) -> C -> D -> sig end } ] | |
module type LongFunctor2 = functor ( _ : A ) ( ) ( _ : B ) ( ) -> C -> D -> sig end |
module type LongFunctor2 = A -> functor ( ) ( _ : B ) ( ) -> C -> D -> sig end } ] | |
let instruction ppf = function | Klabel lbl -> fprintf ppf " L % i " : lbl | Kacc n -> fprintf ppf " \ tacc % i " n | Kenvacc n -> fprintf ppf " \ tenvacc % i " n | Kpush -> fprintf ppf " \ tpush " | Kpop n -> fprintf ppf " \ tpop % i " n | Kassign n -> fprintf ppf " \ tassign % i " n | Kpush_retaddr lbl -> fprintf ppf... |
let rec instruction_list ppf = function [ ] -> ( ) | Klabel lbl :: il -> fprintf ppf " L % i :% a " lbl instruction_list il | instr :: il -> fprintf ppf " % a @ % a " instruction instr instruction_list il |
let instrlist ppf il = fprintf ppf " [ @< v 0 >% a ] " @ instruction_list il |
let rec java_type ppf ( jt : java_type ) java_type = match jt with | ` Boolean -> fprintf ppf " boolean " | ` Byte -> fprintf ppf " byte " | ` Char -> fprintf ppf " char " | ` Double -> fprintf ppf " double " | ` Float -> fprintf ppf " float " | ` Int -> fprintf ppf " int " | ` Long -> fprintf ppf " long " | ` Short ->... |
let non_void_java_type ppf ( jt : non_void_java_type ) non_void_java_type = java_type ppf ( jt :> java_type ) java_type |
let array_type ppf ( jt : array_type ) array_type = java_type ppf ( jt :> java_type ) java_type |
let non_void_java_type_list ppf l = List . iter ( fun jt -> fprintf ppf " @ % a " non_void_java_type jt ) jt l |
let ellipsis ppf = function | true -> fprintf ppf " @ varargs " | false -> ( ) |
let proxy_kind ppf = function | Custom_class_loader -> fprintf ppf " loader " | System_class_loader -> fprintf ppf " system " | Runtime_class_loader -> fprintf ppf " runtime " |
let rec java_primitive ppf = function | Java_constructor ( cn , params , ellip ) ellip -> fprintf ppf " constructor @ % s % a % a " cn non_void_java_type_list params ellipsis ellip | Java_array ( jt , { jpad_total ; jpad_init } jpad_init ) jpad_init -> fprintf ppf " array @ % a @ % d @ % d " array_type jt jpad_total jp... |
let loop_inlining_info ppf = function | Some x -> fprintf ppf [ " inlining % d ] d " x | None -> fprintf ppf [ " no inlining ] inlining " |
let meth_kind ppf = function | Lambda . Self -> fprintf ppf " self " | Lambda . Public -> fprintf ppf " public " | Lambda . Cached -> fprintf ppf " cached " |
let const ppf = function | Lambda_const lsc -> Printlambda . structured_constant ppf lsc | Const_targetint i -> Targetint . print ppf i | Const_null _ -> fprintf ppf [ " @< 2 ( > null ) null ] " @ | Const_javastring s -> fprintf ppf [ " @< 2 ( > javastring @ % S ) S ] " @ s |
let rec jlambda ppf = function | Jvar id -> Ident . print ppf id | Jconst cst -> const ppf cst | Jdirect_apply ( { fl_class ; fl_method } , args , params , return , _ ) _ -> let repr_list ppf l = List . iter ( fun r -> fprintf ppf " @ % a " Printlambda . repr r ) r l in fprintf ppf [ " @< 2 ( > directapply @ % s @ % s ... |
let rec struct_const ppf = function | Const_base ( Const_int n ) -> fprintf ppf " % i " n | Const_base ( Const_char c ) -> fprintf ppf " % C " c | Const_base ( Const_string ( s , _ ) ) -> fprintf ppf " % S " s | Const_immstring s -> fprintf ppf " #% S " s | Const_base ( Const_float f ) -> fprintf ppf " % s " f | Const_... |
let array_kind = function | Pgenarray -> " gen " | Paddrarray -> " addr " | Pintarray -> " int " | Pfloatarray -> " float " |
let boxed_integer_name = function | Pnativeint -> " nativeint " | Pint32 -> " int32 " | Pint64 -> " int64 " |
let value_kind ppf = function | Pgenval -> ( ) | Pintval -> fprintf ppf " [ int ] " | Pfloatval -> fprintf ppf " [ float ] " | Pboxedintval bi -> fprintf ppf " [ % s ] " ( boxed_integer_name bi ) |
let return_kind ppf = function | Pgenval -> ( ) | Pintval -> fprintf ppf " : int @ " | Pfloatval -> fprintf ppf " : float @ " | Pboxedintval bi -> fprintf ppf " : % s @ " ( boxed_integer_name bi ) |
let field_kind = function | Pgenval -> " " * | Pintval -> " int " | Pfloatval -> " float " | Pboxedintval bi -> boxed_integer_name bi |
let print_boxed_integer_conversion ppf bi1 bi2 = fprintf ppf " % s_of_ % s " ( boxed_integer_name bi2 ) ( boxed_integer_name bi1 ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.