text stringlengths 12 786k |
|---|
let late_unwrap_value old_value new_value = let old_value = Obj . repr old_value in List . iter ( fun { parent ; field } -> Js . Unsafe . set parent field new_value ) ( Obj . obj ( Obj . field ( Obj . field old_value ( Obj . size old_value - 1 ) ) 2 ) ) : ( unwrapper ... |
let unwrap s i = if ! Eliom_config . debug_timings then Firebug . console ## ( time ( Js . string " unwrap " ) ) ; let res = raw_unmarshal_and_unwrap apply_unwrapper s i in if ! Eliom_config . debug_timings then Firebug . console ## ( timeEnd ( Js . string " unwrap " ) ) ; ... |
let unwrap_js s = unwrap ( Js . to_bytestring s ) 0 |
let rec string_of_url_path ' = function | [ ] -> " " | [ a ] when a = Eliom_common . eliom_suffix_internal_name -> " " | [ a ] -> Eliom_lib . Url . encode ~ plus : false a | a :: b :: l when b = Eliom_common . eliom_suffix_internal_name -> string_of_url_path ' ( a :: l ... |
let string_of_url_path_suff u = function | None -> string_of_url_path ' u | Some suff -> let pref = string_of_url_path ' u in let suf = string_of_url_path ' suff in if String . length pref = 0 then suf else String . concat " " / [ pref ; suf ] |
let reconstruct_relative_url_path current_url u = let rec drop cururl desturl = match cururl , desturl with | _ :: l , [ _ ] -> l , desturl | [ _ ] , m -> [ ] , m | a :: l , b :: m when a = b -> drop l m | _ :: l , m -> l , m | [ ] , m -> [ ] , m in let rec m... |
let reconstruct_relative_url_path_string current_url u suff = let relurl = reconstruct_relative_url_path current_url u in let s = string_of_url_path_suff relurl suff in if String . length s = 0 then Eliom_common . defaultpagename else if s . [ 0 ] = ' ' / then " . " / ^ s else s |
let make_proto_prefix ? hostname ? port https : string = let sp = Eliom_common . get_sp_option ( ) in let ssl = match sp with | Some sp -> Eliom_request_info . get_csp_ssl_sp sp | None -> false in let host = match hostname , sp with | None , Some sp -> Eliom_request_info . get_csp_hostname_sp... |
let is_https https ssl service = https = Some true || ( https = None && Eliom_config . default_protocol_is_https ( ) ) || Eliom_service . https service || ( https = None && ssl ) |
let make_uri_components_ ? absolute ( ? absolute_path = false ) ? https ( type a ) ( ~ service : ( _ , _ , _ , a , _ , _ , _ , _ , _ , _ , _ ) Eliom_service . t ) ? hostname ? port ? fragment ? keep_nl_params ( ? nl_params = Eliom_parameter . empty_nl_para... |
let make_uri_components ? absolute ? absolute_path ? https ( type a ) ( ~ service : ( _ , _ , _ , a , _ , _ , _ , _ , _ , _ , _ ) Eliom_service . t ) ? hostname ? port ? fragment ? keep_nl_params ? nl_params getparams = let uri , pregetparams , fragment = make... |
let make_string_uri_from_components ( uri , params , fragment ) = let s = Eliom_lib . String . may_concat uri " " ? ( Eliom_parameter . construct_params_string params ) in match fragment with None -> s | Some f -> Eliom_lib . String . concat " " # [ s ; f ] |
let make_string_uri ? absolute ? absolute_path ? https ~ service ? hostname ? port ? fragment ? keep_nl_params ? nl_params getparams : string = make_string_uri_from_components ( make_uri_components ? absolute ? absolute_path ? https ~ service ? hostname ? port ? fragment ? keep_nl_params ? nl_para... |
let make_post_uri_components_ ( ? absolute = ! Eliom_common . is_client_app ) ( ? absolute_path = false ) ? https ( type a ) ( ~ service : ( _ , _ , _ , a , _ , _ , _ , _ , _ , _ , _ ) Eliom_service . t ) ? hostname ? port ? fragment ( ? keep_nl_params... |
let make_post_uri_components ? absolute ? absolute_path ? https ~ service ? hostname ? port ? fragment ? keep_nl_params ? nl_params ? keep_get_na_params getparams postparams = let uri , getparams , fragment , prepostparams = make_post_uri_components_ ? absolute ? absolute_path ? https ~ service ?... |
let make_cookies_info ( https , service ) = let get_path_ ( type a ) ~ ( service : ( _ , _ , _ , a , _ , _ , _ , _ , _ , _ , _ ) Eliom_service . t ) = match Eliom_service . info service with | Eliom_service . Attached attser -> if Eliom_service . is_external... |
let section = Lwt_log . Section . make " eliom : wrap " |
type ' a wrapped_value = poly * ' a |
let with_no_heap_compaction f v = let gc_control = Gc . get ( ) in Gc . set { gc_control with Gc . max_overhead = max_int } ; match f v with | v -> Gc . set gc_control ; v | exception e -> Gc . set gc_control ; raise e |
module Mark : sig type t val wrap_mark : t val do_nothing_mark : t val unwrap_mark : t type t = string let wrap_mark = " wrap_mark " let do_nothing_mark = " do_nothing_mark " let unwrap_mark = " unwrap_mark " end |
type marked_value = { mark : Mark . t ; f : ( Obj . t -> Obj . t ) option } |
let make_mark f mark = { mark ; f } |
let is_marked o = let is_mark o = if Obj . tag o = 0 && Obj . size o = 2 && Obj . field o 0 == Obj . repr Mark . wrap_mark then ( let f = Obj . field o 1 in assert ( Obj . tag f = 0 ) ; assert ( Obj . size f = 1 ) ; assert ( let tag = Obj . tag ( Obj . field f 0 )... |
let wrap_locally o = let mark : marked_value = Obj . obj ( Obj . field o ( Obj . size o - 1 ) ) in match mark . f with Some f -> f o | None -> assert false |
let none = Obj . repr 0 |
module DynArray = struct let rec check_size a i = let len = Array . length ! a in if i > len then ( let old_a = ! a in a := Array . make ( 2 * len ) none ; Array . blit old_a 0 ! a 0 len ; check_size a i ) let make ( ) = ref ( Array . make ( 1 lsl ( bits - 1 ) ) none )... |
let resize_count = ref 0 |
let rehash_count = ref 0 |
module Tbl = struct type t = { mutable size : int ; mutable shift : int ; mutable occupancy : int ; mutable obj : Obj . t array ; mutable idx : int array ; mutable gc : int ; mutable on_resize : ( int -> unit ) list } let cst = Int64 . to_int ( Int64 . shift_right 0x4F1BBCDCBFA53E... |
let obj_kind v = if not ( Obj . is_block v ) then ` Opaque else let tag = Obj . tag v in if tag >= Obj . no_scan_tag then ` Opaque else if tag <= Obj . last_non_constant_constructor_tag then ` Scannable else if tag = Obj . forward_tag then let tag ' = Obj . tag ( Obj . field v 0 ) i... |
let unchanged = Obj . repr 1 |
let modified = Obj . repr 2 |
let iteration_count = ref 0 |
let wrap_count = ref 0 |
let rec find_substs tbl subst_tbl v = incr iteration_count ; match obj_kind v with | ` Opaque -> unchanged | ` Forward -> find_substs tbl subst_tbl ( Obj . field v 0 ) | ` Scannable -> let idx = Tbl . allocate_index tbl v in let v ' = DynArray . get subst_tbl idx in if v ' == none then ... |
let copy_count = ref 0 |
let rec duplicate tbl subst_tbl copy_tbl orig = match obj_kind orig with | ` Opaque -> orig | ` Forward -> duplicate tbl subst_tbl copy_tbl ( Obj . field orig 0 ) | ` Scannable -> let idx = Tbl . get_index tbl orig in let subst = DynArray . get subst_tbl idx in if subst == unchanged then orig... |
let perform_wrap = with_no_heap_compaction @@ fun v -> iteration_count := 0 ; copy_count := 0 ; wrap_count := 0 ; resize_count := 0 ; rehash_count := 0 ; let subst_tbl = DynArray . make ( ) in let copy_tbl = DynArray . make ( ) in let tbl = Tbl . make [ subst_tbl ; copy_tbl ]... |
type ' + a wrapper = marked_value |
let create_wrapper ( f : ' a -> ' b ) : ' a wrapper = make_mark ( Some ( fun x -> Obj . repr ( f ( Obj . obj x ) ) ) ) Mark . wrap_mark |
let empty_wrapper : ' a wrapper = make_mark None Mark . do_nothing_mark |
let id_of_int x = x |
type unwrapper = { id : unwrap_id ; umark : Mark . t } |
let create_unwrapper id = { id ; umark = Mark . unwrap_mark } |
let empty_unwrapper = { id = - 1 ; umark = Mark . do_nothing_mark } |
let wrap v = to_poly Mark . unwrap_mark , Obj . obj ( perform_wrap ( Obj . repr v ) ) |
module type VALUE = sig type value type state type usert end |
module type CORE0 = sig module V : VALUE val setglobal : V . state -> string -> V . value -> unit end |
module type CORE = sig include CORE0 val apply : V . value -> V . state -> V . value list -> V . value end |
module type AST = sig module Value : VALUE type chunk type program val get_value : chunk -> Value . value end |
module type EVALUATOR = sig module Value : VALUE module Ast : ( AST with module Value := Value ) type state = Value . state type value = Value . value exception Error of string val compile : Ast . program -> string include CORE0 with module V := Value end |
module type PARSER = sig type chunk val parse : string -> chunk end |
module type INTERP = sig include EVALUATOR module Parser : PARSER with type chunk = Ast . chunk val dostring : state -> string -> value list val mk : unit -> state end |
module type USERTYPE = sig type t val eq : t -> t -> bool val to_string : t -> string end |
module type TYPEVIEW = sig type combined type t val map : ( combined -> t ) * ( t -> combined ) end |
module type COMBINED_COMMON = sig module T : sig type t end module TV1 : TYPEVIEW with type combined := T . t module TV2 : TYPEVIEW with type combined := T . t end |
module type COMBINED_TYPE = sig module T : USERTYPE include COMBINED_COMMON with module T := T end |
module type BARECODE = sig type state val init : state -> unit end |
module USERCODE ( X : TYPEVIEW ) = struct module type F = functor ( C : CORE with type V . usert = X . combined ) -> BARECODE with type state := C . V . state end |
module Weapon = struct type t end |
module type WEAPON_LIB = sig type t = Weapon . t module T : USERTYPE with type t = t module Make : functor ( TV : TYPEVIEW with type t = t ) -> USERCODE ( TV ) . F end |
module IntSet = Set . Make ( struct type t = int let compare = compare end ) |
type module ' = { module_name : string ; signature : Code . t ; implementation : Code . t ; } |
let emit_enum_type ~ scope ~ params EnumDescriptorProto . { name ; value = values ; options = _ ; reserved_range = _ ; reserved_name = _ } : module ' = let name = Option . value_exn ~ message " : Enums must have a name " name in let module_name = Scope . get_name scope name in let... |
let emit_service_type scope ServiceDescriptorProto . { name ; method ' = methods ; _ } = let emit_method t scope MethodDescriptorProto . { name ; input_type ; output_type ; _ } = Code . emit t ` Begin " let % s = " ( Scope . get_name_exn scope name ) ; Code . emit t ` ... |
let emit_extension ~ scope ~ params field = let FieldDescriptorProto . { name ; extendee ; _ } = field in let name = Option . value_exn ~ message " : Extensions must have a name " name in let module_name = ( Scope . get_name scope name ) in let extendee_type = Scope . get_scoped_name s... |
let is_map_entry = function | Some MessageOptions . { map_entry = Some true ; _ } -> true | _ -> false |
let emit_sub dest ~ is_implementation ~ is_first { module_name ; signature ; implementation } = let ( ) = match is_first with | true -> Code . emit dest ` Begin " module rec % s : sig " module_name | false -> Code . emit dest ` Begin " and % s : sig " module_name in Code . appe... |
let rec emit_nested_types ~ syntax ~ signature ~ implementation ( ? is_first = true ) nested_types = match nested_types with | [ ] -> ( ) | sub :: subs -> emit_sub ~ is_implementation : false signature ~ is_first sub ; emit_sub ~ is_implementation : true implementation ~ is_first sub ; ... |
let rec emit_message ~ params ~ syntax scope DescriptorProto . { name ; field = fields ; extension = extensions ; nested_type = nested_types ; enum_type = enum_types ; extension_range = extension_ranges ; oneof_decl = oneof_decls ; options ; reserved_range = _ ; reserved_name = _ } ... |
let rec wrap_packages ~ params ~ syntax scope message_type services = function | [ ] -> let { module_name = _ ; implementation ; _ } = emit_message ~ params ~ syntax scope message_type in List . iter ~ f ( : fun service -> Code . append implementation ( emit_service_type scope service ... |
let parse_proto_file ~ params scope FileDescriptorProto . { name ; package ; dependency = dependencies ; public_dependency = _ ; weak_dependency = _ ; message_type = message_types ; enum_type = enum_types ; service = services ; extension ; options = _ ; source_code_info = _ ; synt... |
type error = | Stack_frame_too_large of int |
let output_channel = ref stdout |
let emit_string s = output_string ! output_channel s |
let emit_int n = output_string ! output_channel ( Int . to_string n ) |
let emit_char c = output_char ! output_channel c |
let emit_nativeint n = output_string ! output_channel ( Nativeint . to_string n ) |
let emit_printf fmt = Printf . fprintf ! output_channel fmt |
let emit_int32 n = emit_printf " 0x % lx " n |
let emit_symbol esc s = for i = 0 to String . length s - 1 do let c = s . [ i ] in match c with ' A ' . . ' Z ' | ' a ' . . ' z ' | ' 0 ' . . ' 9 ' | ' _ ' -> output_char ! output_channel c | _ -> Printf . fprintf ! output_channel " % c % 02x " ... |
let emit_string_literal s = let last_was_escape = ref false in emit_string " " " ; \ for i = 0 to String . length s - 1 do let c = s . [ i ] in if c >= ' 0 ' && c <= ' 9 ' then if ! last_was_escape then Printf . fprintf ! output_channel " \\% o " ( Char . code c ) els... |
let emit_string_directive directive s = let l = String . length s in if l = 0 then ( ) else if l < 80 then begin emit_string directive ; emit_string_literal s ; emit_char ' \ n ' end else begin let i = ref 0 in while ! i < l do let n = min ( l - ! i ) 80 in emit_string directive ; emi... |
let emit_bytes_directive directive s = let pos = ref 0 in for i = 0 to String . length s - 1 do if ! pos = 0 then emit_string directive else emit_char ' , ' ; emit_int ( Char . code s . [ i ] ) ; incr pos ; if ! pos >= 16 then begin emit_char ' \ n ' ; pos := 0 end done ;... |
let emit_float64_directive directive x = emit_printf " \ t % s \ t0x % Lx \ n " directive x |
let emit_float64_split_directive directive x = let lo = Int64 . logand x 0xFFFF_FFFFL and hi = Int64 . shift_right_logical x 32 in emit_printf " \ t % s \ t0x % Lx , 0x % Lx \ n " directive ( if Arch . big_endian then hi else lo ) ( if Arch . big_endian then lo else hi ) |
let emit_float32_directive directive x = emit_printf " \ t % s \ t0x % lx \ n " directive x |
type frame_debuginfo = | Dbg_alloc of Debuginfo . alloc_dbginfo | Dbg_raise of Debuginfo . t | Dbg_other of Debuginfo . t |
type frame_descr = { fd_lbl : int ; fd_frame_size : int ; fd_live_offset : int list ; fd_debuginfo : frame_debuginfo } |
let frame_descriptors = ref ( [ ] : frame_descr list ) |
let record_frame_descr ~ label ~ frame_size ~ live_offset debuginfo = frame_descriptors := { fd_lbl = label ; fd_frame_size = frame_size ; fd_live_offset = List . sort_uniq ( ) - live_offset ; fd_debuginfo = debuginfo } :: ! frame_descriptors |
type emit_frame_actions = { efa_code_label : int -> unit ; efa_data_label : int -> unit ; efa_8 : int -> unit ; efa_16 : int -> unit ; efa_32 : int32 -> unit ; efa_word : int -> unit ; efa_align : int -> unit ; efa_label_rel : int -> int32 -> unit ; efa_def_label : int -> unit ; ... |
let emit_frames a = let filenames = Hashtbl . create 7 in let label_filename name = try Hashtbl . find filenames name with Not_found -> let lbl = Cmm . new_label ( ) in Hashtbl . add filenames name lbl ; lbl in let defnames = Hashtbl . create 7 in let label_defname filename defname = try snd ( ... |
let isprefix s1 s2 = String . length s1 <= String . length s2 && String . sub s2 0 ( String . length s1 ) = s1 |
let is_generic_function name = List . exists ( fun p -> isprefix p name ) [ " caml_apply " ; " caml_curry " ; " caml_send " ; " caml_tuplify " ] |
let is_cfi_enabled ( ) = Config . asm_cfi_supported |
let cfi_startproc ( ) = if is_cfi_enabled ( ) then emit_string " \ t . cfi_startproc \ n " |
let cfi_endproc ( ) = if is_cfi_enabled ( ) then emit_string " \ t . cfi_endproc \ n " |
let cfi_adjust_cfa_offset n = if is_cfi_enabled ( ) then begin emit_string " \ t . cfi_adjust_cfa_offset \ t " ; emit_int n ; emit_string " \ n " ; end |
let cfi_offset ~ reg ~ offset = if is_cfi_enabled ( ) then begin emit_string " \ t . cfi_offset " ; emit_int reg ; emit_string " , " ; emit_int offset ; emit_string " \ n " end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.