text stringlengths 0 601k |
|---|
let key_type = function | ` RSA _ -> ` RSA | ` ED25519 _ -> ` ED25519 | ` P224 _ -> ` P224 | ` P256 _ -> ` P256 | ` P384 _ -> ` P384 | ` P521 _ -> ` P521 |
let generate ? seed ( ? bits = 4096 ) typ = let g = match seed with | None -> None | Some seed -> Some Mirage_crypto_rng . ( create ~ seed ( module Fortuna ) ) in match typ with | ` RSA -> ` RSA ( Mirage_crypto_pk . Rsa . generate ? g ~ bits ( ) ) | ` ED25519 -> ` ED25519 ( fst ( Mirage_crypto_ec . Ed25519 . generate ?... |
let of_cstruct data = let open Mirage_crypto_ec in let ec_err e = Result . map_error ( fun e -> ` Msg ( Fmt . to_to_string Mirage_crypto_ec . pp_error e ) ) e in function | ` RSA -> Error ( ` Msg " cannot decode an RSA key " ) | ` ED25519 -> let * k = ec_err ( Ed25519 . priv_of_cstruct data ) in Ok ( ` ED25519 k ) | ` ... |
let of_string ? seed_or_data ? bits typ data = match seed_or_data with | None -> begin match typ with | ` RSA -> Ok ( generate ~ seed ( : Cstruct . of_string data ) ? bits ` RSA ) | _ -> let * data = Base64 . decode data in of_cstruct ( Cstruct . of_string data ) typ end | Some ` Seed -> Ok ( generate ~ seed ( : Cstruc... |
let public = function | ` RSA priv -> ` RSA ( Mirage_crypto_pk . Rsa . pub_of_priv priv ) | ` ED25519 priv -> ` ED25519 ( Mirage_crypto_ec . Ed25519 . pub_of_priv priv ) | ` P224 priv -> ` P224 ( Mirage_crypto_ec . P224 . Dsa . pub_of_priv priv ) | ` P256 priv -> ` P256 ( Mirage_crypto_ec . P256 . Dsa . pub_of_priv pri... |
let sign hash ? scheme key data = let open Mirage_crypto_ec in let hashed ( ) = Public_key . hashed hash data and ecdsa_to_cs s = Algorithm . ecdsa_sig_to_cstruct s in let scheme = Key_type . opt_signature_scheme ? scheme ( key_type key ) in try match key , scheme with | ` RSA key , ` RSA_PSS -> let module H = ( val ( ... |
module Asn = struct open Asn . S open Mirage_crypto_pk let other_prime_infos = sequence_of @@ ( sequence3 ( required ~ label " : prime " integer ) ( required ~ label " : exponent " integer ) ( required ~ label " : coefficient " integer ) ) let rsa_private_key = let f ( v , ( n , ( e , ( d , ( p , ( q , ( dp , ( dq , ( ... |
let decode_der cs = Asn_grammars . err_to_msg ( Asn . private_of_cstruct cs ) |
let decode_pem cs = let * data = Pem . parse cs in let rsa_p ( t , _ ) = String . equal " RSA PRIVATE KEY " t and ec_p ( t , _ ) = String . equal " EC PRIVATE KEY " t and pk_p ( t , _ ) = String . equal " PRIVATE KEY " t in let r , _ = List . partition rsa_p data and ec , _ = List . partition ec_p data and p , _ = List... |
let encode_pem p = Pem . unparse ~ tag " : PRIVATE KEY " ( Asn . private_to_cstruct p ) |
module V1 = struct module Ssl = struct module Config = struct type t = [ ` Ssl_not_compiled_in ] [ @@ deriving sexp ] let verify_certificate _ = failwith " Ssl not available , recompile with Async_ssl " let create ? version : _ ? name : _ ? ca_file : _ ? ca_path : _ ? session : _ ? verify : _ ( ) = failwith " Ssl not a... |
module V2 = struct module Ssl = struct module Config = struct type t = [ ` Ssl_not_compiled_in ] [ @@ deriving sexp ] let verify_certificate _ = failwith " Ssl not available , recompile with Async_ssl " let create ? version : _ ? options : _ ? name : _ ? hostname : _ ? allowed_ciphers : _ ? ca_file : _ ? ca_path : _ ? ... |
let verify_certificate connection = match Ssl . Connection . peer_certificate connection with | None -> return false | Some ( Error _ ) -> return false | Some ( Ok _ ) -> return true |
let teardown_connection r w = Writer . close ~ force_close ( : Clock . after ( sec 30 . ) ) w >>= fun ( ) -> Reader . close r |
let reader_writer_pipes r w = let reader_pipe_r , reader_pipe_w = Pipe . create ( ) in let writer_pipe = Writer . pipe w in upon ( Reader . transfer r reader_pipe_w ) ( fun ( ) -> teardown_connection r w >>> fun ( ) -> Pipe . close reader_pipe_w ) ; upon ( Pipe . closed writer_pipe ) ( fun ( ) -> Deferred . choose [ De... |
let reader_writer_of_pipes app_rd app_wr = Reader . of_pipe ( Info . of_string " async_conduit_ssl_reader " ) app_rd >>= fun app_reader -> upon ( Reader . close_finished app_reader ) ( fun ( ) -> Pipe . close_read app_rd ) ; Writer . of_pipe ( Info . of_string " async_conduit_ssl_writer " ) app_wr >>| fun ( app_writer ... |
module V1 = struct module Ssl = struct module Config = struct type t = { version : Ssl . Version . t option ; name : string option ; ca_file : string option ; ca_path : string option ; session : ( Ssl . Session . t [ @ sexp . opaque ] ) option ; verify : ( Ssl . Connection . t -> bool Deferred . t ) option ; } [ @@ der... |
module V2 = struct module Ssl = struct type allowed_ciphers = [ ` Only of string list | ` Openssl_default | ` Secure ] [ @@ deriving sexp ] module Config = struct type t = { version : Ssl . Version . t option ; options : Ssl . Opt . t list option ; name : string option ; hostname : string option ; allowed_ciphers : all... |
type ' a termpc = [ ` And of ' a * ' a ` | Or of ' a * ' a ` | Not of ' a ` | Atom of string ] |
type ' a termk = [ ` Dia of ' a ` | Box of ' a ' | a termpc ] |
module type T = sig type term val map : ( term -> term ) -> term -> term val nnf : term -> term val nnf_not : term -> term end |
module Fpc ( X : T with type term = private [ > ' a termpc ] as ' a ) = struct type term = X . term termpc let nnf = function ` | Not ( ` Atom _ ) as x -> x ` | Not x -> X . nnf_not x | x -> X . map X . nnf x let map f : term -> X . term = function ` | Not x -> ` Not ( f x ) ` | And ( x , y ) -> ` And ( f x , f y ) ` |... |
module Fk ( X : T with type term = private [ > ' a termk ] as ' a ) = struct type term = X . term termk module Pc = Fpc ( X ) let map f : term -> _ = function ` | Dia x -> ` Dia ( f x ) ` | Box x -> ` Box ( f x ) |# termpc as x -> Pc . map f x let nnf = Pc . nnf let nnf_not : term -> _ = function ` | Dia x -> ` Box ( X... |
type ' a termpc = [ ` And of ' a * ' a ` | Or of ' a * ' a ` | Not of ' a ` | Atom of string ] |
type ' a termk = [ ` Dia of ' a ` | Box of ' a ' | a termpc ] |
module type T = sig type term val map : ( term -> term ) -> term -> term val nnf : term -> term val nnf_not : term -> term end |
module Fpc ( X : T with type term = private [ > ' a termpc ] as ' a ) = struct type term = X . term termpc let nnf = function ` | Not ( ` Atom _ ) as x -> x ` | Not x -> X . nnf_not x | x -> X . map X . nnf x let map f : term -> X . term = function ` | Not x -> ` Not ( f x ) ` | And ( x , y ) -> ` And ( f x , f y ) ` |... |
module Fk ( X : T with type term = private [ > ' a termk ] as ' a ) = struct type term = X . term termk module Pc = Fpc ( X ) let map f : term -> _ = function ` | Dia x -> ` Dia ( f x ) ` | Box x -> ` Box ( f x ) |# termpc as x -> Pc . map f x let nnf = Pc . nnf let nnf_not : term -> _ = function ` | Dia x -> ` Box ( X... |
type t = { mutable root : string ; mutable ocaml_home : string ; mutable ocamllib : string ; mutable ocamllib_from_env : bool ; mutable encoding : string option ; mutable name : string ; mutable modified : bool ; mutable author : string ; mutable description : string ; mutable version : string ; mutable files : ( Edito... |
let find_target proj id = List_opt . find ( fun bc -> bc . Target . id = id ) proj . targets ; ; |
let find_target_string proj id = find_target proj ( int_of_string id ) |
let find_task proj name = List_opt . find ( fun et -> et . Task . et_name = name ) ( List . flatten ( List . map ( fun bc -> bc . Target . external_tasks ) proj . targets ) ) ; ; |
let new_prob ( ) = Zident . fresh " prob " |
let typ_prob = Ztypes . make ( Deftypes . Tvar ) |
let prob_varpat x = Zaux . varpat x typ_prob |
let prob_var x = Zaux . var x typ_prob |
let extra_input prob env = Env . add prob { t_sort = Deftypes . value ; t_typ = typ_prob } env , ( prob_varpat prob ) |
let rec expression prob ( { e_desc = e_desc } as e ) = match e_desc with | Eperiod ( { p_phase = opt_p1 ; p_period = p2 } ) -> { e with e_desc = | Eop ( op , e_list ) -> { e with e_desc = Eop ( op , List . map ( expression prob ) e_list ) } | Eapp ( app , op , e_list ) -> let op = expression prob op in let e_list = Lis... |
let implementation impl = match impl . desc with | Eopen _ | Etypedecl _ | Econstdecl _ | Efundecl ( _ , { f_kind = ( S | AS | A | AD | D | C ) } ) -> impl | Efundecl ( n , ( { f_kind = P ; f_args = pat_list ; let prob = new_prob ( ) in let e = expression prob e in let head , tail = Zmisc . firsts pat_list in let f_env... |
let implementation_list impl_list = Zmisc . iter implementation impl_list |
module Example : sig val the_meaning_of_life_the_universe_and_everything : int val subtract_one : int -> int let the_meaning_of_life_the_universe_and_everything = 42 let subtract_one x = x - 1 let a_secret_value = 17 end |
let one_less_than_the_meaning_of_life_etc = Example . subtract_one Example . the_meaning_of_life_the_universe_and_everything ; ; |
let ( ) = assert ( one_less_than_the_meaning_of_life_etc = 41 ) |
module Abstract_type_example : sig type t val to_int : t -> int val zero : t val one : t val add : t -> t -> t type t = int let to_int x = x let zero = 0 let one = 1 let add = ( + ) end |
let two = Abstract_type_example . add Abstract_type_example . one Abstract_type_example . one |
let four = Abstract_type_example . to_int ( Abstract_type_example . add two two ) ; ; |
module Fraction : sig type t type t = int * int let create ~ numerator ~ denominator = numerator , denominator let value ( numerator , denominator ) = Float . of_int numerator . / Float . of_int denominator end Float . ( = ) 2 . 5 ( Fraction . value ( Fraction . create ~ numerator : 5 ~ denominator : 2 ) ) ; ; Float . ... |
module type Sig = sig type ' a t type ' a run val run : ' a t -> ' a run val map : ( ' a -> ' b ) -> ' a t -> ' b t val return : ' a -> ' a t val pair : ' a t -> ' b t -> ( ' a * ' b ) t val join : ' a t t -> ' a t val fix : ( ( ' a -> ' b t ) -> ( ' a -> ' b t ) ) -> ' a -> ' b t val bool : bool t val int_exclusive : ... |
module Random : Sig with type ' a t = Random . State . t -> ' a and type ' a run = ' a type ' a t = Random . State . t -> ' a type ' a run = ' a let run m = let st = Random . State . make_self_init ( ) in m st let map f m = fun st -> f ( m st ) let return v = fun _st -> v let pair m1 m2 = fun st -> ( m1 st , m2 st ) le... |
module Distr : Sig with type ' a t = ( Q . t * ' a ) Seq . t and type ' a run = cmp ( ' : a -> ' a -> int ) -> ( ( int * int ) * ' a ) list type ' a t = ( Q . t * ' a ) Seq . t type ' a run = cmp ( ' : a -> ' a -> int ) -> ( ( int * int ) * ' a ) list let run ( type a ) m ~ cmp = let module M = Map . Make ( struct type... |
let int_reg_name = [ " | a2 " ; " a3 " ; " a4 " ; " a5 " ; " a6 " ; " a7 " ; " a8 " ; " a9 " ; " a10 " ; " a11 " ; " a12 " ; " a13 " ; " a14 " ] | |
let register_class r = match r . typ with | Val | Int | Addr -> 0 | Float -> 0 |
let num_available_registers = [ | 13 ] | |
let first_available_register = [ | 0 ] | |
let register_name r = assert ( r < 13 ) ; int_reg_name . ( r ) |
let hard_int_reg = let v = Array . make 13 Reg . dummy in for i = 0 to 12 do v . ( i ) <- Reg . at_location Int ( Reg i ) done ; v |
let phys_reg n = hard_int_reg . ( n ) |
let stack_slot slot ty = Reg . at_location ty ( Stack slot ) |
let calling_conventions first_reg last_reg make_stack arg = let loc = Array . make ( Array . length arg ) [ | Reg . dummy ] | in let current_reg = ref first_reg in let stack_ofs = ref 0 in for i = 0 to Array . length arg - 1 do match arg . ( i ) with | [ | arg ] | -> begin if ! current_reg <= last_reg then begin loc . ... |
let incoming ofs = Incoming ofs |
let outgoing ofs = Outgoing ofs |
let not_supported _ofs = fatal_error " Proc . loc_results : cannot call " |
let single_regs arg = Array . map ( fun arg -> [ | arg ] ) | arg |
let ensure_single_regs res = Array . map ( function | [ | res ] | -> res | _ -> failwith " Proc . ensure_single_regs " ) res |
let loc_arguments arg = let ( loc , alignment ) = calling_conventions 0 5 outgoing ( single_regs arg ) in ensure_single_regs loc , alignment |
let loc_parameters arg = let ( loc , _ofs ) = calling_conventions 0 5 incoming ( single_regs arg ) in ensure_single_regs loc |
let loc_results res = let ( loc , _ofs ) = calling_conventions 0 3 not_supported ( single_regs res ) in ensure_single_regs loc |
let loc_external_results res = let ( loc , _ofs ) = calling_conventions 4 7 not_supported ( single_regs res ) in ensure_single_regs loc |
let loc_external_arguments arg = calling_conventions 4 9 outgoing arg |
let loc_exn_bucket = phys_reg 0 |
let regs_are_volatile _rs = false |
let call4_destroyed = Array . of_list ( List . map phys_reg [ 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9 ; 10 ; 11 ; 12 ] ) |
let destroyed_at_oper = function | Iop ( Icall_ind _ | Icall_imm _ ) | Iop ( Iextcall { alloc = true ; _ } ) -> all_phys_regs | Iop ( Iextcall _ ) -> call4_destroyed | Iop ( Ialloc _ ) -> Array . of_list ( List . map phys_reg [ 9 ; 10 ; 11 ; 12 ] ) | _ -> [ ] || |
let destroyed_at_reloadretaddr = [ | ] | |
let safe_register_pressure = function | Iextcall _ -> 0 | Icall_ind _ | Icall_imm _ -> 0 | Ialloc _ -> 0 | _ -> 13 |
let max_register_pressure arg = [ | safe_register_pressure arg ] | |
let op_is_pure = function | Icall_ind _ | Icall_imm _ | Itailcall_ind _ | Itailcall_imm _ | Iextcall _ | Istackoffset _ | Istore _ | Ialloc _ | Iintop ( Icheckbound _ ) | Iintop_imm ( Icheckbound _ , _ ) | Ispecific _ -> false | _ -> true |
let frame_required fd = fd . fun_contains_calls || fd . fun_num_stack_slots . ( 0 ) > 0 |
let prologue_required fd = frame_required fd |
let dwarf_register_numbers ~ reg_class : _ = [ | 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9 ; 10 ; 11 ; 12 ; 13 ; 14 ; 15 ] | |
let assemble_file infile outfile = Ccomp . command ( Config . asm ^ " - o " ^ Filename . quote outfile ^ " " ^ Filename . quote infile ) |
let init ( ) = ( ) |
type obj_coord = int * ( float * float ) |
let rec mem_loc ( checkloc : float * float ) ( loclist : obj_coord list ) : bool = match loclist with [ ] | -> false | h :: t -> if ( checkloc = ( snd h ) ) then true else mem_loc checkloc t |
let rec convert_list ( lst : obj_coord list ) : obj_coord list = match lst with [ ] | -> [ ] ( | h :: t ) -> [ ( fst h , ( ( fst ( snd h ) ) . * 16 . , ( snd ( snd h ) ) . * 16 . ) ) ] ( @ convert_list t ) |
let choose_enemy_typ ( typ : int ) : enemy_typ = match typ with | 0 -> RKoopa | 1 -> GKoopa | 2 -> Goomba | _ -> failwith " Shouldn ' t reach here " |
let choose_sblock_typ ( typ : int ) : block_typ = match typ with | 0 -> Brick | 1 -> UnBBlock | 2 -> Cloud | 3 -> QBlock Mushroom | 4 -> Ground | _ -> failwith " Shouldn ' t reach here " |
let rec avoid_overlap ( lst : obj_coord list ) ( currentLst : obj_coord list ) : obj_coord list = match lst with [ ] | -> [ ] | h :: t -> if ( mem_loc ( snd h ) currentLst ) then avoid_overlap t currentLst else [ h ] ( @ avoid_overlap t currentLst ) |
let rec trim_edges ( lst : obj_coord list ) ( blockw : float ) ( blockh : float ) : obj_coord list = match lst with [ ] | -> [ ] | h :: t -> let cx = fst ( snd h ) in let cy = snd ( snd h ) in let pixx = blockw . * 16 . in let pixy = blockh . * 16 . in if ( cx < 128 . || pixx . - cx < 528 . || cy = 0 . || pixy . - cy <... |
let generate_ground_stairs cbx cby typ = let four = [ ( typ , ( cbx , cby ) ) ; ( typ , ( cbx . + 1 . , cby ) ) ; ( typ , ( cbx . + 2 . , cby ) ) ; ( typ , ( cbx . + 3 . , cby ) ) ] in let three = [ ( typ , ( cbx . + 1 . , cby . - 1 . ) ) ; ( typ , ( cbx . + 2 . , cby . - 1 . ) ) ; ( typ , ( cbx . + 3 . , cby . - 1 . )... |
let generate_airup_stairs cbx cby typ = let one = [ ( typ , ( cbx , cby ) ) ; ( typ , ( cbx . + 1 . , cby ) ) ] in let two = [ ( typ , ( cbx . + 3 . , cby . - 1 . ) ) ; ( typ , ( cbx . + 4 . , cby . - 1 . ) ) ] in let three = [ ( typ , ( cbx . + 4 . , cby . - 2 . ) ) ; ( typ , ( cbx . + 5 . , cby . - 2 . ) ) ; ( typ , ... |
let generate_airdown_stairs cbx cby typ = let three = [ ( typ , ( cbx , cby ) ) ; ( typ , ( cbx . + 1 . , cby ) ) ; ( typ , ( cbx . + 2 . , cby ) ) ] in let two = [ ( typ , ( cbx . + 2 . , cby . + 1 . ) ) ; ( typ , ( cbx . + 3 . , cby . + 1 . ) ) ] in let one = [ ( typ , ( cbx . + 5 . , cby . + 2 . ) ) ; ( typ , ( cbx ... |
let rec generate_clouds cbx cby typ num = if ( num = 0 ) then [ ] else [ ( typ , ( cbx , cby ) ) ] @ generate_clouds ( cbx . + 1 . ) cby typ ( num - 1 ) |
let rec generate_coins ( block_coord : obj_coord list ) : obj_coord list = let place_coin = Random . int 2 in match block_coord with [ ] | -> [ ] | h :: t -> if ( place_coin = 0 ) then let xc = fst ( snd h ) in let yc = snd ( snd h ) in [ ( 0 , ( xc , ( yc . - 16 . ) ) ) ] @ generate_coins t else generate_coins t |
let choose_block_pattern ( blockw : float ) ( blockh : float ) ( cbx : float ) ( cby : float ) ( prob : int ) : obj_coord list = if ( cbx > blockw || cby > blockh ) then [ ] else let block_typ = Random . int 4 in let stair_typ = Random . int 2 in let life_block_chance = Random . int 5 in let middle_block = if ( life_bl... |
let rec generate_enemies ( blockw : float ) ( blockh : float ) ( cbx : float ) ( cby : float ) ( acc : obj_coord list ) = if ( cbx > ( blockw . - 32 . ) ) then [ ] else if ( cby > ( blockh . - 1 . ) || cbx < 15 . ) then generate_enemies blockw blockh ( cbx . + 1 . ) 0 . acc else if ( mem_loc ( cbx , cby ) acc || cby = ... |
let rec generate_block_enemies ( block_coord : obj_coord list ) : obj_coord list = let place_enemy = Random . int 20 in let enemy_typ = Random . int 3 in match block_coord with [ ] | -> [ ] | h :: t -> if ( place_enemy = 0 ) then let xc = fst ( snd h ) in let yc = snd ( snd h ) in [ ( enemy_typ , ( xc , ( yc . - 16 . )... |
let rec generate_block_locs ( blockw : float ) ( blockh : float ) ( cbx : float ) ( cby : float ) ( acc : obj_coord list ) : obj_coord list = if ( blockw . - cbx < 33 . ) then acc else if ( cby > ( blockh . - 1 . ) ) then generate_block_locs blockw blockh ( cbx . + 1 . ) 0 . acc else if ( mem_loc ( cbx , cby ) acc || c... |
let generate_panel ( context : Dom_html . canvasRenderingContext2D Js . t ) ( blockw : float ) ( blockh : float ) : collidable = let ob = Object . spawn ( SBlock Panel ) context ( ( blockw . * 16 . ) . - 256 . , ( blockh . * 16 . ) . * 2 . . / 3 . ) in ob |
let rec generate_ground ( blockw : float ) ( blockh : float ) ( inc : float ) ( acc : obj_coord list ) : obj_coord list = if ( inc > blockw ) then acc else if ( inc > 10 . ) then let skip = Random . int 10 in let newacc = acc [ ( @ 4 , ( inc . * 16 . , blockh . * 16 . ) ) ] in if ( skip = 7 && blockw . - inc > 32 . ) t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.