text stringlengths 0 601k |
|---|
type huffman = | Found of int | NeedBit of huffman * huffman | NeedBits of int * huffman array |
type adler32 = { mutable a1 : int ; mutable a2 : int ; } |
type window = { mutable wbuffer : Bytes . t ; mutable wpos : int ; wcrc : adler32 ; } |
type state = | Head | Block | CData | Flat | Crc | Dist | DistOne | Done |
type t = { mutable znbits : int ; mutable zbits : int ; mutable zstate : state ; mutable zfinal : bool ; mutable zhuffman : huffman ; mutable zhuffdist : huffman option ; mutable zlen : int ; mutable zdist : int ; mutable zneeded : int ; mutable zoutput : Bytes . t ; mutable zoutpos : int ; zinput : IO . input ; zlengt... |
type error_msg = | Invalid_huffman | Invalid_data | Invalid_crc | Truncated_data | Unsupported_dictionary |
let error msg = raise ( Error msg ) msg |
let rec tree_depth = function | Found _ -> 0 | NeedBits _ -> assert false | NeedBit ( a , b ) b -> 1 + min ( tree_depth a ) a ( tree_depth b ) b |
let rec tree_compress t = match tree_depth t with | 0 -> t | 1 -> ( match t with | NeedBit ( a , b ) b -> NeedBit ( tree_compress a , tree_compress b ) b | _ -> assert false ) false | d -> let size = 1 lsl d in let tbl = Array . make size ( Found ( - 1 ) 1 ) 1 in tree_walk tbl 0 0 d t ; NeedBits ( d , tbl ) tbl | NeedB... |
let make_huffman lengths pos nlengths maxbits = let counts = Array . make maxbits 0 in for i = 0 to nlengths - 1 do let p = Array . unsafe_get lengths ( i + pos ) pos in if p >= maxbits then error Invalid_huffman ; Array . unsafe_set counts p ( Array . unsafe_get counts p + 1 ) 1 ; done ; let code = ref 0 in let tmp = ... |
let adler32_create ( adler32_create ) adler32_create = { a1 = 1 ; a2 = 0 ; } |
let adler32_update a s p l = let p = ref p in for i = 0 to l - 1 do let c = int_of_char ( Bytes . unsafe_get s ! p ) p in a . a1 <- ( a . a1 + c ) c mod 65521 ; a . a2 <- ( a . a2 + a . a1 ) a1 mod 65521 ; incr p ; done |
let adler32_read ch = let a2a = IO . read_byte ch in let a2b = IO . read_byte ch in let a1a = IO . read_byte ch in let a1b = IO . read_byte ch in { a1 = ( a1a lsl 8 ) 8 lor a1b ; a2 = ( a2a lsl 8 ) 8 lor a2b ; } |
let window_size = 1 lsl 15 |
let buffer_size = 1 lsl 16 |
let window_create size = { wbuffer = Bytes . create buffer_size ; wpos = 0 ; wcrc = adler32_create ( adler32_create ) adler32_create } |
let window_slide w = adler32_update w . wcrc w . wbuffer 0 window_size ; let b = Bytes . create buffer_size in w . wpos <- w . wpos - window_size ; Bytes . unsafe_blit w . wbuffer window_size b 0 w . wpos ; w . wbuffer <- b |
let window_add_bytes w s p len = if w . wpos + len > buffer_size then window_slide w ; Bytes . unsafe_blit s p w . wbuffer w . wpos len ; w . wpos <- w . wpos + len |
let window_add_char w c = if w . wpos = buffer_size then window_slide w ; Bytes . unsafe_set w . wbuffer w . wpos c ; w . wpos <- w . wpos + 1 |
let window_get_last_char w = Bytes . unsafe_get w . wbuffer ( w . wpos - 1 ) 1 |
let window_available w = w . wpos |
let window_checksum w = adler32_update w . wcrc w . wbuffer 0 w . wpos ; w . wcrc |
let fixed_huffman = make_huffman ( Array . init 288 ( fun n -> if n <= 143 then 8 else if n <= 255 then 9 else if n <= 279 then 7 else 8 ) ) 0 288 10 |
let get_bits z n = while z . znbits < n do z . zbits <- z . zbits lor ( ( IO . read_byte z . zinput ) zinput lsl z . znbits ) znbits ; z . znbits <- z . znbits + 8 ; done ; let b = z . zbits land ( 1 lsl n - 1 ) 1 in z . znbits <- z . znbits - n ; z . zbits <- z . zbits lsr n ; b |
let get_bit z = if z . znbits = 0 then begin z . znbits <- 8 ; z . zbits <- IO . read_byte z . zinput ; end ; let b = z . zbits land 1 = 1 in z . znbits <- z . znbits - 1 ; z . zbits <- z . zbits lsr 1 ; b |
let rec get_rev_bits z n = if n = 0 then 0 else if get_bit z then ( 1 lsl ( n - 1 ) 1 ) 1 lor ( get_rev_bits z ( n - 1 ) 1 ) 1 else get_rev_bits z ( n - 1 ) 1 |
let reset_bits z = z . zbits <- 0 ; z . znbits <- 0 |
let add_bytes z s p l = window_add_bytes z . zwindow s p l ; Bytes . unsafe_blit s p z . zoutput z . zoutpos l ; z . zneeded <- z . zneeded - l ; z . zoutpos <- z . zoutpos + l |
let add_char z c = window_add_char z . zwindow c ; Bytes . unsafe_set z . zoutput z . zoutpos c ; z . zneeded <- z . zneeded - 1 ; z . zoutpos <- z . zoutpos + 1 |
let add_dist_one z n = let c = window_get_last_char z . zwindow in let s = Bytes . make n c in add_bytes z s 0 n |
let add_dist z d l = add_bytes z z . zwindow . wbuffer ( z . zwindow . wpos - d ) d l |
let rec apply_huffman z = function | Found n -> n | NeedBit ( a , b ) b -> apply_huffman z ( if get_bit z then b else a ) a | NeedBits ( n , t ) t -> apply_huffman z ( Array . unsafe_get t ( get_bits z n ) n ) n |
let inflate_lengths z a max = let i = ref 0 in let prev = ref 0 in while ! i < max do match apply_huffman z z . zhuffman with | n when n <= 15 -> prev := n ; Array . unsafe_set a ! i n ; incr i | 16 -> let n = 3 + get_bits z 2 in if ! i + n > max then error Invalid_data ; for k = 0 to n - 1 do Array . unsafe_set a ! i ... |
let rec inflate_loop z = match z . zstate with | Head -> let cmf = IO . read_byte z . zinput in let cm = cmf land 15 in let cinfo = cmf lsr 4 in if cm <> 8 || cinfo <> 7 then error Invalid_data ; let flg = IO . read_byte z . zinput in let fdict = flg land 32 <> 0 in if ( cmf lsl 8 + flg ) flg mod 31 <> 0 then error Inv... |
let inflate_data z s pos len = if pos < 0 || len < 0 || pos + len > Bytes . length s then invalid_arg " inflate_data " ; z . zneeded <- len ; z . zoutpos <- pos ; z . zoutput <- s ; try if len > 0 then inflate_loop z ; len - z . zneeded with IO . No_more_input -> error Truncated_data |
let inflate_init ( ? header = true ) true ch = { zfinal = false ; zhuffman = fixed_huffman ; zhuffdist = None ; zlen = 0 ; zdist = 0 ; zstate = ( if header then Head else Block ) Block ; zinput = ch ; zbits = 0 ; znbits = 0 ; zneeded = 0 ; zoutput = Bytes . empty ; zoutpos = 0 ; zlengths = Array . make 19 ( - 1 ) 1 ; z... |
let inflate ( ? header = true ) true ch = let z = inflate_init ~ header ch in let s = Bytes . create 1 in IO . create_in ~ read ( : fun ( fun ) fun -> let l = inflate_data z s 0 1 in if l = 1 then Bytes . unsafe_get s 0 else raise IO . No_more_input ) ~ input ( : fun s p l -> let n = inflate_data z s p l in if n = 0 th... |
type var_info = { used : V . Set . t ; linear : V . Set . t ; assigned : V . Set . t ; closure_environment : V . Set . t ; let_bound_vars_that_can_be_moved : V . Set . t ; } |
let ignore_uconstant ( _ : Clambda . uconstant ) = ( ) |
let ignore_ulambda ( _ : Clambda . ulambda ) = ( ) |
let ignore_ulambda_list ( _ : Clambda . ulambda list ) = ( ) |
let ignore_uphantom_defining_expr_option ( _ : Clambda . uphantom_defining_expr option ) = ( ) |
let ignore_function_label ( _ : Clambda . function_label ) = ( ) |
let ignore_debuginfo ( _ : Debuginfo . t ) = ( ) |
let ignore_int ( _ : int ) = ( ) |
let ignore_var ( _ : V . t ) = ( ) |
let ignore_var_option ( _ : V . t option ) = ( ) |
let ignore_primitive ( _ : Clambda_primitives . primitive ) = ( ) |
let ignore_string ( _ : string ) = ( ) |
let ignore_int_array ( _ : int array ) = ( ) |
let ignore_var_with_provenance ( _ : VP . t ) = ( ) |
let ignore_params_with_value_kind ( _ : ( VP . t * Lambda . value_kind ) list ) = ( ) |
let ignore_direction_flag ( _ : Asttypes . direction_flag ) = ( ) |
let ignore_meth_kind ( _ : Lambda . meth_kind ) = ( ) |
let ignore_value_kind ( _ : Lambda . value_kind ) = ( ) |
let closure_environment_var ( ufunction : Clambda . ufunction ) = if List . length ufunction . params = ufunction . arity + 1 then let ( env_var , _ ) = List . nth ufunction . params ufunction . arity in assert ( VP . name env_var = " env " ) ; Some env_var else None |
let make_var_info ( clam : Clambda . ulambda ) : var_info = let t : int V . Tbl . t = V . Tbl . create 42 in let assigned_vars = ref V . Set . empty in let environment_vars = ref V . Set . empty in let rec loop : Clambda . ulambda -> unit = function | Uvar var -> begin match V . Tbl . find t var with | n -> V . Tbl . r... |
let let_bound_vars_that_can_be_moved var_info ( clam : Clambda . ulambda ) = let obviously_constant = ref V . Set . empty in let can_move = ref V . Set . empty in let let_stack = ref [ ] in let examine_argument_list args = let rec loop let_bound_vars ( args : Clambda . ulambda list ) = match let_bound_vars , args with ... |
let rec substitute_let_moveable is_let_moveable env ( clam : Clambda . ulambda ) : Clambda . ulambda = match clam with | Uvar var -> if not ( V . Set . mem var is_let_moveable ) then clam else begin match V . Map . find var env with | clam -> clam | exception Not_found -> Misc . fatal_errorf " substitute_let_moveable :... |
type moveable = Fixed | Constant | Moveable |
let both_moveable a b = match a , b with | Constant , Constant -> Constant | Constant , Moveable | Moveable , Constant | Moveable , Moveable -> Moveable | Constant , Fixed | Moveable , Fixed | Fixed , Constant | Fixed , Moveable | Fixed , Fixed -> Fixed |
let primitive_moveable ( prim : Clambda_primitives . primitive ) ( args : Clambda . ulambda list ) ( var_info : var_info ) = match prim , args with | Pfield _ , [ Uconst ( Uconst_ref ( _ , _ ) ) ] -> Moveable | Pfield _ , [ Uvar var ] when V . Set . mem var var_info . closure_environment -> Moveable | _ -> match Semant... |
type moveable_for_env = Constant | Moveable |
let rec un_anf_and_moveable var_info env ( clam : Clambda . ulambda ) : Clambda . ulambda * moveable = match clam with | Uvar var -> begin match V . Map . find var env with | Constant , def -> def , Constant | Moveable , def -> def , Moveable | exception Not_found -> let moveable : moveable = if V . Set . mem var var_i... |
let apply ~ what ~ ppf_dump clam = let var_info = make_var_info clam in let let_bound_vars_that_can_be_moved = let_bound_vars_that_can_be_moved var_info clam in let clam = substitute_let_moveable let_bound_vars_that_can_be_moved V . Map . empty clam in let var_info = make_var_info clam in let clam = un_anf var_info V .... |
type ' a t = ' a |
let none = " Uopt . none " |> ( Obj . magic : string -> _ t ) |
let is_none t = phys_equal t none |
let is_some t = not ( is_none t ) |
let invariant invariant_a t = if is_some t then invariant_a t |
let sexp_of_t sexp_of_a t = if is_none t then [ % sexp None ] else [ % sexp Some ( t : a ) ] |
let some a = a |
let value_exn t = if is_none t then failwith " Uopt . value_exn " else t |
let unsafe_value t = t |
let to_option t = if is_none t then None else Some t |
let of_option = function | None -> none | Some a -> some a ; ; |
module Optional_syntax = struct module Optional_syntax = struct let is_none = is_none let unsafe_value = unsafe_value end end |
let usage ( ) = prerr_endline { | Usage : PIPELINE =< PIPELINE_ID > dune exec tezt / records / update . exe exit 1 |
let pipeline = match Sys . getenv_opt " PIPELINE " with | None -> usage ( ) | Some value -> ( match int_of_string_opt value with | None -> prerr_endline " Invalid pipeline ID ( not an integer ) . \ n " ; usage ( ) | Some value -> value ) |
let project = Sys . getenv_opt " PROJECT " |> Option . value ~ default " : tezos / tezos " |
let rec get_all_pages ( ? from = 1 ) ( ? acc = [ ] ) url = let full_url = url ^ " ? page " = ^ string_of_int from in let * response_body = Process . run_and_read_stdout " curl " [ full_url ] in let list = JSON . parse ~ origin : url response_body |> JSON . as_list in Log . info " Found % d jobs in page % d . " ( List .... |
let fetch_record ( url , index ) = let local = records_directory // ( index ^ " . json " ) in let * ( ) = Process . run " curl " [ url ; " -- location " ; " -- output " ; local ] in Log . info " Downloaded : % s " local ; match JSON . parse_file local with | exception ( JSON . Error _ as exn ) -> Log . error " Failed t... |
let remove_existing_records ( ) = let remove_if_looks_like_a_record filename = if filename =~ rex " ^\\ d . +\\ json " $ then ( let filename = records_directory // filename in Sys . remove filename ; Log . info " Removed outdated record : % s " filename ) in Array . iter remove_if_looks_like_a_record ( Sys . readdir re... |
let fetch_pipeline_records ( ) = let * jobs = get_all_pages ( " https :// gitlab . com / api / v4 / projects " / ^ Uri . pct_encode project ^ " / pipelines " / ^ string_of_int pipeline ^ " / jobs " ) in let get_record job = let job_id = JSON . ( job |-> " id " |> as_int ) in let name = JSON . ( job |-> " name " |> as_s... |
let ( ) = Cli . init ( ) ; ( Test . register ~ __FILE__ ~ title " : update records " ~ tags [ " : update " ] @@ fun ( ) -> remove_existing_records ( ) ; fetch_pipeline_records ( ) ) ; Test . run ( ) |
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2014 - 11 - 06 " ] ) ; ( " Action " , [ " UpdateAssociationStatus " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Query ... |
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Xml . member " UpdateAssociationStatusResponse " ( snd xml ) in try Util . or_error ( Util . option_bind resp UpdateAssociationStatusResult . parse ) ( let open Error in BadResponse { body ; message = " Could not find well formed UpdateAssociation... |
let parse_error code err = let errors = [ Errors_internal . TooManyUpdates ; Errors_internal . StatusUnchanged ; Errors_internal . AssociationDoesNotExist ; Errors_internal . InvalidDocument ; Errors_internal . InvalidInstanceId ; Errors_internal . InternalServerError ] @ Errors_internal . common in match Errors_intern... |
let location_map = ref ( NodeMap . create 103 : location NodeMap . t ) |
let getLoc ( node : Node . t ) = try NodeMap . find ! location_map node with Not_found -> Node . location node |
let store_node_location ( n : Node . t ) ( l : location ) : unit = NodeMap . add ! location_map n l |
let update_ids ( old_file : file ) ( ids : max_ids ) ( new_file : file ) ( changes : change_info ) = let vid_max = ref ids . max_vid in let sid_max = ref ids . max_sid in let update_vid_max vid = update_id_max vid_max vid in let update_sid_max sid = update_id_max sid_max sid in let make_vid ( ) = incr vid_max ; ! vid_m... |
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2013 - 04 - 01 " ] ) ; ( " Action " , [ " UpdateHealthCheck " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Query . rend... |
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Xml . member " UpdateHealthCheckResponse " ( snd xml ) in try Util . or_error ( Util . option_bind resp UpdateHealthCheckResponse . parse ) ( let open Error in BadResponse { body ; message = " Could not find well formed UpdateHealthCheckResponse .... |
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None |
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2013 - 04 - 01 " ] ) ; ( " Action " , [ " UpdateHostedZoneComment " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Query ... |
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Xml . member " UpdateHostedZoneCommentResponse " ( snd xml ) in try Util . or_error ( Util . option_bind resp UpdateHostedZoneCommentResponse . parse ) ( let open Error in BadResponse { body ; message = " Could not find well formed UpdateHostedZon... |
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None |
let datadir = ref None |
let get_datadir ( ) = match ! datadir with | None -> Events . ( emit node_uninitialized ) ( ) >>= fun ( ) -> Lwt_exit . exit_and_raise 1 | Some m -> Lwt . return m |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.