text stringlengths 12 786k |
|---|
let print_endline s = output_string stdout s ; output_char stdout ' \ n ' ; flush stdout |
let print_newline ( ) = output_char stdout ' \ n ' ; flush stdout |
let prerr_char c = output_char stderr c |
let prerr_string s = output_string stderr s |
let prerr_bytes s = output_bytes stderr s |
let prerr_int i = output_string stderr ( string_of_int i ) |
let prerr_float f = output_string stderr ( string_of_float f ) |
let prerr_endline s = output_string stderr s ; output_char stderr ' \ n ' ; flush stderr |
let prerr_newline ( ) = output_char stderr ' \ n ' ; flush stderr |
let read_line ( ) = flush stdout ; input_line stdin |
let read_int ( ) = int_of_string ( read_line ( ) ) |
let read_int_opt ( ) = int_of_string_opt ( read_line ( ) ) |
let read_float ( ) = float_of_string ( read_line ( ) ) |
let read_float_opt ( ) = float_of_string_opt ( read_line ( ) ) |
module LargeFile = struct external seek_out : out_channel -> int64 -> unit = " caml_ml_seek_out_64 " external pos_out : out_channel -> int64 = " caml_ml_pos_out_64 " external out_channel_length : out_channel -> int64 = " caml_ml_channel_size_64 " external seek_in : in_channel -> int64 -> unit ... |
let exit_function = ref flush_all |
let at_exit f = let g = ! exit_function in let f_already_ran = ref false in exit_function := fun ( ) -> if not ! f_already_ran then begin f_already_ran := true ; f ( ) end ; g ( ) |
let do_at_exit ( ) = ! exit_function ( ) |
let exit retcode = do_at_exit ( ) ; sys_exit retcode |
let _ = register_named_value " Pervasives . do_at_exit " do_at_exit |
type t = | Eq | Neq |
let foo op g = let a = false in let b = false in match op , a , b with | Eq , true , _ -> f 1 | Neq , true , _ -> f 2 | Eq , _ , true -> f 3 | Neq , _ , true -> f 4 | _ , _ , _ -> g op |
type integer_comparison = Isigned of Cmm . integer_comparison | Iunsigned of Cmm . integer_comparison |
type integer_operation = Iadd | Isub | Imul | Imulh | Idiv | Imod | Iand | Ior | Ixor | Ilsl | Ilsr | Iasr | Icomp of integer_comparison | Icheckbound |
type test = Itruetest | Ifalsetest | Iinttest of integer_comparison | Iinttest_imm of integer_comparison * int | Ifloattest of float_comparison | Ioddtest | Ieventest |
type operation = Imove | Ispill | Ireload | Iconst_int of nativeint | Iconst_float of int64 | Iconst_symbol of string | Icall_ind | Icall_imm of { func : string ; } | Itailcall_ind | Itailcall_imm of { func : string ; } | Iextcall of { func : string ; ty_res : Cmm . machtype ; ty_args... |
type instruction = { desc : instruction_desc ; next : instruction ; arg : Reg . t array ; res : Reg . t array ; dbg : Debuginfo . t ; mutable live : Reg . Set . t ; mutable available_before : Reg_availability_set . t ; mutable available_across : Reg_availability_set . t option ; ... |
type fundecl = { fun_name : string ; fun_args : Reg . t array ; fun_body : instruction ; fun_codegen_options : Cmm . codegen_option list ; fun_dbg : Debuginfo . t ; fun_num_stack_slots : int array ; fun_contains_calls : bool ; } |
let rec dummy_instr = { desc = Iend ; next = dummy_instr ; arg = [ ] ; || res = [ ] ; || dbg = Debuginfo . none ; live = Reg . Set . empty ; available_before = Reg_availability_set . Ok Reg_with_debug_info . Set . empty ; available_across = None ; } |
let end_instr ( ) = { desc = Iend ; next = dummy_instr ; arg = [ ] ; || res = [ ] ; || dbg = Debuginfo . none ; live = Reg . Set . empty ; available_before = Reg_availability_set . Ok Reg_with_debug_info . Set . empty ; available_across = None ; } |
let instr_cons d a r n = { desc = d ; next = n ; arg = a ; res = r ; dbg = Debuginfo . none ; live = Reg . Set . empty ; available_before = Reg_availability_set . Ok Reg_with_debug_info . Set . empty ; available_across = None ; } |
let instr_cons_debug d a r dbg n = { desc = d ; next = n ; arg = a ; res = r ; dbg = dbg ; live = Reg . Set . empty ; available_before = Reg_availability_set . Ok Reg_with_debug_info . Set . empty ; available_across = None ; } |
let rec instr_iter f i = match i . desc with Iend -> ( ) | _ -> f i ; match i . desc with Iend -> ( ) | Ireturn | Iop Itailcall_ind | Iop ( Itailcall_imm _ ) -> ( ) | Iifthenelse ( _tst , ifso , ifnot ) -> instr_iter f ifso ; instr_iter f ifnot ; instr_iter f i . next ... |
let operation_is_pure = function | Icall_ind | Icall_imm _ | Itailcall_ind | Itailcall_imm _ | Iextcall _ | Istackoffset _ | Istore _ | Ialloc _ | Iintop ( Icheckbound ) | Iintop_imm ( Icheckbound , _ ) | Iopaque -> false | Ibeginregion | Iendregion -> false | Iprobe _ -> false | Ip... |
let operation_can_raise op = match op with | Icall_ind | Icall_imm _ | Iextcall _ | Iintop ( Icheckbound ) | Iintop_imm ( Icheckbound , _ ) | Iprobe _ | Ialloc _ -> true | Ispecific sop -> Arch . operation_can_raise sop | _ -> false |
let foldr_funs = ref [ ] ; ; |
let foldl_funs = ref [ ] ; ; Ast . map_expr begin function | <: expr @ loc < def_foldr $ lid : name $ $ e $ >> -> foldr_funs := ( name , e ) :: ! foldr_funs ; <: expr @ loc ( ) <>> | <: expr @ loc < def_foldl $ lid : name $ $ e $ >> -> foldl_funs := ( name , e ) ... |
value a_should_be_present = B + 2 ; print_int ( a_should_be_present + 1 ) ; ENDIF ; print_int ( a_should_be_present + 3 ) ; ENDIF ; print_int ( a_should_be_present + 4 ) ; ELSE print_int ( c_should_not_be_present + 1 ) ; ENDIF ; print_int ( c_should_not_be_present + 2 ) ... |
let examples = Examples . [ ( " bar_styles " , " Demo of possible progress bar configurations " , Bar_styles . run ) ; ( " cargo " , " Port of the Cargo install progress bar " , Cargo . run ) ; ( " download " , " Rainbow - coloured download sequence " , Downlo... |
let available_examples ( ) = Format . eprintf " Available examples : . " ; @ ListLabels . iter examples ~ f ( : fun ( name , desc , _ ) -> Format . eprintf " - %- 12s % a . " @ name Fmt . ( styled ` Faint ( parens string ) ) desc ) |
let usage ( ) = Format . eprintf " . " ; @ available_examples ( ) ; Format . eprintf " \ n % a : dune exec % s % s % s . exe -- [ -- help ] < example_name . " >@ Fmt . ( styled ` Green string ) " usage " Filename . current_dir_name Filename . dir_sep ( Fil... |
let ( ) = Random . self_init ( ) ; Fmt . set_style_renderer Fmt . stderr ` Ansi_tty ; match Sys . argv with | [ | _ ] | | [ | _ ; " - h " | " - help " | " -- help " ] | -> usage ( ) | [ | _ ; " -- list " ] | -> ListLabels . iter ~ f ( ... |
let flag_verbose = ref false |
let verbose_string s = if ! flag_verbose then prerr_string s |
let verbose_endline s = if ! flag_verbose then prerr_endline s |
let input_name = ref " Widgets . src " |
let output_dir = ref " " |
let destfile f = Filename . concat ! output_dir f |
let usage ( ) = prerr_string " Usage : tkcompiler input . src \ n " ; flush stderr ; exit 1 |
let prerr_error_header ( ) = prerr_string " File " " ; \ prerr_string ! input_name ; prerr_string " " , \ line " ; prerr_string ( string_of_int ! Lexer . current_line ) ; prerr_string " : " |
let parse_file filename = let ic = open_in_bin filename in let lexbuf = try let code_list = Ppparse . parse_channel ic in close_in ic ; let buf = Buffer . create 50000 in List . iter ( Ppexec . exec ( fun l -> Buffer . add_string buf ( Printf . sprintf " ## line % d \ n " l ) ) ( ... |
let elements t = let elems = ref [ ] in Hashtbl . iter ( fun _ d -> elems := d :: ! elems ) t ; ! elems ; ; |
let uniq_clauses = function | [ ] -> [ ] | l -> let check_constr constr1 constr2 = if constr1 . template <> constr2 . template then begin let code1 , vars11 , vars12 , opts1 = code_of_template ~ context_widget " : dummy " constr1 . template in let code2 , vars12 , vars22 , opts2 ... |
let option_hack oc = if Hashtbl . mem types_table " options " then let typdef = Hashtbl . find types_table " options " in let hack = { parser_arity = OneToken ; constructors = begin let constrs = List . map typdef . constructors ~ f : begin fun c -> { component = Constructor ; ml_name ... |
let realname name = if ! Flags . camltk then " c " ^ String . capitalize name else name ; ; |
let compile ( ) = verbose_endline " Creating _tkgen . ml . . . " ; let oc = open_out_bin ( destfile " _tkgen . ml " ) in let oc ' = open_out_bin ( destfile " _tkigen . ml " ) in let oc ' ' = open_out_bin ( destfile " _tkfgen . ml " ) in let sorted_types = T... |
module Timer = Timer ; ; \ n \ " ; Hashtbl . iter ( fun name _ -> let cname = realname name in output_string oc ( Printf . sprintf " module % s = % s ; ; \ n " ( String . capitalize name ) ( String . capitalize cname ) ) ) module_table ; output_string oc " \ n \ n... |
let main ( ) = Arg . parse [ " - verbose " , Arg . Unit ( fun ( ) -> flag_verbose := true ) , " Make output verbose " ; " - camltk " , Arg . Unit ( fun ( ) -> Flags . camltk := true ) , " Make CamlTk interface " ; " - outdir " , Arg . String ( ... |
let ( ) = Printexc . catch main ( ) |
let usage = " Usage : ocamlc < options > < files >\ nOptions are " : |
module Options = Main_args . Make_bytecomp_options ( Main_args . Default . Main ) |
let main argv ppf = Clflags . add_arguments __LOC__ Options . list ; Clflags . add_arguments __LOC__ [ " - depend " , Arg . Unit Makedepend . main_from_option , " < options > Compute dependencies ( use ' ocamlc - depend - help ' for details ) " ] ; match Compenv . readenv... |
let mk_a f = " - a " , Arg . Unit f , " Build a library " ; ; |
let mk_alert f = " - alert " , Arg . String f , Printf . sprintf " < list > Enable or disable alerts according to < list >:\ n \ \ +< alertname > enable alert < alertname >\ n \ \ -< alertname > disable alert < alertname >\ n \ \ ++< alertname > treat < alertname > as fatal error ... |
let mk_absname f = " - absname " , Arg . Unit f , " Show absolute filenames in error messages " ; ; |
let mk_annot f = " - annot " , Arg . Unit f , " ( deprecated ) Save information in < filename . > annot " ; ; |
let mk_binannot f = " - bin - annot " , Arg . Unit f , " Save typedtree in < filename . > cmt " ; ; |
let mk_c f = " - c " , Arg . Unit f , " Compile only ( do not link ) " ; ; |
let mk_cc f = " - cc " , Arg . String f , " < command > Use < command > as the C compiler and linker " ; ; |
let mk_cclib f = " - cclib " , Arg . String f , " < opt > Pass option < opt > to the C linker " ; ; |
let mk_ccopt f = " - ccopt " , Arg . String f , " < opt > Pass option < opt > to the C compiler and linker " ; ; |
let mk_clambda_checks f = " - clambda - checks " , Arg . Unit f , " Instrument clambda code with closure and \ field access checks ( for debugging the compiler ) " ; ; |
let mk_compact f = " - compact " , Arg . Unit f , " Optimize code size rather than speed " ; ; |
let mk_compat_32 f = " - compat - 32 " , Arg . Unit f , " Check that generated bytecode can run on 32 - bit platforms " ; ; |
let mk_config f = " - config " , Arg . Unit f , " Print configuration values and exit " ; ; |
let mk_config_var f = " - config - var " , Arg . String f , " Print the value of a configuration variable , a newline , and exit \ n \ ; ; |
let mk_custom f = " - custom " , Arg . Unit f , " Link in custom mode " ; ; |
let mk_dllib f = " - dllib " , Arg . String f , " < lib > Use the dynamically - loaded library < lib " > ; ; |
let mk_dllpath f = " - dllpath " , Arg . String f , " < dir > Add < dir > to the run - time search path for shared libraries " ; ; |
let mk_function_sections f = if Config . function_sections then " - function - sections " , Arg . Unit f , " Generate each function in a separate section if target supports it " else let err ( ) = raise ( Arg . Bad " OCaml has been configured without support for \ - function - sections ... |
let mk_stop_after ~ native f = let pass_names = Clflags . Compiler_pass . available_pass_names ~ filter ( : fun _ -> true ) ~ native in " - stop - after " , Arg . Symbol ( pass_names , f ) , " Stop after the given compilation pass . " ; ; |
let mk_save_ir_after ~ native f = let pass_names = Clflags . Compiler_pass . ( available_pass_names ~ filter : can_save_ir_after ~ native ) in " - save - ir - after " , Arg . Symbol ( pass_names , f ) , " Save intermediate representation after the given compilation pass \ ( may be ... |
let mk_dtypes f = " - dtypes " , Arg . Unit f , " ( deprecated ) same as - annot " ; ; |
let mk_for_pack_byt f = " - for - pack " , Arg . String f , " < ident > Generate code that can later be ` packed ' with \ n \ \ ocamlc - pack - o < ident . > cmo " ; ; |
let mk_for_pack_opt f = " - for - pack " , Arg . String f , " < ident > Generate code that can later be ` packed ' with \ n \ \ ocamlopt - pack - o < ident . > cmx " ; ; |
let mk_g_byt f = " - g " , Arg . Unit f , " Save debugging information " ; ; |
let mk_g_opt f = " - g " , Arg . Unit f , " Record debugging information for exception backtrace " ; ; |
let mk_i f = " - i " , Arg . Unit f , " Print inferred interface " ; ; |
let mk_I f = " - I " , Arg . String f , " < dir > Add < dir > to the list of include directories " ; ; |
let mk_impl f = " - impl " , Arg . String f , " < file > Compile < file > as a . ml file " ; ; |
let mk_init f = " - init " , Arg . String f , " < file > Load < file > instead of default init file " ; ; |
let mk_inline f = " - inline " , Arg . String f , Printf . sprintf " < n >|< round >=< n [ , . . . ] > Aggressiveness of inlining \ ( default . % 02f , higher numbers mean more aggressive ) " Clflags . default_inline_threshold ; ; |
let mk_inline_toplevel f = " - inline - toplevel " , Arg . String f , Printf . sprintf " < n >|< round >=< n [ , . . . ] > Aggressiveness of inlining at \ toplevel ( higher numbers mean more aggressive ) " ; ; |
let mk_inlining_report f = " - inlining - report " , Arg . Unit f , " Emit ` . < round . > inlining ' file ( s ) ( one per \ round ) showing the inliner ' s decisions ( Flambda 1 and 2 ) " ; ; |
let mk_dump_pass f = " - dump - pass " , Arg . String f , Format . asprintf " [ @< 4 > Record transformations performed by these passes :@ [ @% a ] ] " @@ ( Format . pp_print_list ~ pp_sep : Format . pp_print_space Format . pp_print_string ) ! Clflags . all_passes ; ; |
let mk_o2 f = " - O2 " , Arg . Unit f , " Apply increased optimization for speed " ; ; |
let mk_o3 f = " - O3 " , Arg . Unit f , " Apply aggressive optimization for speed ( may \ significantly increase code size and compilation time ) " ; ; |
let mk_rounds f = " - rounds " , Arg . Int f , Printf . sprintf " < n > Repeat tree optimization and inlining phases this \ many times ( default % d ) . Rounds are numbered starting from zero . " ! Clflags . default_simplify_rounds ; ; |
let mk_inline_max_unroll f = " - inline - max - unroll " , Arg . String f , Printf . sprintf " < n >|< round >=< n [ , . . . ] > Unroll recursive functions at most \ this many times ( default % d ) " Clflags . default_inline_max_unroll ; ; |
let mk_classic_inlining f = " - Oclassic " , Arg . Unit f , " Make inlining decisions at function definition \ time rather than at the call site ( replicates previous behaviour of the \ compiler ) . Implies - linscan ( and causes - nolinscan to be ignored ) . " ; ; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.