text
stringlengths
0
601k
let resolve_method ~ resolution ~ class_type ~ method_name = let callable_implementation = Type . split class_type |> fst |> Type . primitive_name >>= GlobalResolution . attribute_from_class_name ~ transitive : true ~ resolution ~ name : method_name ~ instantiated : class_type in match callable_implementation with | So...
module SharedMemoryKey = struct include T let to_string key = sexp_of_t key |> Sexp . to_string let from_string sexp_string = Sexp . of_string sexp_string |> t_of_sexp end
type repr = | Int32 of int32 | Int64 of int64
module type S = sig type t val zero : t val one : t val minus_one : t val neg : t -> t val add : t -> t -> t val sub : t -> t -> t val mul : t -> t -> t val div : t -> t -> t val unsigned_div : t -> t -> t val rem : t -> t -> t val unsigned_rem : t -> t -> t val succ : t -> t val pred : t -> t val abs : t -> t val max_...
module Int32 = struct include Int32 let of_int_exn = match Sys . word_size with | 32 -> Int32 . of_int | 64 -> fun n -> if n < Int32 . ( to_int min_int ) || n > Int32 . ( to_int max_int ) then Misc . fatal_errorf " Targetint . of_int_exn : 0x % x out of range " n else Int32 . of_int n | _ -> assert false let of_int32 x...
module Int64 = struct include Int64 let of_int_exn = Int64 . of_int let of_int64 x = x let to_int64 x = x let repr x = Int64 x let print ppf t = Format . fprintf ppf " % Ld " t end ( match size with | 32 -> ( module Int32 ) | 64 -> ( module Int64 ) | _ -> assert false ) : S )
let rec unit ( t : Odoc_model . Lang . Compilation_unit . t ) = let url = Url . Path . from_identifier t . id in let rest = match t . content with Module sign -> signature sign | Pack _ -> [ ] in url :: rest let rec add_items ~ don ' t acc = function | [ ] -> List . concat ( List . rev acc ) | i :: is -> ( match i with...
module Multiplicity = struct type t = | One | Multiple let check_variable_matches_field ~ loc ~ field ~ variable = let error field variable = User_error . raise ~ loc [ Pp . textf " You can only use the variable { %%% s } if you defined the list of \ targets using the field [ % s ] ( not [ % s ] ) " variable variable f...
module Kind = struct type t = | File | Directory end
module Static = struct type ' path t = { targets : ( ' path * Kind . t ) list ; multiplicity : Multiplicity . t } end
type ' a t = | Static of ' a Static . t | Infer
let decode_target ~ allow_directory_targets = let open Dune_lang . Decoder in let file = let + file = String_with_vars . decode in ( file , Kind . File ) in let dir = let + dir = sum ~ force_parens : true [ ( " dir " , String_with_vars . decode ) ] in if not allow_directory_targets then User_error . raise ~ loc ( : Str...
let decode_static ~ allow_directory_targets = let open Dune_lang . Decoder in let + syntax_version = Dune_lang . Syntax . get_exn Stanza . syntax and + targets = repeat ( decode_target ~ allow_directory_targets ) in if syntax_version < ( 1 , 3 ) then List . iter targets ~ f ( : fun ( target , ( _ : Kind . t ) ) -> if S...
let decode_one_static ~ allow_directory_targets = let open Dune_lang . Decoder in let + ( ) = Dune_lang . Syntax . since Stanza . syntax ( 1 , 11 ) and + target = decode_target ~ allow_directory_targets in Static { targets = [ target ] ; multiplicity = One }
let field ~ allow_directory_targets = let open Dune_lang . Decoder in fields_mutually_exclusive ~ default : Infer [ ( " targets " , decode_static ~ allow_directory_targets ) ; ( " target " , decode_one_static ~ allow_directory_targets ) ]
let test_get_module_and_definition context = let assert_get_module_and_definition ~ source ~ target ~ expected = let resolution = Test . ScratchProject . setup ~ context [ " test . py " , source ] |> Test . ScratchProject . build_resolution |> Analysis . Resolution . global_resolution in let actual = Target . get_modul...
let test_resolve_method context = let assert_get_resolve_method ~ source ~ class_type ~ method_name expected = let resolution = Test . ScratchProject . setup ~ context [ " test . py " , source ] |> Test . ScratchProject . build_global_resolution in assert_equal ~ printer ( : show_optional Target . show_pretty ) expecte...
let ( ) = " callable " >::: [ " get_module_and_definition " >:: test_get_module_and_definition ; " resolve_method " >:: test_resolve_method ; ] |> Test . run
let ( ) = let cwd = Sys . getcwd ( ) in if cwd = " / static " / then print_endline " without node filesystem " else print_endline " with node filesystem " ; try let _files = Sys . readdir " . " in print_endline " Sys . readdir ok " ; let rec get_root s = let parent = Filename . dirname s in if s = parent then s else ge...
type item = Target of Target . t | ETask of Task . t
let cols = new GTree . column_list
let col_data = cols # add Gobject . Data . caml
let col_name = cols # add Gobject . Data . string
let col_default = cols # add Gobject . Data . boolean
let col_visible = cols # add Gobject . Data . boolean let selection_changed = new selection_changed ( ) in let removed = new removed ( ) in let add_target = new add_target ( ) in let add_etask = new add_etask ( ) in let vbox = GPack . vbox ~ spacing : 5 ? packing ( ) in let model = GTree . tree_store cols in let modelf...
let mk_target_filenames project filenames = let filenames = List . filter_map project . Prj . in_source_path filenames in if Sys . win32 then begin List . map begin fun filename -> Miscellanea . filename_unix_implicit filename end filenames end else filenames let changed = new changed ( ) in let xalign = 0 . 0 in let i...
let cols = new GTree . column_list
let col_bc = cols # add Gobject . Data . caml
let col_name = cols # add Gobject . Data . string let sw = GBin . scrolled_window ~ shadow_type ` : IN ~ hpolicy ` : AUTOMATIC ~ vpolicy ` : AUTOMATIC ? packing ( ) in let model = GTree . list_store cols in let renderer = GTree . cell_renderer_text [ ] in let renderer_pixbuf = GTree . cell_renderer_pixbuf [ ] in let vc...
let create = new widget
module To_delete = struct module P = Dune_util . Persistent . Make ( struct type t = Path . Set . t let name = " PROMOTED - TO - DELETE " let version = 1 let to_dyn = Path . Set . to_dyn end ) let fn = Path . relative Path . build_dir " . to - delete - in - source - tree " let db = lazy ( ref ( Option . value ~ default...
let files_in_source_tree_to_delete ( ) = To_delete . get_db ( )
let delete_stale_dot_merlin_file ~ dir ~ source_files_to_ignore = let merlin_file = " . merlin " in let source_dir = Path . Build . drop_build_context_exn dir in let merlin_in_src = Path . Source . ( relative source_dir merlin_file ) in let source_files_to_ignore = if To_delete . mem merlin_in_src && not ( Path . Sourc...
let promote_target_if_not_up_to_date ~ src ~ src_digest ~ dst ~ promote_source ~ promote_until_clean = let open Fiber . O in let * promoted = match Fs_cache . read Fs_cache . Untracked . file_digest ( Path . source dst ) |> Cached_digest . Digest_result . to_option with | Some dst_digest when Digest . equal src_digest ...
let promote ~ dir ( ~ targets : _ Targets . Produced . t ) ~ promote ~ promote_source = let selected_for_promotion : Path . Build . t -> bool = match promote . Rule . Promote . only with | None -> fun ( _ : Path . Build . t ) -> true | Some pred -> fun target -> Predicate_lang . Glob . exec pred ~ standard : Predicate_...
type architecture = | IA32 | X86_64 | ARM | AArch64 | POWER | Z | Riscv
let architecture ( ) : architecture = match Config . architecture with | " i386 " -> IA32 | " amd64 " -> X86_64 | " arm " -> ARM | " arm64 " -> AArch64 | " power " -> POWER | " s390x " -> Z | " riscv " -> Riscv | arch -> Misc . fatal_errorf " Unknown architecture ` % s ' " arch
let is_64_bit = match architecture ( ) with | X86_64 | AArch64 | POWER | Z | Riscv -> true | IA32 | ARM -> false
let is_32_bit = not is_64_bit
type derived_system = | Linux | MinGW_32 | MinGW_64 | Win32 | Win64 | Cygwin | MacOS_like | FreeBSD | NetBSD | OpenBSD | Generic_BSD | Solaris | Dragonfly | GNU | BeOS | Unknown
let derived_system ( ) : derived_system = match architecture ( ) , Config . model , Config . system with | IA32 , _ , " linux_elf " -> Linux | IA32 , _ , " bsd_elf " -> Generic_BSD | IA32 , _ , " beos " -> BeOS | IA32 , _ , " cygwin " -> Cygwin | IA32 , _ , " gnu " -> GNU | IA32 , _ , " mingw " -> MinGW_32 | IA32 , _ ,...
let is_windows ( ) = match derived_system ( ) with | Linux | MacOS_like | FreeBSD | NetBSD | OpenBSD | Generic_BSD | Solaris | Dragonfly | GNU | BeOS | Unknown -> false | MinGW_32 | MinGW_64 | Win32 | Win64 | Cygwin -> true
type assembler = | GAS_like | MacOS | MASM
let assembler ( ) = match derived_system ( ) with | Win32 | Win64 -> MASM | MacOS_like -> MacOS | MinGW_32 | MinGW_64 | Cygwin | Linux | FreeBSD | NetBSD | OpenBSD | Generic_BSD | Solaris | GNU | Dragonfly | BeOS | Unknown -> GAS_like
module Run ( G : sig type node val n : int val index : node -> int val successors : ( node -> unit ) -> node -> unit val iter : ( node -> unit ) -> unit type data = { mutable stacked : bool ; mutable number : int ; mutable low : int ; mutable representative : G . node ; mutable scc : G . node list } let table = let tab...
module Cstruct_io = struct type in_channel = { mutable pos : int ; data : Cstruct . t ; } let make_in_channel data = { pos = 0 ; data } let check_available ch len = min ( Cstruct . length ch . data - ch . pos ) pos len let really_input ic buf pos len = if check_available ic len <> len then raise End_of_file ; Cstruct ....
module Reader = struct type in_channel = Lwt_unix . file_descr type ' a t = ' a Lwt . t let really_read fd = Lwt_cstruct ( . complete ( read fd ) fd ) fd let skip ( ifd : Lwt_unix . file_descr ) file_descr ( n : int ) int = let buffer_size = 32768 in let buffer = Cstruct . create buffer_size in let rec loop ( n : int )...
module Writer = struct type out_channel = Lwt_unix . file_descr type ' a t = ' a Lwt . t let really_write fd = Lwt_cstruct ( . complete ( write fd ) fd ) fd end
let copy_n ifd ofd n = let block_size = 32768 in let buffer = Cstruct . create block_size in let rec loop remaining = if remaining = 0L then Lwt . return_unit else begin let this = Int64 ( . to_int ( min ( of_int block_size ) block_size remaining ) remaining ) remaining in let block = Cstruct . sub buffer 0 this in rea...
let get_next_header ? level ic = HR . read ? level ic >>= function | Error ` Eof -> Lwt . return None | Ok hdr -> Lwt . return ( Some hdr ) hdr
let header_of_file ? level ( file : string ) string : Tar . Header . t Lwt . t = let level = match level with None -> Tar . Header . V7 | Some level -> level in Lwt_unix . LargeFile . stat file >>= fun stat -> Lwt_unix . getpwuid stat . Lwt_unix . LargeFile . st_uid >>= fun pwent -> Lwt_unix . getgrgid stat . Lwt_unix ...
let write_block ? level ( header : Tar . Header . t ) t ( body : Lwt_unix . file_descr -> unit Lwt . t ) t ( fd : Lwt_unix . file_descr ) file_descr = HW . write ? level header fd >>= fun ( ) -> body fd >>= fun ( ) -> really_write fd ( Tar . Header . zero_padding header ) header
let write_end ( fd : Lwt_unix . file_descr ) file_descr = really_write fd Tar . Header . zero_block >>= fun ( ) -> really_write fd Tar . Header . zero_block
module Archive = struct let with_file name flags perms f = Lwt_unix . openfile name flags perms >>= fun fd -> Lwt . finalize ( fun ( ) -> f fd ) fd ( fun ( ) -> Lwt_unix . close fd ) fd let with_next_file ( fd : Lwt_unix . file_descr ) file_descr ( f : Lwt_unix . file_descr -> Tar . Header . t -> ' a Lwt . t ) t = get_...
module Make_KV_RO ( BLOCK : Mirage_block . S ) S = struct type entry = | Value of Tar . Header . t * int64 | Dict of Tar . Header . t * entry StringMap . t type t = { b : BLOCK . t ; map : entry ; info : Mirage_block . info ; } type key = Mirage_kv . Key . t type error = [ Mirage_kv . error | ` Block of BLOCK . error ]...
module Driver = struct type in_channel = Unix . file_descr type out_channel = Unix . file_descr let rec with_restart op fd buf off len = try op fd buf off len with Unix . Unix_error ( Unix . EINTR , _ , _ ) _ -> with_restart op fd buf off len let rec really_input fd buf off = function | 0 -> ( ) | len -> let m = Unix ....
let header_of_file ? level ( file : string ) string : Tar . Header . t = let level = match level with None -> Tar . Header . V7 | Some level -> level in let stat = Unix . LargeFile . lstat file in let file_mode = stat . Unix . LargeFile . st_perm in let user_id = stat . Unix . LargeFile . st_uid in let group_id = stat ...
module Archive = struct include T . Archive let with_file name flags perms f = let fd = Unix . openfile name flags perms in Fun . protect ~ finally ( : fun ( ) -> Unix . close fd ) fd ( fun ( ) -> f fd ) fd let extract dest ifd = let dest hdr = let filename = dest hdr . Tar . Header . file_name in Unix . openfile filen...
type ( ' a , ' b ) t = { creator : OCAAccount . t option ; start_time : float ; thrd : ( ' b * float ) Lwt . t ; log : LogBox . t ; }
let create ~ ctxt f = let log = LogBox . create ( ) in let ctxt = LogBox . set log ctxt in let thrd = f ctxt >|= fun res -> res , Unix . gettimeofday ( ) in { start_time = Unix . gettimeofday ( ) ; creator = ctxt . accnt ; thrd = thrd ; log = log ; }
let wait ~ ctxt t timeout timeout_msg = let timeout_thrd = Lwt_unix . timeout timeout in catch ( fun ( ) -> choose [ timeout_thrd ; t . thrd ] >|= fun res -> Lwt . cancel timeout_thrd ; res ) ( function | Lwt_unix . Timeout -> fail ( Common . Timeout timeout_msg ) | e -> fail e ) >|= fun ( res , end_time ) -> t , end_t...
let create_and_wait ~ ctxt f set timeout timeout_msg = let t = create f ~ ctxt in set t ; wait ~ ctxt t timeout timeout_msg
let set_logger t ctxt = LogBox . set t . log ctxt
let get_logger t = LogBox . copy t . log
let re_error_line = Str . regexp_case_fold " . " ( . ) " , *\\\+\\\ line ( [ \\ 0 - 9 ] ) , +\\ characters ( [ \\ 0 - 9 ] ) ( [ +\\-\\ 0 - 9 ] ) " +\\:?
let re_assert_failure = Str . regexp " . ( *\\ Assert_failure ( " ( . ) " , \\\+\\\ ( [ \\ 0 - 9 ] ) , +\\ ( [ \\ 0 - 9 ] ) ) ) " +\\\\ let project = editor # project in let vbox = GPack . vbox ? packing ( ) in let hbox = GPack . hbox ~ packing : vbox # add ( ) in let tooltips = GData . tooltips ( ) in let toolbar = GB...
let views : ( string * ( view * GObj . widget ) ) list ref = ref [ ]
let create ~ editor task_kind task = let console_id = sprintf " % s % s % s " task . Task . et_name task . Task . et_cmd ( String . concat " " ( List . flatten ( List . filter_map ( fun ( e , v ) -> if e then Some ( Shell . parse_args v ) else None ) task . Task . et_args ) ) ) in try let ( console , _ ) = List . assoc...
let exec_sync ? run_cb ( ? use_thread = true ) ( ? at_exit = ignore ) ~ editor task_groups = let mode : [ ` all | ` group | ` single ] = ` single in let f tasks = try ignore ( List . fold_left begin fun acc ( task_kind , task ) -> let console = match acc with | Some console when mode = ` all || mode = ` group -> consol...
let exec ~ editor ? use_thread ( ? with_deps = false ) task_kind target = let project = editor # project in let can_compile_native = project . Prj . can_compile_native in let filter_tasks = Target . filter_external_tasks target in let tasks_clean ( ) = if Oebuild . check_restrictions target . restrictions then let et_b...
module Pervasives = struct include Pervasives let ref = GT . ref end
module Primitive = struct type boxed_integer = [ % import : Primitive . boxed_integer ] [ @@ deriving gt ~ options { : fmt ; html } ] type native_repr = [ % import : Primitive . native_repr ] [ @@ deriving gt ~ options { : fmt ; html } ] type description = [ % import : Primitive . description ] [ @@ deriving gt ~ optio...
module Ident = struct include Ident let t = { GT . gcata = ( fun _ _ -> assert false ) ; GT . plugins = object method html i = HTML . string @@ Ident . name i method fmt fmt i = Format . fprintf fmt " % s " ( Ident . name i ) end } end
module Path = struct type t = [ % import : Path . t ] [ @@ deriving gt ~ options { : fmt ; html } ] end
module Types = struct type type_expr = [ % import : Types . type_expr ] and row_desc = [ % import : Types . row_desc [ @ with Stdlib . ref := GT . ref ] ] and type_desc = [ % import : Types . type_desc [ @ with Stdlib . ref := GT . ref ] ] and row_field = [ % import : Types . row_field [ @ with Stdlib . ref := GT . ref...
module Env = struct type t = [ % import : Env . t ] let t = { GT . gcata = ( fun _ _ -> failwith " env not implemented " ) ; GT . plugins = object method fmt fmt s = Format . fprintf fmt " < env " >%! method html s = HTML . string " " end } end
type partial = [ % import : Typedtree . partial ] [ @@ deriving gt ~ options { : fmt ; html } ]
type attribute = [ % import : Camlast . attribute ] [ @@ deriving gt ~ options { : fmt ; html } ]
type attributes = attribute GT . list [ @@ deriving gt ~ options { : fmt ; html } ]
type pattern = [ % import : Typedtree . pattern ] inherit [ ' self ] html_pattern_desc_t_stub mut_trfs_here fself method ! c_Tpat_var ( ) _ ident nameloc = let loc_str = Location . show_location nameloc . Asttypes . loc in HTML . ul @@ HTML . seq [ HTML . anchor loc_str @@ HTML . string @@ Printf . sprintf " % S from %...
let html_structure = let { html_structure } = html_fix_case ~ expression0 : { html_expression_func = new expression_with_link } ~ pattern_desc0 : { html_pattern_desc_func = new pattern_desc_with_link } ( ) in html_structure . html_structure_trf
let print_if ppf flag printer arg = if ! flag then fprintf ppf " % a . " @ printer arg ; arg
let ( ) ++ x f = f x
let implementation ppf sourcefile outputprefix = Compmisc . init_path false ; let modulename = module_of_filename ppf sourcefile outputprefix in Env . set_unit_name modulename ; let env = Compmisc . initial_env ( ) in try let parsed = Pparse . parse_implementation ~ tool_name ppf sourcefile in let ( typedtree , _ ) = p...
let process_implementation_file ppf name = let opref = output_prefix name in implementation ppf name opref ; objfiles := ( opref ^ " . cmo " ) :: ! objfiles
let process_file ppf name = Printf . printf " process_file ` % s ` \ n " %! name ; if Filename . check_suffix name " . ml " || Filename . check_suffix name " . mlt " then begin let opref = output_prefix name in implementation ppf name opref ; objfiles := ( opref ^ " . cmo " ) :: ! objfiles raise ( Arg . Bad ( " don ' t...
let usage = " Usage : ocamlc < options > < files >\ nOptions are " :
let before_compile s = Before_compile s
let anonymous filename = readenv ppf ( before_compile filename ) ; process_file ppf filename ; ;
let impl filename = readenv ppf ( before_compile filename ) ; process_implementation_file ppf filename ; ;
let show_config ( ) = Config . print_config stdout ; exit 0 ; ; ;
module Options = Main_args . Make_bytecomp_options ( struct let set r ( ) = r := true let unset r ( ) = r := false let _a = set make_archive let _absname = set Location . absname let _annot = set annotations let _binannot = set binary_annotations let _c = set compile_only let _cc s = c_compiler := Some s let _cclib s =...
let ( ) = readenv ppf Before_args ; Arg . parse Options . list anonymous usage ; ( )
let vs_of_lb_arg = function | Lunit -> invalid_arg " vs_of_lb_arg Lunit " | Lnone vs | Loptional vs | Lnamed vs | Lghost vs -> vs
let ty_of_lb_arg = function | Lunit -> ty_unit | Lnone vs | Loptional vs | Lnamed vs | Lghost vs -> vs . vs_ty
let val_spec sp_args sp_ret sp_pre sp_checks sp_post sp_xpost sp_wr sp_cs sp_diverge sp_pure sp_equiv sp_text sp_loc = { sp_args ; sp_ret ; sp_pre ; sp_checks ; sp_post ; sp_xpost ; sp_wr ; sp_cs ; sp_diverge ; sp_pure ; sp_equiv ; sp_text ; sp_loc ; }
let mk_val_spec args ret pre checks post xpost wr cs dv pure equiv txt loc = let add args = function | Lunit -> args | a -> let vs = vs_of_lb_arg a in if Svs . mem vs args then W . error ~ loc ( W . Duplicated_argument vs . vs_name . id_str ) ; Svs . add vs args in let ( _ : Svs . t ) = List . fold_left add Svs . empty...
let mk_val_description vd_name vd_type vd_prim vd_attrs vd_args vd_ret vd_spec vd_loc = { vd_name ; vd_type ; vd_prim ; vd_attrs ; vd_args ; vd_ret ; vd_spec ; vd_loc }
let type_spec ty_ephemeral ty_fields ty_invariants ty_text ty_loc = { ty_ephemeral ; ty_fields ; ty_invariants ; ty_text ; ty_loc }
let label_declaration ld_field ld_mut ld_loc ld_attrs = { ld_field ; ld_mut ; ld_loc ; ld_attrs }