text stringlengths 0 601k |
|---|
let state , set_state = React . S . create dummy_model |
let update_simulation_state ( simulation_state : simulation_state ) : unit = let ( ) = set_state { simulation_state } in ( ) |
let model : model React . signal = state |
let with_simulation : ' a . label : string -> ( Api . concrete_manager -> t -> ' a Api . result Lwt . t ) -> ' a Api . result Lwt . t = fun ~ label handler -> let project_handler manager = handler manager ( React . S . value state ) in State_project . with_project ~ label project_handler |
let fail_lwt error_msg = Lwt . return ( Api_common . result_error_msg error_msg ) |
let with_simulation_info ( ~ label : string ) ( ? stopped : Api . concrete_manager -> ' a Api . result Lwt . t = fun _ -> fail_lwt " Simulation stopped " ) ( ? initializing : Api . concrete_manager -> ' a Api . result Lwt . t = fun _ -> fail_lwt " Simulation initalizing " ) ( ? ready : Api . concrete_manager -> Api_typ... |
let when_ready ( ~ label : string ) ( ? handler : unit Api . result -> unit Lwt . t = fun _ -> Lwt . return_unit ) ( operation : Api . concrete_manager -> unit Api . result Lwt . t ) : unit = Common . async __LOC__ ( fun ( ) -> with_simulation_info ~ label ~ stopped ( : fun _ -> Lwt . return ( Result_util . ok ( ) ) ) ... |
let rec sync ( ) = match ( React . S . value state ) . simulation_state with | SIMULATION_STATE_STOPPED | SIMULATION_STATE_INITALIZING -> Lwt . return ( Result_util . ok ( ) ) | SIMULATION_STATE_READY _ -> State_project . with_project ~ label " : sync " ( fun manager -> manager # simulation_info >>= ( Api_common . resu... |
let refresh ( ) = State_project . with_project ~ label " : sync " ( fun manager -> manager # simulation_info >>= ( Result_util . fold ~ ok ( : fun simulation_info -> let ( ) = set_state { simulation_state = SIMULATION_STATE_READY simulation_info } in sync ( ) ) ~ error ( : fun _ -> let ( ) = set_state { simulation_stat... |
let init ( ) : unit Lwt . t = Lwt . return_unit |
let continue_simulation ( pause_condition : string ) : unit Api . result Lwt . t = with_simulation_info ~ label " : continue_simulation " ~ stopped : ( fun _ -> let error_msg : string = " Failed to continue simulation , simulation stopped " in Lwt . return ( Api_common . result_error_msg error_msg ) ) ~ initializing : ... |
let pause_simulation ( ) : unit Api . result Lwt . t = with_simulation_info ~ label " : pause_simulation " ~ stopped : ( fun _ -> let error_msg : string = " Failed to pause simulation , simulation stopped " in Lwt . return ( Api_common . result_error_msg error_msg ) ) ~ initializing : ( fun _ -> let error_msg : string ... |
let stop_simulation ( ) : unit Api . result Lwt . t = with_simulation_info ~ label " : stop_simulation " ~ stopped : ( fun _ -> let error_msg : string = " Failed to pause simulation , simulation stopped " in Lwt . return ( Api_common . result_error_msg error_msg ) ) ~ initializing : ( fun _ -> let error_msg : string = ... |
let start_simulation ( simulation_parameter : Api_types_j . simulation_parameter ) : unit Api . result Lwt . t = with_simulation_info ~ label " : start_simulation " ~ stopped : ( fun manager -> let on_error error_msgs : unit Api . result Lwt . t = let ( ) = update_simulation_state SIMULATION_STATE_STOPPED in manager # ... |
let intervene_simulation ( code : string ) : string Api . result Lwt . t = with_simulation_info ~ label " : perturb_simulation " ~ stopped : ( fun _ -> let error_msg : string = " Failed to start simulation , simulation running " in Lwt . return ( Api_common . result_error_msg error_msg ) ) ~ initializing : ( fun _ -> l... |
type t = { typing : Inference . state lazy_t ; term : Mikhailsky . node } |
let compare ( term1 : t ) ( term2 : t ) = let tag1 = Mikhailsky . tag term1 . term in let tag2 = Mikhailsky . tag term2 . term in if tag1 < tag2 then - 1 else if tag1 > tag2 then 1 else 0 |
let equal ( term1 : t ) ( term2 : t ) = let tag1 = Mikhailsky . tag term1 . term in let tag2 = Mikhailsky . tag term2 . term in tag1 = tag2 |
let hash ( t : t ) = Mikhailsky . hash t . term |
type node_statistics = { mutable size : int ; mutable bytes : int ; mutable holes : int ; mutable depth : int ; } |
let pp_statistics fmtr stats = Format . fprintf fmtr " { size = % d ; bytes = % d ; holes = % d } " stats . size stats . bytes stats . holes |
let rec statistics stats depth ( n : Mikhailsky . node ) = stats . size <- stats . size + 1 ; stats . depth <- max depth stats . depth ; match n with | Micheline . Int ( _ , z ) -> stats . bytes <- stats . bytes + ( Z . numbits z / 8 ) | Micheline . String ( _ , s ) -> stats . bytes <- stats . bytes + String . length s... |
let statistics { term ; _ } = let stats = { size = 0 ; bytes = 0 ; holes = 0 ; depth = 0 } in statistics stats 0 term ; stats |
let pp fmtr ( state : t ) = Format . fprintf fmtr " current term . " :@ ; Format . fprintf fmtr " % a . " @ Mikhailsky . pp state . term ; Format . fprintf fmtr " stats . " :@ ; Format . fprintf fmtr " % a . " :@ pp_statistics ( statistics state ) |
type t = int end ) |
let should_get_value ( ) = let value = 42 in let expected = ( value , value ) and computed = run_identity get value in Alcotest . ( check ( pair int int ) ) " Should retrieve value " expected computed ; ; |
let should_get_and_set_a_new_value ( ) = let value = 42 in let program = let * v = get in set @@ ( 1 + v ) in let expected = ( ( ) , value ) and computed = run_identity program 41 in Alcotest . ( check ( pair unit int ) ) " Should retrieve and set a new value " expected computed ; ; |
let should_modify_a_value ( ) = let value = 42 in let program = modify @@ ( + ) 1 in let expected = ( ( ) , value ) and computed = run_identity program 41 in Alcotest . ( check ( pair unit int ) ) " Should modify the value " expected computed ; ; |
let should_set_and_modify_a_value ( ) = let value = 42 in let program = let * ( ) = set 41 in modify @@ ( + ) 1 in let expected = ( ( ) , value ) and computed = run_identity program 0 in Alcotest . ( check ( pair unit int ) ) " Should set and modify the value " expected computed ; ; |
let should_get_set_and_modify_a_value ( ) = let value = 42 in let program = let * v = get in let * ( ) = set @@ ( v + 1 ) in modify @@ ( + ) 1 in let expected = ( ( ) , value ) and computed = run_identity program 40 in Alcotest . ( check ( pair unit int ) ) " Should get and modify the value " expected computed ; ; |
let should_set_modify_and_get_a_value ( ) = let value = 42 in let program = let * ( ) = set 41 in let * ( ) = modify @@ ( + ) 1 in get in let expected = ( value , value ) and computed = run_identity program 0 in Alcotest . ( check ( pair int int ) ) " Should set modify and get the value " expected computed ; ; |
let should_get_modify_and_get_a_value ( ) = let value = 42 in let program = let * v = get in let * ( ) = modify @@ ( + ) v in get in let expected = ( value , value ) and computed = run_identity program 21 in Alcotest . ( check ( pair int int ) ) " Should get modify and get the value " expected computed ; ; |
let cases = let open Alcotest in [ ( " State " , [ test_case " Should retrieve value " ` Quick should_get_value ; test_case " Should retrieve and set new value " ` Quick should_get_and_set_a_new_value ; test_case " Should modify a value " ` Quick should_modify_a_value ; test_case " Should set and modify a value " ` Qui... |
let do_nothing state = Lwt . return ( state , Do_nothing ) |
type proposal_acceptance = Invalid | Outdated_proposal | Valid_proposal |
let is_acceptable_proposal_for_current_level state ( proposal : Baking_state . proposal ) = let current_round = state . round_state . current_round in if Round . ( current_round < proposal . block . round ) then Events . ( emit unexpected_proposal_round ( current_round , proposal . block . round ) ) >>= fun ( ) -> Lwt ... |
let make_consensus_list state proposal = let level = Raw_level . of_int32 state . level_state . current_level |> function | Ok l -> l | _ -> assert false in let round = proposal . block . round in let block_payload_hash = proposal . block . payload_hash in SlotMap . fold ( fun _slot ( delegate , slots ) acc -> ( delega... |
let make_preendorse_action state proposal = let updated_state = let round_state = { state . round_state with current_phase = Awaiting_preendorsements } in { state with round_state } in let preendorsements : ( delegate * consensus_content ) list = make_consensus_list state proposal in Inject_preendorsements { preendorse... |
let update_proposal state proposal = Events . ( emit updating_latest_proposal proposal . block . hash ) >>= fun ( ) -> let new_level_state = { state . level_state with latest_proposal = proposal } in Lwt . return { state with level_state = new_level_state } |
let may_update_proposal state ( proposal : proposal ) = assert ( Compare . Int32 . ( state . level_state . latest_proposal . block . shell . level = proposal . block . shell . level ) ) ; if Round . ( state . level_state . latest_proposal . block . round < proposal . block . round ) then update_proposal state proposal ... |
let preendorse state proposal = Events . ( emit preendorsing_proposal proposal . block . hash ) >>= fun ( ) -> if Protocol_hash . ( proposal . block . protocol <> proposal . block . next_protocol ) then let new_round_state = { state . round_state with current_phase = Idle } in let new_state = { state with round_state =... |
let extract_pqc state ( new_proposal : proposal ) = match new_proposal . block . prequorum with | None -> None | Some pqc -> let add_voting_power acc ( op : Kind . preendorsement Operation . t ) = let open Protocol . Alpha_context . Operation in let { shell = _ ; protocol_data = { contents = Single ( Preendorsement { s... |
let may_update_endorsable_payload_with_internal_pqc state ( new_proposal : proposal ) = match ( new_proposal . block . prequorum , state . level_state . endorsable_payload ) with | ( None , _ ) -> state | ( Some { round = new_round ; _ } , Some { prequorum = { round = old_round ; _ } ; _ } ) when Round . ( new_round < ... |
let rec handle_new_proposal state ( new_proposal : proposal ) = let current_level = state . level_state . current_level in let new_proposal_level = new_proposal . block . shell . level in if Compare . Int32 . ( current_level > new_proposal_level ) then Events . ( emit baker_is_ahead_of_node ( current_level , new_propos... |
let round_proposer state delegate_slots round = let round_mod = Int32 . to_int ( Round . to_int32 round ) mod state . global_state . constants . parametric . consensus_committee_size in SlotMap . find state . level_state . delegate_slots . all_slots_by_round . ( round_mod ) delegate_slots |
let propose_fresh_block_action ~ endorsements ? last_proposal ( ~ predecessor : block_info ) state delegate round = let operation_pool = let current_mempool = let pool = Operation_worker . get_current_operations state . global_state . operation_worker in match last_proposal with | Some proposal -> let { Operation_pool ... |
let repropose_block_action state delegate round ( proposal : proposal ) = match state . level_state . endorsable_payload with | None -> Events . ( emit no_endorsable_payload_fresh_block ( ) ) >>= fun ( ) -> assert ( state . level_state . locked_round = None ) ; let last_proposal_consensus_ops = proposal . block . quoru... |
let end_of_round state current_round = let new_round = Round . succ current_round in let new_round_state = { state . round_state with current_round = new_round } in let new_state = { state with round_state = new_round_state } in match round_proposer new_state new_state . level_state . delegate_slots . own_delegate_slot... |
let time_to_bake state at_round = let round_proposer_opt = round_proposer state state . level_state . next_level_delegate_slots . own_delegate_slots at_round in match ( state . level_state . elected_block , round_proposer_opt ) with | ( None , _ ) | ( _ , None ) -> assert false | ( Some elected_block , Some ( delegate ... |
let update_locked_round state round payload_hash = let locked_round = Some { payload_hash ; round } in let new_level_state = { state . level_state with locked_round } in { state with level_state = new_level_state } |
let make_endorse_action state proposal = let updated_state = let new_round_state = { state . round_state with current_phase = Awaiting_endorsements } in let new_state = { state with round_state = new_round_state } in update_locked_round new_state proposal . block . round proposal . block . payload_hash in let endorseme... |
let prequorum_reached_when_awaiting_preendorsements state candidate preendorsements = let latest_proposal = state . level_state . latest_proposal in if Block_hash . ( candidate . Operation_worker . hash <> latest_proposal . block . hash ) then Events . ( emit unexpected_prequorum_received ( candidate . hash , latest_pr... |
let quorum_reached_when_waiting_endorsements state candidate endorsement_qc = let latest_proposal = state . level_state . latest_proposal in if Block_hash . ( candidate . Operation_worker . hash <> latest_proposal . block . hash ) then Events . ( emit unexpected_quorum_received ( candidate . hash , latest_proposal . bl... |
let step ( state : Baking_state . t ) ( event : Baking_state . event ) : ( Baking_state . t * Baking_actions . t ) Lwt . t = let phase = state . round_state . current_phase in Events . ( emit step_current_phase ( phase , event ) ) >>= fun ( ) -> match ( phase , event ) with | ( _ , Timeout ( End_of_round { ending_round... |
module Make ( Lexer : Sig . Lexer ) and module Token = Lexer . Token module Structure = Structure . Make Lexer ; module Delete = Delete . Make Structure ; module Insert = Insert . Make Structure ; module Fold = Fold . Make Structure ; include Structure ; value gram = let gkeywords = Hashtbl . create 301 in { gkeywords ... |
module InitialCallablesSharedMemory = Memory . Serializer ( struct type t = FetchCallables . t module Serialized = struct type t = FetchCallables . t let prefix = Prefix . make ( ) let description = " Initial callables to analyze " end let serialize = Fn . id let deserialize = Fn . id end ) |
module OverrideGraphSharedMemory = Memory . Serializer ( struct type t = OverrideGraph . Heap . cap_overrides_result module Serialized = struct type t = { overrides : OverrideGraph . Heap . serializable ; skipped_overrides : Target . t list ; } let prefix = Prefix . make ( ) let description = " Cached override graph " ... |
module ClassHierarchyGraphSharedMemory = Memory . Serializer ( struct type t = ClassHierarchyGraph . t module Serialized = struct type t = ClassHierarchyGraph . t let prefix = Prefix . make ( ) let description = " Class hierarchy graph " end let serialize = Fn . id let deserialize = Fn . id end ) |
module Cache = struct type cached = { module_tracker : Analysis . ModuleTracker . t } type error = | InvalidByCodeChange | LoadError | NotFound | Disabled type t = { cache : ( cached , error ) Result . t ; save_cache : bool ; scheduler : Scheduler . t ; configuration : Configuration . Analysis . t ; } let get_save_dire... |
let type_check ~ scheduler ~ configuration ~ cache = Cache . type_environment cache ( fun ( ) -> let configuration = { configuration with Configuration . Analysis . analyze_external_sources = true } in Check . check ~ scheduler ~ configuration ~ call_graph_builder ( : module Analysis . Callgraph . NullBuilder ) |> fun ... |
let parse_and_save_decorators_to_skip ~ inline_decorators { Configuration . Analysis . taint_model_paths ; _ } = Analysis . InlineDecorator . set_should_inline_decorators inline_decorators ; if inline_decorators then ( let timer = Timer . start ( ) in Log . info " Getting decorators to skip when inlining . . . " ; let ... |
let get_source ~ environment qualifier = let ast_environment = TypeEnvironment . ReadOnly . ast_environment environment in AstEnvironment . ReadOnly . get_processed_source ast_environment qualifier |
let build_class_hierarchy_graph ~ scheduler ~ cache ~ environment ~ qualifiers = Cache . class_hierarchy_graph cache ( fun ( ) -> let timer = Timer . start ( ) in let build_class_hierarchy_graph _ qualifiers = List . fold qualifiers ~ init : ClassHierarchyGraph . empty ~ f ( : fun accumulator qualifier -> match get_sou... |
let build_class_intervals class_hierarchy_graph = let timer = Timer . start ( ) in Interprocedural . IntervalSet . compute_intervals class_hierarchy_graph |> Interprocedural . IntervalSet . SharedMemory . store ; Statistics . performance ~ name " : Computed class intervals " ~ phase_name " : Computing class intervals "... |
let build_call_graph ~ scheduler ~ static_analysis_configuration ~ environment ~ attribute_targets ~ callables = let call_graph = let build_call_graph call_graph callable = Interprocedural . CallGraph . call_graph_of_callable ~ static_analysis_configuration ~ store_shared_memory : true ~ environment ~ attribute_targets... |
let build_dependency_graph ~ initial_callables ~ callgraph ~ override_dependencies = let override_targets = Target . Map . keys override_dependencies in let dependencies , callables_to_analyze = let dependencies = DependencyGraph . from_callgraph callgraph |> DependencyGraph . union override_dependencies in let { Depen... |
let purge_shared_memory ~ environment ~ qualifiers = let ast_environment = TypeEnvironment . ast_environment environment in AstEnvironment . remove_sources ast_environment qualifiers ; Memory . SharedMemory . collect ` aggressive ; ( ) |
let section = Lwt_log . Section . make " ocsigen : ext : staticmod " |
type static_site_kind = | Dir of string | Regexp of regexp_site { source_regexp : Pcre . regexp ; dest : Ocsigen_extensions . ud_string ; http_status_filter : Pcre . regexp option ; root_checks : Ocsigen_extensions . ud_string option } |
let http_status_match status_filter status = match status_filter with | None -> true | Some r -> Ocsigen_lib . Netstring_pcre . string_match r ( string_of_int Cohttp . Code ( . code_of_status ( status :> status_code ) status_code ) status_code ) status_code 0 <> None |
let correct_user_local_file = let regexp = Ocsigen_lib . Netstring_pcre . regexp ( ) ( ) " . . . . " /\\\\/|/\\\\$ in fun path -> try ignore ( Ocsigen_lib . Netstring_pcre . search_forward regexp path 0 ) 0 ; false with Not_found -> true |
let find_static_page ~ request ~ usermode ~ dir ( ~ err : Cohttp . Code . status ) status ~ pathstring = let status_filter , filename , root = match dir with | Dir d -> ( ( false , Filename . concat d pathstring , match usermode with | None -> Some d | Some { Ocsigen_extensions . localfiles_root } localfiles_root -> So... |
let gen ~ usermode ? cache dir = function | Ocsigen_extensions . Req_found _ -> Lwt . return Ocsigen_extensions . Ext_do_nothing | Ocsigen_extensions . Req_not_found ( err , ( { Ocsigen_extensions . request_info ; _ } _ as request ) request ) request -> let try_block ( ) = Lwt_log . ign_info ~ section " Is it a static ... |
let rewrite_local_path userconf path = match userconf with | None -> path | Some { Ocsigen_extensions . localfiles_root } localfiles_root -> localfiles_root ^ " " / ^ path |
type options = { opt_dir : string option ; opt_regexp : Pcre . regexp option ; opt_code : Pcre . regexp option ; opt_dest : Ocsigen_extensions . ud_string option ; opt_root_checks : Ocsigen_extensions . ud_string option ; opt_cache : int option } |
let kind dir regexp code dest root_checks = match dir , regexp , code , dest , root_checks with | None , None , None , _ , _ -> Ocsigen_extensions . badconfig " Missing attribute dir , regexp , or code for < static " > | Some d , None , None , None , None -> Dir ( Ocsigen_lib . Url . remove_end_slash d ) d | None , Som... |
let parse_config userconf _ : Ocsigen_extensions . parse_config_aux = fun _ _ _ element -> let opt = ref { opt_dir = None ; opt_regexp = None ; opt_code = None ; opt_dest = None ; opt_root_checks = None ; opt_cache = None } in Ocsigen_extensions ( . Configuration . process_element ~ in_tag " : host " ~ other_elements (... |
let ( ) = Ocsigen_extensions . register ~ name ~ fun_site ( : fun path _ -> parse_config path ) path ( ) |
let preprocess s = " " ^ ^ s ^ " " $ |
let dir = Ocsigen_server . Site . Config . key ( ) |
let regexp = Ocsigen_server . Site . Config . key ~ preprocess ( ) |
let code = Ocsigen_server . Site . Config . key ~ preprocess ( ) |
let dest = Ocsigen_server . Site . Config . key ( ) |
let root_checks = Ocsigen_server . Site . Config . key ( ) |
let extension = Ocsigen_server . Site . create_extension ( fun { Ocsigen_server . Site . Config . accessor } accessor -> let kind = kind ( accessor dir ) dir ( Ocsigen_lib . Option . map Pcre . regexp ( accessor regexp ) regexp ) regexp ( Ocsigen_lib . Option . map Pcre . regexp ( accessor code ) code ) code ( accessor... |
module Make ( T : Pure . THEORY ) = struct |
let rec check_A s = function | [ ] -> raise ( TypeError ( " The sort ' " ^ s " ' ^ has no type . Check axioms " ) ) ? | ( s1 , s2 ) :: ss -> if s = s1 then SORT s2 else check_A s ss |
let rec check_R ( s1 , s2 ) = function | [ ] -> raise ( TypeError ( " Illegal Pi Type : value of type ' " ^ s2 " ' ^ cannot depend on value of type ' " ^ s1 " ' " ) ) ^ | ( s1 ' , s2 ' , s3 ) :: rs -> if s1 = s1 ' && s2 = s2 ' then SORT s3 else check_R ( s1 , s2 ) rs |
let ( ) ++ ( g , d ) kv = ( g ++ kv , d ) |
let go = Fun . const ( ) |
let rec synth ( ( g , d ) as c ) = function | SORT s -> check_A s T . axioms | F x -> begin match Context . find_opt x g with | Some a -> go @@ synth c a ; a | _ -> raise ( TypeError ( " Unbound var : ' " ^ x " ' " ) ) ^ end | B _ -> raise ( Failure " Should never be type checking a bound var " ) | ANNOT ( e , t ) -> g... |
let synthtype = synth end |
module Domain = struct type static_information = { global_static_information : Analyzer_headers . global_static_information ; } type local_dynamic_information = unit type dynamic_information = { local : local_dynamic_information ; global : Analyzer_headers . global_dynamic_information } let get_global_static_informatio... |
let program = compile_and_parse ~ flags [ : " -- enable " ; " use - js - string " ] { | let lr = ref [ ] let black_box v = lr := ( Obj . repr v ) :: ! lr let constant = " abcdefghijklmnopqrstuvwxyz " let call_with_char c = black_box c let ex = call_with_char constant . [ - 10 ] ; ; black_box ex let ax = call_with_char ... |
module TokenIndices = struct let authority = 0 let _method = 1 let path = 3 let scheme = 5 let status = 7 let accept_charset = 14 let accept_encoding = 15 let accept_language = 16 let accept_ranges = 17 let accept = 18 let access_control_allow_origin = 19 let age = 20 let allow = 21 let authorization = 22 let cache_con... |
let table = [ | " : authority " , " " ; " : method " , " GET " ; " : method " , " POST " ; " : path " , " " / ; " : path " , " / index . html " ; " : scheme " , " http " ; " : scheme " , " https " ; " : status " , " 200 " ; " : status " , " 204 " ; " : status " , " 206 " ; " : status " , " 304 " ; " : status " , " 400 ... |
let lookup_token_index name = match String . length name with | 3 -> ( match name [ . 0 ] 0 with | ' a ' when name = " age " -> 20 | ' v ' when name = " via " -> 59 | _ -> - 1 ) 1 | 4 -> ( match name [ . 0 ] 0 with | ' d ' when name = " date " -> 32 | ' e ' when name = " etag " -> 33 | ' f ' when name = " from " -> 36 ... |
let mean list = let count = ref 0 in let sum = ref 0 . in List . iter ( fun value -> incr count ; sum := ! sum . + value ) list ; ! sum . / float ! count |
let median list = let sorted = List . sort Float . compare list |> Array . of_list in let count = Array . length sorted in if count > 0 then if count mod 2 = 0 then let i = count / 2 in ( sorted . ( i - 1 ) . + sorted . ( i ) ) . / 2 . else sorted . ( count / 2 ) else invalid_arg " Long_test . median : empty list " |
let stddev list = let list_mean = mean list in let squared_diffs = List . map ( fun x -> let d = x . - list_mean in d . * d ) list in sqrt ( mean squared_diffs ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.