text stringlengths 0 601k |
|---|
let implementation_label = " native toplevel " |
let global_symbol id = let sym = Compilenv . symbol_for_global id in match Tophooks . lookup sym with | None -> fatal_error ( " Toploop . global_symbol " ^ ( Ident . unique_name id ) ) | Some obj -> obj |
let remembered = ref Ident . empty |
let rec remember phrase_name i = function | [ ] -> ( ) | Sig_value ( id , _ , _ ) :: rest | Sig_module ( id , _ , _ , _ , _ ) :: rest | Sig_typext ( id , _ , _ , _ ) :: rest | Sig_class ( id , _ , _ , _ ) :: rest -> remembered := Ident . add id ( phrase_name , i ) ! remembered ; remember phrase_name ( succ i ) rest | _... |
let toplevel_value id = try Ident . find_same id ! remembered with _ -> Misc . fatal_error @@ " Unknown ident : " ^ Ident . unique_name id |
let close_phrase lam = let open Lambda in Ident . Set . fold ( fun id l -> let glb , pos = toplevel_value id in let glob = Lprim ( Pfield ( pos , Pointer , Mutable ) , [ Lprim ( Pgetglobal glb , [ ] , Loc_unknown ) ] , Loc_unknown ) in Llet ( Strict , Pgenval , id , glob , l ) ) ( free_variables lam ) lam |
let toplevel_value id = let glob , pos = if Config . flambda then toplevel_value id else Translmod . nat_toplevel_name id in ( Obj . magic ( global_symbol glob ) ) . ( pos ) |
module EvalBase = struct let eval_ident id = try if Ident . persistent id || Ident . global id then global_symbol id else toplevel_value id with _ -> raise ( Undefined_global ( Ident . name id ) ) end |
let may_trace = ref false |
let load_lambda ppf ~ module_ident ~ required_globals phrase_name lam size = if ! Clflags . dump_rawlambda then fprintf ppf " % a . " @ Printlambda . lambda lam ; let slam = Simplif . simplify_lambda lam in if ! Clflags . dump_lambda then fprintf ppf " % a . " @ Printlambda . lambda slam ; let program = { Lambda . code... |
let pr_item = Printtyp . print_items ( fun env -> function | Sig_value ( id , { val_kind = Val_reg ; val_type } , _ ) -> Some ( outval_of_value env ( toplevel_value id ) val_type ) | _ -> None ) |
let phrase_seqid = ref 0 |
let execute_phrase print_outcome ppf phr = match phr with | Ptop_def sstr -> let oldenv = ! toplevel_env in incr phrase_seqid ; let phrase_name = " TOP " ^ string_of_int ! phrase_seqid in Compilenv . reset ? packname : None phrase_name ; Typecore . reset_delayed_checks ( ) ; let sstr , rewritten = match sstr with | [ {... |
let getvalue _ = assert false |
let setvalue _ _ = assert false |
let load_file _ ppf name0 = let name = try Some ( Load_path . find name0 ) with Not_found -> None in match name with | None -> fprintf ppf " File not found : % s . " @ name0 ; false | Some name -> let fn , tmp = if Filename . check_suffix name " . cmx " || Filename . check_suffix name " . cmxa " then let cmxs = Filenam... |
let init ( ) = Compmisc . init_path ( ) ; Clflags . dlcode := true ; ( ) |
let rec uniq = function x :: l when List . mem x l -> uniq l | x :: l -> x :: uniq l | l -> l |
let split_in_words s = let l = String . length s in let rec split i j = if j < l then let j ' = succ j in match s . [ j ] with ( ' ' ' |\ t ' ' |\ n ' ' |\ r ' ' , ' ) | -> let rem = split j ' j ' in if i < j then ( String . sub s i ( j - i ) ) :: rem else rem | _ -> split i j ' else if i < j then [ String . sub s i ( ... |
let normalize_dirname d = let s = String . copy d in let l = String . length d in let norm_dir_unix ( ) = for k = 1 to l - 1 do if s . [ k ] = ' ' / && s . [ k - 1 ] = ' ' / then s . [ k ] <- Char . chr 0 ; if s . [ k ] = ' ' / && k = l - 1 then s . [ k ] <- Char . chr 0 done in let norm_dir_win ( ) = if l >= 1 && s . ... |
let forbidden = ref ( [ ] : string list ) |
let loaded = ref ( [ ] : string list ) |
let predicates = ref ( [ ] : string list ) |
let add_directory d = let d = normalize_dirname d in let d = expand_directory Config . standard_library d in if not ( List . mem d ! Config . load_path ) then begin Config . load_path := d :: ! Config . load_path ; if real_toploop then fprintf std_formatter " [ ` @% s ' added to search path ] . " @@ d end |
let add_predicates pl = predicates := uniq ( pl @ ! predicates ) |
let syntax s = add_predicates [ " syntax " ; s ] |
let standard_syntax ( ) = syntax " camlp4o " |
let revised_syntax ( ) = syntax " camlp4r " |
let load pl = List . iter ( fun p -> if not ( List . mem p ! loaded ) then begin let d = Findlib . package_directory p in add_directory d ; if not ( List . mem p ! forbidden ) then begin let archive = ( try Findlib . package_property ! predicates p " archive " with Not_found -> " " ) in let archives = split_in_words ar... |
let load_deeply pl = load ( Findlib . package_deep_ancestors ! predicates pl ) |
let don ' t_load pl = forbidden := uniq ( pl @ ! forbidden ) ; List . iter ( fun p -> ignore ( Findlib . package_directory p ) ) pl |
let don ' t_load_deeply pl = List . iter ( fun p -> ignore ( Findlib . package_directory p ) ) pl ; don ' t_load ( Findlib . package_deep_ancestors ! predicates pl ) |
let protect f x = try ignore ( f x ) with Failure s -> fprintf err_formatter " [ @% s ] . " @@ s |
let reset ( ) = loaded := [ ] ; Hashtbl . replace directive_table " require " ( Directive_string ( protect ( fun s -> load_deeply ( split_in_words s ) ) ) ) ; Hashtbl . replace directive_table " predicates " ( Directive_string ( protect ( fun s -> add_predicates ( split_in_words s ) ) ) ) ; Hashtbl . replace directive_... |
let announce ( ) = if real_toploop then begin print_endline ( " Findlib has been successfully loaded . Additional directives :\ n " ^ " # require " \ package " ; ; \ to load a package \ n " ^ " # list ; ; to list the available packages \ n " ^ " # camlp4o ; ; to load camlp4 ( standard syntax ) \ n " ^ " # camlp4r ; ; t... |
let lookup sym = Dynlink . unsafe_get_global_value ~ bytecode_or_asm_symbol : sym |
let need_symbol sym = Option . is_none ( Dynlink . unsafe_get_global_value ~ bytecode_or_asm_symbol : sym ) |
let dll_run dll entry = match ( try Result ( Obj . magic ( ndl_run_toplevel dll entry ) ) with exn -> Exception exn ) with | Exception _ as r -> r | Result r -> match Obj . magic r with | Ok x -> Result x | Err s -> fatal_error ( " Toploop . dll_run " ^ s ) |
module Backend = struct let symbol_for_global ' = Compilenv . symbol_for_global ' let closure_symbol = Compilenv . closure_symbol let really_import_approx = Import_approx . really_import_approx let import_symbol = Import_approx . import_symbol let size_int = Arch . size_int let big_endian = Arch . big_endian let max_se... |
let backend = ( module Backend : Backend_intf . S ) |
let load ppf phrase_name program = let dll = if ! Clflags . keep_asm_file then phrase_name ^ ext_dll else Filename . temp_file ( " caml " ^ phrase_name ) ext_dll in let filename = Filename . chop_extension dll in let middle_end = if Config . flambda then Flambda_middle_end . lambda_to_clambda else Closure_middle_end . ... |
type lookup_fn = string -> Obj . t option |
type load_fn = Format . formatter -> string -> Lambda . program -> Topcommon . evaluation_outcome |
type assembler = { mutable lookup : lookup_fn ; mutable load : load_fn } |
let fns = { lookup ; load } |
let load ppf = fns . load ppf |
let lookup sym = fns . lookup sym |
let register_loader ~ lookup ~ load = fns . lookup <- lookup ; fns . load <- load |
type output_type = [ | ` HTML of string | ` CSV of string ] |
module Configuration = struct type t = { name : string ; rna_gene_fpkm_tracking_file : string option ; rna_min_gene_expression : float ; rna_transcript_fpkm_tracking_file : string option ; rna_min_transcript_expression : float ; rna_transcript_fkpm_gtf_file : string option ; mhc_epitope_lengths : int list ; only_novel_... |
let run ( ~ run_with : Machine . t ) ~ configuration ~ reference_build ~ vcfs ~ predictor ~ alleles_file ~ output = let open KEDSL in let open Hla_utilities in let topiary = Machine . get_tool run_with Machine . Tool . Default . topiary in let predictor_tool = predictor_to_tool ~ run_with predictor in let ( predictor_e... |
let received_msg = option int |
let s = " ReWeb . Topic " , [ Alcotest . test_case " make , subscribe , publish , pull " ` Quick begin fun ( ) -> let topic = Topic . make ( ) in Lwt_main . run begin let open Lwt . Syntax in let * subscription = Topic . subscribe topic in let * ( ) = Topic . publish topic ~ msg in let + msg_option = Topic . pull subsc... |
module type Env = sig val bool : string -> bool val native : bool val native_dynlink : bool end |
module type Exts = sig val interface : string list val interface_opt : string list val library : string list val module_library : string list end |
module type Pkg = sig type builder = [ ` OCamlbuild | ` Other of string * string ] type moves type field = ? cond : bool -> ? exts : string list -> ? dst : string -> string -> moves val lib : field val lib_exec : ? auto : bool -> field val bin : ? auto : bool -> field val sbin : ? auto : bool -> field val toplevel : fi... |
module Topkg : sig val cmd : [ ` Build | ` Explain | ` Help ] val env : ( string * bool ) list val err_parse : string -> ' a val err_mdef : string -> ' a val err_miss : string -> ' a val err_file : string -> string -> ' a val warn_unused : string -> unit let err fmt = let k _ = exit 1 in Format . kfprintf k Format . er... |
module Env : sig include Env val get : unit -> ( string * bool ) list let env = ref [ ] let get ( ) = ! env let add_bool key b = env := ( key , b ) :: ! env let bool key = let b = try List . assoc key Topkg . env with | Not_found -> if Topkg . cmd = ` Build then Topkg . err_miss key else true in add_bool key b ; b let ... |
module Exts : Exts = struct let interface = [ " . mli " ; " . cmi " ; " . cmti " ] let interface_opt = " . cmx " :: interface let library = [ " . cma " ; " . cmxa " ; " . cmxs " ; " . a " ] let module_library = ( interface_opt @ library ) end |
module Pkg : Pkg = struct type builder = [ ` OCamlbuild | ` Other of string * string ] type moves = ( string * ( string * string ) ) list type field = ? cond : bool -> ? exts : string list -> ? dst : string -> string -> moves let str = Printf . sprintf let warn_unused ( ) = let keys = List . map fst Topkg . env in let ... |
let cmds = [ Bistro . cmd ; Browse . cmd ; Build . cmd ; Clean . cmd ; Distrib . cmd ; Doc . cmd ; Help . cmd ; Ipc . cmd ; Issue . cmd ; Lint . cmd ; Log . cmd ; Opam . cmd ; Publish . cmd ; Run . cmd ; Status . cmd ; Tag . cmd ; Test . cmd ; ] |
let main ( ) = ` Help ( ` Pager , None ) None |
let doc = " Topkg package care " |
let man = [ ` S Manpage . s_description ; ` P ( " $ mname ) mname takes care of topkg packages . " ; ` P " Use ' ( $ mname ) mname help release ' for help to release a package . " ; ` Noblank ; ` P " Use ' ( $ mname ) mname help delegate ' for help about the topkg delegate . " ; ` Noblank ; ` P " Use ' ( $ mname ) mnam... |
let main = Term ( . ret ( const main $ Cli . setup ) setup ) setup , Term . info " topkg " ~ version " :%% VERSION " %% ~ doc ~ sdocs ~ exits ~ man |
let main ( ) = Topkg . Private . disable_main ( ) ; Term ( . exit_status @@ eval_choice main cmds ) cmds |
let ( ) = main ( ) |
let ocamlbuild_flags = Topkg_cmd ( . empty % " - use - ocamlfind " % " - classic - display ) " |
let build_cmd c os = let ocamlbuild = Topkg_conf . tool " ocamlbuild " os in let build_dir = Topkg_conf . build_dir c in let toolchain = match Topkg_conf . toolchain c with | Some toolchain -> Topkg_cmd ( . v " - toolchain " % toolchain ) toolchain | _ -> Topkg_cmd . empty in let debug = Topkg_cmd ( . on ( Topkg_conf .... |
let clean_cmd os ~ build_dir = let ocamlbuild = Topkg_conf . tool " ocamlbuild " os in Topkg_cmd ( . ocamlbuild %% ocamlbuild_flags % " - build - dir " % build_dir % " - clean ) " |
type t = { prepare_on_pin : bool ; dir : Topkg_fpath . t ; pre : Topkg_conf . t -> unit result ; cmd : Topkg_conf . t -> Topkg_conf . os -> Topkg_fpath . t list -> unit result ; post : Topkg_conf . t -> unit result ; clean : Topkg_conf . os -> build_dir : Topkg_fpath . t -> unit result ; } |
let with_dir b dir = { b with dir } |
let nop = fun _ -> Ok ( ) |
let cmd c os files = Topkg_os . Cmd . run @@ Topkg_cmd ( . build_cmd c os %% of_list files ) files |
let clean os ~ build_dir = Topkg_os . Cmd . run @@ clean_cmd os ~ build_dir |
let v ( ? prepare_on_pin = true ) true ( ? dir = " _build ) " ( ? pre = nop ) nop ( ? cmd = cmd ) cmd ( ? post = nop ) nop ( ? clean = clean ) clean ( ) = { prepare_on_pin ; dir ; pre ; cmd ; post ; clean ; } |
let prepare_on_pin b = b . prepare_on_pin |
let dir b = b . dir |
let pre b = b . pre |
let cmd b = b . cmd |
let post b = b . post |
let clean b = b . clean |
let codec = let prepare_on_pin = Topkg_codec ( . with_kind " prepare_on_pin " @@ bool ) bool in let dir = Topkg_codec ( . with_kind " dir " @@ string ) string in let fields = let stub _ = invalid_arg " not executable outside package definition " in ( fun b -> b . prepare_on_pin , b . dir ) dir , ( fun ( prepare_on_pin ... |
let ocb_tag c key tag = let tag = Topkg_string . strf " % s ( s % a ) a " tag ( Topkg_conf . pp_value c ) c key in Topkg_cmd ( . v " - tag " % tag ) tag |
let ocb_bool_tag c key tag = Topkg_cmd ( . on ( Topkg_conf . value c key ) key @@ v " - tag " % tag ) tag |
let ocb_bool_tags c tags = let f ( key , tag ) tag = Topkg_cmd ( ) . %% ( ocb_bool_tag c key tag ) tag in List . fold_right f tags Topkg_cmd . empty |
module Tar = struct type ptime = int type t = string list let empty = [ ] let to_unix_path_string = if Fpath . dir_sep = " " / then Fpath . to_string else fun f -> String . concat ~ sep " " :/ ( Fpath . segs f ) f let set_filename h f = let s = to_unix_path_string f in match String . length s with | n when n <= 100 -> ... |
let path_set_of_dir dir ~ exclude_paths = let add_prefix p acc = Fpath ( . Set . add ( dir // p ) p acc ) acc in let exclude_paths = Fpath . Set ( . fold add_prefix exclude_paths empty ) empty in let not_excluded p = Ok ( not ( Fpath . Set . mem p exclude_paths ) exclude_paths ) exclude_paths in let traverse = ` Sat no... |
let tar dir ~ exclude_paths ~ root ~ mtime = let tar_add file tar = let fname = match Fpath . rem_prefix dir file with | None -> assert false | Some file -> Fpath ( . root // file ) file in Logs . info ( fun m -> m " Archiving % a " Fpath . pp fname ) fname ; tar >>= fun tar -> OS . Dir . exists file >>= function | tru... |
let bzip2_cmd = OS . Env ( . value " TOPKG_BZIP2 " cmd ~ absent ( : Cmd . v " bzip2 ) ) " |
let ensure_bzip2 ( ) = OS . Cmd . must_exist bzip2_cmd >>| fun _ -> ( ) |
let bzip2 s ~ dst = OS . Cmd ( . in_string s |> run_io bzip2_cmd |> to_file dst ) dst |
let tar_cmd = OS . Env ( . value " TOPKG_TAR " cmd ~ absent ( : Cmd . v " tar ) ) " |
let ensure_tar ( ) = OS . Cmd . must_exist tar_cmd >>| fun _ -> ( ) |
let untbz ( ? clean = false ) false ar = let clean_dir dir = OS . Dir . exists dir >>= function | true when clean -> OS . Dir . delete ~ recurse : true dir | _ -> Ok ( ) in let archive_dir , ar = Fpath . split_base ar in let unarchive ar = let dir = Fpath . rem_ext ar in OS . Cmd . must_exist tar_cmd >>= fun cmd -> cle... |
let run_delegate pkg args = let verbosity = Logs . level_to_string ( Logs . level ( ) ) in Topkg_care_pkg . delegate pkg >>= fun del -> Ok Cmd ( . del % " ipc " % verbosity %% args ) args >>= fun cmd -> OS . Cmd . run_status cmd >>= function | ` Exited 0 -> Ok ( ) | ` Exited 1 -> R . error_msgf " Action unsupported by ... |
let publish_distrib p ~ msg ~ archive = Topkg_care_pkg . name p >>= fun name -> Topkg_care_pkg . version p >>= fun version -> Topkg_care_pkg . distrib_uri p >>= fun distrib_uri -> run_delegate p Cmd ( . v " publish " % " distrib " % distrib_uri % name % version % msg % p archive ) archive |
let publish_doc p ~ msg ~ docdir = let doc_uri p = Topkg_care_pkg . opam_field_hd p " doc " >>= function | None -> Ok " " | Some uri -> Ok uri in Topkg_care_pkg . name p >>= fun name -> Topkg_care_pkg . version p >>= fun version -> doc_uri p >>= fun doc_uri -> run_delegate p Cmd ( . v " publish " % " doc " % doc_uri % ... |
let publish_alt p ~ kind ~ msg ~ archive = Topkg_care_pkg . name p >>= fun name -> Topkg_care_pkg . version p >>= fun version -> Topkg_care_pkg . distrib_uri p >>= fun distrib_uri -> run_delegate p Cmd ( . v " publish " % " alt " % distrib_uri % kind % name % version % msg % p archive ) archive |
let publish_in_git_branch ~ remote ~ branch ~ name ~ version ~ docdir ~ dir = let pp_distrib ppf ( name , version ) version = Fmt . pf ppf " % a % a " Topkg_care_text . Pp . name name Topkg_care_text . Pp . version version in let log_publish_result msg distrib dir = Logs . app ( fun m -> m " % s % a @ in @ directory @ ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.