text
stringlengths
12
786k
let vlib t = t . vlib
let impl t = t . impl
let impl_cm_kind t = t . impl_cm_kind
let impl_modules t m = match t with | None -> m | Some t -> Modules . impl ~ vlib : t . vlib_modules m
let make ~ vlib ~ impl ~ vlib_modules ~ vlib_foreign_objects = let impl_cm_kind = let vlib_info = Lib . info vlib in let { Mode . Dict . byte ; native = _ } = Lib_info . modes vlib_info in Mode . cm_kind ( if byte then Byte else Native ) in let vlib_obj_map = Modules . obj_map vlib_modu...
let vlib_stubs_o_files = function | None -> [ ] | Some t -> t . vlib_foreign_objects
let vlib_obj_map t = t . vlib_obj_map
module type ViolationArg = sig include MyARG . S with module Edge = MyARG . InlineEdge val prev : Node . t -> ( Edge . t * Node . t ) list val violations : Node . t list end
let find_sinks ( type node ) ( module Arg : ViolationArg with type Node . t = node ) = let module NHT = BatHashtbl . Make ( Arg . Node ) in let non_sinks = NHT . create 100 in let rec iter_node node = if not ( NHT . mem non_sinks node ) then begin NHT . replace non_sinks node ( ) ...
module type Feasibility = sig module Node : MyARG . Node type result = | Feasible | Infeasible of ( Node . t * MyARG . inline_edge * Node . t ) list | Unknown val check_path : ( Node . t * MyARG . inline_edge * Node . t ) list -> result end
module UnknownFeasibility ( Node : MyARG . Node ) : Feasibility with module Node = Node = struct module Node = Node type result = | Feasible | Infeasible of ( Node . t * MyARG . inline_edge * Node . t ) list | Unknown let check_path _ = Unknown end
module type PathArg = MyARG . S with module Edge = MyARG . InlineEdge
type ' node result = | Feasible of ( module PathArg with type Node . t = ' node ) | Infeasible of ( ' node * MyARG . inline_edge * ' node ) list | Unknown
let find_path ( type node ) ( module Arg : ViolationArg with type Node . t = node ) ( module Feasibility : Feasibility with type Node . t = node ) : node result = let module NHT = BatHashtbl . Make ( Arg . Node ) in let rec trace_path next_nodes node2 = if NHT . mem next_nodes node2 th...
module WP ( Node : MyARG . Node ) : Feasibility with module Node = Node = struct module Node = Node open Z3 open Cil let cfg = [ ( " model " , " true " ) ; ( " unsat_core " , " true " ) ; ] let ctx = mk_context cfg type var = varinfo module Var = CilType . Varinfo mo...
module Configuration = struct type t = { name : string ; parameters : ( string * string ) list } let to_json { name ; parameters } : Yojson . Basic . json = ` Assoc [ " name " , ` String name ; " parameters " , ` Assoc ( List . map parameters ~ f ( : fun ( a , ...
let run ~ run_with ~ normal ~ tumor ~ result_prefix ( ? more_edges = [ ] ) ~ configuration ( ) = let open KEDSL in let open Configuration in let name = Filename . basename result_prefix in let result_file suffix = result_prefix ^ suffix in let output_file = result_file " - somatic . vcf "...
module Pp_spec : sig type t val make : Preprocess . Without_instrumentation . t Preprocess . t Module_name . Per_item . t -> Ocaml_version . t -> t val pped_module : t -> Module . t -> Module . t type t = ( Module . t -> Module . t ) Module_name . Per_item . t let make preprocess v ...
let setup_copy_rules_for_impl ~ sctx ~ dir vimpl = let ctx = Super_context . context sctx in let vlib = Vimpl . vlib vimpl in let impl = Vimpl . impl vimpl in let impl_obj_dir = Dune_file . Library . obj_dir ~ dir impl in let vlib_obj_dir = Lib . obj_dir vlib in let add_rule = Super_context . ad...
let impl sctx ( ~ lib : Dune_file . Library . t ) ~ scope = let open Memo . O in match lib . implements with | None -> Memo . return None | Some ( loc , implements ) -> ( Lib . DB . find ( Scope . libs scope ) implements >>= function | None -> User_error . raise ~ loc [ P...
type t = | Public | Private
let to_string = function | Public -> " public " | Private -> " private "
let to_dyn t = Dyn . string ( to_string t )
let encode = let open Dune_lang . Encoder in function | Public -> string " public " | Private -> string " private "
let decode = let open Dune_lang . Decoder in plain_string ( fun ~ loc -> function | " public " -> Public | " private " -> Private | _ -> User_error . raise ~ loc [ Pp . text " Not a valid visibility . Valid visibility is public or private " ] )
let is_public = function | Public -> true | Private -> false
let is_private t = not ( is_public t )
module Map = struct type ' a t = { public : ' a ; private_ : ' a } let make_both a = { public = a ; private_ = a } let find { private_ ; public } = function | Private -> private_ | Public -> public end
module Bounds = struct type t = { min_x : int ; min_y : int ; max_x : int ; max_y : int } [ @@ deriving sexp , equal ] end
let get_conservative_vis_bounds ( element : Dom_html . element Js . t ) : Bounds . t option = let client_bounds = element ## getBoundingClientRect in let client_x = client_bounds . ## left and client_y = client_bounds . ## top and client_bottom = client_bounds . ## bottom and client_right = ...
module T = struct module Input = struct type t = Bounds . t -> unit Vdom . Effect . t [ @@ deriving sexp_of ] let combine left right bounds = Vdom . Effect . sequence_as_sibling ( left bounds ) ~ unless_stopped ( : fun ( ) -> right bounds ) ; ; end module State = struct type t =...
module Hook = Vdom . Attr . Hooks . Make ( T )
let on_change f = Vdom . Attr . create_hook " bounds - change " ( Hook . create f )
type node = | Expression of Expression . t | Statement of Statement . t | Argument of Identifier . t Node . t | Parameter of Parameter . t | Reference of Reference . t Node . t | Substring of Substring . t | Generator of Comprehension . Generator . t
module type NodeVisitor = sig type t val node : t -> node -> t val visit_statement_children : t -> Statement . t -> bool val visit_format_string_children : t -> Expression . t -> bool end
module MakeNodeVisitor ( Visitor : NodeVisitor ) = struct let visit_node ~ state ~ visitor node = state := visitor ! state node let visit_argument { Call . Argument . value ; _ } ~ visit_expression = visit_expression value let visit_parameter ( { Node . value = { Parameter . value ; ...
module type Visitor = sig type t val expression : t -> Expression . t -> t val statement : t -> Statement . t -> t end
module Make ( Visitor : Visitor ) = struct let visit = let module NodeVisitor = MakeNodeVisitor ( struct type t = Visitor . t let node state = function | Expression expression -> Visitor . expression state expression | Statement statement -> Visitor . statement state statement | _ -> state let ...
module type StatementVisitor = sig type t val visit_children : Statement . t -> bool val statement : Source . t -> t -> Statement . t -> t end
module MakeStatementVisitor ( Visitor : StatementVisitor ) = struct let visit state ( { Source . statements ; _ } as source ) = let state = ref state in let open Statement in let rec visit_statement { Node . location ; value } = if Visitor . visit_children { Node . location ; value...
module type ExpressionPredicate = sig type t val predicate : Expression . t -> t option end
module type StatementPredicate = sig type t val visit_children : Statement . t -> bool val predicate : Statement . t -> t option end
module type NodePredicate = sig type t val predicate : node -> t option end
module Collector ( ExpressionPredicate : ExpressionPredicate ) ( StatementPredicate : StatementPredicate ) ( NodePredicate : NodePredicate ) = struct type collection = { expressions : ExpressionPredicate . t list ; statements : StatementPredicate . t list ; nodes : NodePredicate . t list...
module UnitPredicate = struct type t = unit let visit_children _ = true let predicate _ = None end
module ExpressionCollector ( Predicate : ExpressionPredicate ) = struct let collect source = let module Collector = Collector ( Predicate ) ( UnitPredicate ) ( UnitPredicate ) in let { Collector . expressions ; _ } = Collector . collect source in expressions end
module StatementCollector ( Predicate : StatementPredicate ) = struct module CollectingVisit = MakeStatementVisitor ( struct type t = Predicate . t list let visit_children = Predicate . visit_children let statement _ statements statement = match Predicate . predicate statement with | Some result ->...
module NodeCollector ( Predicate : NodePredicate ) = struct let collect source = let module Collector = Collector ( UnitPredicate ) ( UnitPredicate ) ( Predicate ) in let { Collector . nodes ; _ } = Collector . collect source in nodes end
let collect_locations source = let module Collector = Collector ( UnitPredicate ) ( UnitPredicate ) ( struct type t = Location . t let predicate = function | Expression node -> Some ( Node . location node ) | Statement node -> Some ( Node . location node ) | Argument node -> Some ( N...
let collect_calls statement = let open Expression in let module Collector = ExpressionCollector ( struct type t = Call . t Node . t let predicate expression = match expression with | { Node . location ; value = Call call } -> Some { Node . location ; value = call } | _ -> None end ) i...
let collect_names ( ? only_simple = false ) statement = let open Expression in let module Collector = ExpressionCollector ( struct type t = Name . t Node . t let predicate expression = match expression with | { Node . location ; value = Name name } -> if only_simple && not ( is_simple_name...
let collect_calls_and_names statement = let open Expression in let module Collector = ExpressionCollector ( struct type t = Expression . t let predicate expression = match expression with | { Node . value = Call _ ; _ } -> Some expression | { Node . value = Name _ ; _ } -> Some express...
let collect_base_identifiers statement = let open Expression in let module Collector = ExpressionCollector ( struct type t = Identifier . t Node . t let predicate expression = match expression with | { Node . location ; value = Name ( Name . Identifier identifier ) } -> Some { Node . loca...
let rec collect_non_generic_type_names { Node . value ; _ } = match value with | Expression . Call { Call . arguments ; _ } -> List . concat_map ~ f ( : fun { Call . Argument . value ; _ } -> collect_non_generic_type_names value ) arguments | Tuple elements | List elements ...
let collect_format_strings_with_ignores ~ ignore_line_map source = let module CollectIgnoredFormatStrings = ExpressionCollector ( struct type t = Expression . t * Ignore . t list let predicate = function | { Node . value = Expression . FormatString _ ; location } as expression -> Map . find ...
let test_collect _ = let assert_collect statements expected = let collect = let module ExpressionPredicate = struct type t = Expression . t let predicate expression = Some expression end in let module StatementPredicate = struct type t = Statement . t let visit_children _ = true let predicate statement ...
let test_collect_location _ = let assert_collect_location source expected_locations = let source = parse ~ handle " : test . py " source in let actual_locations = Visit . collect_locations source in let expected_locations = let create_location ( start_line , start_column , end_line , end_column ...
let test_collect_non_generic_type_names _ = let assert_non_generic_type_names expression expected = assert_equal ~ cmp [ :% equal : string list ] ~ printer [ :% show : string list ] expected ( Visit . collect_non_generic_type_names ( parse_single_expression ~ preprocess : true expression ) ) ...
let test_collect_format_strings_with_ignores _ = let assert_format_strings_with_ignores source expected = let ( { Source . typecheck_flags = { ignore_lines ; _ } ; _ } as source ) = parse source in let ignore_line_map = List . map ignore_lines ~ f ( : fun ( { Ignore . ignored_line ...
let test_node_visitor _ = let module Visitor = struct type t = int String . Table . t let node state node = let increment hash_table key = match Hashtbl . find hash_table key with | None -> Hashtbl . set hash_table ~ key ~ data : 1 | Some value -> Hashtbl . set hash_table ~ key ~ data ( : v...
let test_statement_visitor _ = let module StatementVisitor = struct type t = int String . Table . t let visit_children _ = true let statement _ visited statement = let increment hash_table key = match Hashtbl . find hash_table key with | None -> Hashtbl . set hash_table ~ key ~ data : 1 | Some v...
let test_statement_visitor_source _ = let module StatementVisitor = struct type t = string let visit_children _ = true let statement { Source . source_path = { ModulePath . relative ; _ } ; _ } _ _ = relative end in let module Visit = Visit . MakeStatementVisitor ( StatementVisitor ) ...
let ( ) = " visit " >::: [ " collect " >:: test_collect ; " collect_location " >:: test_collect_location ; " collect_non_generic_type_names " >:: test_collect_non_generic_type_names ; " collect_format_strings_with_ignores " >:: test_collect_format_strings_with_ignores ; " node_...
let gauss a b x = let xb = Vec . sub x b in . ~- ( exp ( dot xb ( symv a xb ) . / 2 . 0 ) )
let dgauss a b x = symv ~ alpha ( : gauss a b x ) a ( Vec . sub x b )
let gnuplot f = let oc = Unix . open_process_out " gnuplot " in let ppf = formatter_of_out_channel oc in f ppf ; pp_print_flush ppf ( ) ; print_endline " Press Enter to exit gnuplot " ; ignore ( read_line ( ) ) ; ignore ( Unix . close_process_out oc )
let splot_fun ( ? option = " " ) ( ? n = 10 ) ( ? x1 = - 10 . 0 ) ( ? x2 = 10 . 0 ) ( ? y1 = - 10 . 0 ) ( ? y2 = 10 . 0 ) ppf f = let cx = ( x2 . - x1 ) . / float n in let cy = ( y2 . - y1 ) . / float n in fprintf ppf " splot ' ' -...
let steepest_descent ppf ~ loops ~ eta df f x = fprintf ppf " splot ' ' - with linespoints linetype 2 title ' ' @\ n \ % a 0 @\ n " pp_rfvec x ; for i = 1 to loops do axpy ~ alpha ( . :~- eta ) ( df x ) x ; fprintf ppf " % a 0 @\ n " pp_rfvec x done ; fprintf ppf " end...
let ( ) = let a = [ % mat [ - 0 . 1 , 0 . 1 ; 0 . 1 , - 0 . 2 ] ] in let b = [ % vec [ 1 . 0 ; 3 . 0 ] ] in let ( x1 , x2 , y1 , y2 ) = ( - 2 . 0 , 3 . 0 , 0 . 0 , 5 . 0 ) in gnuplot ( fun ppf -> fprintf ppf " set mult...
module type core = sig type t val t : t Ctypes . typ val ctype : t Ctypes . typ val null : t val ctype_opt : t option Ctypes . typ val pp : Format . formatter -> t -> unit val array : t list -> t Ctypes . CArray . t val array_opt : t list -> t option Ctypes . CArray . t end
module type S = sig include core val to_ptr : t -> nativeint val unsafe_from_ptr : nativeint -> t end
module type S_non_dispatchable = sig include core val to_int64 : t -> int64 val unsafe_from_int64 : int64 -> t end
module Make ( ) : S = struct type self type t = self Ctypes . structure Ctypes . ptr let t : t Ctypes . typ = Ctypes . ptr ( Ctypes . structure " " ) let ctype = t let null = Ctypes . ( coerce @@ ptr void ) t Ctypes . null let ctype_opt = let read v = if v = null then None else ...
module Make_non_dispatchable ( ) : S_non_dispatchable = struct type self type t = int64 let t : t Ctypes . typ = Ctypes . int64_t let ctype = t let null = 0L let ctype_opt = let read v = if v = null then None else Some v in let write = function | None -> null | Some x -> x in Ctypes . view ~ ...
module type intlike = sig type t val zero : t val ctype : t Ctypes . typ end
let integer_opt ( type a ) ( module I : intlike with type t = a ) = let read x = if x = I . zero then None else Some x in let write = function None -> I . zero | Some x -> x in Ctypes . view ~ read ~ write I . ctype
let integer_opt ' zero ctype = let read x = if x = zero then None else Some x in let write = function None -> zero | Some x -> x in Ctypes . view ~ read ~ write ctype
let uint_32_t = Ctypes . view ~ read ( : U32 . to_int ) ~ write ( : U32 . of_int ) Ctypes . uint32_t
let uint_16_t = Ctypes . view ~ read ( : U16 . to_int ) ~ write ( : U16 . of_int ) Ctypes . uint16_t
module Int = struct type t = int let zero = 0 let pp = Format . pp_print_int let ctype = Ctypes . int end
module Uint_8_t = struct open U8 type t = U8 . t let ctype = Ctypes . uint8_t let zero = of_int 0 let of_int = of_int let to_int = to_int let to_string = to_string let pp ppf x = Format . pp_print_string ppf ( to_string x ) end
let bool_32 = let true ' = U32 . of_int Vk__Const . true ' and false ' = U32 . of_int Vk__Const . false ' in Ctypes . view ~ read ( : ( ) = true ' ) ~ write ( : fun x -> if x then true ' else false ' ) Ctypes . uint32_t
let bool_32_opt = let true ' = U32 . of_int Vk__Const . true ' and false ' = U32 . of_int Vk__Const . false ' in Ctypes . view ~ read ( : fun x -> if U32 . zero = x then None else if x = true ' then Some true else Some false ) ~ write ( : function None -> U32 . zero | Some x -...
module Size_t_0 = struct let of_int = S . of_int let to_int = S . to_int let zero = of_int 0 let to_string = S . to_string let pp ppf x = Format . fprintf ppf " % s " ( S . to_string x ) type t = S . t let ctype = Ctypes . size_t end
module Size_t = struct include Size_t_0 let ctype_opt = integer_opt ( module Size_t_0 ) end
let size_t_opt = integer_opt ( module Size_t )
module Uint_32_t_0 = struct let zero = 0 let of_int x = x let to_int x = x let to_string = string_of_int let pp ppf x = Format . fprintf ppf " % d " x type t = int let ctype = uint_32_t end
module Uint_32_t = struct include Uint_32_t_0 let ctype_opt = integer_opt ( module Uint_32_t_0 ) end
module Uint_16_t_0 = struct let zero = 0 let of_int x = x let to_int x = x let to_string = string_of_int let pp ppf x = Format . fprintf ppf " % d " x type t = int let ctype = uint_16_t end
module Uint_16_t = struct include Uint_16_t_0 let ctype_opt = integer_opt ( module Uint_16_t_0 ) end
module Bool_32 = struct type t = bool let t = bool let ctype = bool_32 let ctype_opt = bool_32_opt let zero = true let pp = Format . pp_print_bool end
module Int_32_t = struct let zero = 0 let of_int x = x let to_int x = x let to_string = string_of_int let pp ppf x = Format . fprintf ppf " % d " x type t = int let read = Int32 . to_int let write = Int32 . of_int let ctype = Ctypes . view ~ read ~ write Ctypes . int32_t let ctype_opt = int...
module Int_64_t = struct let zero = 0 let of_int x = x let to_int x = x let to_string = string_of_int let pp ppf x = Format . fprintf ppf " % d " x type t = int let read = Int64 . to_int let write = Int64 . of_int let ctype = Ctypes . view ~ read ~ write Ctypes . int64_t let ctype_opt = int...
module Uint_64_t = struct let of_int = U64 . of_int let to_int = U64 . to_int let zero = of_int 0 let to_string = U64 . to_string let pp ppf x = Format . fprintf ppf " % s " ( U64 . to_string x ) type t = U64 . t let ctype = Ctypes . uint64_t let ctype_opt = integer_opt ' zero ctype e...
module type aliased = sig type t val zero : t val ctype : t Ctypes . typ val ctype_opt : t option Ctypes . typ val of_int : int -> t val to_int : t -> int val to_string : t -> string end
module type alias = sig type x type t = private x val make : x -> t val ctype : t Ctypes . typ val ctype_opt : t option Ctypes . typ val of_int : int -> t val zero : t val to_int : t -> int val pp : Format . formatter -> t -> unit end
module Alias ( X : aliased ) : alias with type x := X . t = struct type t = X . t let make x = x let zero = X . zero let ctype = X . ctype let ctype_opt = X . ctype_opt let of_int = X . of_int let to_int = X . to_int let pp ppf x = Format . fprintf ppf " % s " ( X . to_string x ...
module Float = struct type t = float let pp = Format . pp_print_float let ctype = Ctypes . float end
module Double = struct type t = float let pp = Format . pp_print_float let ctype = Ctypes . double end
module Void = struct type t = void let ctype = Ctypes . void let pp = Vk__helpers . Pp . abstract end