text stringlengths 0 601k |
|---|
let register ds = docstrings := ds :: ! docstrings |
let docstring_body ds = ds . ds_body |
let docstring_loc ds = ds . ds_loc |
type docs = { docs_pre : docstring option ; docs_post : docstring option ; } |
let empty_docs = { docs_pre = None ; docs_post = None } |
let doc_loc = { txt = " ocaml . doc " ; loc = Location . none } |
let docs_attr ds = let open Parsetree in let body = ds . ds_body in let loc = ds . ds_loc in let exp = { pexp_desc = Pexp_constant ( Pconst_string ( body , loc , None ) ) ; pexp_loc = loc ; pexp_loc_stack = [ ] ; pexp_attributes = [ ] ; } in let item = { pstr_desc = Pstr_eval ( exp , [ ] ) ; pstr_loc = loc } in { attr_... |
let add_docs_attrs docs attrs = let attrs = match docs . docs_pre with | None | Some { ds_body " " ; = _ } -> attrs | Some ds -> docs_attr ds :: attrs in let attrs = match docs . docs_post with | None | Some { ds_body " " ; = _ } -> attrs | Some ds -> attrs @ [ docs_attr ds ] in attrs |
type info = docstring option |
let add_info_attrs info attrs = match info with | None | Some { ds_body " " ; = _ } -> attrs | Some ds -> attrs @ [ info_attr ds ] |
type text = docstring list |
let empty_text_lazy = lazy [ ] |
let text_loc = { txt = " ocaml . text " ; loc = Location . none } |
let text_attr ds = let open Parsetree in let body = ds . ds_body in let loc = ds . ds_loc in let exp = { pexp_desc = Pexp_constant ( Pconst_string ( body , loc , None ) ) ; pexp_loc = loc ; pexp_loc_stack = [ ] ; pexp_attributes = [ ] ; } in let item = { pstr_desc = Pstr_eval ( exp , [ ] ) ; pstr_loc = loc } in { attr_... |
let add_text_attrs dsl attrs = let fdsl = List . filter ( function { ds_body " " } = -> false | _ -> true ) dsl in ( List . map text_attr fdsl ) @ attrs |
let get_docstring ~ info dsl = let rec loop = function | [ ] -> None | { ds_attached = Info ; _ } :: rest -> loop rest | ds :: _ -> ds . ds_attached <- if info then Info else Docs ; Some ds in loop dsl |
let get_docstrings dsl = let rec loop acc = function | [ ] -> List . rev acc | { ds_attached = Info ; _ } :: rest -> loop acc rest | ds :: rest -> ds . ds_attached <- Docs ; loop ( ds :: acc ) rest in loop [ ] dsl |
let associate_docstrings dsl = List . iter ( fun ds -> match ds . ds_associated with | Zero -> ds . ds_associated <- One | ( One | Many ) -> ds . ds_associated <- Many ) dsl |
let pre_table : ( Lexing . position , docstring list ) Hashtbl . t = Hashtbl . create 50 |
let set_pre_docstrings pos dsl = if dsl <> [ ] then Hashtbl . add pre_table pos dsl |
let get_pre_docs pos = try let dsl = Hashtbl . find pre_table pos in associate_docstrings dsl ; get_docstring ~ info : false dsl with Not_found -> None |
let mark_pre_docs pos = try let dsl = Hashtbl . find pre_table pos in associate_docstrings dsl with Not_found -> ( ) |
let post_table : ( Lexing . position , docstring list ) Hashtbl . t = Hashtbl . create 50 |
let set_post_docstrings pos dsl = if dsl <> [ ] then Hashtbl . add post_table pos dsl |
let get_post_docs pos = try let dsl = Hashtbl . find post_table pos in associate_docstrings dsl ; get_docstring ~ info : false dsl with Not_found -> None |
let mark_post_docs pos = try let dsl = Hashtbl . find post_table pos in associate_docstrings dsl with Not_found -> ( ) |
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 total ) ] |
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 . download_rate <- max 0 ( t . download_rate... |
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 display = Display . start Multi . ( blank ++ blank ++ ... |
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_to_remember : Code_id . Set . t ; slot_offset... |
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 @ % a ) ] @@ \ [ @< hov 1 ( > continuation_uses_e... |
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_exn_handlers = Continuation . Set . em... |
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 else t . denv in { t wi... |
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 } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.