text stringlengths 0 601k |
|---|
type ( ' data , ' dicmvbdu , ' diclist , ' dicrlist , ' dicvlist ) f = Exception . method_handler -> ( bool Mvbdu_sig . cell -> bool Mvbdu_sig . cell -> int ) -> bool Mvbdu_sig . skeleton -> bool Mvbdu_sig . cell -> ( int -> bool Mvbdu_sig . mvbdu ) -> ( ' data , ' dicmvbdu , ' diclist , ' dicrlist , ' dicvlist , bool ... |
type ( ' data , ' dicmvbdu , ' diclist , ' dicrlist , ' dicvlist ) g = Exception . method_handler -> ( int List_sig . cell -> int List_sig . cell -> int ) -> int List_sig . skeleton -> int List_sig . cell -> ( int -> int List_sig . list ) -> ( ' data , ' dicmvbdu , ' diclist , ' dicrlist , ' dicvlist , bool , int ) Mem... |
type ( ' data , ' dicmvbdu , ' diclist , ' dicrlist , ' dicvlist ) h = Exception . method_handler -> ( unit List_sig . cell -> unit List_sig . cell -> int ) -> unit List_sig . skeleton -> unit List_sig . cell -> ( int -> unit List_sig . list ) -> ( ' data , ' dicmvbdu , ' diclist , ' dicrlist , ' dicvlist , bool , int ... |
type ( ' mvbdu_handler , ' dicmvbdu , ' diclist , ' dicrlist , ' dicvlist , ' data ) remanent = { mvbdu_handler : ' mvbdu_handler ; error : Exception . method_handler ; output : out_channel ; allocate_mvbdu : ( ' data , ' dicmvbdu , ' diclist , ' dicrlist , ' dicvlist ) f ; allocate_uniquely_mvbdu : ( ' data , ' dicmvb... |
let initial_remanent make_mvbdu_handler make_allocate_mvbdu make_allocate_association_list make_allocate_variables_list = let error = Exception . empty_error_handler in let error , handler = make_mvbdu_handler error in { output = stdout ; mvbdu_handler = handler ; error = error ; parameters = Remanent_parameters . get_... |
let test reg leds = lightLeds leds ; Printf . printf " The pulse mode . . . \ n " ; %! applyRegPulse reg leds 2 . ; Printf . printf " The classic mode . . . \ n " ; %! applyRegAll reg leds ; Unix . sleep 2 ; Printf . printf " Only one led :\ n " ; %! clearLeds leds ; leds . ( 1 ) <- true ; Printf . printf " The pulse m... |
let anim_01 reg leds n = for i = 0 to n do clearLeds leds ; for k = 0 to ( Array . length leds ) - 1 do leds . ( k ) <- true ; applyReg reg leds 0 . 2 ; leds . ( k ) <- false done ; for k = ( Array . length leds ) - 2 downto 0 do leds . ( k ) <- true ; applyReg reg leds 0 . 2 ; leds . ( k ) <- false done ; lightLeds le... |
let anim_02 reg leds n = let t = ref 1 . in for i = 0 to n do clearLeds leds ; for k = 0 to ( Array . length leds ) - 1 do leds . ( k ) <- true ; applyReg reg leds ( ! t . / 10 . ) ; leds . ( k ) <- false done ; for k = ( Array . length leds ) - 2 downto 0 do leds . ( k ) <- true ; applyReg reg leds ( ! t . / 10 . ) ; ... |
let _ = let t = true and f = false in ignore ( setupPhys ( ) ) ; let reg = genReg 11 13 15 ~ invert : g_invert ~ pulse : g_pulse in let leds = initReg reg ~ nb_reg : g_nb_reg in Printf . printf " Début \ n " ; %! anim_01 reg leds max_int ; |
module Apply_diff_bench : Benchmark . S = struct include Interpreter_benchmarks . Default_config include Interpreter_benchmarks . Default_boilerplate let name = " SAPLING_APPLY_DIFF " let info = " Benchmarking SAPLING_APPLY_DIFF " let tags = [ " sapling " ] let diff_from_tx ( tx : Alpha_context . Sapling . transaction ... |
let ( ) = Registration_helpers . register ( module Apply_diff_bench ) |
module Sapling_gen_cmd = struct let lift_opt f opt_arg state = match opt_arg with None -> state | Some arg -> f arg state let max name = Clic . arg ~ doc ( : Printf . sprintf " Maximum number of % s " name ) ~ long ( : Printf . sprintf " max -% s " name ) ~ placeholder " : integer " ( Clic . parameter ( fun ( _ : unit ... |
let ( ) = Registration . add_command Sapling_gen_cmd . command |
type sapling_gen_options = { max_inputs : int ; max_outputs : int ; max_nullifiers : int ; max_additional_commitments : int ; seed : int option ; } |
let default_sapling_gen_options = { max_inputs = 100 ; max_outputs = 100 ; max_nullifiers = 100 ; max_additional_commitments = 50 ; seed = None ; } |
let alpha_to_raw ( x : Alpha_context . t ) : Raw_context . t = Obj . magic x |
let raw_to_alpha ( x : Raw_context . t ) : Alpha_context . t = Obj . magic x |
let fisher_yates n state = let a = Array . init n ( fun i -> i ) in for i = 0 to Array . length a - 1 do let j = Random . State . int state ( i + 1 ) in let tmp = a . ( j ) in a . ( j ) <- a . ( i ) ; a . ( i ) <- tmp done ; a |
let random_injection m n state = if m > n then invalid_arg " random_injection " else let a = fisher_yates n state in Array . sub a 0 m |
type sapling_transition = { state_seed : int64 ; nullifier_count : int64 ; commitment_count : int64 ; sapling_tx : Alpha_context . Sapling . transaction ; } |
type forge_info = { rcm : Tezos_sapling . Core . Client . Rcm . t ; position : int64 ; amount : int64 ; address : Tezos_sapling . Core . Client . Viewing_key . address ; nf : Tezos_sapling . Core . Client . Nullifier . t ; } |
let random_amount sum = Random . int64 ( Int64 . sub Tezos_sapling . Core . Validator . UTXO . max_amount sum ) |
let reverse diff = Protocol . Sapling_repr . { diff with commitments_and_ciphertexts = List . rev diff . commitments_and_ciphertexts ; } |
let pp_rpc_diff fmtr ( diff : Protocol . Sapling_repr . diff ) = let json = Data_encoding . Json . construct Protocol . Sapling_repr . diff_encoding diff in Format . fprintf fmtr " % a " Data_encoding . Json . pp json |
let random_bytes state size = Bytes . init size ( fun _ -> Char . chr ( Random . State . int state 256 ) ) |
let rec gen_rcm state = let rcm = Data_encoding . Binary . of_bytes_exn Tezos_sapling . Core . Client . Rcm . encoding ( random_bytes state 32 ) in try Tezos_sapling . Core . Client . Rcm . assert_valid rcm ; rcm with _ -> gen_rcm state |
let add_input diff vk index position sum state = let rcm = gen_rcm state in let amount = random_amount sum in let ( new_idx , address ) = Tezos_sapling . Core . Client . Viewing_key . new_address vk index in let cv = Tezos_sapling . Core . Client . CV . of_bytes ( random_bytes state 32 ) |> WithExceptions . Option . ge... |
let generate_commitments ~ vk ~ nb_input ~ nb_cm ~ nb_nf ~ diff ~ index state = let inj = random_injection nb_input nb_cm state in let use_for_input i = Array . exists ( fun k -> k = i ) inj in let rec loop i cm_index nb_nf diff to_forge sum = if i = nb_cm then return ( reverse diff , to_forge ) else if use_for_input i... |
let rec add_root nb_root ctxt id vk index size diff state = if nb_root > 0 then add_input Protocol . Sapling_storage . empty_diff vk index size 0L state >>=? fun ( diff_to_add , { position = size ; _ } , new_idx ) -> Protocol . Sapling_storage . apply_diff ctxt id diff_to_add >|= Protocol . Environment . wrap_tzresult ... |
let state_from_rpc_diff rpc_diff = Tezos_sapling . Storage . add ( Tezos_sapling . Storage . empty ~ memo_size : 0 ) rpc_diff . Protocol . Sapling_repr . commitments_and_ciphertexts |
let output proving_ctx vk sum = let address = Tezos_sapling . Core . Client . Viewing_key . dummy_address ( ) in let amount = random_amount sum in let rcm = Tezos_sapling . Core . Client . Rcm . random ( ) in let esk = Tezos_sapling . Core . Client . DH . esk_random ( ) in let ( cv_o , proof_o ) = Tezos_sapling . Core ... |
let outputs nb_output proving_ctx vk = let rec aux output_amount list_outputs nb_output sum = match nb_output with | 0 -> ( output_amount , list_outputs ) | nb_output -> let ( output , amount ) = output proving_ctx vk sum in assert ( Int64 . compare amount ( Int64 . sub Int64 . max_int Tezos_sapling . Core . Validator ... |
let make_inputs to_forge local_state proving_ctx sk vk root anti_replay = List . map_ep ( fun { rcm ; position ; amount ; address ; nf } -> let witness = Tezos_sapling . Storage . get_witness local_state position in let ar = Tezos_sapling . Core . Client . Proving . ar_random ( ) in let ( cv , rk , proof ) = Tezos_sapl... |
let init_fresh_sapling_state ctxt = let open Protocol . Environment . Error_monad in Protocol . Lazy_storage_diff . fresh Protocol . Lazy_storage_kind . Sapling_state ~ temporary : false ctxt >>=? fun ( ctxt , id ) -> Protocol . Sapling_storage . init ctxt id ~ memo_size : 0 >>=? fun ctxt -> return ( ctxt , id ) |
let generate_spending_and_viewing_keys state = let sk = Tezos_sapling . Core . Client . Spending_key . of_seed ( random_bytes state 32 ) in let vk = Tezos_sapling . Core . Client . Viewing_key . of_sk sk in ( sk , vk ) |
let prepare_seeded_state_internal ( ~ nb_input : int ) ( ~ nb_nf : int ) ( ~ nb_cm : int ) ( ctxt : Raw_context . t ) ( state : Random . State . t ) : ( Sapling_repr . diff * forge_info list * Tezos_sapling . Core . Client . Spending_key . t * Tezos_sapling . Core . Client . Viewing_key . t * Raw_context . t * Protocol... |
let prepare_seeded_state { state_seed ; nullifier_count ; commitment_count ; sapling_tx } ctxt = let rng_state = Random . State . make [ | Int64 . to_int state_seed ] | in prepare_seeded_state_internal ~ nb_input ( : List . length sapling_tx . inputs ) ~ nb_nf ( : Int64 . to_int nullifier_count ) ~ nb_cm ( : Int64 . to... |
let generate ( ~ nb_input : int ) ( ~ nb_output : int ) ( ~ nb_nf : int ) ( ~ nb_cm : int ) ( ~ anti_replay : string ) ~ ctxt state = assert ( nb_input <= nb_cm ) ; assert ( nb_nf <= nb_cm - nb_input ) ; prepare_seeded_state_internal ~ nb_input ~ nb_nf ~ nb_cm ctxt state >>=? fun ( diff , to_forge , sk , vk , ctxt , id... |
let sapling_transition_encoding = let open Data_encoding in conv ( fun { state_seed ; nullifier_count ; commitment_count ; sapling_tx } -> ( state_seed , nullifier_count , commitment_count , sapling_tx ) ) ( fun ( state_seed , nullifier_count , commitment_count , sapling_tx ) -> { state_seed ; nullifier_count ; commitm... |
let sapling_dataset_encoding = Data_encoding . list sapling_transition_encoding |
let save ~ filename ~ txs = let str = match Data_encoding . Binary . to_string sapling_dataset_encoding txs with | Error err -> Format . eprintf " Sapling_generation . save : encoding failed ( % a ) ; exiting " Data_encoding . Binary . pp_write_error err ; exit 1 | Ok res -> res in ignore ( Lwt_main . run @@ Tezos_stdl... |
let load_file filename = Lwt_main . run @@ ( Tezos_stdlib_unix . Lwt_utils_unix . read_file filename >>= fun str -> Format . eprintf " Sapling_generation . load : loaded % s . " @ filename ; match Data_encoding . Binary . of_string sapling_dataset_encoding str with | Ok result -> let result = List . map ( fun tx -> ( f... |
let get_all_sapling_data_files directory = let is_sapling_data file = let regexp = Str . regexp " . . *\\ sapling " in Str . string_match regexp file 0 in let lift file = directory ^ " " / ^ file in let handle = Unix . opendir directory in let rec loop acc = match Unix . readdir handle with | file -> if is_sapling_data... |
let load ~ filename = if not ( Sys . file_exists filename ) then ( Format . eprintf " Sapling_generation . load : file does not exist . " @ ; Stdlib . failwith " Sapling_generation . load " ) else if Sys . is_directory filename then let ( ) = Format . eprintf " Sapling_generation . load : loading all . sapling files fr... |
let shared_seed = [ | 9798798 ; 217861209 ; 876786 ] | |
let generate ( save_to : string ) ( tx_count : int ) ( sapling_gen_options : sapling_gen_options ) = let result = Lwt_main . run ( let { max_inputs ; max_outputs ; max_nullifiers ; max_additional_commitments ; seed ; } = sapling_gen_options in let rng_state = Random . State . make @@ Option . fold ~ none : shared_seed ... |
let apply_diff ctxt id diff = let open Protocol . Environment . Error_monad in Sapling_storage . apply_diff ( alpha_to_raw ctxt ) id diff >>=? fun ( ctxt , size ) -> return ( raw_to_alpha ctxt , size ) |
module Common = struct let memo_size_of_int i = match Alpha_context . Sapling . Memo_size . parse_z @@ Z . of_int i with | Ok memo_size -> memo_size | Error _ -> assert false let int_of_memo_size ms = Alpha_context . Sapling . Memo_size . unparse_to_z ms |> Z . to_int let wrap e = Lwt . return ( Environment . wrap_tzre... |
module Alpha_context_helpers = struct include Common let init ( ) = Context . init 1 >>=? fun ( b , _ ) -> Alpha_context . prepare b . context ~ level : b . header . shell . level ~ predecessor_timestamp : b . header . shell . timestamp ~ timestamp : b . header . shell . timestamp >>= wrap >|=? fun ( ctxt , _ , _ ) -> ... |
module Interpreter_helpers = struct include Common include Contract_helpers let originate_contract file storage src b baker = originate_contract file storage src b baker >|=? fun ( dst , b ) -> let anti_replay = Format . asprintf " % a % a " Alpha_context . Contract . pp dst Chain_id . pp Chain_id . zero in ( dst , b ,... |
type diff = { commitments_and_ciphertexts : ( Sapling . Commitment . t * Sapling . Ciphertext . t ) list ; nullifiers : Sapling . Nullifier . t list ; } |
let diff_encoding = let open Data_encoding in conv ( fun d -> ( d . commitments_and_ciphertexts , d . nullifiers ) ) ( fun ( commitments_and_ciphertexts , nullifiers ) -> ( match commitments_and_ciphertexts with | [ ] -> ( ) | ( _cm_hd , ct_hd ) :: rest -> let memo_size = Sapling . Ciphertext . get_memo_size ct_hd in L... |
module Memo_size = struct type t = int let encoding = Data_encoding . uint16 let equal = Compare . Int . ( = ) let max_uint16 = 0xffff let max_uint16_z = Z . of_int max_uint16 let err = Error ( " a positive 16 - bit integer ( between 0 and " ^ string_of_int max_uint16 ^ " ) " ) let parse_z z = if Compare . Z . ( Z . ze... |
let transaction_get_memo_size ( transaction : Sapling . UTXO . transaction ) = match transaction . outputs with | [ ] -> None | { ciphertext ; _ } :: _ -> Some ( Sapling . Ciphertext . get_memo_size ciphertext ) |
let input_in_memory_size = let cv_size = string_size_gen 32 in let nf_size = string_size_gen 32 in let rk_size = string_size_gen 32 in let proof_i_size = string_size_gen @@ ( 48 + 96 + 48 ) in let signature_size = string_size_gen 64 in header_size +! ( word_size *? 5 ) +! cv_size +! nf_size +! rk_size +! proof_i_size +... |
let ciphertext_size = let cv_size = string_size_gen 32 in let epk_size = string_size_gen 32 in let nonce_enc_size = string_size_gen 24 in let payload_out_size = string_size_gen ( 32 + 32 + 16 ) in let nonce_out_size = string_size_gen 24 in let fixed_payload_data_size = 11 + 8 + 32 + 16 + 4 in fun memo_size -> let paylo... |
let output_in_memory_size = let cm_size = string_size_gen 32 in let proof_o_size = string_size_gen @@ ( 48 + 96 + 48 ) in let ciphertext_size = ciphertext_size in fun memo_size -> header_size +! ( word_size *? 3 ) +! cm_size +! proof_o_size +! ciphertext_size memo_size |
let transaction_in_memory_size ( transaction : Sapling . UTXO . transaction ) = let binding_sig_size = string_size_gen 64 in let balance_size = int64_size in let root_size = string_size_gen 32 in let inputs = List . length transaction . inputs in let outputs = List . length transaction . outputs in let memo_size = Opti... |
let diff_in_memory_size ( { commitments_and_ciphertexts ; nullifiers } : diff ) = let cms_and_cts = List . length commitments_and_ciphertexts in let nfs = List . length nullifiers in let cm_size = string_size_gen 32 in let nf_size = string_size_gen 32 in let memo_size = match commitments_and_ciphertexts with | [ ] -> 0... |
let custom_root = ( RPC_path . ( open_root / " context " / " sapling " ) : RPC_context . t RPC_path . context ) |
type diff_query = { offset_commitment : Int64 . t option ; offset_nullifier : Int64 . t option ; } |
module S = struct module Args = struct type ( ' query_type , ' output_type ) t = { name : string ; description : string ; query : ' query_type RPC_query . t ; output : ' output_type Data_encoding . t ; f : context -> Sapling . Id . t -> ' query_type -> ' output_type tzresult Lwt . t ; } let get_diff_query : diff_query ... |
let register ( ) = let reg ~ chunked ( service , f ) = Services_registration . register1 ~ chunked service f in reg ~ chunked : false S . get_diff |
let mk_call1 ( service , _f ) ctxt block id q = RPC_context . make_call1 service ctxt block id q ( ) |
let get_diff ctxt block id ? offset_commitment ? offset_nullifier ( ) = mk_call1 S . get_diff ctxt block id { offset_commitment ; offset_nullifier } |
module type COMMITMENTS = sig val init : Raw_context . t -> Storage . Sapling . id -> Raw_context . t Lwt . t val default_root : Sapling . Hash . t val get_root : Raw_context . t -> Storage . Sapling . id -> ( Raw_context . t * Sapling . Hash . t ) tzresult Lwt . t val add : Raw_context . t -> Storage . Sapling . id ->... |
module Commitments : COMMITMENTS = struct module H = Sapling . Hash let pow2 h = Int64 . ( shift_left 1L h ) let max_height = 32 let max_size = pow2 max_height let assert_node node height = assert ( let first_of_height = pow2 ( max_height - height ) in let first_of_next_height = Int64 . shift_left first_of_height 1 in ... |
module Ciphertexts = struct let init ctx id = Storage . Sapling . ciphertexts_init ctx id let add ctx id c pos = Storage . Sapling . Ciphertexts . init ( ctx , id ) pos c let get_from ctx id offset = let rec aux ( ctx , acc ) pos = Storage . Sapling . Ciphertexts . find ( ctx , id ) pos >>=? fun ( ctx , c ) -> match c ... |
module Nullifiers = struct let init = Storage . Sapling . nullifiers_init let size ctx id = Storage . Sapling . Nullifiers_size . get ( ctx , id ) let mem ctx id nf = Storage . Sapling . Nullifiers_hashed . mem ( ctx , id ) nf let add ctx id nfs = assert ( Compare . Int . ( List . compare_length_with nfs 1000 <= 0 ) ) ... |
module Roots = struct let size = 120l let get ctx id = Storage . Sapling . Roots_pos . get ( ctx , id ) >>=? fun pos -> Storage . Sapling . Roots . get ( ctx , id ) pos let init ctx id = let [ @ coq_struct " pos " ] rec aux ctx pos = if Compare . Int32 . ( pos < 0l ) then return ctx else Storage . Sapling . Roots . ini... |
type state = { id : Lazy_storage_kind . Sapling_state . Id . t option ; diff : Sapling_repr . diff ; memo_size : Sapling_repr . Memo_size . t ; } |
let empty_diff = Sapling_repr . { commitments_and_ciphertexts = [ ] ; nullifiers = [ ] } |
let empty_state ? id ~ memo_size ( ) = { id ; diff = empty_diff ; memo_size } |
let state_from_id ctxt id = Storage . Sapling . Memo_size . get ( ctxt , id ) >|=? fun memo_size -> ( { id = Some id ; diff = empty_diff ; memo_size } , ctxt ) |
let get_memo_size ctx id = Storage . Sapling . Memo_size . get ( ctx , id ) |
let init ctx id ~ memo_size = Storage . Sapling . Memo_size . add ( ctx , id ) memo_size >>= fun ctx -> Storage . Sapling . Commitments_size . add ( ctx , id ) Int64 . zero >>= fun ctx -> Commitments . init ctx id >>= fun ctx -> Nullifiers . init ctx id >>= fun ctx -> Roots . init ctx id >>=? fun ctx -> Ciphertexts . i... |
let sapling_apply_diff_cost ~ inputs ~ outputs = let open Saturation_repr in add ( safe_int 1_300_000 ) ( add ( scale_fast ( mul_safe_of_int_exn 5_000 ) ( safe_int inputs ) ) ( scale_fast ( mul_safe_of_int_exn 55_000 ) ( safe_int outputs ) ) ) |
let apply_diff ctx id diff = let open Sapling_repr in let nb_commitments = List . length diff . commitments_and_ciphertexts in let nb_nullifiers = List . length diff . nullifiers in let sapling_cost = sapling_apply_diff_cost ~ inputs : nb_nullifiers ~ outputs : nb_commitments in Raw_context . consume_gas ctx sapling_co... |
let add { id ; diff ; memo_size } cm_cipher_list = assert ( List . for_all ( fun ( _cm , cipher ) -> Compare . Int . ( Sapling . Ciphertext . get_memo_size cipher = memo_size ) ) cm_cipher_list ) ; { id ; diff = { diff with commitments_and_ciphertexts = List . rev cm_cipher_list @ diff . commitments_and_ciphertexts ; }... |
let root_mem ctx { id ; _ } tested_root = match id with | Some id -> Roots . mem ctx id tested_root | None -> return Compare . Int . ( Sapling . Hash . compare tested_root Commitments . default_root = 0 ) |
let nullifiers_mem ctx { id ; diff ; _ } nf = let exists_in_diff = List . exists ( fun v -> Compare . Int . ( Sapling . Nullifier . compare nf v = 0 ) ) diff . nullifiers in if exists_in_diff then return ( ctx , true ) else match id with | None -> return ( ctx , false ) | Some id -> Nullifiers . mem ctx id nf |
let nullifiers_add { id ; diff ; memo_size } nf = { id ; diff = { diff with nullifiers = nf :: diff . nullifiers } ; memo_size } |
let get_diff ctx id ( ? offset_commitment = 0L ) ( ? offset_nullifier = 0L ) ( ) = if not Sapling . Commitment . ( valid_position offset_commitment && valid_position offset_nullifier ) then failwith " Invalid argument . " else Commitments . get_from ctx id offset_commitment >>=? fun commitments -> Roots . get ctx id >>... |
let rec check_and_update_nullifiers ctxt state inputs = match inputs with | [ ] -> return ( ctxt , Some state ) | input :: inputs -> ( Sapling_storage . nullifiers_mem ctxt state Sapling . UTXO . ( input . nf ) >>=? function | ( ctxt , true ) -> return ( ctxt , None ) | ( ctxt , false ) -> let state = Sapling_storage .... |
let verify_update : Raw_context . t -> Sapling_storage . state -> Sapling_repr . transaction -> string -> ( Raw_context . t * ( Int64 . t * Sapling_storage . state ) option ) tzresult Lwt . t = fun ctxt state transaction key -> assert ( Compare . Int . ( List . compare_length_with transaction . inputs 5208 <= 0 ) ) ; a... |
let ano_n = ref 0 |
let gen_ano_f _loc : ident = let s = Printf . sprintf " f_anonym_ % d " ! ano_n in incr ano_n ; IdLid ( _loc , s ) |
let gen_kernel ( ) = ( ) EXTEND Gram GLOBAL : str_item expr ; str_item : [ [ " kmodule " ; name = UIDENT ; " " ; = " struct " ; " begin_const " ; mod_consts = LIST0 mod_const_expr ; " end_const " ; " begin_fun " ; mod_funs = LIST0 mod_funs_expr ; " end_fun " ; " end " -> let new_module = { mod_name = name ; mod_constan... |
let gen_body2 = <: expr < spoc_gen_kernel $ n_body2 $ $ List . fold_left ( fun a b -> <: expr < spoc_local_env $ b $ $ a ) $>> b_body ! arg_list $>> in |
let gen_args = parse_args args gen_body in |
let ret = incr arg_idx ; match ! return_type with | TUnknown -> <: expr < return_unknown ( ) , Dummy >> | TInt32 -> <: expr < return_int $ ExInt ( Loc . ghost , string_of_int ( ! arg_idx ) ) $ " " , Vector . int32 >> | TInt64 -> <: expr < return_int $ ExInt ( Loc . ghost , string_of_int ( ! arg_idx ) ) $ " " , Vector .... |
let fst_ ( a , b , c , d , e , f ) = a |
let tup_args , list_args , class_legacy , list_to_args1 , list_to_args2 = let args_fst_list = ( List . map fst_ ( List . map gen_arg_from_patt3 args ) ) in let args_com = paCom_of_list args_fst_list in let args_list = let l = ( List . map snd_ ( List . map gen_arg_from_patt3 args ) ) in exSem_of_list l in let args_thd_... |
let class_name = " kirc_class " ( ^ string_of_int ! nb_ker ) in |
let has_vector = ref false in |
let extensions = match ! extensions with | [ ] -> <: expr < [ ] ||>> | t [ ] :: -> <: expr < [ |$ t ] $|>> | _ -> <: expr [ <|$ exSem_of_list ! extensions ] $|>> in |
let res = if ! has_vector then <: expr < let module M = struct let exec_fun $ tup_args $ = Spoc . Kernel . exec $ list_args ; ; $ class [ ' a , ' b ] $ lid : class_name $ = object ( self ) inherit [ $ class_legacy $ ] Spoc . Kernel . spoc_kernel " kirc_kernel " " spoc_dummy " method exec = exec_fun method args_to_list ... |
let local = Hashtbl . fold ( fun key ( funv , stri , _ ) init -> <: str_item < <: str_item <>> in <: expr < let module Local_funs = struct $ local $ end $ res $ >> ] ] ; str_item : [ [ " klet " ; name = ident ; " " ; = " fun " ; args = LIST1 k_patt ; " " ; -> body = kernel_body -> arg_idx := 0 ; return_type := TUnknown... |
let gen_body2 = <: expr < spoc_gen_kernel $ n_body2 $ $ List . fold_left ( fun a b -> <: expr < spoc_local_env $ b $ $ a ) $>> b_body ! arg_list $>> in |
let gen_args = parse_args args gen_body in |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.