text
stringlengths
0
601k
let bin_reader_int_64bit = { read = Read . bin_read_int_64bit ; vtag_read = variant_wrong_type " int_64bit " } ; ;
let bin_int_64bit = { shape = bin_shape_int_64bit ; writer = bin_writer_int_64bit ; reader = bin_reader_int_64bit } ; ;
let bin_writer_int64_bits = { size = Size . bin_size_int64_bits ; write = Write . bin_write_int64_bits } ; ;
let bin_reader_int64_bits = { read = Read . bin_read_int64_bits ; vtag_read = variant_wrong_type " int64_bits " } ; ;
let bin_int64_bits = { shape = bin_shape_int64_bits ; writer = bin_writer_int64_bits ; reader = bin_reader_int64_bits } ; ;
let bin_writer_network16_int = { size = Size . bin_size_network16_int ; write = Write . bin_write_network16_int } ; ;
let bin_reader_network16_int = { read = Read . bin_read_network16_int ; vtag_read = variant_wrong_type " network16_int " } ; ;
let bin_network16_int = { shape = bin_shape_network16_int ; writer = bin_writer_network16_int ; reader = bin_reader_network16_int } ; ;
let bin_writer_network32_int = { size = Size . bin_size_network32_int ; write = Write . bin_write_network32_int } ; ;
let bin_reader_network32_int = { read = Read . bin_read_network32_int ; vtag_read = variant_wrong_type " network32_int " } ; ;
let bin_network32_int = { shape = bin_shape_network32_int ; writer = bin_writer_network32_int ; reader = bin_reader_network32_int } ; ;
let bin_writer_network32_int32 = { size = Size . bin_size_network32_int32 ; write = Write . bin_write_network32_int32 } ; ;
let bin_reader_network32_int32 = { read = Read . bin_read_network32_int32 ; vtag_read = variant_wrong_type " network32_int32 " } ; ;
let bin_network32_int32 = { shape = bin_shape_network32_int32 ; writer = bin_writer_network32_int32 ; reader = bin_reader_network32_int32 } ; ;
let bin_writer_network64_int = { size = Size . bin_size_network64_int ; write = Write . bin_write_network64_int } ; ;
let bin_reader_network64_int = { read = Read . bin_read_network64_int ; vtag_read = variant_wrong_type " network64_int " } ; ;
let bin_network64_int = { shape = bin_shape_network64_int ; writer = bin_writer_network64_int ; reader = bin_reader_network64_int } ; ;
let bin_writer_network64_int64 = { size = Size . bin_size_network64_int64 ; write = Write . bin_write_network64_int64 } ; ;
let bin_reader_network64_int64 = { read = Read . bin_read_network64_int64 ; vtag_read = variant_wrong_type " network64_int64 " } ; ;
let bin_network64_int64 = { shape = bin_shape_network64_int64 ; writer = bin_writer_network64_int64 ; reader = bin_reader_network64_int64 } ; ;
let bin_writer_array_no_length bin_writer_el = { size = ( fun v -> ( Size . bin_size_array_no_length [ @ warning " - 3 " ] ) bin_writer_el . size v ) ; write = ( fun buf ~ pos v -> ( Write . bin_write_array_no_length [ @ warning " - 3 " ] ) bin_writer_el . write buf ~ pos v ) } ; ;
let cnv_writer cnv tp_class = { size = ( fun v -> tp_class . size ( cnv v ) ) ; write = ( fun buf ~ pos v -> tp_class . write buf ~ pos ( cnv v ) ) } ; ;
let cnv_reader cnv tp_class = { read = ( fun buf ~ pos_ref -> cnv ( tp_class . read buf ~ pos_ref ) ) ; vtag_read = ( fun buf ~ pos_ref vtag -> cnv ( tp_class . vtag_read buf ~ pos_ref vtag ) ) } ; ;
let cnv for_shape for_writer for_reader tp_class = { shape = for_shape tp_class . shape ; writer = cnv_writer for_writer tp_class . writer ; reader = cnv_reader for_reader tp_class . reader } ; ;
let { Logger . log } = Logger . for_section log_section
type type_info = | Modtype of Env . t * Types . module_type | Type of Env . t * Types . type_expr | Type_decl of Env . t * Ident . t * Types . type_declaration | String of string
type typed_enclosings = ( Location . t * type_info * Query_protocol . is_tail_position ) list
let from_nodes ~ path = let aux ( env , node , tail ) = let open Browse_raw in let ret x = Some ( Mbrowse . node_loc node , x , tail ) in match [ @ ocaml . warning " - 9 " ] node with | Expression { exp_type = t } | Pattern { pat_type = t } | Core_type { ctyp_type = t } | Value_description { val_desc = { ctyp_type = t ...
let from_reconstructed ~ nodes ~ cursor ~ verbosity exprs = let open Browse_raw in let env , node = Mbrowse . leaf_node nodes in log ~ title " : from_reconstructed " " node = % s \ nexprs = [ % s ] " ( Browse_raw . string_of_node node ) ( String . concat ~ sep " ; " : ( List . map exprs ~ f ( : fun l -> l . Location . ...
type ( ' a , ' b ) t = T : ( ' a , ' a ) t [ @@ deriving_inline sexp_of ]
let sexp_of_t : ' a ' b . ( ' a -> Sexplib0 . Sexp . t ) -> ( ' b -> Sexplib0 . Sexp . t ) -> ( ' a , ' b ) t -> Sexplib0 . Sexp . t = fun ( type a__003_ b__004_ ) : ( ( a__003_ -> Sexplib0 . Sexp . t ) -> ( b__004_ -> Sexplib0 . Sexp . t ) -> ( a__003_ , b__004_ ) t -> Sexplib0 . Sexp . t ) -> fun _of_a__001_ _of_b__0...
type ( ' a , ' b ) equal = ( ' a , ' b ) t
let sym ( type a b ) ( T : ( a , b ) t ) : ( b , a ) t = T
let trans ( type a b c ) ( T : ( a , b ) t ) ( T : ( b , c ) t ) : ( a , c ) t = T
let conv ( type a b ) ( T : ( a , b ) t ) ( a : a ) : b = a
module Lift ( X : sig type ' a t end ) = struct let lift ( type a b ) ( T : ( a , b ) t ) : ( a X . t , b X . t ) t = T end
module Lift2 ( X : sig type ( ' a1 , ' a2 ) t end ) = struct let lift ( type a1 b1 a2 b2 ) ( T : ( a1 , b1 ) t ) ( T : ( a2 , b2 ) t ) : ( ( a1 , a2 ) X . t , ( b1 , b2 ) X . t ) t = T ; ; end
module Lift3 ( X : sig type ( ' a1 , ' a2 , ' a3 ) t end ) = struct let lift ( type a1 b1 a2 b2 a3 b3 ) ( T : ( a1 , b1 ) t ) ( T : ( a2 , b2 ) t ) ( T : ( a3 , b3 ) t ) : ( ( a1 , a2 , a3 ) X . t , ( b1 , b2 , b3 ) X . t ) t = T ; ; end
let detuple2 ( type a1 a2 b1 b2 ) ( T : ( a1 * a2 , b1 * b2 ) t ) : ( a1 , b1 ) t * ( a2 , b2 ) t = T , T ; ;
let tuple2 ( type a1 a2 b1 b2 ) ( T : ( a1 , b1 ) t ) ( T : ( a2 , b2 ) t ) : ( a1 * a2 , b1 * b2 ) t = T
module type Injective = sig type ' a t val strip : ( ' a t , ' b t ) equal -> ( ' a , ' b ) equal end
module type Injective2 = sig type ( ' a1 , ' a2 ) t val strip : ( ( ' a1 , ' a2 ) t , ( ' b1 , ' b2 ) t ) equal -> ( ' a1 , ' b1 ) equal * ( ' a2 , ' b2 ) equal end
module Composition_preserves_injectivity ( M1 : Injective ) ( M2 : Injective ) = struct type ' a t = ' a M1 . t M2 . t let strip e = M1 . strip ( M2 . strip e ) end
module Obj = struct module Extension_constructor = struct [ @@@ ocaml . warning " - 3 " ] let id = Caml . Obj . extension_id let of_val = Caml . Obj . extension_constructor end end
module Id = struct module Uid = Int module Witness = struct module Key = struct type _ t = . . type type_witness_int = [ ` type_witness of int ] [ @@ deriving_inline sexp_of ] let sexp_of_type_witness_int = ( fun ( ` type_witness v__005_ ) -> Sexplib0 . Sexp . List [ Sexplib0 . Sexp . Atom " type_witness " ; sexp_of_in...
[ %% expect { | ^ bool because it is in the condition of an if - statement } ] ; ; | [ %% expect { | ^ bool because it is in the condition of an if - statement } ] ; ; | [ %% expect { | ^ int } ] ; ; | [ %% expect { | ^ bool because it is in the condition of an if - statement } ] ; ; | [ %% expect { | ^ bool because it...
let ordered_list_with x y = if x <= y then [ x ; y ] else if x > y then [ y ; x ] [ %% expect { | ^^^^ because it is in the result of a conditional with no else branch The constructor :: does not belong to type unit } ] ; ; | ( function | y when y + 1 -> ( ) | _ -> ( ) ) ; ; [ %% expect { | ^^^^^ bool because it is in ...
module Helper ( A : Variant_and_record_intf . S ) ( B : Variant_and_record_intf . S ) = struct type map = { map : ' a . ' a A . t -> ' a B . t } let map_variant ( type variant ) { map } ( variant : variant A . Variant . t ) = let map_create = function | A . Tag . Args fct -> B . Tag_internal . Args fct | A . Tag . Cons...
module type Named = sig type ' a computation module Context : sig type t val create : unit -> t end type ' a t val init : Context . t -> ' a Typename . t -> ' a t val get_wip_computation : ' a t -> ' a computation val set_final_computation : ' a t -> ' a computation -> ' a computation val share : _ Typerep . t -> bool ...
module type Computation = sig type ' a t include Variant_and_record_intf . S with type ' a t := ' a t val int : int t val int32 : int32 t val int64 : int64 t val nativeint : nativeint t val char : char t val float : float t val string : string t val bytes : bytes t val bool : bool t val unit : unit t val option : ' a t...
module Make_named_for_closure ( X : sig type ' a input type ' a output type ' a t = ' a input -> ' a output end ) = struct module Context = struct type t = unit let create = ignore end type ' a t = { runtime_dereference : ' a X . t ; runtime_reference : ' a X . t ref ; compiletime_dereference : ' a X . t option ref } e...
module Ident = struct type t = { name : string ; implements : Typename . Uid . t -> bool } exception Broken_dependency of string let check_dependencies name required = match required with | [ ] -> fun _ -> ( ) | _ -> fun uid -> List . iter ( fun { name = name ' ; implements } -> if not ( implements uid ) then ( let mes...
module type Extending = sig type ' a t type ' a computation = ' a t val ident : Ident . t exception Not_implemented of string * string module type S = sig type t include Typerepable . S with type t := t val compute : t computation end module type S1 = sig type ' a t include Typerepable . S1 with type ' a t := ' a t val...
module type S_implementation = sig include Extending val raise_not_implemented : string -> ' a type implementation = { generic : ' a . ' a Typerep . t -> ' a computation } val _using_extended_implementation : implementation -> ' a Typerep . Named . t -> ' a Typerep . t lazy_t option -> ' a computation val find_extended...
module type S = sig include Extending val of_typerep : ' a Typerep . t -> [ ` generic of ' a computation ] module Computation : Computation with type ' a t = ' a t end
module Make_S_implementation ( X : sig type ' a t val name : string val required : Ident . t list end ) : S_implementation with type ' a t = ' a X . t = struct type ' a t = ' a X . t type ' a computation = ' a t include Type_generic_intf . M ( struct type ' a t = ' a computation end ) module Uid_table = struct include ...
module _ = Hashtbl . Make ( Typename . Key )
module Make ( X : sig type ' a t val name : string val required : Ident . t list include Computation with type ' a t := ' a t end ) = struct module Computation = X include Make_S_implementation ( X ) module Memo = Typename . Table ( struct type ' a t = ' a X . Named . t end ) module Helper = Helper ( Typerep ) ( Comput...
module M ( X : sig type ' a t end ) = struct module type S = sig type t include Typerepable . S with type t := t val compute : t X . t end module type S1 = sig type ' a t include Typerepable . S1 with type ' a t := ' a t val compute : ' a X . t -> ' a t X . t end module type S2 = sig type ( ' a , ' b ) t include Typere...
module type S = sig type ' a t include module type of M ( struct type ' a computation = ' a t type ' a t = ' a computation end ) end
module Make ( D : Debugger . S ) ( Cmt_cache : Cmt_cache_intf . S ) = struct let type_and_env_from_dwarf_type0 ~ dwarf_type ~ cmt_cache = let cmt_file_and_ident_name = match Dwarf_name_laundry . split_base_type_die_name dwarf_type with | None -> None | Some { compilation_unit ; ident_name ; ident_stamp ; is_parameter ;...
let helpers_error msg = raise ( Type_helpers_error msg )
let michelson_type_to_ex_ty ( typ : Alpha_context . Script . expr ) ( ctxt : Alpha_context . t ) = Script_ir_translator . parse_ty ctxt ~ legacy : false ~ allow_lazy_storage : false ~ allow_operation : false ~ allow_contract : false ~ allow_ticket : false ( Micheline . root typ ) |> Environment . wrap_tzresult |> funct...
let rec michelson_type_list_to_ex_stack_ty ( stack_ty : Alpha_context . Script . expr list ) ctxt = let open Script_ir_translator in let open Script_typed_ir in match stack_ty with | [ ] -> Ex_stack_ty Bot_t | hd :: tl -> ( let ex_ty = michelson_type_to_ex_ty hd ctxt in match ex_ty with | Ex_ty ty -> ( let ex_stack_ty ...
let base_type_to_michelson_type ( typ : Type . Base . t ) = let typ = Mikhailsky . map_var ( fun _ -> Mikhailsky . unit_ty ) typ in Mikhailsky . to_michelson typ
let rec stack_type_to_michelson_type_list ( typ : Type . Stack . t ) = let node = typ . node in match node with | Type . Stack . Stack_var_t _ -> helpers_error " stack_type_to_michelson_type_list : bug found " | Type . Stack . Empty_t -> [ ] | Type . Stack . Item_t ( ty , tl ) -> base_type_to_michelson_type ty :: stack...
let base_type_to_ex_ty ty = michelson_type_to_ex_ty ( base_type_to_michelson_type ty )
module Key = struct type t = int [ @@ deriving compare , sexp_of ] let hash x = x end
module Allowed_ints = struct type t = | None | All | Hash_set of Hash_set . M ( Key ) . t | From_zero_to of int let _invariant = function | None | All | Hash_set _ -> ( ) | From_zero_to n -> assert ( n >= 0 ) ; ; let int_is_value t i = match t with | None -> false | All -> true | Hash_set hash_set -> Hash_set . mem has...
module Immediacy = struct type t = | Always | Sometimes | Never [ @@ deriving compare ] let equal = [ % compare . equal : t ] let to_string = function | Always -> " Always " | Sometimes -> " Sometimes " | Never -> " Never " ; ; end
module T : sig type ' a t val create : ' a Typename . t -> Immediacy . t -> Allowed_ints . t -> ' a t val create_with_name : string -> Immediacy . t -> Allowed_ints . t -> _ t val immediacy : _ t -> Immediacy . t val allowed_ints : _ t -> Allowed_ints . t val typename : _ t -> string module Never_values : sig val int32...
let int = create typename_of_int Always Allowed_ints . All
let unit = create typename_of_unit Always ( Allowed_ints . From_zero_to 0 )
let bool = create typename_of_bool Always ( Allowed_ints . From_zero_to 1 )
let char = create typename_of_char Always ( Allowed_ints . From_zero_to 255 )
module Computation_impl = struct type nonrec ' a t = ' a t include Type_generic . Variant_and_record_intf . M ( struct type nonrec ' a t = ' a t end ) include Never_values let ref_ _ = ref_ let array _ = array let tuple2 _ _ = tuple2 let tuple3 _ _ _ = tuple3 let tuple4 _ _ _ _ = tuple4 let tuple5 _ _ _ _ _ = tuple5 le...
module Generic = Type_generic . Make ( Computation_impl )
let of_typerep typerep = let ( ` generic t ) = Generic . of_typerep typerep in t ; ;
module For_all_parameters ( M : sig val immediacy : Immediacy . t end ) = struct let witness typerep1 typerep2 = let t1 = of_typerep typerep1 in let t2 = of_typerep typerep2 in let i1 = immediacy t1 in let i2 = immediacy t2 in if not ( Immediacy . equal i1 i2 ) then failwith ( sprintf " type % s is not independent of i...
let int_is_value t int = Allowed_ints . int_is_value ( allowed_ints t ) int
let int_as_value ( type a ) ( t : a t ) int = if int_is_value t int then Some ( Obj . magic ( int : int ) : a ) else None ; ;
let int_as_value_exn ( type a ) ( t : a t ) int = if int_is_value t int then ( Obj . magic ( int : int ) : a ) else failwith ( sprintf " Immediate . int_as_value_exn : typename :% S int :% d " ( T . typename t ) int ) ; ;
let value_as_int_exn ( type a ) ( t : a t ) a = if Obj . is_int ( Obj . repr a ) then ( Obj . magic ( a : a ) : int ) else failwith ( sprintf " Immediate . value_as_int_exn : typename :% S " ( T . typename t ) ) ; ;
let value_as_int ( type a ) ( _ : a t ) a = if Obj . is_int ( Obj . repr a ) then Some ( Obj . magic ( a : a ) : int ) else None ; ;
let value_is_int ( type a ) ( _ : a t ) a = Obj . is_int ( Obj . repr a )
module Always = struct type nonrec ' a t = ' a t include For_all_parameters ( struct let immediacy = Always end ) let of_typerep typerep = let t = of_typerep typerep in match immediacy t with | Always -> Some t | Never | Sometimes -> None ; ; let of_typerep_exn here typerep = Option . value_exn ~ here ( of_typerep type...
module Sometimes = struct type nonrec ' a t = ' a t include For_all_parameters ( struct let immediacy = Sometimes end ) let of_typerep typerep = let t = of_typerep typerep in match immediacy t with | Sometimes -> Some t | Always | Never -> None ; ; let of_typerep_exn here typerep = Option . value_exn ~ here ( of_typere...
module Never = struct type nonrec ' a t = ' a t include For_all_parameters ( struct let immediacy = Never end ) let of_typerep typerep = let t = of_typerep typerep in match immediacy t with | Never -> Some t | Always | Sometimes -> None ; ; let of_typerep_exn here typerep = Option . value_exn ~ here ( of_typerep typere...
type ' a dest = | Always of ' a Always . t | Sometimes of ' a Sometimes . t | Never of ' a Never . t
let dest t = let module I = Immediacy in match immediacy t with | I . Always -> Always t | I . Sometimes -> Sometimes t | I . Never -> Never t ; ;
( module struct module Typerep_obj = Typerep_lib . Std . Typerep_obj type ' a t = { int_as_value : int -> ' a option ; int_as_value_exn : int -> ' a ; int_is_value : int -> bool ; value_as_int : ' a -> int option ; value_as_int_exn : ' a -> int ; value_is_int : ' a -> bool } let get_conv typerep_of_t = let immediacy = ...
( module struct type t = | Always | Sometimes | Never let imm_t = typerep_of_unit let box_t = typerep_of_ref typerep_of_int let is_imm v = Obj . is_int ( Obj . repr v ) let check expected typerep list = if List . length list = 0 then failwith " Must provide at least one test case . " ; let actual = ( Type_immediacy . d...
let hash_string_hex s = let md5_hex = Digest . string s |> Digest . to_hex in assert ( String . length md5_hex = 32 ) ; String . sub md5_hex 0 7
let is_alpha c = match c with | ' A ' . . ' Z ' | ' a ' . . ' z ' -> true | _ -> false
let force_capitalize s = let need_prefix = s = " " || not ( is_alpha s . [ 0 ] ) in if need_prefix then capital_prefix ^ s else String . capitalize_ascii s
let name_of_token ( token : token ) = Punct . to_alphanum token . name
let encode_prec_name name = for i = 0 to String . length name - 1 do match name . [ i ] with | ' A ' . . ' Z ' | ' a ' . . ' z ' | ' 0 ' . . ' 9 ' -> ( ) | c -> failwith ( sprintf " Unsupported character % C in named precedence level % S " c name ) done ; name
let name_of_num_prec n = if n >= 0 then sprintf " p % d " n else sprintf " n % d " ( abs n )
let name_of_prec_value ( p : Tree_sitter_t . prec_value ) = match p with | Num_prec n -> name_of_num_prec n | Named_prec name -> sprintf " x % s " ( encode_prec_name name )
let name_of_opt_prec_value p = match p with | None -> " 0 " | Some p -> " x " ^ name_of_prec_value p