text stringlengths 12 786k |
|---|
let toremove = ref ( [ ] : string list ) |
let option opt ( ) = compargs := opt :: ! compargs |
let option_with_arg opt arg = compargs := ( Filename . quote arg ) :: opt :: ! compargs ; ; |
let make_archive = ref false ; ; |
let with_impl = ref false ; ; |
let with_intf = ref false ; ; |
let with_mli = ref false ; ; |
let with_ml = ref false ; ; |
let process_file filename = if Filename . check_suffix filename " . ml " then with_ml := true ; if Filename . check_suffix filename " . mli " then with_mli := true ; compargs := ( Filename . quote filename ) :: ! compargs ; ; |
let usage = " Usage : ocamlcp < options > < files >\ noptions are " : |
let incompatible o = fprintf stderr " ocamlcp : profiling is incompatible with the % s option \ n " o ; exit 2 |
module Options = Main_args . Make_bytecomp_options ( struct let _a ( ) = make_archive := true ; option " - a " ( ) let _annot = option " - annot " let _c = option " - c " let _cc s = option_with_arg " - cc " s let _cclib s = option_with_arg " - cclib " s let _ccopt s ... |
let add_profarg s = profargs := ( Filename . quote s ) :: " - m " :: ! profargs ; ; |
let optlist = ( " - p " , Arg . String add_profarg , " [ afilmt ] Profile constructs specified by argument ( default fm ) :\ n \ \ 032 a Everything \ n \ \ 032 f Function calls and method calls \ n \ \ 032 i if . . . then . . . else \ n \ \ 032 l while and for loops ... |
let status = Sys . command ( Printf . sprintf " ocamlc - pp " \ ocamlprof - instrument % s " \ % s % s " ( String . concat " " ( List . rev ! profargs ) ) ( if ! make_archive then " " else " profiling . cmo " ) ( String . concat " " ( List . rev ! compa... |
let load_path = ref ( [ ] : ( string * string array ) list ) |
let ml_synonyms = ref [ " . ml " ] |
let mli_synonyms = ref [ " . mli " ] |
let native_only = ref false |
let force_slash = ref false |
let error_occurred = ref false |
let raw_dependencies = ref false |
let fix_slash s = if Sys . os_type = " Unix " then s else begin let r = String . copy s in for i = 0 to String . length r - 1 do if r . [ i ] = ' ' \\ then r . [ i ] <- ' ' / done ; r end |
let add_to_load_path dir = try let dir = Misc . expand_directory Config . standard_library dir in let contents = Sys . readdir dir in load_path := ! load_path @ [ dir , contents ] with Sys_error msg -> fprintf Format . err_formatter " [ @ Bad - I option : % s ] . " @@ msg ; error_o... |
let add_to_synonym_list synonyms suffix = if ( String . length suffix ) > 1 && suffix . [ 0 ] = ' . ' then synonyms := suffix :: ! synonyms else begin fprintf Format . err_formatter " [ @ Bad suffix : ' % s ' ] . " @@ suffix ; error_occurred := true end |
let find_file name = let uname = String . uncapitalize name in let rec find_in_array a pos = if pos >= Array . length a then None else begin let s = a . ( pos ) in if s = name || s = uname then Some s else find_in_array a ( pos + 1 ) end in let rec find_in_path = function [ ] -> raise Not_... |
let rec find_file_in_list = function [ ] -> raise Not_found |
let find_dependency modname ( byt_deps , opt_deps ) = try let candidates = List . map ( ( ) ^ modname ) ! mli_synonyms in let filename = find_file_in_list candidates in let basename = Filename . chop_extension filename in let optname = if List . exists ( fun ext -> Sys . file_exists ( ... |
let ( depends_on , escaped_eol ) = ( " " , : " \\\ n " ) |
let print_filename s = let s = if ! force_slash then fix_slash s else s in if not ( String . contains s ' ' ) then begin print_string s ; end else begin let rec count n i = if i >= String . length s then n else if s . [ i ] = ' ' then count ( n + 1 ) ( i + 1 ) else count n ( ... |
let print_dependencies target_file deps = print_filename target_file ; print_string depends_on ; let rec print_items pos = function [ ] -> print_string " \ n " | dep :: rem -> if pos + 1 + String . length dep <= 77 then begin print_string " " ; print_filename dep ; print_items ( pos ... |
let print_raw_dependencies source_file deps = print_filename source_file ; print_string " " ; : Depend . StringSet . iter ( fun dep -> if ( String . length dep > 0 ) && ( match dep . [ 0 ] with ' A ' . . ' Z ' -> true | _ -> false ) then begin print_char ' ' ; ... |
let preprocessor = ref None |
let preprocess sourcefile = match ! preprocessor with None -> sourcefile | Some pp -> flush Pervasives . stdout ; let tmpfile = Filename . temp_file " camlpp " " " in let comm = Printf . sprintf " % s % s > % s " pp sourcefile tmpfile in if Sys . command comm <> 0 then begin Misc . ... |
let remove_preprocessed inputfile = match ! preprocessor with None -> ( ) | Some _ -> Misc . remove_file inputfile |
let is_ast_file ic ast_magic = try let buffer = String . create ( String . length ast_magic ) in really_input ic buffer 0 ( String . length ast_magic ) ; if buffer = ast_magic then true else if String . sub buffer 0 9 = String . sub ast_magic 0 9 then failwith " Ocaml and preprocessor hav... |
let parse_use_file ic = if is_ast_file ic Config . ast_impl_magic_number then let _source_file = input_value ic in [ Ptop_def ( input_value ic : Parsetree . structure ) ] else begin seek_in ic 0 ; let lb = Lexing . from_channel ic in Parse . use_file lb end |
let parse_interface ic = if is_ast_file ic Config . ast_intf_magic_number then let _source_file = input_value ic in ( input_value ic : Parsetree . signature ) else begin seek_in ic 0 ; let lb = Lexing . from_channel ic in Parse . interface lb end |
let ml_file_dependencies source_file = Depend . free_structure_names := Depend . StringSet . empty ; let input_file = preprocess source_file in let ic = open_in_bin input_file in try let ast = parse_use_file ic in Depend . add_use_file Depend . StringSet . empty ast ; if ! raw_dependencies then be... |
let mli_file_dependencies source_file = Depend . free_structure_names := Depend . StringSet . empty ; let input_file = preprocess source_file in let ic = open_in_bin input_file in try let ast = parse_interface ic in Depend . add_signature Depend . StringSet . empty ast ; if ! raw_dependencies then... |
type file_kind = ML | MLI ; ; |
let file_dependencies_as kind source_file = Location . input_name := source_file ; try if Sys . file_exists source_file then begin match kind with | ML -> ml_file_dependencies source_file | MLI -> mli_file_dependencies source_file end with x -> let report_err = function | Lexer . Error ( err , rang... |
let file_dependencies source_file = if List . exists ( Filename . check_suffix source_file ) ! ml_synonyms then file_dependencies_as ML source_file else if List . exists ( Filename . check_suffix source_file ) ! mli_synonyms then file_dependencies_as MLI source_file else ( ) |
let usage = " Usage : ocamldep [ options ] < source files >\ nOptions are " : |
let print_version ( ) = printf " ocamldep , version % s . " @ Sys . ocaml_version ; exit 0 ; ; ; |
let print_version_num ( ) = printf " % s . " @ Sys . ocaml_version ; exit 0 ; ; ; |
let _ = Clflags . classic := false ; add_to_load_path Filename . current_dir_name ; Arg . parse [ " - I " , Arg . String add_to_load_path , " < dir > Add < dir > to the list of include directories " ; " - impl " , Arg . String ( file_dependencies_as ML ) , " < f > ... |
module Make ( Ast : Sig . Camlp4Ast ) ( Gram : Sig . Grammar . Static with module Loc = Ast . Loc with type Token . t = Sig . camlp4_token ) ( Quotation : Sig . Quotation with module Ast = Sig . Camlp4AstToAst Ast ) and module Ast = Ast and module Token = Gram . Token and module Gr... |
let instr_fun = ref false |
let cur_point = ref 0 |
let copy_buffer = String . create 256 |
let copy_chars_unix nchars = let n = ref nchars in while ! n > 0 do let m = input ! inchan copy_buffer 0 ( min ! n 256 ) in if m = 0 then raise End_of_file ; output ! outchan copy_buffer 0 m ; n := ! n - m done |
let copy_chars_win32 nchars = for i = 1 to nchars do let c = input_char ! inchan in if c <> ' \ r ' then output_char ! outchan c done |
let copy_chars = match Sys . os_type with " Win32 " | " Cygwin " -> copy_chars_win32 | _ -> copy_chars_unix |
let copy next = assert ( next >= ! cur_point ) ; seek_in ! inchan ! cur_point ; copy_chars ( next - ! cur_point ) ; cur_point := next ; ; ; |
let prof_counter = ref 0 ; ; |
let instr_mode = ref false |
type insert = Open | Close ; ; |
let to_insert = ref ( [ ] : ( insert * int ) list ) ; ; |
let insert_action st en = to_insert := ( Open , st ) :: ( Close , en ) :: ! to_insert ; ; |
let add_incr_counter modul ( kind , pos ) = copy pos ; match kind with | Open -> fprintf ! outchan " ( % sProfiling . incr % s % s_cnt % d ; " modprefix idprefix modul ! prof_counter ; incr prof_counter ; | Close -> fprintf ! outchan " ) " ; ; ; |
let counters = ref ( Array . create 0 0 ) |
let special_id = ref " " |
let add_val_counter ( kind , pos ) = if kind = Open then begin copy pos ; fprintf ! outchan " " ! special_id ! counters . ( ! prof_counter ) ; incr prof_counter ; end ; ; |
let insert_profile rw_exp ex = let st = ex . pexp_loc . loc_start . Lexing . pos_cnum and en = ex . pexp_loc . loc_end . Lexing . pos_cnum and gh = ex . pexp_loc . loc_ghost in if gh || st = en then rw_exp true ex else begin insert_action st en ; rw_exp false ex ; end ; ; |
let pos_len = ref 0 |
let init_rewrite modes mod_name = cur_point := 0 ; if ! instr_mode then begin fprintf ! outchan " module % sProfiling = Profiling ; ; " modprefix ; fprintf ! outchan " let % s % s_cnt = Array . create 000000000 " idprefix mod_name ; pos_len := pos_out ! outchan ; fprintf ! outchan "... |
let final_rewrite add_function = to_insert := Sort . list ( fun x y -> snd x < snd y ) ! to_insert ; prof_counter := 0 ; List . iter add_function ! to_insert ; copy ( in_channel_length ! inchan ) ; if ! instr_mode then begin let len = string_of_int ! prof_counter in if String . length ... |
let rec rewrite_patexp_list iflag l = rewrite_exp_list iflag ( List . map snd l ) rewrite_exp_list iflag ( List . map snd l ) rewrite_exp_list iflag ( List . map snd l ) List . iter ( rewrite_exp iflag ) l if iflag then insert_profile rw_exp sexp else rw_exp false sexp match sexp . pexp_desc ... |
let rewrite_file srcfile add_function = inchan := open_in_bin srcfile ; let lb = Lexing . from_channel ! inchan in Location . input_name := srcfile ; Location . init lb srcfile ; List . iter ( rewrite_str_item false ) ( Parse . implementation lb ) ; final_rewrite add_function ; close_in... |
let null_rewrite srcfile = inchan := open_in_bin srcfile ; copy ( in_channel_length ! inchan ) ; close_in ! inchan ; ; |
let set_flags s = for i = 0 to String . length s - 1 do match String . get s i with ' f ' -> instr_fun := true | ' m ' -> instr_match := true | ' i ' -> instr_if := true | ' l ' -> instr_loops := true | ' t ' -> instr_try := true | ' a ' -> instr_fun := true ; instr_m... |
let modes = ref " fm " |
let dumpfile = ref " ocamlprof . dump " |
let process_intf_file filename = null_rewrite filename ; ; |
let process_impl_file filename = let modname = Filename . basename ( Filename . chop_extension filename ) in if ! instr_mode then begin set_flags ! modes ; init_rewrite ! modes modname ; rewrite_file filename ( add_incr_counter modname ) ; end else begin let ic = open_in_bin ! dumpfile in let a... |
let process_anon_file filename = if Filename . check_suffix filename " . ml " then process_impl_file filename else process_intf_file filename ; ; |
let usage = " Usage : ocamlprof < options > < files >\ noptions are " : |
let print_version ( ) = printf " ocamlprof , version % s . " @ Sys . ocaml_version ; exit 0 ; ; ; |
let print_version_num ( ) = printf " % s . " @ Sys . ocaml_version ; exit 0 ; ; ; |
let main ( ) = try Warnings . parse_options false " a " ; Arg . parse [ " - f " , Arg . String ( fun s -> dumpfile := s ) , " < file > Use < file > as dump file ( default ocamlprof . dump ) " ; " - F " , Arg . String ( fun s -> special_id := s ) , " ... |
let _ = main ( ) |
module Id = struct value name = " Camlp4 . Printers . OCamlr " ; value version = Sys . ocaml_version ; end ; |
module Make ( Syntax : Sig . Camlp4Syntax ) = struct include Syntax ; open Sig ; module PP_o = OCaml . Make Syntax ; open PP_o ; value pp = fprintf ; value is_keyword = let keywords = [ " where " ] and not_keywords = [ " false " ; " function " ; " true " ; " val " ... |
module MakeMore ( Syntax : Sig . Camlp4Syntax ) include Make Syntax ; value margin = ref 78 ; value comments = ref True ; value locations = ref False ; value curry_constr = ref True ; value print output_file fct = let o = new printer ~ comments : comments . val ~ curry_constr : curry_const... |
let input_line_opt ic = try Some ( input_line ic ) with End_of_file -> None |
module Char = struct include Char let is_blank c = c = ' ' || c = ' \ 012 ' || c = ' \ n ' || c = ' \ r ' || c = ' \ t ' end |
module Filename = struct include Filename let path_sep = if Sys . win32 then " ; " else " " : let maybe_quote f = if String . contains f ' ' || String . contains f ' " ' \ || String . contains f ' \ t ' || f = " " then Filename . quote f else f let make_filename name ext ... |
module List = struct include List let rec concatmap f = function | [ ] -> [ ] | x :: xs -> ( f x ) @ ( concatmap f xs ) end |
module String = struct include Misc . Stdlib . String let string_of_char = String . make 1 let words s = let l = String . length s in let rec f quote w ws i = if i >= l then begin if w " " <> then List . rev ( w :: ws ) else List . rev ws end else begin let j = i + 1 in match s . [ i... |
module Sys = struct include Sys let erase_file path = try Sys . remove path with Sys_error _ when Sys . win32 && Ocamltest_config . libunix <> None -> let ( ) = try Unix . chmod path 0o666 with Sys_error _ -> ( ) in Sys . remove path let rm_rf path = let rec erase path = if Sys . is_dire... |
module Seq = struct include Seq let rec equal s1 s2 = match s1 ( ) , s2 ( ) with | Nil , Nil -> true | Cons ( e1 , s1 ) , Cons ( e2 , s2 ) -> e1 = e2 && equal s1 s2 | _ , _ -> false end |
let no_native_compilers _log env = ( Result . skip_with_reason " native compilers disabled " , env ) |
let native_action a = if Ocamltest_config . native_compiler then a else ( Actions . update a no_native_compilers ) |
let get_backend_value_from_env env bytecode_var native_var = Ocaml_backends . make_backend_function ( Environments . safe_lookup bytecode_var env ) ( Environments . safe_lookup native_var env ) |
let modules env = Actions_helpers . words_of_variable env Ocaml_variables . modules |
let plugins env = Actions_helpers . words_of_variable env Ocaml_variables . plugins |
let directories env = Actions_helpers . words_of_variable env Ocaml_variables . directories |
let directory_flags env = let f dir = ( " - I " ^ dir ) in let l = List . map f ( directories env ) in String . concat " " l |
let flags env = Environments . safe_lookup Ocaml_variables . flags env |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.