text stringlengths 12 786k |
|---|
let simple simple = Simple . pattern_match simple ~ const ( : fun _ -> 1 ) ~ name ( : fun _ ~ coercion : _ -> 0 ) |
let static_consts _ = 0 |
let apply apply = match Apply_expr . call_kind apply with | Function { function_call = Direct _ ; _ } -> direct_call_size | Function { function_call = Indirect_unknown_arity ; alloc_mode = _ } -> indirect_call_size | Function { function_call = Indirect_known_arity _ ; alloc_mode = _ } ... |
let apply_cont apply_cont = let size = match Apply_cont_expr . trap_action apply_cont with | None -> 0 | Some ( Push _ ) -> 4 | Some ( Pop _ ) -> 2 in size + 1 |
let switch switch = 0 + ( 5 * Switch_expr . num_arms switch ) |
let [ @ ocamlformat " disable " ] print ppf t = Format . fprintf ppf " % d " t |
let of_int t = t |
let to_int t = t |
let evaluate ~ args : _ t = float_of_int t |
let free_names t = match t with | Id -> Name_occurrences . empty | Change_depth { from ; to_ } -> Name_occurrences . union ( Rec_info_expr . free_names from ) ( Rec_info_expr . free_names to_ ) |
let free_names_in_types t = match t with | Id -> Name_occurrences . empty | Change_depth { from ; to_ } -> Name_occurrences . union ( Rec_info_expr . free_names_in_types from ) ( Rec_info_expr . free_names_in_types to_ ) |
let apply_renaming t renaming = match t with | Id -> t | Change_depth { from ; to_ } -> let new_from = Rec_info_expr . apply_renaming from renaming in let new_to_ = Rec_info_expr . apply_renaming to_ renaming in if new_from == from && new_to_ == to_ then t else change_depth ~ from : new_from ~ to... |
let compose_exn t1 ~ then_ : t2 = match compose t1 ~ then_ : t2 with | Some t -> t | None -> Misc . fatal_errorf " Invalid composition : % a @ >>@ % a " print t1 print t2 |
let all_ids_for_export t = match t with | Id -> Ids_for_export . empty | Change_depth { from ; to_ } -> Ids_for_export . union ( Rec_info_expr . all_ids_for_export from ) ( Rec_info_expr . all_ids_for_export to_ ) |
module type S = sig type variable type rec_info_expr type t = private | Id | Change_depth of { from : rec_info_expr ; to_ : rec_info_expr } val change_depth : from : rec_info_expr -> to_ : rec_info_expr -> t val id : t val is_id : t -> bool val inverse : t -> t val compose : t -> then_ : t -> ... |
module Make ( Rec_info_expr : Rec_info_expr0 . S ) : S with type variable = Rec_info_expr . variable and type rec_info_expr = Rec_info_expr . t = struct type variable = Rec_info_expr . variable type rec_info_expr = Rec_info_expr . t type t = | Id | Change_depth of { from : rec_info_expr ; t... |
type plain = [ ` black | ` blue | ` cyan | ` green | ` magenta | ` red | ` white | ` yellow ] |
type t = Ansi of [ plain | ` bright of plain ] | Rgb of int * int * int |
let pp_plain ppf x = Format . fprintf ppf ( match x with | ` black -> " black " | ` blue -> " blue " | ` cyan -> " cyan " | ` green -> " green " | ` magenta -> " magenta " | ` red -> " red " | ` white -> " white " | ` yellow -> " yellow " ) |
let pp_dump ppf = function | Rgb ( r , g , b ) -> Format . fprintf ppf " RGB ( % d , % d , % d ) " r g b | Ansi ( # plain as x ) -> Format . fprintf ppf " ANSI ( % a ) " pp_plain x | Ansi ( ` bright x ) -> Format . fprintf ppf " ANSI ( bright % a ) " pp_p... |
let ansi x = Ansi x |
let rgb = let invalid_component typ n = Format . kasprintf invalid_arg " Color . rgb : invalid % s component % d " typ n in fun r g b -> if r < 0 || r > 255 then invalid_component " red " r ; if g < 0 || g > 255 then invalid_component " green " g ; if b < 0 || b > 255 then inval... |
let hex = let invalid_length = Format . kasprintf invalid_arg " Color . hex : invalid hexstring length % d " in let hex c = if c >= ' 0 ' && c <= ' 9 ' then Char . code c - Char . code ' 0 ' else if c >= ' a ' && c <= ' f ' then Char . code c - Char . code ' a ' ... |
module OrderedRegSet = Set . Make ( struct type t = Reg . t let compare r1 r2 = let open Reg in let c1 = r1 . spill_cost and d1 = r1 . degree in let c2 = r2 . spill_cost and d2 = r2 . degree in let n = c2 * d1 - c1 * d2 in if n <> 0 then n else let n = c2 - c1 in if n <> 0 then n else let... |
let allocate_registers ( ) = let constrained = ref OrderedRegSet . empty in let unconstrained = ref [ ] in let num_stack_slots = Array . make Proc . num_register_classes 0 in let remove_reg reg = let cl = Proc . register_class reg in if reg . spill then begin let nslots = num_stack_slots . (... |
module type T = sig type row module Contents : Stringable val name : string val group : string option val get : row -> Contents . t val set : row -> Contents . t -> row val editable : bool val focus_on_edit : bool val sort_by : Contents . t -> Sort_key . t end |
type ' a t = ( module T with type row = ' a ) |
let create ( type row contents ) ~ name ? group ? sort_by ? focus_on_edit ( module Contents : Stringable with type t = contents ) ~ editable ~ get ~ set = let sort_by = match sort_by with | Some f -> f | None -> fun x -> Sort_key . String ( Contents . to_string x ) in ( module struct t... |
let of_field ( type contents ) field ? group ? sort_by ? focus_on_edit ( module Contents : Stringable with type t = contents ) ~ editable = create ~ name ( : Field . name field ) ? group ? sort_by ? focus_on_edit ( module Contents ) ~ editable ~ get ( : Field . get field ) ~ set ... |
let name ( type row ) ( module T : T with type row = row ) = T . name |
let group ( type row ) ( module T : T with type row = row ) = T . group |
let editable ( type row ) ( module T : T with type row = row ) = T . editable |
let focus_on_edit ( type row ) ( module T : T with type row = row ) = T . focus_on_edit |
let get ( type row ) ( module T : T with type row = row ) row = T . Contents . to_string ( T . get row ) ; ; |
let set ( type row ) ( module T : T with type row = row ) row string = let open Or_error . Let_syntax in let % map v = Or_error . try_with ( fun ( ) -> T . Contents . of_string string ) in T . set row v ; ; |
let sort_by ( type row ) ( module T : T with type row = row ) row = T . sort_by ( T . get row ) |
let to_table_widget_column t = let name = name t in let group = group t in let sort_by _row_id row = sort_by t row in Ts_table . Column . create ~ header ( : Vdom . Node . text name ) ~ sort_by ? group ( ) ; ; |
module Make_primitives ( Gates : Gates ) = struct include Gates let vdd = of_constant ( Constant . of_int ~ width : 1 1 ) let gnd = of_constant ( Constant . of_int ~ width : 1 0 ) let bits_lsb x = let w = width x in Array . to_list ( Array . init w ~ f ( : fun i -> select x i i ... |
type nonrec ( ' a , ' b ) with_valid2 = ( ' a , ' b ) with_valid2 = { valid : ' a ; value : ' b } |
type nonrec ' a with_valid = ' a with_valid |
module Make ( Prims : Primitives ) = struct type t = Prims . t let equal = Prims . equal let empty = Prims . empty let is_empty = Prims . is_empty let ( -- ) a b = Prims . ( -- ) a b let width = Prims . width let [ @ cold ] raise_arg_greater_than_zero fn x = raise_s [ % messag... |
type pending_alloc = { reg : Reg . t ; dbginfos : Debuginfo . alloc_dbginfo ; totalsz : int ; mode : Lambda . alloc_mode } |
type allocation_state = No_alloc | Pending_alloc of pending_alloc |
let rec combine i allocstate = match i . desc with Iend | Ireturn | Iexit _ | Iraise _ -> ( i , allocstate ) | Iop ( Ialloc { bytes = sz ; dbginfo ; mode } ) -> assert ( List . length dbginfo = 1 ) ; begin match allocstate with | Pending_alloc { reg ; dbginfos ; totalsz ; ... |
let fundecl f = { f with fun_body = combine_restart f . fun_body } |
let get_random_partition r n k = let r = Random . State . float r 1 . 0 in let rec loop pos accratio = let accratio = accratio . + ( get_partition_ratio n k pos ) in if r <= accratio then pos else loop ( pos - 1 ) accratio in loop k 0 . 0 |
let set = Hashtbl . create 7901 |
let floyds_sampling r n k = Hashtbl . clear set ; for j = n - k + 1 to n do let t = ( Random . State . int r j ) + 1 in if Hashtbl . mem set t then ( Hashtbl . add set j true ) else ( Hashtbl . add set t true ) done ; set |
type ' a optional_branching_factor = ? branching_factor : int -> ' a |
type ' a with_valid = ( ' a , ' a ) with_valid2 { valid : ' a ; value : ' b } |
module type TypedMath = sig type t type v val of_signal : t -> v val to_signal : v -> t val ( +: ) : v -> v -> v val ( -: ) : v -> v -> v val ( *: ) : v -> v -> v val ( <: ) : v -> v -> v val ( >: ) : v -> v -> v val ( <=: ) : v -> v -> v val ( >=: ) : v -> v ... |
module type Gates = sig type t [ @@ deriving sexp_of ] include Equal . S with type t := t val empty : t val is_empty : t -> bool val width : t -> int val of_constant : Constant . t -> t val to_constant : t -> Constant . t val concat_msb : t list -> t val select : t -> int -> int -> t val ( ... |
module type Primitives = sig include Gates val mux : t -> t list -> t val ( +: ) : t -> t -> t val ( -: ) : t -> t -> t val ( *: ) : t -> t -> t val ( *+ ) : t -> t -> t val ( ==: ) : t -> t -> t val ( <: ) : t -> t -> t end |
module type S = sig type t [ @@ deriving sexp_of ] include Equal . S with type t := t val empty : t val is_empty : t -> bool val ( -- ) : t -> string -> t val width : t -> int val address_bits_for : int -> int val num_bits_to_represent : int -> int val of_constant : Constant . t -> t val t... |
module type Comb = sig module type Gates = Gates module type Primitives = Primitives module type S = S type nonrec ' a optional_branching_factor = ' a optional_branching_factor type nonrec ( ' a , ' b ) with_valid2 = ( ' a , ' b ) with_valid2 = { valid : ' a ; value : ' b } ty... |
let jobs = ref 1 |
let no_tag_handler _ = failwith " no_tag_handler " |
let tag_handler = ref no_tag_handler |
let atomize l = S ( List . map ( fun x -> A x ) l ) |
let atomize_paths l = S ( List . map ( fun x -> P x ) l ) |
let env_path = lazy begin let path_var = Sys . getenv " PATH " in let paths = try Lexers . parse_environment_path ( Lexing . from_string path_var ) with Lexers . Error msg -> raise ( Lexers . Error ( " $ PATH : " ^ msg ) ) in let norm_current_dir_name path = if path = " " then... |
let virtual_solvers = Hashtbl . create 32 |
let setup_virtual_command_solver virtual_command solver = Hashtbl . replace virtual_solvers virtual_command solver |
let virtual_solver virtual_command = let solver = try Hashtbl . find virtual_solvers virtual_command with Not_found -> failwith ( sbprintf " no solver for the virtual command % S \ ( setup one with Command . setup_virtual_command_solver ) " virtual_command ) in try solver ( ) with Not_found ->... |
let search_in_path cmd = if Filename . is_implicit cmd then let path = List . find begin fun path -> if path = Filename . current_dir_name then sys_file_exists cmd else sys_file_exists ( filename_concat path cmd ) end !* env_path in filename_concat path cmd else cmd |
let rec string_of_command_spec_with_calls call_with_tags call_with_target resolve_virtuals spec = let self = string_of_command_spec_with_calls call_with_tags call_with_target resolve_virtuals in let b = Buffer . create 256 in let first = ref true in let put_space ( ) = if ! first then first := false else ... |
let string_of_command_spec x = string_of_command_spec_with_calls ignore ignore false x |
let string_target_and_tags_of_command_spec spec = let rtags = ref Tags . empty in let rtarget = ref " " in let union_rtags tags = rtags := Tags . union ! rtags tags in let s = string_of_command_spec_with_calls union_rtags ( ( ) := rtarget ) true spec in let target = if ! rtarget = " " the... |
let string_print_of_command_spec spec quiet pretend = let s , target , tags = string_target_and_tags_of_command_spec spec in fun ( ) -> if not quiet then Log . event ~ pretend s target tags ; s |
let print_escaped_string f = Format . fprintf f " % S " |
let rec print f = function | Cmd spec -> Format . pp_print_string f ( string_of_command_spec spec ) | Seq seq -> List . print print f seq | Nop -> Format . pp_print_string f " nop " | Echo ( texts , dest_path ) -> Format . fprintf f " [ @< 2 > Echo ( % a , @ % a ) ] " ... |
let to_string x = sbprintf " % a " print x |
let add_parallel_stat , dump_parallel_stats = let xmin = ref max_int in let xmax = ref 0 in let xsum = ref 0 in let xsumall = ref 0 in let xcount = ref 0 in let xcountall = ref 0 in let add_parallel_stat x = if x > 0 then begin incr xcountall ; xsumall := x + ! xsumall ; end ; if x > 1 then ... |
module Primitives = struct let do_echo texts dest_path = with_output_file dest_path begin fun oc -> List . iter ( output_string oc ) texts end let echo x y ( ) = do_echo x y ; " " end |
let rec list_rev_iter f = function | [ ] -> ( ) | x :: xs -> list_rev_iter f xs ; f x |
let flatten_commands quiet pretend cmd = let rec loop acc = function | [ ] -> acc | Nop :: xs -> loop acc xs | Cmd spec :: xs -> loop ( string_print_of_command_spec spec quiet pretend :: acc ) xs | Echo ( texts , dest_path ) :: xs -> loop ( Primitives . echo texts dest_path :: acc ) x... |
let execute_many ( ? quiet = false ) ( ? pretend = false ) cmds = add_parallel_stat ( List . length cmds ) ; let degraded = !* My_unix . is_degraded || Sys . os_type = " Win32 " in let jobs = ! jobs in if jobs < 0 then invalid_arg " jobs < 0 " ; let max_jobs = if jobs = 0 ... |
let execute ? quiet ? pretend cmd = match execute_many ? quiet ? pretend [ cmd ] with | Some ( _ , exn ) -> raise exn | _ -> ( ) |
let iter_tags f x = let rec spec x = match x with | N | A _ | Sh _ | P _ | Px _ | V _ | Quote _ -> ( ) | S l -> List . iter spec l | T tags -> f tags in let rec cmd x = match x with | Nop | Echo _ -> ( ) | Cmd ( s ) -> spec s | Seq ( s ) -> List . iter cmd s in cmd x |
let fold_pathnames f x = let rec spec = function | N | A _ | Sh _ | V _ | Quote _ | T _ -> fun acc -> acc | P p | Px p -> f p | S l -> List . fold_right spec l in let rec cmd = function | Nop -> fun acc -> acc | Echo ( _ , p ) -> f p | Cmd ( s ) -> spec s | Seq ( s ) -> Li... |
let rec reduce x = let rec self x acc = match x with | N -> acc | A _ | Sh _ | P _ | Px _ | V _ -> x :: acc | S l -> List . fold_right self l acc | T tags -> self ( ! tag_handler tags ) acc | Quote s -> Quote ( reduce s ) :: acc in match self x [ ] with | [ ] -> N | [ x ] ... |
let digest = let list = List . fold_right in let text x acc = Digest . string x :: acc in let rec cmd = function | Cmd spec -> fun acc -> string_of_command_spec spec :: acc | Seq seq -> list cmd seq | Nop -> fun acc -> acc | Echo ( texts , dest_path ) -> list text ( dest_path :: texts ) i... |
let all_deps_of_tags = ref [ ] |
let cons deps acc = List . rev & List . fold_left begin fun acc dep -> if List . mem dep acc then acc else dep :: acc end acc deps |
let deps_of_tags tags = List . fold_left begin fun acc ( xtags , xdeps ) -> if Tags . does_match tags xtags then cons xdeps acc else acc end [ ] ! all_deps_of_tags |
let set_deps_of_tags tags deps = all_deps_of_tags := ( tags , deps ) :: ! all_deps_of_tags |
let dep tags deps = set_deps_of_tags ( Tags . of_list tags ) deps |
let pdep tags ptag deps = Param_tags . declare ptag ( fun param -> dep ( Param_tags . make ptag param :: tags ) ( deps param ) ) | S specs1 :: specs2 -> cmd_of_spec ( specs1 @ specs2 ) | ( T _ | Quote _ ) :: _ -> assert false in let rec cmd_of_cmds = function | Nop | Seq [ ] ... |
type dbg_instruction = { instr_name : string ; instr_prio : bool ; instr_action : formatter -> lexbuf -> unit ; instr_repeat : bool ; instr_help : string } |
let instruction_list = ref ( [ ] : dbg_instruction list ) |
type dbg_variable = { var_name : string ; var_action : ( lexbuf -> unit ) * ( formatter -> unit ) ; var_help : string } |
let variable_list = ref ( [ ] : dbg_variable list ) |
type dbg_info = { info_name : string ; info_action : lexbuf -> unit ; info_help : string } |
let info_list = ref ( [ ] : dbg_info list ) |
let error text = eprintf " % s . " @ text ; raise Toplevel |
let check_not_windows feature = match Sys . os_type with | " Win32 " -> error ( " ' " \^ feature " ' ^\ feature not supported on Windows " ) | _ -> ( ) |
let eol = end_of_line Lexer . lexeme |
let matching_elements list name instr = List . filter ( function a -> isprefix instr ( name a ) ) ! list |
let all_matching_instructions = matching_elements instruction_list ( fun i -> i . instr_name ) |
let matching_instructions instr = let all = all_matching_instructions instr in let prio = List . filter ( fun i -> i . instr_prio ) all in if prio = [ ] then all else prio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.