text
stringlengths
12
786k
let get_info pos = try let dsl = Hashtbl . find post_table pos in get_docstring ~ info : true dsl with Not_found -> None
let floating_table : ( Lexing . position , docstring list ) Hashtbl . t = Hashtbl . create 50
let set_floating_docstrings pos dsl = if dsl <> [ ] then Hashtbl . add floating_table pos dsl
let get_text pos = try let dsl = Hashtbl . find floating_table pos in get_docstrings dsl with Not_found -> [ ]
let get_post_text pos = try let dsl = Hashtbl . find post_table pos in get_docstrings dsl with Not_found -> [ ]
let pre_extra_table : ( Lexing . position , docstring list ) Hashtbl . t = Hashtbl . create 50
let set_pre_extra_docstrings pos dsl = if dsl <> [ ] then Hashtbl . add pre_extra_table pos dsl
let get_pre_extra_text pos = try let dsl = Hashtbl . find pre_extra_table pos in get_docstrings dsl with Not_found -> [ ]
let post_extra_table : ( Lexing . position , docstring list ) Hashtbl . t = Hashtbl . create 50
let set_post_extra_docstrings pos dsl = if dsl <> [ ] then Hashtbl . add post_extra_table pos dsl
let get_post_extra_text pos = try let dsl = Hashtbl . find post_extra_table pos in get_docstrings dsl with Not_found -> [ ]
let symbol_docs ( ) = { docs_pre = get_pre_docs ( Parsing . symbol_start_pos ( ) ) ; docs_post = get_post_docs ( Parsing . symbol_end_pos ( ) ) ; }
let symbol_docs_lazy ( ) = let p1 = Parsing . symbol_start_pos ( ) in let p2 = Parsing . symbol_end_pos ( ) in lazy { docs_pre = get_pre_docs p1 ; docs_post = get_post_docs p2 ; }
let rhs_docs pos1 pos2 = { docs_pre = get_pre_docs ( Parsing . rhs_start_pos pos1 ) ; docs_post = get_post_docs ( Parsing . rhs_end_pos pos2 ) ; }
let rhs_docs_lazy pos1 pos2 = let p1 = Parsing . rhs_start_pos pos1 in let p2 = Parsing . rhs_end_pos pos2 in lazy { docs_pre = get_pre_docs p1 ; docs_post = get_post_docs p2 ; }
let mark_symbol_docs ( ) = mark_pre_docs ( Parsing . symbol_start_pos ( ) ) ; mark_post_docs ( Parsing . symbol_end_pos ( ) )
let mark_rhs_docs pos1 pos2 = mark_pre_docs ( Parsing . rhs_start_pos pos1 ) ; mark_post_docs ( Parsing . rhs_end_pos pos2 )
let symbol_info ( ) = get_info ( Parsing . symbol_end_pos ( ) )
let rhs_info pos = get_info ( Parsing . rhs_end_pos pos )
let symbol_text ( ) = get_text ( Parsing . symbol_start_pos ( ) )
let symbol_text_lazy ( ) = let pos = Parsing . symbol_start_pos ( ) in lazy ( get_text pos )
let rhs_text pos = get_text ( Parsing . rhs_start_pos pos )
let rhs_post_text pos = get_post_text ( Parsing . rhs_end_pos pos )
let rhs_text_lazy pos = let pos = Parsing . rhs_start_pos pos in lazy ( get_text pos )
let symbol_pre_extra_text ( ) = get_pre_extra_text ( Parsing . symbol_start_pos ( ) )
let symbol_post_extra_text ( ) = get_post_extra_text ( Parsing . symbol_end_pos ( ) )
let rhs_pre_extra_text pos = get_pre_extra_text ( Parsing . rhs_start_pos pos )
let rhs_post_extra_text pos = get_post_extra_text ( Parsing . rhs_end_pos pos ) end
let symbol_docs ( startpos , endpos ) = { docs_pre = get_pre_docs startpos ; docs_post = get_post_docs endpos ; }
let symbol_docs_lazy ( p1 , p2 ) = lazy { docs_pre = get_pre_docs p1 ; docs_post = get_post_docs p2 ; }
let rhs_docs pos1 pos2 = { docs_pre = get_pre_docs pos1 ; docs_post = get_post_docs pos2 ; }
let rhs_docs_lazy p1 p2 = lazy { docs_pre = get_pre_docs p1 ; docs_post = get_post_docs p2 ; }
let mark_symbol_docs ( startpos , endpos ) = mark_pre_docs startpos ; mark_post_docs endpos ; ( )
let mark_rhs_docs pos1 pos2 = mark_pre_docs pos1 ; mark_post_docs pos2 ; ( )
let symbol_info endpos = get_info endpos
let rhs_info endpos = get_info endpos
let symbol_text startpos = get_text startpos
let symbol_text_lazy startpos = lazy ( get_text startpos )
let rhs_text pos = get_text pos
let rhs_post_text pos = get_post_text pos
let rhs_text_lazy pos = lazy ( get_text pos )
let symbol_pre_extra_text startpos = get_pre_extra_text startpos
let symbol_post_extra_text endpos = get_post_extra_text endpos
let rhs_pre_extra_text pos = get_pre_extra_text pos
let rhs_post_extra_text pos = get_post_extra_text pos end
let init ( ) = docstrings := [ ] ; Hashtbl . reset pre_table ; Hashtbl . reset post_table ; Hashtbl . reset floating_table ; Hashtbl . reset pre_extra_table ; Hashtbl . reset post_extra_table
let pick_colour = Utils . colour_picker ( )
let bar ~ total = let open Line in let spinner = spinner ~ color ( : Color . ansi ` green ) ( ) in let bar = bar ~ color ( : pick_colour ( ) ) ~ style ` : ASCII total in list [ spinner ; brackets ( elapsed ( ) ) ; bar ; bytes ; parens ( const " eta : " ++ eta to...
module Worker = struct type t = { mutable todo : int ; mutable download_rate : int ; mutable reporter : int Reporter . t option } let empty ( ) = { todo = 0 ; reporter = None ; download_rate = 100_000 } let make_progress t = let progress = min t . todo t . download_rate in t . d...
type t = { mutable active_workers : Worker . t list ; mutable files : int list }
let run ( ) = let total_files = 18 in let files = List . init total_files ( fun _ -> Random . int 100_000_000 ) in let bottom_line = Line . ( spacer 4 ++ ticker_to ~ sep ( : const " / " ) total_files ++ const " files downloaded , elapsed : " ++ elapsed ( ) ) in let di...
type t = { denv : DE . t ; continuation_uses_env : CUE . t ; shareable_constants : Symbol . t Static_const . Map . t ; used_value_slots : Name_occurrences . t ; lifted_constants : LCS . t ; data_flow : Data_flow . t ; demoted_exn_handlers : Continuation . Set . t ; code_ids_t...
let [ @ ocamlformat " disable " ] print ppf { denv ; continuation_uses_env ; shareable_constants ; used_value_slots ; lifted_constants ; data_flow ; demoted_exn_handlers ; code_ids_to_remember ; slot_offsets } = Format . fprintf ppf " [ @< hov 1 ( >\ [ @< hov 1 ( > denv ...
let create denv continuation_uses_env = { denv ; continuation_uses_env ; slot_offsets = Code_id . Map . empty ; shareable_constants = Static_const . Map . empty ; used_value_slots = Name_occurrences . empty ; lifted_constants = LCS . empty ; data_flow = Data_flow . empty ; demoted_ex...
let denv t = t . denv
let data_flow t = t . data_flow
let with_continuation_uses_env t ~ cont_uses_env = { t with continuation_uses_env = cont_uses_env }
let record_continuation_use t cont use_kind ~ env_at_use ~ arg_types = let cont_uses_env , id = CUE . record_continuation_use t . continuation_uses_env cont use_kind ~ env_at_use ~ arg_types in with_continuation_uses_env t ~ cont_uses_env , id
let delete_continuation_uses t cont = let cont_uses_env = CUE . delete_continuation_uses t . continuation_uses_env cont in with_continuation_uses_env t ~ cont_uses_env
let num_continuation_uses t cont = CUE . num_continuation_uses t . continuation_uses_env cont
let continuation_uses_env t = t . continuation_uses_env
let code_age_relation t = TE . code_age_relation ( DE . typing_env ( denv t ) )
let with_code_age_relation t code_age_relation = let typing_env = TE . with_code_age_relation ( DE . typing_env ( denv t ) ) code_age_relation in with_denv t ( DE . with_typing_env ( denv t ) typing_env )
let typing_env t = DE . typing_env ( denv t )
let add_variable t var ty = with_denv t ( DE . add_variable ( denv t ) var ty )
let get_typing_env_no_more_than_one_use t k = CUE . get_typing_env_no_more_than_one_use t . continuation_uses_env k
let add_to_lifted_constant_accumulator ? also_add_to_env t constants = let also_add_to_env = match also_add_to_env with None -> false | Some ( ) -> true in let lifted_constants = LCS . union t . lifted_constants constants in let denv = if also_add_to_env then LCS . add_to_denv t . denv constants els...
let get_lifted_constants t = t . lifted_constants
let clear_lifted_constants t = { t with lifted_constants = LCS . empty }
let no_lifted_constants t = LCS . is_empty t . lifted_constants
let get_and_clear_lifted_constants t = let constants = t . lifted_constants in let t = clear_lifted_constants t in t , constants
let set_lifted_constants t consts = { t with lifted_constants = consts }
let find_shareable_constant t static_const = Static_const . Map . find_opt static_const t . shareable_constants
let consider_constant_for_sharing t symbol static_const = if not ( Static_const . can_share static_const ) then t else { t with shareable_constants = Static_const . Map . add static_const symbol t . shareable_constants }
let with_shareable_constants t ~ shareable_constants = { t with shareable_constants }
let shareable_constants t = t . shareable_constants
let add_use_of_value_slot t value_slot = { t with used_value_slots = Name_occurrences . add_value_slot_in_projection t . used_value_slots value_slot Name_mode . normal }
let used_value_slots t = t . used_value_slots
let all_continuations_used t = CUE . all_continuations_used t . continuation_uses_env
let with_used_value_slots t ~ used_value_slots = { t with used_value_slots }
let add_code_ids_to_remember t code_ids = if DE . at_unit_toplevel t . denv then t else { t with code_ids_to_remember = Code_id . Set . union code_ids t . code_ids_to_remember }
let code_ids_to_remember t = t . code_ids_to_remember
let with_code_ids_to_remember t ~ code_ids_to_remember = { t with code_ids_to_remember }
let set_do_not_rebuild_terms_and_disable_inlining t = { t with denv = DE . set_do_not_rebuild_terms_and_disable_inlining t . denv }
let are_rebuilding_terms t = DE . are_rebuilding_terms t . denv
let do_not_rebuild_terms t = Are_rebuilding_terms . do_not_rebuild_terms ( are_rebuilding_terms t )
let demote_exn_handler t cont = { t with demoted_exn_handlers = Continuation . Set . add cont t . demoted_exn_handlers }
let demoted_exn_handlers t = t . demoted_exn_handlers
let slot_offsets t = t . slot_offsets
let with_slot_offsets t ~ slot_offsets = { t with slot_offsets }
type resolver = Compilation_unit . t -> Flambda2_types . Typing_env . t option
type get_imported_names = unit -> Name . Set . t
type get_imported_code = unit -> Exported_code . t
type t = { round : int ; typing_env : TE . t ; inlined_debuginfo : Debuginfo . t ; can_inline : bool ; inlining_state : Inlining_state . t ; float_const_prop : bool ; at_unit_toplevel : bool ; unit_toplevel_return_continuation : Continuation . t ; unit_toplevel_exn_continuation : Con...
let print_debuginfo ppf dbg = if Debuginfo . is_none dbg then Format . pp_print_string ppf " None " else Debuginfo . print_compact ppf dbg
let [ @ ocamlformat " disable " ] print ppf { round ; typing_env ; inlined_debuginfo ; can_inline ; inlining_state ; float_const_prop ; at_unit_toplevel ; unit_toplevel_exn_continuation ; variables_defined_at_toplevel ; cse ; do_not_rebuild_terms ; closure_info ; unit_toplevel_return_...
let create ~ round ( ~ resolver : resolver ) ( ~ get_imported_names : get_imported_names ) ( ~ get_imported_code : get_imported_code ) ~ float_const_prop ~ unit_toplevel_exn_continuation ~ unit_toplevel_return_continuation = { round ; typing_env = TE . create ~ resolver ~ get_imported_na...
let all_code t = t . all_code
let resolver t = TE . resolver t . typing_env
let typing_env t = t . typing_env