text stringlengths 12 786k |
|---|
type ts = t list [ @@ deriving sexp ] |
let to_string t = Sexplib . Sexp . to_string_hum ( sexp_of_ts t ) |
type overlap = | AABB | BBAA | BABA | BAAB | ABBA | ABAB |
let classify { start = a_start ; length = a_length } { start = b_start ; length = b_length } = let a_end = add a_start a_length in let b_end = add b_start b_length in if b_end < a_start then BBAA else if a_end < b_start then AABB else begin if b_start < a_start then begin if b_end < a_end then BA... |
let difference ( { start = a_start ; length = a_length } as a ) ( { start = b_start ; length = b_length } as b ) = let a_end = add a_start a_length in let b_end = add b_start b_length in match classify a b with | BBAA | AABB -> [ a ] | BABA -> [ { start = b_end ; length = sub... |
let intersect ( { start = a_start ; length = a_length } as a ) ( { start = b_start ; length = b_length } as b ) : t list = let a_end = add a_start a_length in let b_end = add b_start b_length in match classify a b with | BBAA | AABB -> [ ] | BABA -> [ { start = a_start ; leng... |
type parsed_type = { constraint_vars : expression list ; arg_list : string list ; id_list : core_type list ; } |
let id = ref 0 |
let idx = ref 1 |
let arg_string = ref " " |
let arg_string2 = ref " " |
let new_fresh_var loc = let v = " spoc_var " ( ^ string_of_int ! id ) in let a = Ast_builder . Default . estring ~ loc v in incr id ; a , v |
let rec parse_ctyp = function | { ptyp_desc = Ptyp_arrow ( Nolabel , typ1 , typ2 ) ; _ } -> let l1 = parse_ctyp typ1 and l2 = parse_ctyp typ2 in { constraint_vars = l1 . constraint_vars @ l2 . constraint_vars ; arg_list = l1 . arg_list @ l2 . arg_list ; id_list = l1 . id_list ... |
let rec concrete_type_to_type t = let loc = t . ptyp_loc in match t with | [ % type : float64 ] -> [ % type : float ] | [ % type : Spoc . Vector . vfloat64 ] -> [ % type : ( float , Bigarray . float64_elt ) Vector . vector ] | [ % type : Spoc . Vector . vfloat32 ] ... |
let rec type_to_type t = let loc = t . ptyp_loc in match t with | [ % type : float64 ] -> [ % type : float ] | [ % type : Spoc . Vector . vfloat64 ] -> [ % type : ( ' spoc_a , ' spoc_b ) Vector . vector ] | [ % type : Spoc . Vector . vfloat32 ] -> [ % type ... |
let rec parseTyp t var = incr idx ; let loc = t . ptyp_loc in let i = Ast_builder . Default . evar ~ loc var in ( match t with | [ % type : char ] [ ->% expr Spoc . Kernel . Char [ % e i ] ] | [ % type : int ] | [ % type : int32 ] [ ->% expr Spoc . Kernel . Int32 ... |
let gen_args loc type_list = id := 0 ; arg_string := " " ; let var_list = ref [ ] in let l = List . tl ( List . rev type_list ) in let l = List . rev l in let translate t = let e , v = new_fresh_var loc in var_list := ! var_list @ [ e , v ] ; let t2 = type_to_type t in let t... |
let first_vector = ref false |
let relaxed loc nv = if not ! first_vector then ( first_vector := true ; [ % expr [ % e Ast_builder . Default . evar ~ loc nv ] ] ) else [ % expr Spoc . Kernel . relax_vector [ % e Ast_builder . Default . evar ~ loc nv ] ] |
let rec gen_inv_id t loc nv = match t with | [ % type : Spoc . Vector . vfloat64 ] | [ % type : Spoc . Vector . vfloat32 ] | [ % type : Spoc . Vector . localvfloat32 ] | [ % type : Spoc . Vector . localvfloat64 ] | [ % type : Spoc . Vector . vchar ] | [ % type... |
let rec parseInvTyp t i = incr idx ; arg_string2 := i " ^ " ( ^! arg_string2 ) ; ( match t with | [ % type : char ] -> Longident . Lident " Char " | [ % type : int ] | [ % type : int32 ] -> Longident . Lident " Int32 " | [ % type : int64 ] -> Longident . Li... |
let gen_inv_args loc type_list = id := 0 ; arg_string := " " ; let var_list = ref [ ] in first_vector := false ; let l = List . tl ( List . rev type_list ) in let l = List . rev l in let translate t = let e , v = new_fresh_var loc in var_list := ! var_list @ [ e , v ] ; [ ... |
let gen_ktyp id_list = let ktyp = List . map concrete_type_to_type id_list in let ktyp = List . tl ( List . rev ktyp ) in let ktyp = List . rev ktyp in match ktyp with | [ ] -> assert false | [ x ] -> x | a :: _tl -> Ast_builder . Default . ptyp_tuple ~ loc : a . ptyp_loc ktyp ob... |
let _ = Driver . register_transformation " external_kernel " ~ impl ( : new ext_kernel_mapper ) # structure |
type t ' a ' b = list ( matching ' a ' b ) [ Eapp of list patt | Eacc of list patt | Econ of string | Estr of string | Eint of string | Etup of list patt | Evar of unit ] ; fun [ [ m :: ml ] -> match m . expr a with [ None -> apply_matchings a ml | x -> x ] | [ ] -> None ... |
let load_path = ref [ ] |
let first = ref true |
let digest_interface unit loadpath = let filename = let shortname = unit ^ " . cmi " in try Misc . find_in_path_uncap loadpath shortname with Not_found -> failwith ( Printf . sprintf " Cannot find interface % s in load path " shortname ) in let ic = open_in_bin filename in try let buffer = rea... |
let print_crc unit = try let crc = digest_interface unit ( ! load_path @ [ " . " ] ) in if ! first then first := false else print_string " ; \ n " ; print_string " " " ; \ print_string ( String . capitalize_ascii unit ) ; print_string " " , \\ n " " ; \ for i ... |
let usage = " Usage : extract_crc [ - I < dir ] > < files " > |
let main ( ) = print_string " let crc_unit_list = [ \ n " ; Arg . parse [ " - I " , Arg . String ( fun dir -> load_path := ! load_path @ [ dir ] ) , " < dir > Add < dir > to the list of include directories " ] print_crc usage ; print_string " \ n ] \ n " |
let _ = main ( ) ; exit 0 |
let known_valid_projections ~ env ~ projections ~ which_variables = Projection . Set . filter ( fun projection -> let from = Projection . projecting_from projection in let outer_var = match Variable . Map . find from which_variables with | exception Not_found -> assert false | ( outer_var : Fla... |
let rec analyse_expr ~ which_variables expr = let projections = ref Projection . Set . empty in let used_which_variables = ref Variable . Set . empty in let check_free_variable var = if Variable . Map . mem var which_variables then begin used_which_variables := Variable . Set . add var ! used_whi... |
let from_function_decl ~ env ~ which_variables ( ~ function_decl : Flambda . function_declaration ) = let projections , used_which_variables = analyse_expr ~ which_variables function_decl . body in let projections = known_valid_projections ~ env ~ projections ~ which_variables in Projection . Set... |
let read ch = let b = Buffer . create 1024 in let s = Bytes . create 1024 in let rec read ( ) = let n = input ch s 0 1024 in if n > 0 then ( Buffer . add_subbytes b s 0 n ; read ( ) ) in read ( ) ; Buffer . contents b |
let h c = match c with | ' 0 ' . . ' 9 ' -> Char . code c - Char . code ' 0 ' | ' a ' . . ' f ' -> Char . code c - Char . code ' a ' + 10 | _ -> assert false |
let rec parse b s i = match s . [ i ] with | ' ' ' \ -> Buffer . contents b | ' ' \\ -> ( match s . [ i + 1 ] with | ' ' ' \ -> Buffer . add_char b ' ' ' ; \ parse b s ( i + 2 ) | ' x ' -> Buffer . add_char b ( Char . chr ( ( 16 * h s . [ ... |
let _ = let s = read stdin in let prefix = " __eliom_request_data = ' " in let re = Str . regexp_string prefix in let i = Str . search_forward re s 0 in let b = Buffer . create 1024 in let s = parse b s ( i + String . length prefix ) in output_string stdout s |
let add cl = let update_instr prev ( i : _ Cfg . instruction ) = let dbg = if ( not ( Debuginfo . is_none prev ) ) && Debuginfo . is_none i . dbg then prev else i . dbg in let fdo = Fdo_info . create ~ discriminator : i . id ~ dbg in dbg , { i with fdo } in let cfg = CL . cf... |
let _ = let top = openTk ( ) in let fw = Frame . create top in pack [ fw ] ; let c = Canvas . create ~ width : 200 ~ height : 200 fw in let create_eye cx cy wx wy ewx ewy bnd = let o2 = Canvas . create_oval ~ x1 ( : cx - wx ) ~ y1 ( : cy - wy ) ~ x2 ( : cx + wx ) ~ y2 ... |
let _ = Printexc . print mainLoop ( ) |
let cstruct_equal a b = let check_contents a b = try for i = 0 to Cstruct . len a - 1 do let a ' = Cstruct . get_char a i in let b ' = Cstruct . get_char b i in if a ' <> b ' then raise Cstruct_differ done ; true with _ -> false in ( Cstruct . len a = ( Cstruct . len b ) ) && ( ... |
module Memory = struct let alloc bytes = if bytes = 0 then Cstruct . create 0 else let n = ( bytes + 4095 ) / 4096 in let pages = Io_page . ( to_cstruct ( get n ) ) in Cstruct . sub pages 0 bytes end |
let constant size v = let buf = Memory . alloc size in for i = 0 to size - 1 do Cstruct . set_uint8 buf i v done ; buf |
let sectors_in_2mib = 2 * 1024 * 2 |
let empty_2mib = constant ( sectors_in_2mib * 512 ) 0 |
let sector_all_zeroes = constant 512 0 |
let sector_all_ones = constant 512 0xff |
module Int64 = struct include Int64 let ( ++ ) = add let ( -- ) = sub let ( // ) = div let ( ** ) = mul let ( lsl ) = shift_left let ( lsr ) = shift_right_logical let roundup_sector x = ( ( x ++ ( 1L lsl sector_shift -- 1L ) ) lsr sector_shift ) lsl sector_shift end |
let roundup_sector x = ( ( x + ( 1 lsl sector_shift - 1 ) ) lsr sector_shift ) lsl sector_shift |
let mib = Int64 . ( 1024L ** kib ) |
let gib = Int64 . ( 1024L ** mib ) |
let max_disk_size = Int64 . ( 2040L ** gib ) |
let blank_uuid = match Uuidm . of_bytes ( String . make 16 ' \ 000 ' ) with | Some x -> x | None -> assert false |
module Feature = struct type t = | Temporary let of_int32 x = if Int32 . logand x 1l <> 0l then [ Temporary ] else [ ] let to_int32 ts = let one = function | Temporary -> 1 in let reserved = 2 in Int32 . of_int ( List . fold_left ( lor ) reserved ( List . map one ts ) ) let to_... |
module Disk_type = struct type t = | Fixed_hard_disk | Dynamic_hard_disk | Differencing_hard_disk exception Unknown of int32 let of_int32 = let open Rresult in function | 2l -> R . ok Fixed_hard_disk | 3l -> R . ok Dynamic_hard_disk | 4l -> R . ok Differencing_hard_disk | x -> R . error ( Unk... |
module Host_OS = struct type t = | Windows | Macintosh | Other of int32 let of_int32 = function | 0x5769326bl -> Windows | 0x4d616320l -> Macintosh | x -> Other x let to_int32 = function | Windows -> 0x5769326bl | Macintosh -> 0x4d616320l | Other x -> x let to_string = function | Windows -> " ... |
module Geometry = struct type t = { cylinders : int ; heads : int ; sectors : int ; } let of_sectors sectors = let open Int64 in let max_secs = 65535L ** 255L ** 16L in let secs = min max_secs sectors in let secs_per_track = ref 0L in let heads = ref 0L in let cyls_times_heads = ref 0L in i... |
module Checksum = struct type t = int32 let of_cstruct m = let rec inner n cur = if n = Cstruct . len m then cur else inner ( n + 1 ) ( Int32 . add cur ( Int32 . of_int ( Cstruct . get_uint8 m n ) ) ) in Int32 . lognot ( inner 0 0l ) let sub_int32 t x = let open Int32 in let t ' ... |
module UTF16 = struct type t = int array let to_utf8_exn s = let utf8_chars_of_int i = if i < 0x80 then [ char_of_int i ] else if i < 0x800 then begin let z = i land 0x3f and y = ( i lsr 6 ) land 0x1f in [ char_of_int ( 0xc0 + y ) ; char_of_int ( 0x80 + z ) ] end else if i < 0x10... |
module Footer = struct type t = { features : Feature . t list ; data_offset : int64 ; time_stamp : int32 ; creator_application : string ; creator_version : int32 ; creator_host_os : Host_OS . t ; original_size : int64 ; current_size : int64 ; geometry : Geometry . t ; disk_type : D... |
type footer = { magic : uint8_t [ @ len 8 ] ; features : uint32_t ; version : uint32_t ; data_offset : uint64_t ; time_stamp : uint32_t ; creator_application : uint8_t [ @ len 4 ] ; creator_version : uint32_t ; creator_host_os : uint32_t ; original_size : uint64_t ; current_siz... |
module Platform_code = struct type t = | None | Wi2r | Wi2k | W2ru | W2ku | Mac | MacX let wi2r = 0x57693272l let wi2k = 0x5769326Bl let w2ru = 0x57327275l let w2ku = 0x57326b75l let mac = 0x4d616320l let macx = 0x4d616358l let of_int32 = let open Rresult in function | 0l -> R . ok None | x ... |
module Parent_locator = struct type t = { platform_code : Platform_code . t ; platform_data_space : int32 ; platform_data_space_original : int32 ; platform_data_length : int32 ; platform_data_offset : int64 ; platform_data : Cstruct . t ; } let equal a b = true && ( a . platform_code ... |
module Header = struct type t = { table_offset : int64 ; max_table_entries : int ; block_size_sectors_shift : int ; checksum : int32 ; parent_unique_id : Uuidm . t ; parent_time_stamp : int32 ; parent_unicode_name : int array ; parent_locators : Parent_locator . t array ; } let default... |
module BAT = struct type t = { max_table_entries : int ; data : Cstruct . t ; mutable highest_value : int32 ; } let unused = 0xffffffffl let unused ' = 0xffffffffL let get t i = Cstruct . BE . get_uint32 t . data ( i * 4 ) let set t i j = Cstruct . BE . set_uint32 t . data ( ... |
module Batmap_header = struct [ %% cstruct type header = { magic : uint8_t [ @ len 8 ] ; offset : uint64_t ; size_in_sectors : uint32_t ; major_version : uint16_t ; minor_version : uint16_t ; checksum : uint32_t ; marker : uint8_t ; } [ @@ big_endian ] ] let magic = " tdbat... |
module Batmap = struct type t = Cstruct . t let sizeof_bytes ( x : Header . t ) = ( x . Header . max_table_entries + 7 ) lsr 3 let sizeof ( x : Header . t ) = roundup_sector ( sizeof_bytes x ) let set t n = let byte = Cstruct . get_uint8 t ( n / 8 ) in let bit = n mod 8 in... |
module Bitmap = struct type t = | Full | Partial of Cstruct . t let get t sector_in_block = match t with | Full -> true | Partial buf -> let sector_in_block = Int64 . to_int sector_in_block in let bitmap_byte = Cstruct . get_uint8 buf ( sector_in_block / 8 ) in let bitmap_bit = sector_in_block m... |
module Bitmap_cache = struct type t = { cache : ( int * Bitmap . t ) option ref ; all_zeroes : Cstruct . t ; all_ones : Cstruct . t ; } let all_ones size = if size = Cstruct . len sector_all_ones then sector_all_ones else constant size 0xff let all_zeroes size = if size = Cstruct . le... |
module Sector = struct type t = Cstruct . t let dump t = if Cstruct . len t = 0 then Printf . printf " Empty sector \ n " else for i = 0 to Cstruct . len t - 1 do if ( i mod 16 = 15 ) then Printf . printf " % 02x \ n " ( Cstruct . get_uint8 t i ) else Printf . printf " %... |
module Vhd = struct type ' a t = { filename : string ; rw : bool ; handle : ' a ; header : Header . t ; footer : Footer . t ; parent : ' a t option ; bat : BAT . t ; batmap : ( Batmap_header . t * Batmap . t ) option ; bitmap_cache : Bitmap_cache . t ; } let resiz... |
module Raw = struct type ' a t = { filename : string ; handle : ' a ; } end |
type size = { total : int64 ; metadata : int64 ; empty : int64 ; copy : int64 ; } |
let empty = { total = 0L ; metadata = 0L ; empty = 0L ; copy = 0L } |
module Stream = functor ( A : S . ASYNC ) -> struct open A type ' a ll = | Cons of ' a * ( unit -> ' a ll t ) | End let rec iter f = function | Cons ( x , rest ) -> f x >>= fun ( ) -> rest ( ) >>= fun x -> iter f x | End -> return ( ) let rec fold_left f initial xs = ... |
module Fragment = struct type t = | Header of Header . t | Footer of Footer . t | BAT of BAT . t | Batmap of Batmap . t | Block of int64 * Cstruct . t end |
module From_input = functor ( I : S . INPUT ) -> struct open I type ' a ll = | Cons of ' a * ( unit -> ' a ll t ) | End let ( ) >>|= m f = match m with | Error e -> fail e | Ok x -> f x let ( ) >+> m f = return ( Cons ( m , f ) ) open Memory let openstream size_opt fd ... |
module From_file = functor ( F : S . FILE ) -> struct open F let ( ) >>|= m f = match m with | Error e -> fail e | Ok x -> f x let search filename path = let rec loop = function | [ ] -> return None | x :: xs -> let possibility = Filename . concat x filename in ( F . exists possibil... |
let ws_fact = let fact = Spel . variable " fact " in let n = Spel . variable " n " in let return = Spel . variable " return " in let res = Spel . variable " res " in let base = Wcs . dialog_node " Base " ~ conditions_spel : ( Spel . or_ ( Spel . eq n ( Spel . int 0 ) ... |
let main ( ) = let wcs_cred_file = ref None in let ws_id = ref None in let print = ref false in let deploy = ref false in let exec = ref false in let speclist = Arg . align [ " - cred " , Arg . String ( fun s -> wcs_cred_file := Some s ) , " cred . json The file containing the Watson... |
let _ = begin try main ( ) with | Log . Error ( module_name , msg ) when not ! Log . debug_message -> Format . eprintf " % s . " @ msg ; exit 1 end |
module Make ( Structure : Structure . S ) = struct module Tools = Tools . Make Structure ; module Search = Search . Make Structure ; module Print = Print . Make Structure ; open Structure ; open Format ; fun [ Snterm e -> " [ " ^ e . ename ^ " ] " | Snterml e l -> " [ ... |
module Antiquotable = struct module Loc = Camlp4 . PreCast . Loc type ' a t = | Val of Loc . t * ' a | Ant of Loc . t * string end |
module Identity_type_functor = struct type ' a t = ' a end |
module MakeLambdaSyntax ( Node : sig type ' a t end ) = struct type term ' = | Lam of var * term | App of term * term | Var of var | Int of num and term = term ' Node . t and num = int Node . t and var = string Node . t end |
module LambdaParser = struct open Antiquotable ; ; open AntiquotableLambdaSyntax ; ; open Camlp4 . PreCast ; ; module LambdaGram = MakeGram ( Lexer ) ; ; let term = LambdaGram . Entry . mk " term " ; ; let term_eoi = LambdaGram . Entry . mk " lambda term quotation " ; ; ... |
module LambdaLifter = struct open Antiquotable ; ; open AntiquotableLambdaSyntax ; ; module CamlSyntax = Camlp4OCamlParser . Make ( Camlp4OCamlRevisedParser . Make ( Camlp4 . PreCast . Syntax ) ) ; ; module Ast = Camlp4 . PreCast . Ast let expr_of_string = CamlSyntax . Gram . par... |
module LambadExpander = struct module Q = Camlp4 . PreCast . Syntax . Quotation ; ; let expand_lambda_quot_expr loc _loc_name_opt quotation_contents = LambdaLifter . term_to_expr ( LambdaParser . parse_string loc quotation_contents ) ; ; Q . add " lam " Q . DynAst . expr_tag expand_l... |
let get_ff_type p = match p with | PaId ( _loc , IdLid ( _loc2 , x ) ) -> ( let var = ( Hashtbl . find ! current_args x ) in match var . var_type with | TInt32 -> <: str_item < let $ lid ( " : task_ " ^ x ) $ = field task $ str " : task_ " ^ x $ int >> | TInt64 -... |
let f p = match p with | PaId ( _loc , IdLid ( _loc2 , x ) ) -> x | _ -> assert false |
let rec get_ff_type_str p = match p with | PaId ( _loc , IdLid ( _loc2 , x ) ) -> ( let var = ( Hashtbl . find ! current_args x ) in Printf . sprintf " let task_ % s = field task " \ task_ % s " \ % s " x x ( match var . var_type with | TFloat32 -> " float " | TInt3... |
let rec string_of_patt = function | PaId ( _ , x ) -> string_of_ident x | PaTyc ( _ , x , _ ) -> string_of_patt x | _ -> assert false |
let print_task args nameid _loc = let moduleName = ( String . capitalize_ascii ( string_of_ident nameid ) ) in let res = <: expr < object ( self ) method offloadTask = $ lid : moduleName . $ offloadTask method noMoreTasks = $ lid : moduleName . $ accNomoretasks method getResult = $ lid... |
let laws = [ { law_name = " Leftover Ocaml compilation files " ; law_rules = [ Not " . cmo " ; Not " . cmi " ; Not " . cmx " ; Not " . cma " ; Not " . cmxa " ] ; law_penalty = Fail } ; { law_name = " Leftover Ocaml type annotation files " ; law_rule... |
let inspect entry = dprintf 5 " Doing sanity checks " ; let evil = ref false in match Hygiene . check ? sanitize : begin if ! Options . sanitize then Some ( Pathname . concat ! Options . build_dir ! Options . sanitization_script ) else None end laws entry with | [ ] -> ( ) | stuff... |
type ' a located = { txt : ' a ; loc : location } |
type variable = string located |
type continuation_id = string located |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.