text stringlengths 0 601k |
|---|
let create l key acc r = let hl = height l in let hr = height r in Node ( l , key , r , succ ( min hl hr ) , acc ) |
let bal l x w r = let hl = height l in let hr = height r in if hl > hr + 2 then begin match l with | Empty -> invalid_arg " Val_map . bal " | Node ( ll , lv , lr , _ , acc_l ) -> let acc_r = accval r in if height ll >= height lr then create ll lv ( Int64 . add ( Int64 . add acc_l w ) acc_r ) ( create lr x ( Int64 . add... |
let is_empty = function Empty -> true | Node _ -> false |
let rec add key weight = function | Empty -> Node ( Empty , key , Empty , 1 , Int64 . of_int weight ) | Node ( l , key ' , r , h , acc ) -> if key = key ' then Node ( l , key , r , h , Int64 . add ( Int64 . add ( Int64 . of_int weight ) ( accval l ) ) ( accval r ) ) else let weight ' = Int64 . sub ( Int64 . sub acc ( a... |
let rec find_acc aim_acc = function | Empty -> raise Not_found | Node ( l , key , r , _ , acc ) -> if aim_acc >= acc then raise Not_found else let acc_l = accval l in let acc_r = accval r in if acc_l > aim_acc then find_acc aim_acc l else if Int64 . add acc_r acc_l > aim_acc then find_acc ( Int64 . sub aim_acc acc_l ) ... |
let rec mem key = function | Empty -> false | Node ( l , key ' , r , _ , _ ) -> let c = Mods . int_compare key key ' in c = 0 || ( mem key ( if c < 0 then l else r ) ) |
let rec min_binding = function | Empty -> raise Not_found | Node ( Empty , x , r , _ , acc ) -> ( x , Int64 . sub acc ( accval r ) ) | Node ( l , _ , _ , _ , _ ) -> min_binding l |
let rec remove_min_binding = function | Empty -> invalid_arg " Val_map . remove_min_elt " | Node ( Empty , _ , r , _ , _ ) -> r | Node ( l , x , r , _ , acc ) -> let weight = Int64 . sub ( Int64 . sub acc ( accval l ) ) ( accval r ) in bal ( remove_min_binding l ) x weight r |
let merge t1 t2 = match ( t1 , t2 ) with | ( Empty , t ) -> t | ( t , Empty ) -> t | ( Node _ , Node _ ) -> let ( x , w ) = min_binding t2 in bal t1 x w ( remove_min_binding t2 ) |
let rec remove x = function | Empty -> Empty | Node ( l , v , r , _ , acc ) -> let c = compare x v in if c = 0 then merge l r else let weight = Int64 . sub ( Int64 . sub acc ( accval l ) ) ( accval r ) in if c < 0 then bal ( remove x l ) v weight r else bal l v weight ( remove x r ) |
let random state m = try let r = Random . State . int64 state ( accval m ) in find_acc r m with | Invalid_argument _ -> invalid_arg " Val_map . random_val " |
module type DFA = sig type states val states : states Fin . set type transitions val transitions : transitions Fin . set type label val label : transitions Fin . elt -> label val source : transitions Fin . elt -> states Fin . elt val target : transitions Fin . elt -> states Fin . elt end |
module type INPUT = sig include DFA val initials : ( states Fin . elt -> unit ) -> unit val finals : ( states Fin . elt -> unit ) -> unit val refinements : refine ( : iter ( ( : states Fin . elt -> unit ) -> unit ) -> unit ) -> unit end |
let index_transitions ( type state ) ( type transition ) ( states : state Fin . set ) ( transitions : transition Fin . set ) ( target : transition Fin . elt -> state Fin . elt ) : state Fin . elt -> ( transition Fin . elt -> unit ) -> unit = let f = Array . make ( Fin . Set . cardinal states + 1 ) 0 in Fin . Set . iter... |
let discard_unreachable ( type state ) ( type transition ) ( blocks : state Partition . t ) ( transitions_of : state Fin . elt -> ( transition Fin . elt -> unit ) -> unit ) ( target : transition Fin . elt -> state Fin . elt ) = Partition . iter_marked_elements blocks 0 ( fun state -> transitions_of state ( fun transiti... |
module Minimize ( Label : Map . OrderedType ) ( In : INPUT with type label := Label . t ) : sig include DFA with type label = Label . t val initials : states Fin . elt array val finals : states Fin . elt array val transport_state : In . states Fin . elt -> states Fin . elt option val transport_transition : In . transit... |
type t = | Int of int | Int32 of Int32 . t | Int64 of Int64 . t | Nativeint of Nativeint . t | Float of float | Float_array of float array | String of string | Object of t array | Block of int * t array |
let rec bprint buf value = let open Printf in match value with | Int n -> bprintf buf " % d " n | Int32 n -> bprintf buf " % ldl " n | Int64 n -> bprintf buf " % LdL " n | Nativeint n -> bprintf buf " % ndn " n | Float f -> bprintf buf " % F " f | Float_array t -> bprint_mlarray ( fun buf f -> bprintf buf " % F " f ) b... |
let to_string value = let buf = Buffer . create 16 in bprint buf value ; Buffer . contents buf |
let rec of_obj obj = let tag = Obj . tag obj in if tag = Obj . lazy_tag then fail " unexpected lazy block " ; if tag = Obj . closure_tag then fail " unexpected closure " ; if tag = Obj . infix_tag then fail " unexpected closure " ; if tag = Obj . abstract_tag then fail " unexpected abstract block " ; if tag = Obj . obj... |
let make_to_obj ( ) = let float_htbl = Hashtbl . create 16 in let int32_htbl = Hashtbl . create 16 in let int64_htbl = Hashtbl . create 16 in let nativeint_htbl = Hashtbl . create 16 in let unify htbl v = try Hashtbl . find htbl v with Not_found -> let o = Obj . repr v in Hashtbl . add htbl v o ; o in let rec to_obj va... |
module type Value = sig type t val zero : t val zero_of_type : type_t -> t val compare : t -> t -> int val to_string : t -> string end |
module type Valuation = functor ( V : Value ) -> sig type key = string type value_t = V . t type t val make : string list -> V . t list -> t val vars : t -> string list val bound : string -> t -> bool val value : string -> t -> V . t val consistent : t -> t -> bool val add : t -> string -> V . t -> t val bind : t -> ( ... |
module AbstractValuation : Valuation = functor ( V : Value ) -> struct module StringMap = Map . Make ( String ) type key = StringMap . key type value_t = V . t type t = V . t StringMap . t let make vars values = List . fold_left ( fun acc ( k , v ) -> StringMap . add k v acc ) StringMap . empty ( List . combine vars va... |
module rec K3Value : sig type single_map_t = t K3ValuationMap . t and map_t = single_map_t K3ValuationMap . t and t = | Unit | BaseValue of Constants . const_t | Tuple of t list | Fun of ( t -> t ) | SingleMap of single_map_t | DoubleMap of map_t | FloatList of t list | TupleList of t list | SingleMapList of ( t list *... |
module Make ( D : Debugger . S ) = struct module V = D . Value let rec copy0 ( v : V . t ) : ' a = if debug then begin Format . printf " Value_copier . copy0 % a \ n " %! V . print v end ; if V . is_int v then begin if debug then begin Format . printf " Value is an immediate . \ n " %! end ; match V . int v with | None... |
module type Make_subtype_arg = sig type value val here : Source_code_position . t val name : string val is_in_subtype : value -> bool end |
type ' a funcall = ? should_profile : bool -> ' a |
module type Funcall = sig type t type value val funcall0 : ( t -> value ) funcall val funcall1 : ( t -> value -> value ) funcall val funcall2 : ( t -> value -> value -> value ) funcall val funcall3 : ( t -> value -> value -> value -> value ) funcall val funcall4 : ( t -> value -> value -> value -> value -> value ) func... |
module type Subtype = sig type value type t = private value [ @@ deriving sexp_of ] val eq : t -> t -> bool val is_in_subtype : value -> bool include Valueable0 . S with type t := t end |
module type Type = sig type value type ' a t val create : Sexp . t -> ( ' a -> Sexp . t ) -> ( value -> ' a ) -> ( ' a -> value ) -> ' a t val with_of_value_exn : ' a t -> ( value -> ' a ) -> ' a t val to_sexp : ' a t -> ' a -> Sexp . t val bool : bool t val float : float t val ignored : unit t val int : int t val stri... |
module type Value = sig type t = Value0 . t [ @@ deriving sexp_of ] include Funcall with type t := t with type value := t val intern : string -> t val nil : t val t : t val list : t list -> t val cons : t -> t -> t val car_exn : t -> t val cdr_exn : t -> t val to_list_exn : t -> f ( : t -> ' a ) -> ' a list val vector ... |
module Make ( D : Debugger . S ) ( Cmt_cache : Cmt_cache_intf . S ) ( Type_helper : Type_helper_intf . S with module Cmt_cache := Cmt_cache with module D := D ) ( Type_printer : Type_printer_intf . S with module Cmt_cache := Cmt_cache ) = struct module Our_type_oracle = Type_oracle . Make ( D ) ( Cmt_cache ) module V =... |
type ' a t = { symbol : Symbol . t ; type_ : ' a Value . Type . t } |
let sexp_of_t _ { symbol ; type_ } = [ % message " " ~ _ ( : symbol : Symbol . t ) ~ _ ( : type_ : _ Value . Type . t ) ] ; ; |
type ' a var = ' a t [ @@ deriving sexp_of ] |
let create symbol type_ = { symbol ; type_ = Value . Type . with_of_value_exn type_ ( fun value -> try Value . Type . of_value_exn type_ value with | exn -> raise_s [ % message " " ~ _ ( : concat [ " invalid value for variable : " ; symbol |> Symbol . name ] ) ~ _ ( : exn : exn ) ] ) } ; ; |
module Wrap = struct let ( <: ) name type_ = create ( name |> Symbol . intern ) type_ include ( Value . Type : Value . Type . S ) end |
let symbol_as_value t = t . symbol |> Symbol . to_value |
let default_value = Funcall . Wrap . ( " default - value " <: Symbol . t @-> return value ) |
let default_value_exn t = default_value t . symbol |> Value . Type . of_value_exn t . type_ |
let default_boundp = Funcall . Wrap . ( " default - boundp " <: Symbol . t @-> return bool ) |
let default_value_is_defined t = default_boundp t . symbol |
let set_default = Funcall . Wrap . ( " set - default " <: Symbol . t @-> value @-> return nil ) |
let set_default_value t a = set_default t . symbol ( a |> Value . Type . to_value t . type_ ) |
let make_variable_buffer_local = Funcall . Wrap . ( " make - variable - buffer - local " <: Symbol . t @-> return nil ) ; ; |
let make_buffer_local_always t = add_gc_root ( symbol_as_value t ) ; make_variable_buffer_local t . symbol ; ; |
let local_variable_if_set_p = Funcall . Wrap . ( " local - variable - if - set - p " <: Symbol . t @-> Buffer . t @-> return bool ) ; ; |
let is_buffer_local_if_set t buffer = local_variable_if_set_p t . symbol buffer |
let is_buffer_local_always var = let buffer = Buffer . create ~ name " :* for [ Var . is_buffer_local_always ] " * in let result = is_buffer_local_if_set var buffer in Buffer . Blocking . kill buffer ; result ; ; |
module And_value = struct type t = T : ' a var * ' a -> t [ @@ deriving sexp_of ] end |
module And_value_option = struct type t = T : ' a var * ' a option -> t [ @@ deriving sexp_of ] end |
let hash_variant s = let accu = ref 0 in for i = 0 to String . length s - 1 do accu := 223 * ! accu + Char . code s . [ i ] done ; accu := ! accu land ( 1 lsl 31 - 1 ) ; if ! accu > 0x3FFFFFFF then ! accu - 1 lsl 31 else ! accu |
let lexer = make_lexer [ " " ; -> " " ] $$ |
let main ( ) = let s = lexer ( Stream . of_channel stdin ) in let tags = Hashtbl . create 57 in try while true do let ( strm__ : _ Stream . t ) = s in match Stream . peek strm__ with Some ( Ident tag ) -> Stream . junk strm__ ; print_string " # define MLTAG_ " ; print_string tag ; print_string " \ tVal_int ( " ; let ha... |
let _ = Printexc . print main ( ) |
type t = ( Name . t * Kind . t ) t list |
let to_string ( env : t ) t : string = [ " " ^ List . fold_left ( fun s ( name , k ) k -> s ^ " , " ^ Name . to_string name ^ " : " ^ Kind . to_string k ) k " " env ^ " ] " |
let rec union ( env1 : t ) t ( env2 : t ) t : t = match env1 with | [ ] -> env2 | ( name , kind ) kind :: env -> ( match List . assoc_opt name env2 with | None -> ( name , kind ) kind :: union env env2 | Some kind ' -> let env2 = List . remove_assoc name env2 in let kind = Kind . union kind kind ' in ( name , kind ) ki... |
let unions ( envs : t list ) list : t = List . fold_left union [ ] envs |
let reorg ( names : Name . t list ) list ( env : t ) t : t = names |> List . filter_map ( fun name -> match List . assoc_opt name env with | None -> None | Some kind -> Some ( name , kind ) kind ) kind |
let rec group_by_kind_aux ( env : t ) t ( kind : Kind . t ) t : ( Kind . t * Name . t list ) list list * Name . t list * Kind . t = match env with | [ ] -> ( [ ] , [ ] , kind ) kind | [ ( name , k ) k ] -> ( [ ] , [ name ] , k ) k | ( name , k ) k :: ls -> let ls , names , k ' = group_by_kind_aux ls k in if k = k ' the... |
let group_by_kind ( env : t ) t : ( Kind . t * Name . t list ) list list = match env with | [ ] -> [ ] | [ ( name , k ) k ] -> [ ( k , [ name ] ) ] | ( name , k ) k :: ls -> let ls , names , k ' = group_by_kind_aux ls k in if k = k ' then ( k , names @ [ name ] ) :: ls else if List . length names = 0 then ( k , [ name ... |
let remove ( keys : Name . t list ) list ( env : t ) t : t = env |> List . filter ( fun ( name , _ ) _ -> not ( List . mem name keys ) keys ) keys |
let keep_only ( keys : Name . t list ) list ( env : t ) t : t = env |> List . filter ( fun ( name , _ ) _ -> List . mem name keys ) keys |
module Spec = struct exception Top include Analyses . DefaultSpec module D = struct include PartitionDomain . ExpPartitions let invariant c ss = fold ( fun s a -> if B . mem MyCFG . unknown_exp s then a else let module B_prod = BatSet . Make2 ( Exp ) ( Exp ) in let s_prod = B_prod . cartesian_product s s in let i = B_p... |
let _ = MCP . register_analysis ( module Spec : MCPSpec ) |
type t = { compilation_unit : Compilation_unit . t ; name : string ; name_stamp : int ; } type nonrec t = t let compare t1 t2 = if t1 == t2 then 0 else let c = t1 . name_stamp - t2 . name_stamp in if c <> 0 then c else Compilation_unit . compare t1 . compilation_unit t2 . compilation_unit let equal t1 t2 = if t1 == t2 ... |
let previous_name_stamp = ref ( - 1 ) |
let create_with_name_string ? current_compilation_unit name = let compilation_unit = match current_compilation_unit with | Some compilation_unit -> compilation_unit | None -> Compilation_unit . get_current_exn ( ) in let name_stamp = incr previous_name_stamp ; ! previous_name_stamp in { compilation_unit ; name ; name_s... |
let create ? current_compilation_unit name = let name = ( name : Internal_variable_names . t :> string ) in create_with_name_string ? current_compilation_unit name |
let create_with_same_name_as_ident ident = create_with_name_string ( Ident . name ident ) |
let rename ? current_compilation_unit t = create_with_name_string ? current_compilation_unit t . name |
let in_compilation_unit t cu = Compilation_unit . equal cu t . compilation_unit |
let get_compilation_unit t = t . compilation_unit |
let name t = t . name |
let unique_name t = t . name ^ " _ " ^ ( Int . to_string t . name_stamp ) |
let print_list ppf ts = List . iter ( fun t -> Format . fprintf ppf " @ % a " print t ) ts |
let debug_when_stamp_matches t ~ stamp ~ f = if t . name_stamp = stamp then f ( ) |
let print_opt ppf = function | None -> Format . fprintf ppf " < no var " > | Some t -> print ppf t |
type pair = t * t |
module Pair = Identifiable . Make ( Identifiable . Pair ( T ) ( T ) ) |
let compare_lists l1 l2 = Misc . Stdlib . List . compare compare l1 l2 |
let output_full chan t = Compilation_unit . output chan t . compilation_unit ; output_string chan " . " ; output chan t |
type exporter = value -> string |
type t = { variable_name : string ; variable_description : string ; variable_exporter : exporter } |
let compare v1 v2 = String . compare v1 . variable_name v2 . variable_name |
let default_exporter varname value = Printf . sprintf " % s =% s " varname value |
let make ( name , description ) = if name " " = then raise Empty_variable_name else { variable_name = name ; variable_description = description ; variable_exporter = default_exporter name } |
let make_with_exporter exporter ( name , description ) = if name " " = then raise Empty_variable_name else { variable_name = name ; variable_description = description ; variable_exporter = exporter } |
let name_of_variable v = v . variable_name |
let description_of_variable v = v . variable_description |
let ( variables : ( string , t ) Hashtbl . t ) = Hashtbl . create 10 |
let register_variable variable = if Hashtbl . mem variables variable . variable_name then raise ( Variable_already_registered variable . variable_name ) else Hashtbl . add variables variable . variable_name variable |
let find_variable variable_name = try Some ( Hashtbl . find variables variable_name ) with Not_found -> None |
let string_of_binding variable value = variable . variable_exporter value |
let get_registered_variables ( ) = let f _variable_name variable variable_list = variable :: variable_list in List . sort compare ( Hashtbl . fold f variables [ ] ) |
let suite : ( string * [ ` > Quick ] * ( unit -> unit ) ) list = [ ( " nullable " , ` Quick , fun ( ) -> let _ , mk_variables , _ = [ % graphql { | query Foo ( $ int : Int , $ string : String , $ bool : Boolean , $ float : Float , $ id : ID , $ enum : COLOR ) { non_nullable_int } } ] | in let variables = mk_variables i... |
let test_query variables = Test_common . test_query Echo_schema . schema ( ) ~ variables |
let suite : ( string * [ > ` Quick ] * ( unit -> unit ) ) list = [ ( " string variable " , ` Quick , fun ( ) -> let variables = [ ( " x " , ` String " foo bar baz " ) ] in let query = " { string ( x : $ x ) } " in test_query variables query ( ` Assoc [ ( " data " , ` Assoc [ ( " string " , ` String " foo bar baz " ) ] ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.