text stringlengths 0 601k |
|---|
module Rf = struct let mk ( ? loc = ! default_loc ) ( ? attrs = [ ] ) desc = { prf_desc = desc ; prf_loc = loc ; prf_attributes = attrs ; } let tag ? loc ? attrs label const tys = mk ? loc ? attrs ( Rtag ( label , const , tys ) ) let inherit_ ? loc ty = mk ? loc ( Rinherit ty ) end |
module Of = struct let mk ( ? loc = ! default_loc ) ( ? attrs [ ] ) = desc = { pof_desc = desc ; pof_loc = loc ; pof_attributes = attrs ; } let tag ? loc ? attrs label ty = mk ? loc ? attrs ( Otag ( label , ty ) ) let inherit_ ? loc ty = mk ? loc ( Oinherit ty ) end |
let empty_record loc = err loc " Records cannot be empty . " |
let invalid_tuple loc = err loc " Tuples must have at least 2 components . " |
let no_args loc = err loc " Function application with no argument . " |
let empty_let loc = err loc " Let with no bindings . " |
let empty_type loc = err loc " Type declarations cannot be empty . " |
let complex_id loc = err loc " Functor application not allowed here . " |
let simple_longident id = let rec is_simple = function | Longident . Lident _ -> true | Longident . Ldot ( id , _ ) -> is_simple id | Longident . Lapply _ -> false in if not ( is_simple id . txt ) then complex_id id . loc |
let iterator = let super = Ast_iterator . default_iterator in let type_declaration self td = super . type_declaration self td ; let loc = td . ptype_loc in match td . ptype_kind with | Ptype_record [ ] -> empty_record loc | _ -> ( ) in let typ self ty = super . typ self ty ; let loc = ty . ptyp_loc in match ty . ptyp_d... |
let structure st = iterator . structure iterator st |
let signature sg = iterator . signature iterator sg |
type iterator = { attribute : iterator -> attribute -> unit ; attributes : iterator -> attribute list -> unit ; binding_op : iterator -> binding_op -> unit ; case : iterator -> case -> unit ; cases : iterator -> case list -> unit ; class_declaration : iterator -> class_declaration -> unit ; class_description : iterator... |
let iter_fst f ( x , _ ) = f x |
let iter_snd f ( _ , y ) = f y |
let iter_tuple f1 f2 ( x , y ) = f1 x ; f2 y |
let iter_tuple3 f1 f2 f3 ( x , y , z ) = f1 x ; f2 y ; f3 z |
let iter_opt f = function None -> ( ) | Some x -> f x |
let iter_loc sub { loc ; txt = _ } = sub . location sub loc |
module T = struct let row_field sub { prf_desc ; prf_loc ; prf_attributes ; } = sub . location sub prf_loc ; sub . attributes sub prf_attributes ; match prf_desc with | Rtag ( _ , _ , tl ) -> List . iter ( sub . typ sub ) tl | Rinherit t -> sub . typ sub t let object_field sub { pof_desc ; pof_loc ; pof_attributes ; } ... |
module CT = struct let iter sub { pcty_loc = loc ; pcty_desc = desc ; pcty_attributes = attrs } = sub . location sub loc ; sub . attributes sub attrs ; match desc with | Pcty_constr ( lid , tys ) -> iter_loc sub lid ; List . iter ( sub . typ sub ) tys | Pcty_signature x -> sub . class_signature sub x | Pcty_arrow ( _la... |
let iter_functor_param sub = function | Unit -> ( ) | Named ( name , mty ) -> iter_loc sub name ; sub . module_type sub mty |
module MT = struct let iter sub { pmty_desc = desc ; pmty_loc = loc ; pmty_attributes = attrs } = sub . location sub loc ; sub . attributes sub attrs ; match desc with | Pmty_ident s -> iter_loc sub s | Pmty_alias s -> iter_loc sub s | Pmty_signature sg -> sub . signature sub sg | Pmty_functor ( param , mt2 ) -> iter_f... |
module M = struct let iter sub { pmod_loc = loc ; pmod_desc = desc ; pmod_attributes = attrs } = sub . location sub loc ; sub . attributes sub attrs ; match desc with | Pmod_ident x -> iter_loc sub x | Pmod_structure str -> sub . structure sub str | Pmod_functor ( param , body ) -> iter_functor_param sub param ; sub . ... |
module E = struct let iter sub { pexp_loc = loc ; pexp_desc = desc ; pexp_attributes = attrs } = sub . location sub loc ; sub . attributes sub attrs ; match desc with | Pexp_ident x -> iter_loc sub x | Pexp_constant _ -> ( ) | Pexp_let ( _r , vbs , e ) -> List . iter ( sub . value_binding sub ) vbs ; sub . expr sub e |... |
module P = struct let iter sub { ppat_desc = desc ; ppat_loc = loc ; ppat_attributes = attrs } = sub . location sub loc ; sub . attributes sub attrs ; match desc with | Ppat_any -> ( ) | Ppat_var s -> iter_loc sub s | Ppat_alias ( p , s ) -> sub . pat sub p ; iter_loc sub s | Ppat_constant _ -> ( ) | Ppat_interval _ ->... |
module CE = struct let iter sub { pcl_loc = loc ; pcl_desc = desc ; pcl_attributes = attrs } = sub . location sub loc ; sub . attributes sub attrs ; match desc with | Pcl_constr ( lid , tys ) -> iter_loc sub lid ; List . iter ( sub . typ sub ) tys | Pcl_structure s -> sub . class_structure sub s | Pcl_fun ( _lab , e , ... |
let default_iterator = { structure = ( fun this l -> List . iter ( this . structure_item this ) l ) ; structure_item = M . iter_structure_item ; module_expr = M . iter ; signature = ( fun this l -> List . iter ( this . signature_item this ) l ) ; signature_item = MT . iter_signature_item ; module_type = MT . iter ; wit... |
type mapper = { attribute : mapper -> attribute -> attribute ; attributes : mapper -> attribute list -> attribute list ; binding_op : mapper -> binding_op -> binding_op ; case : mapper -> case -> case ; cases : mapper -> case list -> case list ; class_declaration : mapper -> class_declaration -> class_declaration ; cla... |
let map_fst f ( x , y ) = ( f x , y ) |
let map_snd f ( x , y ) = ( x , f y ) |
let map_tuple f1 f2 ( x , y ) = ( f1 x , f2 y ) |
let map_tuple3 f1 f2 f3 ( x , y , z ) = ( f1 x , f2 y , f3 z ) |
let map_opt f = function None -> None | Some x -> Some ( f x ) |
let map_loc sub { loc ; txt } = { loc = sub . location sub loc ; txt } |
module C = struct let map sub c = match c with | Pconst_integer _ | Pconst_char _ | Pconst_float _ -> c | Pconst_string ( s , loc , quotation_delimiter ) -> let loc = sub . location sub loc in Const . string ~ loc ? quotation_delimiter s end |
module T = struct let row_field sub { prf_desc ; prf_loc ; prf_attributes ; } = let loc = sub . location sub prf_loc in let attrs = sub . attributes sub prf_attributes in let desc = match prf_desc with | Rtag ( l , b , tl ) -> Rtag ( map_loc sub l , b , List . map ( sub . typ sub ) tl ) | Rinherit t -> Rinherit ( sub .... |
module CT = struct let map sub { pcty_loc = loc ; pcty_desc = desc ; pcty_attributes = attrs } = let open Cty in let loc = sub . location sub loc in let attrs = sub . attributes sub attrs in match desc with | Pcty_constr ( lid , tys ) -> constr ~ loc ~ attrs ( map_loc sub lid ) ( List . map ( sub . typ sub ) tys ) | Pc... |
let map_functor_param sub = function | Unit -> Unit | Named ( s , mt ) -> Named ( map_loc sub s , sub . module_type sub mt ) |
module MT = struct let map sub { pmty_desc = desc ; pmty_loc = loc ; pmty_attributes = attrs } = let open Mty in let loc = sub . location sub loc in let attrs = sub . attributes sub attrs in match desc with | Pmty_ident s -> ident ~ loc ~ attrs ( map_loc sub s ) | Pmty_alias s -> alias ~ loc ~ attrs ( map_loc sub s ) |... |
module M = struct let map sub { pmod_loc = loc ; pmod_desc = desc ; pmod_attributes = attrs } = let open Mod in let loc = sub . location sub loc in let attrs = sub . attributes sub attrs in match desc with | Pmod_ident x -> ident ~ loc ~ attrs ( map_loc sub x ) | Pmod_structure str -> structure ~ loc ~ attrs ( sub . st... |
module E = struct let map sub { pexp_loc = loc ; pexp_desc = desc ; pexp_attributes = attrs } = let open Exp in let loc = sub . location sub loc in let attrs = sub . attributes sub attrs in match desc with | Pexp_ident x -> ident ~ loc ~ attrs ( map_loc sub x ) | Pexp_constant x -> constant ~ loc ~ attrs ( sub . consta... |
module P = struct let map sub { ppat_desc = desc ; ppat_loc = loc ; ppat_attributes = attrs } = let open Pat in let loc = sub . location sub loc in let attrs = sub . attributes sub attrs in match desc with | Ppat_any -> any ~ loc ~ attrs ( ) | Ppat_var s -> var ~ loc ~ attrs ( map_loc sub s ) | Ppat_alias ( p , s ) -> ... |
module CE = struct let map sub { pcl_loc = loc ; pcl_desc = desc ; pcl_attributes = attrs } = let open Cl in let loc = sub . location sub loc in let attrs = sub . attributes sub attrs in match desc with | Pcl_constr ( lid , tys ) -> constr ~ loc ~ attrs ( map_loc sub lid ) ( List . map ( sub . typ sub ) tys ) | Pcl_str... |
let default_mapper = { constant = C . map ; structure = ( fun this l -> List . map ( this . structure_item this ) l ) ; structure_item = M . map_structure_item ; module_expr = M . map ; signature = ( fun this l -> List . map ( this . signature_item this ) l ) ; signature_item = MT . map_signature_item ; module_type = M... |
let extension_of_error { kind ; main ; sub } = if kind <> Location . Report_error then raise ( Invalid_argument " extension_of_error : expected kind Report_error " ) ; let str_of_pp pp_msg = Format . asprintf " % t " pp_msg in let extension_of_sub sub = { loc = sub . loc ; txt = " ocaml . error " } , PStr ( [ Str . eva... |
let attribute_of_warning loc s = Attr . mk { loc ; txt = " ocaml . ppwarning " } ( PStr ( [ Str . eval ~ loc ( Exp . constant ( Pconst_string ( s , loc , None ) ) ) ] ) ) |
let cookies = ref String . Map . empty |
let get_cookie k = try Some ( String . Map . find k ! cookies ) with Not_found -> None |
let set_cookie k v = cookies := String . Map . add k v ! cookies |
let tool_name_ref = ref " _none_ " |
let tool_name ( ) = ! tool_name_ref |
module PpxContext = struct open Longident open Asttypes open Ast_helper let lid name = { txt = Lident name ; loc = Location . none } let make_string s = Exp . constant ( Const . string s ) let make_bool x = if x then Exp . construct ( lid " true " ) None else Exp . construct ( lid " false " ) None let rec make_list f l... |
let extension_of_exn exn = match error_of_exn exn with | Some ( ` Ok error ) -> extension_of_error error | Some ` Already_displayed -> { loc = Location . none ; txt = " ocaml . error " } , PStr [ ] | None -> raise exn |
let apply_lazy ~ source ~ target mapper = let implem ast = let fields , ast = match ast with | { pstr_desc = Pstr_attribute ( { attr_name = { txt = " ocaml . ppx . context " } ; attr_payload = x } ) } :: l -> PpxContext . get_fields x , l | _ -> [ ] , ast in PpxContext . restore fields ; let ast = try let mapper = mapp... |
let drop_ppx_context_str ~ restore = function | { pstr_desc = Pstr_attribute { attr_name = { Location . txt = " ocaml . ppx . context " } ; attr_payload = a ; attr_loc = _ } } :: items -> if restore then PpxContext . restore ( PpxContext . get_fields a ) ; items | items -> items |
let drop_ppx_context_sig ~ restore = function | { psig_desc = Psig_attribute { attr_name = { Location . txt = " ocaml . ppx . context " } ; attr_payload = a ; attr_loc = _ } } :: items -> if restore then PpxContext . restore ( PpxContext . get_fields a ) ; items | items -> items |
let add_ppx_context_str ~ tool_name ast = Ast_helper . Str . attribute ( ppx_context ~ tool_name ( ) ) :: ast |
let add_ppx_context_sig ~ tool_name ast = Ast_helper . Sig . attribute ( ppx_context ~ tool_name ( ) ) :: ast |
let apply ~ source ~ target mapper = apply_lazy ~ source ~ target ( fun ( ) -> mapper ) |
let run_main mapper = try let a = Sys . argv in let n = Array . length a in if n > 2 then let mapper ( ) = try mapper ( Array . to_list ( Array . sub a 1 ( n - 3 ) ) ) with exn -> let f _ _ = raise exn in { default_mapper with structure = f ; signature = f } in apply_lazy ~ source : a . ( n - 2 ) ~ target : a . ( n - 1... |
let register_function = ref ( fun _name f -> run_main f ) |
let register name f = ! register_function name f |
let output_line ch s = output_string ch s ; output_char ch ' \ n ' |
let ( ) = if Array . length Sys . argv <> 2 then failwith ( " usage : " ^ Sys . argv . ( 0 ) " ^ file_t . mli " ) ; let input_file_name = Sys . argv . ( 1 ) in let ouput_file_name = if Filename . check_suffix input_file_name " . mli " then ( Filename . chop_suffix input_file_name " . mli " ) ^ " . rmli " else if Filena... |
type error = | Multiple_attributes of string | No_payload_expected of string |
let get_no_payload_attribute alt_names attrs = match List . filter ( fun a -> List . mem a . attr_name . txt alt_names ) attrs with | [ ] -> None | [ { attr_name = name ; attr_payload = PStr [ ] ; attr_loc = _ } ] -> Some name | [ { attr_name = name ; _ } ] -> raise ( Error ( name . loc , No_payload_expected name . txt... |
let has_no_payload_attribute alt_names attrs = match get_no_payload_attribute alt_names attrs with | None -> false | Some _ -> true |
let report_error ppf = function | Multiple_attributes name -> fprintf ppf " Too many ` % s ' attributes " name | No_payload_expected name -> fprintf ppf " Attribute ` % s ' does not accept a payload " name |
let ( ) = Location . register_error_of_exn ( function | Error ( loc , err ) -> Some ( Location . error_of_printer ~ loc report_error err ) | _ -> None ) |
let position = Raylib . Vector3 . create 0 . 0 0 . 0 0 . 0 |
type circle_wave = { position : Raylib . Vector2 . t ; radius : float ; alpha : float ; speed : float ; color : Raylib . Color . t ; } |
let colors = Raylib . [ | Color . orange ; Color . red ; Color . gold ; Color . lime ; Color . blue ; Color . violet ; Color . brown ; Color . lightgray ; Color . pink ; Color . yellow ; Color . green ; Color . skyblue ; Color . purple ; Color . beige ; ] | |
let random_circle ( ) = Raylib . ( let radius = get_random_value 10 40 in { alpha = 0 . 0 ; radius = Float . of_int radius ; position = Vector2 . create ( Float . of_int ( get_random_value radius ( width - radius ) ) ) ( Float . of_int ( get_random_value radius ( height - radius ) ) ) ; speed = Float . of_int ( get_ran... |
let setup ( ) = let open Raylib in set_config_flags [ ConfigFlags . Msaa_4x_hint ] ; init_window width height " raylib [ audio ] example - module playing ( streaming ) " ; init_audio_device ( ) ; let circles = Array . init max_circles ( fun _ -> random_circle ( ) ) in let music = load_music_stream " resources / mini111... |
let rec loop circles music pause = match Raylib . window_should_close ( ) with | true -> let open Raylib in unload_music_stream music ; close_audio_device ( ) ; close_window ( ) | false -> let open Raylib in update_music_stream music ; if is_key_pressed Key . Space then ( stop_music_stream music ; play_music_stream mus... |
let ( ) = let circles , music = setup ( ) in loop circles music false |
let setup ( ) = let open Raylib in init_window width height " raylib [ audio ] example - music playing ( streaming ) " ; init_audio_device ( ) ; let music = load_music_stream " resources / country . mp3 " in play_music_stream music ; set_target_fps 60 ; music |
let rec loop music pause = let open Raylib in match window_should_close ( ) with | true -> unload_music_stream music ; close_audio_device ( ) ; close_window ( ) | false -> update_music_stream music ; if is_key_pressed Key . Space then ( stop_music_stream music ; play_music_stream music ) ; let pause = if is_key_pressed... |
let ( ) = let music = setup ( ) in loop music false |
module Definition = struct type t = | Existing_inner_free_var of Variable . t | Projection_from_existing_specialised_arg of Projection . t include Identifiable . Make ( struct type nonrec t = t let compare t1 t2 = match t1 , t2 with | Existing_inner_free_var var1 , Existing_inner_free_var var2 -> Variable . compare var... |
module What_to_specialise = struct type t = { definitions : Definition . t list Variable . Pair . Map . t ; set_of_closures : Flambda . set_of_closures ; make_direct_call_surrogates_for : Variable . Set . t ; } let create ~ set_of_closures = { definitions = Variable . Pair . Map . empty ; set_of_closures ; make_direct_... |
module type S = sig val pass_name : string val what_to_specialise : env : Inline_and_simplify_aux . Env . t -> set_of_closures : Flambda . set_of_closures -> What_to_specialise . t end |
module Processed_what_to_specialise = struct type for_one_function = { fun_var : Variable . t ; function_decl : Flambda . function_declaration ; make_direct_call_surrogates : bool ; new_definitions_indexed_by_new_inner_vars : Definition . t Variable . Map . t ; all_new_definitions : Definition . Set . t ; new_inner_to_... |
let check_invariants ~ pass_name ( ~ set_of_closures : Flambda . set_of_closures ) ~ original_set_of_closures = if ! Clflags . flambda_invariant_checks then begin Variable . Map . iter ( fun fun_var ( function_decl : Flambda . function_declaration ) -> let params = Parameter . Set . vars function_decl . params in Varia... |
module Make ( T : S ) = struct let ( ) = Pass_wrapper . register ~ pass_name : T . pass_name let rename_function_and_parameters ~ fun_var ( ~ function_decl : Flambda . function_declaration ) = let new_fun_var = Variable . rename fun_var in let params_renaming_list = List . map ( fun param -> let new_param = Parameter .... |
let avail_at_exit = Hashtbl . create 42 |
let avail_at_raise = ref RAS . Unreachable |
let augment_availability_at_raise avail = avail_at_raise := RAS . inter avail ! avail_at_raise |
let check_invariants ( instr : M . instruction ) ( ~ avail_before : RAS . t ) = match avail_before with | Unreachable -> ( ) | Ok avail_before -> if not ( R . Set . subset instr . live ( RD . Set . forget_debug_info avail_before ) ) then begin Misc . fatal_errorf " Live registers not a subset of available registers : \... |
let rec available_regs ( instr : M . instruction ) ( ~ avail_before : RAS . t ) : RAS . t = check_invariants instr ~ avail_before ; instr . available_before <- avail_before ; let avail_across , avail_after = let ok set = RAS . Ok set in let unreachable = RAS . Unreachable in match avail_before with | Unreachable -> Non... |
let fundecl ( f : M . fundecl ) = if ! Clflags . debug && ! Clflags . debug_runavail then begin assert ( Hashtbl . length avail_at_exit = 0 ) ; avail_at_raise := RAS . Unreachable ; let fun_args = R . set_of_array f . fun_args in let avail_before = RAS . Ok ( RD . Set . without_debug_info fun_args ) in ignore ( ( avail... |
type ' a ref = { mutable contents : ' a } [ @@ noalloc ] = " caml_blit_bytes " [ @@ noalloc ] = " caml_blit_string " [ @@ noalloc ] |
let extend s left right = let invalid_arg s = raise ( Invalid_argument s ) in let ( ++ ) a b = match a < 0 , b < 0 with true , true -> 42 | _ -> invalid_arg " foo " in let x = s ++ left ++ right in if left < 0 then 0 else x |
let unix = B0_ocaml . libname " unix " |
let compiler_libs_toplevel = B0_ocaml . libname " compiler - libs . toplevel " |
let rresult = B0_ocaml . libname " rresult " |
let rresult_top = B0_ocaml . libname " rresult . top " |
let astring = B0_ocaml . libname " astring " |
let astring_top = B0_ocaml . libname " astring . top " |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.