text stringlengths 12 786k |
|---|
module Key = struct type t = { tag : Dwarf_tag . t ; has_children : Child_determination . t ; attribute_specs : Dwarf_attributes . Attribute_specification . Sealed . Set . t } include Identifiable . Make ( struct type nonrec t = t let compare { tag = tag1 ; has_children = has_childre... |
type t = Abbreviations_table_entry . t Key . Map . t |
let create ( ) = Key . Map . empty |
let add t entry = let tag = Abbreviations_table_entry . tag entry in let has_children = Abbreviations_table_entry . has_children entry in let attribute_specs = Abbreviations_table_entry . attribute_specs entry in let key : Key . t = { tag ; has_children ; attribute_specs } in Key . Map . add k... |
let find t ~ tag ~ has_children ~ attribute_specs = let key : Key . t = { tag ; has_children ; attribute_specs } in match Key . Map . find key t with | exception Not_found -> None | entry -> Some ( Abbreviations_table_entry . abbreviation_code entry ) |
let size t = let ( + ) = Dwarf_int . add in Dwarf_value . size ( Dwarf_value . uleb128 Uint64 . zero ) + Key . Map . fold ( fun _key entry size -> size + Abbreviations_table_entry . size entry ) t ( Dwarf_int . zero ( ) ) |
let emit ~ asm_directives t = let module Asm_directives = ( val asm_directives : Asm_directives . S ) in Key . Map . iter ( fun _key entry -> Asm_directives . new_line ( ) ; Abbreviations_table_entry . emit ~ asm_directives entry ) t ; Dwarf_value . emit ~ asm_directives ( Dwarf_va... |
type t = { abbreviation_code : Abbreviation_code . t ; tag : Dwarf_tag . t ; has_children : Child_determination . t ; attribute_specs : Dwarf_attributes . Attribute_specification . Sealed . Set . t } |
let create ~ abbreviation_code ~ tag ~ has_children ~ attribute_specs = { abbreviation_code ; tag ; has_children ; attribute_specs } |
let size t = let ( + ) = Dwarf_int . add in Abbreviation_code . size t . abbreviation_code + Dwarf_tag . size t . tag + Child_determination . size t . has_children + AS . Set . fold ( fun attr_spec size -> Dwarf_int . add size ( AS . size attr_spec ) ) t . attribute_specs ( ... |
let emit ~ asm_directives t = Abbreviation_code . emit ~ asm_directives t . abbreviation_code ; Dwarf_tag . emit ~ asm_directives t . tag ; Child_determination . emit ~ asm_directives t . has_children ; AS . Set . iter ( fun spec -> AS . emit ~ asm_directives spec ) t . attribute_sp... |
let tag t = t . tag |
let has_children t = t . has_children |
let attribute_specs t = t . attribute_specs |
let abbreviation_code t = t . abbreviation_code |
let rec ack ( x , y ) = if x = 0 then y + 1 else if y = 0 then ack ( x - 1 , 1 ) else ack ( x - 1 , ack ( x , y - 1 ) ) |
let rec ack_cps ( x , y , cnt ) = if x = 0 then cnt ( y + 1 ) else if y = 0 then ack_cps ( x - 1 , 1 , cnt ) else ack_cps ( x , y - 1 , fun a -> ack_cps ( x - 1 , a , cnt ) ) |
let ack_2 ( x , y ) = ack_cps ( x , y , fun x -> x ) |
let rec ack_cps_dfc ( x , y , cnt ) = if x = 0 then apply_cnt ( cnt , y + 1 ) else if y = 0 then ack_cps_dfc ( x - 1 , 1 , cnt ) else ack_cps_dfc ( x , y - 1 , x :: cnt ) | ( [ ] , x ) -> x | ( x :: cnt , a ) -> ack_cps_dfc ( x - 1 , a , cnt ) |
let ack_3 ( x , y ) = ack_cps_dfc ( x , y , [ ] ) |
type state = ACK of int * int * ( int list ) | APP of ( int list ) * int |
let rec string_of_int_list_aux = function | [ ] -> " " | [ t ] -> ( string_of_int t ) | t :: rest -> ( string_of_int t ) ^ " , " ^ ( string_of_int_list_aux rest ) |
let string_of_int_list l = " [ " ^ ( string_of_int_list_aux l ) ^ " ] " |
let print_state n = function | APP ( cnt , m ) -> print_string ( ( string_of_int n ) ^ " " | ACK ( x , y , cnt ) -> print_string ( ( string_of_int n ) ^ " " |
let step = function | ACK ( 0 , y , cnt ) -> APP ( cnt , y + 1 ) | ACK ( x , 0 , cnt ) -> ACK ( x - 1 , 1 , cnt ) | ACK ( x , y , cnt ) -> ACK ( x , y - 1 , x :: cnt ) | APP ( x :: cnt , a ) -> ACK ( x - 1 , a , cnt ) | s -> s |
let rec driver n state = let _ = print_state n state in match state with | APP ( [ ] , v ) -> v | s -> driver ( n + 1 ) ( step s ) |
let ack_4 ( x , y ) = driver 0 ( ACK ( x , y , [ ] ) ) |
type code = out_channel -> Environments . t -> Result . t * Environments . t |
type t = { name : string ; body : code ; mutable hook : code option } |
let name a = a . name |
let action_name = Variables . make ( " action_name " , " Name of the current action " ) |
let make n c = { name = n ; body = c ; hook = None } |
let update action code = { action with body = code } |
let compare a1 a2 = String . compare a1 . name a2 . name |
let ( actions : ( string , t ) Hashtbl . t ) = Hashtbl . create 10 |
let register action = Hashtbl . add actions action . name action |
let get_registered_actions ( ) = let f _name action acc = action :: acc in let unsorted_actions = Hashtbl . fold f actions [ ] in List . sort compare unsorted_actions |
let lookup name = try Some ( Hashtbl . find actions name ) with Not_found -> None |
let set_hook name hook = let action = ( Hashtbl . find actions name ) in action . hook <- Some hook |
let clear_hook name = let action = ( Hashtbl . find actions name ) in action . hook <- None |
let clear_all_hooks ( ) = let f _name action = action . hook <- None in Hashtbl . iter f actions |
let run log env action = let code = match action . hook with | None -> action . body | Some code -> code in let env = Environments . add action_name action . name env in code log env |
module ActionSet = Set . Make ( struct type nonrec t = t let compare = compare end ) |
let _ = Variables . register_variable action_name |
let skip_with_reason reason = let code _log env = let result = Result . skip_with_reason reason in ( result , env ) in Actions . make " skip " code |
let pass_or_skip test pass_reason skip_reason _log env = let open Result in let result = if test then pass_with_reason pass_reason else skip_with_reason skip_reason in ( result , env ) |
let mkreason what commandline exitcode = Printf . sprintf " % s : command \ n % s \ nfailed with exit code % d " what commandline exitcode |
let testfile env = match Environments . lookup Builtin_variables . test_file env with | None -> assert false | Some t -> t |
let test_source_directory env = Environments . safe_lookup Builtin_variables . test_source_directory env |
let test_build_directory env = Environments . safe_lookup Builtin_variables . test_build_directory env |
let test_build_directory_prefix env = Environments . safe_lookup Builtin_variables . test_build_directory_prefix env |
let words_of_variable env variable = String . words ( Environments . safe_lookup variable env ) |
let exit_status_of_variable env variable = try int_of_string ( Environments . safe_lookup variable env ) with _ -> 0 |
let files env = words_of_variable env Builtin_variables . files |
let setup_symlinks test_source_directory build_directory files = let symlink filename = let src = Filename . concat test_source_directory filename in let dst = Filename . concat build_directory filename in let ( ) = if Sys . file_exists dst then if Sys . win32 && Sys . is_directory dst then Sys . ... |
let setup_build_env add_testfile additional_files ( _log : out_channel ) env = let build_dir = ( test_build_directory env ) in let some_files = additional_files @ ( files env ) in let files = if add_testfile then ( testfile env ) :: some_files else some_files in setup_symlinks ( test_source_di... |
let setup_simple_build_env add_testfile additional_files log env = let build_env = Environments . add Builtin_variables . test_build_directory ( test_build_directory_prefix env ) env in setup_build_env add_testfile additional_files log build_env |
let run_cmd ( ? environment [ ] ) =|| ( ? stdin_variable = Builtin_variables . stdin ) ( ? stdout_variable = Builtin_variables . stdout ) ( ? stderr_variable = Builtin_variables . stderr ) ( ? append = false ) ( ? timeout = 0 ) log env original_cmd = let log_redirection s... |
let run ( log_message : string ) ( redirect_output : bool ) ( can_skip : bool ) ( prog_variable : Variables . t ) ( args_variable : Variables . t option ) ( log : out_channel ) ( env : Environments . t ) = match Environments . lookup prog_variable env with | None -> let msg... |
let run_program = run " Running program " true false Builtin_variables . program ( Some Builtin_variables . arguments ) |
let run_script log env = let response_file = Filename . temp_file " ocamltest " - " . response " in Printf . fprintf log " Script should write its response to % s \ n " %! response_file ; let scriptenv = Environments . add Builtin_variables . ocamltest_response response_file env in let ( ... |
let run_hook hook_name log input_env = Printf . fprintf log " Entering run_hook for hook % s \ n " %! hook_name ; let response_file = Filename . temp_file " ocamltest " - " . response " in Printf . fprintf log " Hook should write its response to % s \ n " %! response_file ; let hook... |
let check_output kind_of_output output_variable reference_variable log env = let to_int = function None -> 0 | Some s -> int_of_string s in let skip_lines = to_int ( Environments . lookup Builtin_variables . skip_header_lines env ) in let skip_bytes = to_int ( Environments . lookup Builtin_variables... |
let main ( ) = let top = opentk ( ) in let en1 = Entry . create top [ TextWidth 6 ; Relief Sunken ] in let lab1 = Label . create top [ Text " plus " ] in let en2 = Entry . create top [ TextWidth 6 ; Relief Sunken ] in let lab2 = Label . create top [ Text " " ] = in l... |
let _ = Printexc . catch main ( ) ; ; |
let norec = ref false |
let input_file file = let ic = try open_in file with _ -> failwith ( " input_file : " ^ file ) in let b = Buffer . create 1024 in let buf = String . create 1024 and len = ref 0 in while len := input ic buf 0 1024 ; ! len > 0 do Buffer . add_substring b buf 0 ! len done ; close_in i... |
module SMap = struct include Map . Make ( struct type t = string let compare = compare end ) let rec removes l m = match l with [ ] -> m | k :: l -> let m = try remove k m with Not_found -> m in removes l m end |
let rec labels_of_sty sty = match sty . ptyp_desc with Ptyp_arrow ( lab , _ , rem ) -> lab :: labels_of_sty rem | Ptyp_alias ( rem , _ ) -> labels_of_sty rem | _ -> [ ] |
let rec labels_of_cty cty = match cty . pcty_desc with Pcty_fun ( lab , _ , rem ) -> let ( labs , meths ) = labels_of_cty rem in ( lab :: labs , meths ) | Pcty_signature ( _ , fields ) -> ( [ ] , List . fold_left fields ~ init [ ] : ~ f : begin fun meths -> functio... |
let rec pattern_vars pat = match pat . ppat_desc with Ppat_var s -> [ s ] | Ppat_alias ( pat , s ) -> s :: pattern_vars pat | Ppat_tuple l | Ppat_array l -> List . concat ( List . map pattern_vars l ) | Ppat_construct ( _ , Some pat , _ ) | Ppat_variant ( _ , Some pat ) |... |
let pattern_name pat = match pat . ppat_desc with Ppat_var s -> Some s | Ppat_constraint ( { ppat_desc = Ppat_var s } , _ ) -> Some s | _ -> None |
let insertions = ref [ ] |
let add_insertion pos s = insertions := ( pos , s ) :: ! insertions |
let sort_insertions ( ) = List . sort ! insertions ~ cmp ( : fun ( pos1 , _ ) ( pos2 , _ ) -> pos1 - pos2 ) |
let is_space = function ' ' ' |\ t ' ' |\ n ' ' |\ r ' -> true | _ -> false |
let is_alphanum = function ' A ' . . ' Z ' ' | a ' . . ' z ' ' | _ ' ' |\ 192 ' . . ' \ 214 ' ' |\ 216 ' . . ' \ 246 ' | ' \ 248 ' . . ' \ 255 ' ' ' ' ' |\| 0 ' . . ' 9 ' -> true | _ -> false |
let rec insertion_point pos ~ text = let pos ' = ref ( pos - 1 ) in while is_space text . [ ! pos ' ] do decr pos ' done ; if text . [ ! pos ' ] = ' ( ' then insertion_point ! pos ' ~ text else if ! pos ' >= 5 && String . sub text ~ pos ( :! pos ' - 4 ) ~ l... |
let rec insertion_point2 pos ~ text = let pos ' = ref ( pos - 1 ) in while is_space text . [ ! pos ' ] do decr pos ' done ; if text . [ ! pos ' ] = ' ( ' then insertion_point2 ! pos ' ~ text else if ! pos ' >= 5 && String . sub text ~ pos ( :! pos ' - 4 ) ~... |
let rec insert_labels ~ labels ~ text expr = match labels , expr . pexp_desc with l :: labels , Pexp_function ( l ' , _ , [ pat , rem ] ) -> if l <> " " && l . [ 0 ] <> ' ' ? && l ' = " " then begin let start_c = pat . ppat_loc . Location . loc_start . Lex... |
let rec insert_labels_class ~ labels ~ text expr = match labels , expr . pcl_desc with l :: labels , Pcl_fun ( l ' , _ , pat , rem ) -> if l <> " " && l . [ 0 ] <> ' ' ? && l ' = " " then begin let start_c = pat . ppat_loc . Location . loc_start . Lexing . p... |
let rec insert_labels_type ~ labels ~ text ty = match labels , ty . ptyp_desc with l :: labels , Ptyp_arrow ( l ' , _ , rem ) -> if l <> " " && l . [ 0 ] <> ' ' ? && l ' = " " then begin let start_c = ty . ptyp_loc . Location . loc_start . Lexing . pos_cnum in... |
let rec insert_labels_app ~ labels ~ text args = match labels , args with l :: labels , ( l ' , arg ) :: args -> if l <> " " && l . [ 0 ] <> ' ' ? && l ' = " " then begin let pos0 = arg . pexp_loc . Location . loc_start . Lexing . pos_cnum in let pos = insertion_... |
let insert_labels_app ~ labels ~ text args = let labels , opt_labels = List . partition labels ~ f ( : fun l -> l = " " || l . [ 0 ] <> ' ' ) ? in let nopt_labels = List . map opt_labels ~ f ( : fun l -> String . sub l ~ pos : 1 ~ len ( : String . length l - 1 ) ... |
let rec add_labels_expr ~ text ~ values ~ classes expr = let add_labels_rec ( ? values = values ) expr = add_labels_expr ~ text ~ values ~ classes expr in match expr . pexp_desc with Pexp_apply ( { pexp_desc = Pexp_ident ( Longident . Lident s ) } , args ) -> begin try let labels = SM... |
let rec add_labels_class ~ text ~ classes ~ values ~ methods cl = match cl . pcl_desc with Pcl_constr _ -> ( ) | Pcl_structure ( p , l ) -> let values = SMap . removes ( pattern_vars p ) values in let values = match pattern_name p with None -> values | Some s -> List . fold_left method... |
let add_labels ~ intf ~ impl ~ file = insertions := [ ] ; let values , classes = List . fold_left intf ~ init ( : SMap . empty , SMap . empty ) ~ f : begin fun ( values , classes as acc ) item -> match item . psig_desc with Psig_value ( name , { pval_type = sty } ) -> ... |
let process_file file = prerr_endline ( " Processing " ^ file ) ; if Filename . check_suffix file " . ml " then let intf = Filename . chop_suffix file " . ml " ^ " . mli " in let ic = open_in intf in let lexbuf = Lexing . from_channel ic in Location . init lexbuf intf ; let i... |
let main ( ) = let files = ref [ ] in Arg . parse [ " - norec " , Arg . Set norec , " do not labelize recursive calls " ] ( fun f -> files := f :: ! files ) " addlabels [ - norec ] < files " ; > let files = List . rev ! files in List . iter files ~ f : process... |
let ( ) = main ( ) |
let size t = Dwarf_value . size ( Dwarf_value . uleb128 ( Uint64 . of_nonnegative_int64_exn t ) ) |
let emit ~ asm_directives ? comment t = Dwarf_value . emit ~ asm_directives ( Dwarf_value . uleb128 ? comment ( Uint64 . of_nonnegative_int64_exn t ) ) type nonrec t = t let compare = Stdlib . compare let hash = Hashtbl . hash let equal t1 t2 = compare t1 t2 = 0 let print ppf t = Format . ... |
module Pair = struct type nonrec t = t * t include Identifiable . Make ( struct type nonrec t = t let compare = Stdlib . compare let hash = Hashtbl . hash let equal t1 t2 = compare t1 t2 = 0 let print ppf ( x , y ) = Format . fprintf ppf " ( % Ld , % Ld ) " x y let output _ _ = ... |
module Entry = struct type t = { addr : Asm_label . t ; adjustment : int } include Identifiable . Make ( struct type nonrec t = t let compare { addr = addr1 ; adjustment = adjustment1 } { addr = addr2 ; adjustment = adjustment2 } = let c = Asm_label . compare addr1 addr2 in if c <>... |
type entry_and_soc_symbol = { entry : Entry . t ; start_of_code_symbol : Asm_symbol . t } |
type t = { base_addr : Asm_label . t ; mutable next_index : Address_index . t ; mutable table : entry_and_soc_symbol Address_index . Map . t ; mutable rev_table : Address_index . t Entry . Map . t } |
let create ( ) = { base_addr = Asm_label . create ( DWARF Debug_addr ) ; next_index = Address_index . zero ; table = Address_index . Map . empty ; rev_table = Entry . Map . empty } |
let add ( ? adjustment = 0 ) t ~ start_of_code_symbol addr = let entry : Entry . t = { addr ; adjustment } in match Entry . Map . find entry t . rev_table with | exception Not_found -> let index = t . next_index in t . next_index <- Address_index . succ index ; t . rev_table <- E... |
let base_addr t = t . base_addr |
let initial_length t = let num_entries = Int64 . of_int ( Address_index . Map . cardinal t . table ) in let size_entries = Int64 . mul num_entries ( Int64 . of_int Dwarf_arch_sizes . size_addr ) in Initial_length . create ( Dwarf_int . of_int64_exn ( Int64 . add 4L size_entries ) )... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.