text stringlengths 0 601k |
|---|
let fold_left2 f x a b = let la = length a in if la <> length b then invalid_arg " ROArray . fold_left2 : arrays must have the same length " else let r = ref x in for i = 0 to la - 1 do r := f ! r ( unsafe_get a i ) ( unsafe_get b i ) done ; ! r |
let fold_left3 f x a b c = let la = length a in if la <> length b || la <> length c then invalid_arg " ROArray . fold_left2 : arrays must have the same length " else let r = ref x in for i = 0 to la - 1 do r := f ! r ( unsafe_get a i ) ( unsafe_get b i ) ( unsafe_get c i ) done ; ! r |
let for_all2 p a b = let n = length a in if n <> length b then invalid_arg " ROArray . for_all2 : arrays must have the same length " ; let rec loop i = if i = n then true else if p ( unsafe_get a i ) ( unsafe_get b i ) then loop ( succ i ) else false in loop 0 |
module G = Graph . Graphviz . Dot ( struct type nonrec t = t module V = struct type t = Node . t end module E = struct type t = { parent : Node . t ; child : Node . t } let src t = t . parent let dst t = t . child end let iter_vertex ( f : V . t -> unit ) unit ( t : t ) t = Hashtbl . iter t . nodes ~ f let iter_edges_e... |
let write_graph ( _ : t ) t = let _ = G . output_graph in ( ) |
let verify_transition ~ logger ~ consensus_constants ~ trust_system ~ frontier ~ unprocessed_transition_cache enveloped_transition = let sender = Envelope . Incoming . sender enveloped_transition in let genesis_state_hash = Transition_frontier . genesis_state_hash frontier in let transition_with_hash = Envelope . Incom... |
let find_map_ok ? how xs ~ f = let res = Ivar . create ( ) in let errs = ref [ ] in don ' t_wait_for ( let % map ( ) = Deferred . List . iter xs ? how ~ f ( : fun x -> if Ivar . is_full res then Deferred . unit else match % map choose [ choice ( Ivar . read res ) res ( fun _ -> ` Finished ) Finished ; choice ( f x ) x ... |
type download_state_hashes_error = [ ` Peer_moves_too_fast | ` No_common_ancestor | ` Failed_to_download_transition_chain_proof | ` Invalid_transition_chain_proof ] |
let rec contains_no_common_ancestor = function | [ ] -> false | ` No_common_ancestor :: _ -> true | _ :: errors -> contains_no_common_ancestor errors |
let try_to_connect_hash_chain t hashes ~ frontier ~ blockchain_length_of_target_hash = let logger = t . logger in let blockchain_length_of_root = Transition_frontier . root frontier |> Transition_frontier . Breadcrumb . consensus_state |> Consensus . Data . Consensus_state . blockchain_length in List . fold_until ( Non... |
module Downloader = struct module Key = struct module T = struct type t = State_hash . t * Length . t [ @@ deriving to_yojson , hash , sexp ] sexp let compare ( h1 , n1 ) n1 ( h2 , n2 ) n2 = match Length . compare n1 n2 with 0 -> State_hash . compare h1 h2 | c -> c end include T include Hashable . Make ( T ) T include ... |
let with_lengths hs ~ target_length = List . filter_mapi ( Non_empty_list . to_list hs ) hs ~ f ( : fun i x -> let open Option . Let_syntax in let % map x_len = Length . sub target_length ( Length . of_int i ) i in ( x , x_len ) x_len ) |
let download_state_hashes t ~ logger ~ trust_system ~ network ~ frontier ~ target_hash ~ target_length ~ downloader ~ blockchain_length_of_target_hash ~ preferred_peers = [ % log debug ] debug ~ metadata [ : ( " target_hash " , State_hash . to_yojson target_hash ) target_hash ] " Doing a catchup job with target $ targe... |
module Initial_validate_batcher = struct open Network_pool . Batcher type input = ( Mina_block . t , State_hash . t ) t With_hash . t Envelope . Incoming . t type nonrec ' a t = ( input , input , ' a ) ' a t let create ~ verifier ~ precomputed_values : _ t = create ~ logger : ( Logger . create ~ metadata [ : ( " name "... |
module Verify_work_batcher = struct open Network_pool . Batcher type input = Mina_block . initial_valid_block Envelope . Incoming . t type nonrec ' a t = ( input , input , ' a ) ' a t let create ~ verifier : _ t = let works ( x : input ) input = let wh , _ = x . data in Body . staged_ledger_diff ( Mina_block . body wh ... |
let initial_validate ( ~ precomputed_values : Precomputed_values . t ) t ~ logger ~ trust_system ( ~ batcher : _ Initial_validate_batcher . t ) t ~ frontier ~ unprocessed_transition_cache transition = let verification_start_time = Core . Time . now ( ) in let open Deferred . Result . Let_syntax in let state_hash = Enve... |
let check_invariant ~ downloader t = Downloader . check_invariant downloader ; [ % test_eq : int ] int ( Downloader . total_jobs downloader ) downloader ( Hashtbl . count t . nodes ~ f ( : fun node -> Node . State . Enum . equal ( Node . State . enum node . state ) state To_download ) ) |
let download s d ~ key ~ attempts = let logger = Logger . create ( ) in [ % log debug ] debug ~ metadata [ : ( " key " , Downloader . Key . to_yojson key ) key ; ( " caller " , ` String s ) s ] " Download download $ key " ; Downloader . download d ~ key ~ attempts |
let create_node ~ downloader t x = let attempts = Attempt_history . empty in let state , h , blockchain_length , parent , result = match x with | ` Root root -> ( Node . State . Finished , Breadcrumb . state_hash root , Breadcrumb . consensus_state root |> Consensus . Data . Consensus_state . blockchain_length , Breadc... |
let set_state t node s = set_state t node s ; write_graph t |
let pick ~ constants ( x : Mina_state . Protocol_state . Value . t State_hash . With_state_hashes . t ) t ( y : Mina_state . Protocol_state . Value . t State_hash . With_state_hashes . t ) t = let f = With_hash . map ~ f : Mina_state . Protocol_state . consensus_state in match Consensus . Hooks . select ~ constants ~ e... |
let forest_pick forest = with_return ( fun { return } -> List . iter forest ~ f ( : Rose_tree . iter ~ f : return ) return ; assert false ) |
let setup_state_machine_runner ~ t ~ verifier ~ downloader ~ logger ~ precomputed_values ~ trust_system ~ frontier ~ unprocessed_transition_cache ~ catchup_breadcrumbs_writer ( ~ build_func : ? skip_staged_ledger_verification [ : ` All | ` Proofs ] -> logger : Logger . t -> precomputed_values : Precomputed_values . t -... |
let run_catchup ~ logger ~ trust_system ~ verifier ~ network ~ frontier ~ build_func ( ~ catchup_job_reader : ( State_hash . t * ( Mina_block . initial_valid_block Envelope . Incoming . t , State_hash . t ) Cached . t Rose_tree . t list ) Strict_pipe . Reader . t ) ~ precomputed_values ~ unprocessed_transition_cache ( ... |
let run ~ logger ~ precomputed_values ~ trust_system ~ verifier ~ network ~ frontier ~ catchup_job_reader ~ catchup_breadcrumbs_writer ~ unprocessed_transition_cache : unit = O1trace . background_thread " perform_super_catchup " ( fun ( ) -> run_catchup ~ logger ~ trust_system ~ verifier ~ network ~ frontier ~ catchup_... |
let default_context_flags ( ctx : Context . t ) ~ project = let cflags = Ocaml_config . ocamlc_cflags ctx . ocaml_config in let cxxflags = List . filter cflags ~ f ( : fun s -> not ( String . is_prefix s ~ prefix " :- std " ) ) = in let c , cxx = match Dune_project . use_standard_c_and_cxx_flags project with | None | S... |
module Env_tree : sig type t val get_node : t -> dir : Path . Build . t -> Env_node . t Memo . t val get_context_env : t -> Env . t val create : context : Context . t -> host_env_tree : t option -> scopes : Scope . DB . t -> default_env : Env_node . t Memo . Lazy . t -> stanzas_per_dir : Stanza . t list Dir_with_dune .... |
module Lib_entry = struct type t = | Library of Lib . Local . t | Deprecated_library_name of Dune_file . Deprecated_library_name . t let name = function | Library lib -> Lib . Local . to_lib lib |> Lib . name | Deprecated_library_name { old_name = old_public_name , _ ; _ } -> Dune_file . Public_lib . name old_public_na... |
type t = { context : Context . t ; scopes : Scope . DB . t ; public_libs : Lib . DB . t ; installed_libs : Lib . DB . t ; stanzas : Dune_file . Stanzas . t Dir_with_dune . t list ; stanzas_per_dir : Dune_file . Stanzas . t Dir_with_dune . t Path . Build . Map . t ; packages : Package . t Package . Name . Map . t ; arti... |
let context t = t . context |
let context_env t = Env_tree . get_context_env t . env_tree |
let stanzas t = t . stanzas |
let stanzas_in t ~ dir = Path . Build . Map . find t . stanzas_per_dir dir |
let packages t = t . packages |
let equal = ( ( == ) : t -> t -> bool ) |
let hash t = Context . hash t . context |
let to_dyn_concise t = Context . to_dyn_concise t . context |
let to_dyn t = Context . to_dyn t . context |
let host t = Option . value t . host ~ default : t |
let any_package_aux ~ packages ~ context pkg = match Package . Name . Map . find packages pkg with | Some p -> Memo . return ( Some ( Expander . Local p ) ) | None -> ( let open Memo . O in Findlib . find_root_package context . Context . findlib pkg >>| function | Ok p -> Some ( Expander . Installed p ) | Error Not_fou... |
let any_package t pkg = any_package_aux ~ packages : t . packages ~ context : t . context pkg |
let get_site_of_packages_aux ~ loc ~ any_package ~ pkg ~ site = let find_site sites ~ pkg ~ site = match Section . Site . Map . find sites site with | Some section -> section | None -> User_error . raise ~ loc [ Pp . textf " Package % s doesn ' t define a site % s " ( Package . Name . to_string pkg ) ( Section . Site .... |
let get_site_of_packages t ~ loc ~ pkg ~ site = get_site_of_packages_aux ~ loc ~ any_package ( : any_package t ) ~ pkg ~ site |
let lib_entries_of_package t pkg_name = Package . Name . Map . find t . lib_entries_by_package pkg_name |> Option . value ~ default [ ] : |
let internal_lib_names t = List . fold_left t . stanzas ~ init : Lib_name . Set . empty ~ f ( : fun acc { Dir_with_dune . data = stanzas ; _ } -> List . fold_left stanzas ~ init : acc ~ f ( : fun acc -> function | Dune_file . Library lib -> Lib_name . Set . add ( match lib . visibility with | Private _ -> acc | Public ... |
let public_libs t = t . public_libs |
let installed_libs t = t . installed_libs |
let find_scope_by_dir t dir = Scope . DB . find_by_dir t . scopes dir |
let find_scope_by_project t = Scope . DB . find_by_project t . scopes |
let find_project_by_key t = Dune_project . File_key . Map . find_exn t . projects_by_key |
let expander t ~ dir = Env_tree . expander t . env_tree ~ dir |
let get_node t = Env_tree . get_node t |
let extend_action t ~ dir build = let open Action_builder . O in let + ( act : Action . Full . t ) = build and + env = Action_builder . of_memo ( let open Memo . O in get_node t . env_tree ~ dir >>= Env_node . external_env ) in act |> Action . Full . add_env env |> Action . Full . map ~ f ( : function | Chdir _ as a ->... |
let make_rule t ? mode ? loc ~ dir { Action_builder . With_targets . build ; targets } = let build = extend_action t build ~ dir in Rule . make ? mode ~ info ( : Rule . Info . of_loc_opt loc ) ~ context ( : Some ( Context . build_context t . context ) ) ~ targets build |
let add_rule t ? mode ? loc ~ dir build = let rule = make_rule t ? mode ? loc ~ dir build in Rules . Produce . rule rule |
let add_rule_get_targets t ? mode ? loc ~ dir build = let rule = make_rule t ? mode ? loc ~ dir build in let + ( ) = Rules . Produce . rule rule in rule . targets |
let add_rules t ~ dir builds = Memo . parallel_iter builds ~ f ( : add_rule t ~ dir ) |
let add_alias_action t alias ~ dir ~ loc action = let build = extend_action t action ~ dir in Rules . Produce . Alias . add_action ~ context ( : Context . build_context t . context ) alias ~ loc build |
let build_dir_is_vendored build_dir = match Path . Build . drop_build_context build_dir with | Some src_dir -> Dune_engine . Source_tree . is_vendored src_dir | None -> Memo . return false |
let ocaml_flags t ~ dir ( spec : Ocaml_flags . Spec . t ) = let * expander = Env_tree . expander t . env_tree ~ dir in let * flags = let + ocaml_flags = get_node t . env_tree ~ dir >>= Env_node . ocaml_flags in Ocaml_flags . make ~ spec ~ default : ocaml_flags ~ eval ( : Expander . expand_and_eval_set expander ) in bui... |
let js_of_ocaml_runtest_alias t ~ dir = let + js_of_ocaml = get_node t . env_tree ~ dir >>= Env_node . js_of_ocaml in match js_of_ocaml . runtest_alias with | None -> Alias . Name . runtest | Some a -> a |
let js_of_ocaml_compilation_mode t ~ dir = let + js_of_ocaml = get_node t . env_tree ~ dir >>= Env_node . js_of_ocaml in match js_of_ocaml . compilation_mode with | None -> if Profile . is_dev t . context . profile then Js_of_ocaml . Compilation_mode . Separate_compilation else Whole_program | Some m -> m |
let js_of_ocaml_flags t ~ dir ( spec : Js_of_ocaml . Flags . Spec . t ) = let + expander = Env_tree . expander t . env_tree ~ dir and + js_of_ocaml = get_node t . env_tree ~ dir >>= Env_node . js_of_ocaml in Js_of_ocaml . Flags . make ~ spec ~ default : js_of_ocaml . flags ~ eval ( : Expander . expand_and_eval_set expa... |
let foreign_flags t ~ dir ~ expander ~ flags ~ language = let ccg = Context . cc_g t . context in let default = get_node t . env_tree ~ dir >>| Env_node . foreign_flags >>| fun dict -> Foreign_language . Dict . get dict language in let open Action_builder . O in let name = Foreign_language . proper_name language in let... |
let link_flags t ~ dir ( spec : Link_flags . Spec . t ) = let * expander = Env_tree . expander t . env_tree ~ dir in let + link_flags = get_node t . env_tree ~ dir >>= Env_node . link_flags in Link_flags . make ~ spec ~ default : link_flags ~ eval ( : Expander . expand_and_eval_set expander ) |
let menhir_flags t ~ dir ~ expander ~ flags = let t = t . env_tree in let default = get_node t ~ dir >>| Env_node . menhir_flags |> Action_builder . of_memo_join in Action_builder . memoize " menhir flags " ( Expander . expand_and_eval_set expander flags ~ standard : default ) |
let local_binaries t ~ dir = get_node t . env_tree ~ dir >>= Env_node . local_binaries |
let odoc t ~ dir = get_node t . env_tree ~ dir >>= Env_node . odoc |
let coq t ~ dir = get_node t . env_tree ~ dir >>= Env_node . coq |
let format_config t ~ dir = get_node t . env_tree ~ dir >>= Env_node . format_config |
let dump_env t ~ dir = let t = t . env_tree in let ocaml_flags = get_node t ~ dir >>= Env_node . ocaml_flags in let foreign_flags = get_node t ~ dir >>| Env_node . foreign_flags in let link_flags = get_node t ~ dir >>= Env_node . link_flags in let menhir_flags = get_node t ~ dir >>| Env_node . menhir_flags in let coq_f... |
let resolve_program t ~ dir ? hint ~ loc bin = let t = t . env_tree in let * bin_artifacts = Env_tree . bin_artifacts_host t ~ dir in Artifacts . Bin . binary ? hint ~ loc bin_artifacts bin |
let get_installed_binaries stanzas ( ~ context : Context . t ) = let open Memo . O in let install_dir = Local_install_path . bin_dir ~ context : context . name in let expand_str ~ dir sw = Expander . With_reduced_var_set . expand_str ~ context ~ dir sw in let expand_str_partial ~ dir sw = Expander . With_reduced_var_se... |
let create_lib_entries_by_package ~ public_libs stanzas = Dir_with_dune . Memo . deep_fold stanzas ~ init [ ] : ~ f ( : fun d stanza acc -> match stanza with | Dune_file . Library ( { visibility = Private ( Some pkg ) ; _ } as lib ) -> ( let + lib = let db = Scope . libs d . scope in Lib . DB . find db ( Dune_file . Li... |
let create_projects_by_package projects : Dune_project . t Package . Name . Map . t = List . concat_map projects ~ f ( : fun project -> Dune_project . packages project |> Package . Name . Map . values |> List . map ~ f ( : fun ( pkg : Package . t ) -> let name = Package . name pkg in ( name , project ) ) ) |> Package .... |
let modules_of_lib = Fdecl . create Dyn . opaque |
let create ( ~ context : Context . t ) ~ host ~ projects ~ packages ~ stanzas = let lib_config = Context . lib_config context in let projects_by_package = create_projects_by_package projects in let installed_libs = Lib . DB . create_from_findlib context . findlib ~ lib_config ~ projects_by_package in let modules_of_lib... |
let filter_out_stanzas_from_hidden_packages ~ visible_pkgs = List . filter_map ~ f ( : fun stanza -> let include_stanza = match Dune_file . stanza_package stanza with | None -> true | Some package -> let name = Package . name package in Package . Name . Map . mem visible_pkgs name in if include_stanza then Some stanza ... |
let all = Memo . lazy_ ( fun ( ) -> let open Memo . O in let * { Dune_load . dune_files ; packages ; projects } = Dune_load . load ( ) and * contexts = Context . DB . all ( ) and * only_packages = Only_packages . get ( ) in let packages = Option . value only_packages ~ default : packages in let rec sctxs = lazy ( Conte... |
let find name = let open Memo . O in let + all = Memo . Lazy . force all in Context_name . Map . find all name |
let dir_status_db t = t . dir_status_db |
module As_memo_key = struct type nonrec t = t let equal = equal let hash = hash let to_dyn = to_dyn_concise module And_package = struct type nonrec t = t * Package . t let hash ( x , y ) = Hashtbl . hash ( hash x , Package . hash y ) let equal ( x1 , y1 ) ( x2 , y2 ) = equal x1 x2 && y1 == y2 let to_dyn ( s , p ) = Dyn... |
let report_error ppf = function | Env . Illegal_renaming ( Illegal_renamingname , modname , filename ) filename -> fprintf ppf [ " @ You referred to the module % s , but we ' ve found one called % s instead . @ \ Is the name ' s casing right ] " ?@ name modname | Inconsistent_import ( Inconsistent_importname , source1 ... |
let setup ( ) = Location . register_error_of_exn ( function | Env . Error ( Missing_module ( loc , _ , _ ) _ | Illegal_value_name ( loc , _ ) _ as err ) err when loc <> Location . none -> Some ( Super_location . error_of_printer loc report_error err ) err | Env . Error err -> Some ( Super_location . error_of_printer_fi... |
let file_lines filePath = let chan = open_in_bin filePath in let lines = ref [ ] in try while true do lines := ( input_line chan ) chan :: ! lines done ; [ ] || with | End_of_file -> begin close_in chan ; List . rev ( ! lines ) lines |> Array . of_list end |
let setup_colors ( ) = Misc . Color . setup ! Clflags . color |
let print_filename ppf file = match file with | " _none_ " | " " -> Format . fprintf ppf ( " No file name ) name " | real_file -> Format . fprintf ppf " % s " ( Location . show_filename real_file ) real_file |
let print_loc ~ normalizedRange ppf loc = setup_colors ( ) ; let ( file , _ , _ ) _ = Location . get_pos_info loc . loc_start in if file = " // toplevel " // then begin if highlight_locations ppf [ loc ] loc then ( ) else fprintf ppf " Characters % i -% i " loc . loc_start . pos_cnum loc . loc_end . pos_cnum end else l... |
let print ~ is_warning intro ppf loc = setup_colors ( ) ; if loc . loc_start . pos_fname = " // toplevel " // && highlight_locations ppf [ loc ] loc then ( ) else if is_warning then fprintf ppf [ { " @@< info >% s } ] , " @@@ intro else begin fprintf ppf [ { " @@< error >% s } ] , " @@@ intro end ; let ( file , start_l... |
let rec super_error_reporter ppf ( { Location . loc ; msg ; sub ; if_highlight } if_highlight as err ) err = let highlighted = if if_highlight <> " " then let rec collect_locs locs { Location . loc ; sub ; if_highlight ; _ } _ = List . fold_left collect_locs ( loc :: locs ) locs sub in let locs = collect_locs [ ] err i... |
let super_warning_printer loc ppf w = if Warnings . is_active w then begin setup_colors ( ) ; Format . fprintf ppf [ " @< v 2 , >@% a , @% a ] , " @@ ( print ~ is_warning : true ( " Warning number " ^ ( Warnings . number w |> string_of_int ) string_of_int ) string_of_int ) string_of_int loc ( Warnings . super_print Sup... |
let print_phanton_error_prefix ppf = Format . pp_print_as ppf 2 " " |
let errorf ( ? loc = none ) none ( ? sub = [ ] ) ( ? if_highlight = ) " " fmt = Location . pp_ksprintf ~ before : print_phanton_error_prefix ( fun msg -> { loc ; msg ; sub ; if_highlight } if_highlight ) if_highlight fmt |
let error_of_printer loc print x = errorf ~ loc " % a " @? print x |
let error_of_printer_file print x = error_of_printer ( in_file ! input_name ) input_name print x |
let setup ( ) = Location . error_reporter := super_error_reporter ; Location . warning_printer := super_warning_printer ; |
let string_slice ~ start str = let last = String . length str in if last <= start then " " else String . sub str start ( last - start ) start |
let number_of_digits n = let digits = ref 1 in let nn = ref n in while ( ( ! nn ) nn / 10 ) 10 > 0 do ( nn := ( ( ! nn ) nn / 10 ) 10 ; digits := ( ( ! digits ) digits + 1 ) 1 ) 1 done ; ! digits |
let pad ( ? ch = ' ' ) ' content n = ( String . make ( n - ( String . length content ) content ) content ch ) ch ^ content |
let leading_space_count str = let rec _leading_space_count str str_length current_index = if current_index == str_length then current_index else if ( str [ . current_index ] current_index ) current_index <> ' ' then current_index else _leading_space_count str str_length ( current_index + 1 ) 1 in _leading_space_count s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.