text stringlengths 12 786k |
|---|
let load_path_for = Hashtbl . create 7 |
let checkpoint_big_step = ref ( ~~ " 10000 " ) |
let checkpoint_small_step = ref ( ~~ " 1000 " ) |
let checkpoint_max_count = ref 15 |
let make_checkpoints = ref ( match Sys . os_type with " Win32 " -> false | _ -> true ) |
let break_on_load = ref true |
let environment = ref [ ] |
type t = { label : Asm_label . t ; name : Asm_symbol . t option ; abbreviation_code : Abbreviation_code . t ; attribute_values : AV . t ASS . Map . t } |
let create ~ label ~ name ~ abbreviation_code ~ attribute_values = { label ; name ; abbreviation_code ; attribute_values } |
let null = lazy { label = Asm_label . create ( DWARF Debug_info ) ; name = None ; abbreviation_code = Abbreviation_code . null ; attribute_values = ASS . Map . empty } |
let create_null ( ) = Lazy . force null |
let emit ~ asm_directives t = let module A = ( val asm_directives : Asm_directives . S ) in if not ( Abbreviation_code . is_null t . abbreviation_code ) then begin begin match t . name with | None -> ( ) | Some symbol -> A . define_data_symbol symbol end ; A . define_label t . label ... |
let size t = ASS . Map . fold ( fun _attribute_spec attribute_value size -> Dwarf_int . add size ( AV . size attribute_value ) ) t . attribute_values ( Abbreviation_code . size t . abbreviation_code ) |
let label t = t . label |
let abbreviation_code t = t . abbreviation_code |
let attribute_values t = t . attribute_values |
let is_null t = t == Lazy . force null |
let symbol t = t . name |
module Scoped_location = struct type scope_item = | Sc_anonymous_function | Sc_value_definition | Sc_module_definition | Sc_class_definition | Sc_method_definition | Sc_partial_or_eta_wrapper | Sc_lazy type scopes = | Empty | Cons of { item : scope_item ; str : string ; str_fun : string ; name :... |
type item = { dinfo_file : string ; dinfo_line : int ; dinfo_char_start : int ; dinfo_char_end : int ; dinfo_start_bol : int ; dinfo_end_bol : int ; dinfo_end_line : int ; dinfo_scopes : Scoped_location . scopes ; } |
type t = item list |
type alloc_dbginfo_item = { alloc_words : int ; alloc_dbg : t } |
type alloc_dbginfo = alloc_dbginfo_item list |
let is_none = function | [ ] -> true | _ :: _ -> false |
let to_string dbg = match dbg with | [ ] -> " " | ds -> let items = List . map ( fun d -> Printf . sprintf " % s :% d , % d -% d " d . dinfo_file d . dinfo_line d . dinfo_char_start d . dinfo_char_end ) ds in " { " ^ String . concat " ; " items ^ " } " |
let item_from_location ~ scopes loc = let valid_endpos = String . equal loc . loc_end . pos_fname loc . loc_start . pos_fname in { dinfo_file = loc . loc_start . pos_fname ; dinfo_line = loc . loc_start . pos_lnum ; dinfo_char_start = loc . loc_start . pos_cnum - loc . loc_start . ... |
let from_location = function | Scoped_location . Loc_unknown -> [ ] | Scoped_location . Loc_known { scopes ; loc } -> assert ( not ( Location . is_none loc ) ) ; [ item_from_location ~ scopes loc ] |
let to_location = function | [ ] -> Location . none | d :: _ -> let loc_start = { pos_fname = d . dinfo_file ; pos_lnum = d . dinfo_line ; pos_bol = d . dinfo_start_bol ; pos_cnum = d . dinfo_start_bol + d . dinfo_char_start ; } in let loc_end = { pos_fname = d . dinfo_fil... |
let inline dbg1 dbg2 = dbg1 @ dbg2 |
let compare dbg1 dbg2 = let rec loop ds1 ds2 = match ds1 , ds2 with | [ ] , [ ] -> 0 | _ :: _ , [ ] -> 1 | [ ] , _ :: _ -> - 1 | d1 :: ds1 , d2 :: ds2 -> let c = String . compare d1 . dinfo_file d2 . dinfo_file in if c <> 0 then c else let c = compare d1 . din... |
let hash t = List . fold_left ( fun hash item -> Hashtbl . hash ( hash , item ) ) 0 t |
let rec print_compact ppf t = let print_item item = Format . fprintf ppf " % a :% i " Location . print_filename item . dinfo_file item . dinfo_line ; if item . dinfo_char_start >= 0 then begin Format . fprintf ppf " , % i --% i " item . dinfo_char_start item . dinfo_char_end end in m... |
type t = { dies : DIE . t list ; debug_abbrev_label : Asm_label . t ; compilation_unit_header_label : Asm_label . t } |
let create ~ dies ~ debug_abbrev_label ~ compilation_unit_header_label = { dies ; debug_abbrev_label ; compilation_unit_header_label } |
let dwarf_version ( ) = match ! Dwarf_flags . gdwarf_version with | Four -> Dwarf_version . four | Five -> Dwarf_version . five |
let debug_abbrev_offset t = Dwarf_value . offset_into_debug_abbrev ~ comment " : abbrevs . for this comp . unit " t . debug_abbrev_label |
let address_width_in_bytes_on_target = Dwarf_value . int8 ~ comment " : Dwarf_arch_sizes . size_addr " ( Numbers . Int8 . of_int_exn Dwarf_arch_sizes . size_addr ) |
let size_without_first_word t = let ( + ) = Dwarf_int . add in let total_die_size = List . fold_left ( fun size die -> size + DIE . size die ) ( Dwarf_int . zero ( ) ) t . dies in match ! Dwarf_flags . gdwarf_version with | Four -> Dwarf_version . size ( dwarf_version ( ) ) ... |
let size t = let size_without_first_word = size_without_first_word t in let initial_length = Initial_length . create size_without_first_word in Dwarf_int . add ( Initial_length . size initial_length ) size_without_first_word |
let emit ~ asm_directives t = let module A = ( val asm_directives : Asm_directives . S ) in let size_without_first_word = size_without_first_word t in let initial_length = Initial_length . create size_without_first_word in A . define_label t . compilation_unit_header_label ; Initial_length . emit ... |
module Bits = struct include Bits let hash_fold_t state t = Bits . to_string t |> String . hash_fold_t state end |
module Structure_kind = struct type t = | Empty | Const of Bits . t | Op of Signal . signal_op | Mux | Cat | Not | Wire of string list | Select of int * int | Mem_read_port | Dont_dedup of Signal . Uid . t [ @@ deriving sexp_of , compare , hash ] let equal a b = compare a b = 0 end |
let structure_kind ( signal : Signal . t ) = match signal with | Signal . Empty -> Structure_kind . Empty | Signal . Const { constant ; _ } -> Structure_kind . Const constant | Signal . Op2 { op ; _ } -> Structure_kind . Op op | Signal . Mux _ -> Structure_kind . Mux | Si... |
let children ( signal : Signal . t ) = match structure_kind signal with | Structure_kind . Dont_dedup _ -> [ ] | _ -> ( match signal with | Wire { driver ; _ } -> [ ! driver ] | Mem_read_port { memory ; read_address ; _ } -> [ memory ; read_address ] | _ -> Signal... |
let signal_id_map_children s ~ f = { s with Signal . s_id = Signal . new_id ( ) ; s_deps = List . map s . Signal . s_deps ~ f } ; ; |
let map_children signal ~ f = match signal with | Signal . Empty -> signal | Signal . Const _ -> signal | Signal . Op2 { signal_id ; op ; arg_a ; arg_b } -> let arg_a = f arg_a in let arg_b = f arg_b in Signal . Op2 { signal_id = { signal_id with s_id = Signal . new_id ( ) ; s... |
let find_by_signal_uid memo s = Hashtbl . find_exn memo ( Signal . uid s ) |
let signal_hash memo signal = Hashtbl . find_or_add memo ( Signal . uid signal ) ~ default ( : fun ( ) -> let children_hashes = List . map ( children signal ) ~ f ( : find_by_signal_uid memo ) in [ % hash : Structure_kind . t * int list ] ( structure_kind signal , children_ha... |
let make_canonical_signal canonical sequential_wires signal = match structure_kind signal with | Structure_kind . Dont_dedup _ -> let wire = Signal . wire ( Signal . width signal ) in Hashtbl . add_exn sequential_wires ~ key ( : Signal . uid signal ) ~ data ( : signal , wire ) ; wire ... |
let is_anonymous signal = Signal . is_empty signal || List . is_empty ( Signal . names signal ) |
let rec shallow_equal a b = is_anonymous a && is_anonymous b && Structure_kind . equal ( structure_kind a ) ( structure_kind b ) && match a , b with | Wire { driver = r_a ; _ } , Wire { driver = r_b ; _ } -> shallow_equal ! r_a ! r_b | _ -> [ % equal : Signal . Uid . t l... |
let transform_sequential_signal canonical signal = let get_canonical signal = Hashtbl . find_exn canonical ( Signal . uid signal ) in let rewrite_instantiation ( instantiation : Signal . instantiation ) = let inst_inputs = List . map instantiation . inst_inputs ~ f ( : fun ( name , s ) ... |
let rec unwrap_wire s = match s with | Signal . Wire { driver ; _ } when List . is_empty ( Signal . names s ) -> unwrap_wire ! driver | _ -> s ; ; |
let fix_mem_read_ports signals = List . iter signals ~ f ( : function | Signal . Wire { driver ; _ } -> ( match ! driver with | Signal . Mem_read_port { signal_id ; memory = Wire { driver = mem_ref ; _ } ; read_address } -> let memory = match unwrap_wire ! mem_ref with | Sig... |
let compress_wires signals = Signal_graph . create signals |> Signal_graph . iter ~ f ( : function | Signal . Wire { driver ; _ } -> driver := unwrap_wire ! driver | _ -> ( ) ) ; ; |
let canonicalize signals = let hash_memo = Hashtbl . create ( module Signal . Uid ) in let canonical = Hashtbl . create ( module Signal . Uid ) in let canonical_by_hash = Hashtbl . create ( module Int ) in let sequential_wires = Hashtbl . create ( module Signal . Uid ) in List . ite... |
let deduplicate circuit = let all_original_signals = Circuit . signal_graph circuit |> Signal_graph . filter ~ f ( : Fn . const true ) in let canonical = canonicalize ( all_original_signals @ Map . data ( Circuit . assertions circuit ) ) in let outputs = Circuit . outputs circuit in let ... |
module Make ( Structure : Structure . S ) = struct module Tools = Tools . Make Structure ; module Parser = Parser . Make Structure ; open Structure ; let rec delete_in_tree symbols tree = match ( symbols , tree ) with [ ( [ s :: sl ] , Node n ) -> if Tools . logically_eq_symbo... |
let db = quick_connect ~ database " : test " ( ) |
let table = [ ( " one " , 1 , 1 . 0 ) ; ( " two " , 2 , 2 . 0 ) ; ( " three " , 3 , 3 . 0 ) ; ( " , ' " :- , 4 , 4 . 0 ) ] |
let mk_table ( ) = let _r = exec db " create table caml ( a char ( 64 ) , b int , c float ) " in db |
let fill_table c = let ml2values ( a , b , c ) = values [ ml2str a ; ml2int b ; ml2float c ] in let insert values = " insert into caml values " ^ values in let rec loop = function | [ ] -> ( ) | x :: xs -> ( ignore ( exec c ( insert ( ml2values x ) ) ) ; loop xs ) ... |
let read_table c = let r = exec c " select * from caml " in let col = column r in let row x = ( not_null str2ml ( col ~ key " : a " ~ row : x ) , not_null int2ml ( col ~ key " : b " ~ row : x ) , not_null float2ml ( col ~ key " : c " ~ row : x ) ) in let rec loop = ... |
let main ( ) = let c = mk_table ( ) in ( fill_table c ; ignore ( read_table c ) ; ignore ( exec c " drop table caml " ) ; disconnect c ) |
let _ = Printexc . print main ( ) |
let ( _ : Thread . t ) = Thread . create ( fun ( ) -> let i = ref 0 in while true do Gc . compact ( ) ; incr i ; if ! i mod 100 = 0 then ( print_char ' . ' ; flush stdout ) done ) ( ) |
let db = Mysql . quick_connect ~ database ( : s " test " ) ~ user ( : s " root " ) ( ) |
let ( _ : Mysql . result ) = Mysql . exec db ( s " CREATE TABLE test ( id INT , v VARCHAR ( 10 ) ) ENGINE = MEMORY " ) |
let ( ) = let insert = P . create db ( s " INSERT INTO test VALUES ( , ) " ) ?? in for i = 10 to 15 do ignore ( P . execute insert [ | string_of_int i ; sprintf " value % d " i ] ) | done ; for i = 16 to 20 do ignore ( P . execute_null insert [ | Some ( string_... |
let ( ) = let rec loop t = match P . fetch t with | Some arr -> Array . iter ( function Some s -> printf " % s " s | None -> print_string " < NULL > " ) arr ; print_endline " " ; loop t | None -> ( ) in let select = P . create db ( s " SELECT * FROM test WHERE id > "... |
let ( _ : Mysql . result ) = Mysql . exec db ( s " DROP TABLE test " ) |
let ( ) = Mysql . disconnect db |
let pp_deps = ref [ ] |
type map_tree = Node of String . Set . t * bound_map |
let bound = Node ( String . Set . empty , String . Map . empty ) |
let get_map ( Node ( _s , m ) ) = m |
let make_leaf s = Node ( String . Set . singleton s , String . Map . empty ) |
let make_node m = Node ( String . Set . empty , m ) |
let rec weaken_map s ( Node ( s0 , m0 ) ) = Node ( String . Set . union s s0 , String . Map . map ( weaken_map s ) m0 ) |
let rec collect_free ( Node ( s , m ) ) = String . Map . fold ( fun _ n -> String . Set . union ( collect_free n ) ) m s |
let rec lookup_free p m = match p with [ ] -> raise Not_found | s :: p -> let Node ( f , m ' ) = String . Map . find s m in try lookup_free p m ' with Not_found -> f |
let rec lookup_map lid m = match lid with Lident s -> String . Map . find s m | Ldot ( l , s ) -> String . Map . find s ( get_map ( lookup_map l m ) ) | Lapply _ -> raise Not_found |
let free_structure_names = ref String . Set . empty |
let add_names s = free_structure_names := String . Set . union s ! free_structure_names |
let rec add_path bv ( ? p [ ] ) = = function | Lident s -> let free = try lookup_free ( s :: p ) bv with Not_found -> String . Set . singleton s in add_names free | Ldot ( l , s ) -> add_path bv ~ p ( : s :: p ) l | Lapply ( l1 , l2 ) -> add_path bv l1 ; add_path bv l2 |
let open_module bv lid = match lookup_map lid bv with | Node ( s , m ) -> add_names s ; String . Map . fold String . Map . add m bv | exception Not_found -> add_path bv lid ; bv |
let add_parent bv lid = match lid . txt with Ldot ( l , _s ) -> add_path bv l | _ -> ( ) |
let add_module_path bv lid = add_path bv lid . txt |
let handle_extension ext = match ( fst ext ) . txt with | " error " | " ocaml . error " -> raise ( Location . Error ( Builtin_attributes . error_of_extension ext ) ) | _ -> ( ) |
let rec add_type bv ty = match ty . ptyp_desc with Ptyp_any -> ( ) | Ptyp_var _ -> ( ) | Ptyp_arrow ( _ , t1 , t2 ) -> add_type bv t1 ; add_type bv t2 | Ptyp_tuple tl -> List . iter ( add_type bv ) tl | Ptyp_constr ( c , tl ) -> add bv c ; List . iter ( add_type bv ) ... |
let add_opt add_fn bv = function None -> ( ) | Some x -> add_fn bv x |
let add_constructor_arguments bv = function | Pcstr_tuple l -> List . iter ( add_type bv ) l | Pcstr_record l -> List . iter ( fun l -> add_type bv l . pld_type ) l |
let add_constructor_decl bv pcd = add_constructor_arguments bv pcd . pcd_args ; Option . iter ( add_type bv ) pcd . pcd_res |
let add_type_declaration bv td = List . iter ( fun ( ty1 , ty2 , _ ) -> add_type bv ty1 ; add_type bv ty2 ) td . ptype_cstrs ; add_opt add_type bv td . ptype_manifest ; let add_tkind = function Ptype_abstract -> ( ) | Ptype_variant cstrs -> List . iter ( add_constructor_decl bv ) ... |
let add_extension_constructor bv ext = match ext . pext_kind with Pext_decl ( args , rty ) -> add_constructor_arguments bv args ; Option . iter ( add_type bv ) rty | Pext_rebind lid -> add bv lid |
let add_type_extension bv te = add bv te . ptyext_path ; List . iter ( add_extension_constructor bv ) te . ptyext_constructors |
let add_type_exception bv te = add_extension_constructor bv te . ptyexn_constructor |
let pattern_bv = ref String . Map . empty |
let rec add_pattern bv pat = match pat . ppat_desc with Ppat_any -> ( ) | Ppat_var _ -> ( ) | Ppat_alias ( p , _ ) -> add_pattern bv p | Ppat_interval _ | Ppat_constant _ -> ( ) | Ppat_tuple pl -> List . iter ( add_pattern bv ) pl | Ppat_construct ( c , op ) -> add bv c ... |
let add_pattern bv pat = pattern_bv := bv ; add_pattern bv pat ; ! pattern_bv |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.