text stringlengths 0 601k |
|---|
let preserve ( ? rev_namespace = [ ] ) ocaml = translate ~ rev_namespace ~ ocaml ~ coq : ocaml |
let rec find ( ? rev_namespace = [ ] ) ~ ocaml t = let prefix = String . concat " . " rev_namespace in match Option . bind ( Table . find_opt prefix t ) ( Namespace . find ~ ocaml ) with | Some coq -> Some coq | None -> ( match rev_namespace with | _ :: rev_namespace -> find ~ rev_namespace ~ ocaml t | _ -> None ) |
let types_table = let rec ( -- ) x y = if x < y then x :: ( x + 1 -- y ) else [ y ] in let translate_tuples l ns = List . fold_left ( fun ns x -> Namespace . translate ~ ocaml ( : Format . sprintf " Coq_coqffi . Shim . tupl % d " x ) ~ coq ( : Format . sprintf " tupl % d " x ) ns ) ns l in let ns = Namespace . empty |>... |
type token = | Range of Ckappa_sig . c_site_name * Ckappa_sig . c_state list | Equiv of ( Ckappa_sig . c_site_name * Ckappa_sig . c_state ) * ( Ckappa_sig . c_site_name * Ckappa_sig . c_state ) | Imply of ( Ckappa_sig . c_site_name * Ckappa_sig . c_state ) * ( Ckappa_sig . c_site_name * Ckappa_sig . c_state ) | Partiti... |
type rename_sites = ( Remanent_parameters_sig . parameters -> Exception . method_handler -> Ckappa_sig . Site_map_and_set . Map . elt -> Exception . method_handler * Ckappa_sig . Site_map_and_set . Map . elt ) |
let non_relational parameters handler error mvbdu = let error , handler , list = Ckappa_sig . Views_bdu . mvbdu_cartesian_abstraction parameters handler error mvbdu in let error , handler , mvbdu_true = Ckappa_sig . Views_bdu . mvbdu_true parameters handler error in let error , handler , recomposition = List . fold_lef... |
let try_partitioning parameters handler error ( rename_site_inverse : rename_sites ) mvbdu = let error , handler , mvbdu_true = Ckappa_sig . Views_bdu . mvbdu_true parameters handler error in let error , handler , var_hconsed_list = Ckappa_sig . Views_bdu . variables_list_of_mvbdu parameters handler error mvbdu in let ... |
let translate parameters handler error ( rename_site_inverse : rename_sites ) mvbdu = let error , handler , list = Ckappa_sig . Views_bdu . extensional_of_mvbdu parameters handler error mvbdu in let error , list = List . fold_left ( fun ( error , list ) elt1 -> let error , elt1 = List . fold_left ( fun ( error , list )... |
let rec print ? beginning_of_sentence ( : beggining = true ) ? prompt_agent_type ( : prompt_agent_type = true ) ? html_mode ( : html_mode = false ) ~ show_dep_with_dimmension_higher_than : dim_min parameters handler_kappa error agent_string agent_type agent_id translation t = let tab = if html_mode then " < PRE > </ PR... |
let rec convert_views_internal_constraints_list_aux ~ show_dep_with_dimmension_higher_than : dim_min parameters handler_kappa error agent_string agent_type agent_id translation t current_list = let error , current_list = match translation with | Range ( site_type , state_list ) -> begin if dim_min <= 1 then begin match... |
let convert_views_internal_constraints_list ~ show_dep_with_dimmension_higher_than : dim_min parameters handler_kappa error agent_string agent_type translation current_list = let t = Site_graphs . KaSa_site_graph . empty in let error ' , agent_id , t = Site_graphs . KaSa_site_graph . add_agent parameters error handler_... |
let print ? beginning_of_sentence ( : beggining = true ) ? prompt_agent_type ( : prompt_agent_type = true ) ? html_mode ( : html_mode = false ) ~ show_dep_with_dimmension_higher_than : dim_min parameters handler_kappa error agent_string agent_type translation = let t = Site_graphs . KaSa_site_graph . empty in let error... |
exception Internal_error of [ ` Cannot_parse of exn | ` Ast_changed | ` Doc_comment of Normalize . docstring_error list | ` Comment | ` Comment_dropped of Cmt . t list | ` Warning50 of ( Location . t * Warnings . t ) list ] * ( string * Sexp . t ) list |
let internal_error msg kvs = raise ( Internal_error ( msg , kvs ) ) |
type error = | Invalid_source of { exn : exn } | Unstable of { iteration : int ; prev : string ; next : string } | Ocamlformat_bug of { exn : exn } | User_error of string |
let ellipsis n msg = let msg = String . strip msg in if n > 0 && String . length msg > ( n * 2 ) + 10 then Format . sprintf " % s . . . % s " ( String . prefix msg n ) ( String . suffix msg n ) else msg |
let ellipsis_cmt = ellipsis 50 |
let with_file input_name output_file suf ext f = let dir = match output_file with | Some filename -> Filename . dirname filename | None -> Filename . get_temp_dir_name ( ) in let base = Filename . remove_extension ( Filename . basename input_name ) in let tmp = Filename . concat dir ( base ^ suf ^ ext ) in Out_channel ... |
let dump_ast ~ input_name ? output_file ~ suffix fmt = let ext = " . ast " in with_file input_name output_file suffix ext ( fun oc -> fmt ( Format . formatter_of_out_channel oc ) ) |
let dump_formatted ~ input_name ? output_file ~ suffix fmted = let ext = Filename . extension input_name in with_file input_name output_file suffix ext ( fun oc -> Out_channel . output_string oc fmted ) |
let print_error ~ fmt ~ exe ~ debug ~ quiet ~ input_name error = match error with | Invalid_source _ when quiet -> ( ) | Invalid_source { exn } -> ( let reason = match exn with | Syntaxerr . Error _ | Lexer . Error _ -> " ( syntax error ) " | Warning50 _ -> " ( misplaced documentation comments - warning 50 ) " | _ -> "... |
let check_all_locations fmt cmts_t = match Cmts . remaining_locs cmts_t with | [ ] -> ( ) | l -> let print l = Format . fprintf fmt " % a \ n " %! Location . print l in Format . fprintf fmt " Warning : Some locations have not been considered \ n " %! ; List . iter ~ f : print ( List . sort l ~ compare : Location . comp... |
let check_margin conf ~ filename ~ fmted = List . iteri ( String . split_lines fmted ) ~ f ( : fun i line -> if String . length line > conf . Conf . margin then Format . fprintf Format . err_formatter " Warning : % s :% i exceeds the margin \ n " %! filename i ) |
let with_optional_box_debug ~ box_debug k = if box_debug then Fmt . with_box_debug k else k |
let with_buffer_formatter ~ buffer_size k = let buffer = Buffer . create buffer_size in let fs = Format_ . formatter_of_buffer buffer in Fmt . eval fs k ; Format_ . pp_print_flush fs ( ) ; if Buffer . length buffer > 0 then Format_ . pp_print_newline fs ( ) ; Buffer . contents buffer |
let equal fragment ~ ignore_doc_comments c a b = Normalize . equal fragment ~ ignore_doc_comments c a . Parse_with_comments . ast b . Parse_with_comments . ast |
let normalize fragment c { Parse_with_comments . ast ; _ } = Normalize . normalize fragment c ast |
let recover ( type a ) : a Traverse . fragment -> _ = function | Traverse . Structure -> Parse_wyc . Make_parsable . structure | Traverse . Signature -> Parse_wyc . Make_parsable . signature | Traverse . Use_file -> Parse_wyc . Make_parsable . use_file |
let format fragment ? output_file ~ input_name ~ prev_source ~ parsed conf opts = let open Result . Monad_infix in let dump_ast ~ suffix ast = if opts . Conf . debug then Some ( dump_ast ~ input_name ? output_file ~ suffix ( fun fmt -> Migrate_ast . Printast . fragment fragment fmt ast ) ) else None in let dump_formatt... |
let parse_result fragment conf ( opts : Conf . opts ) ~ source ~ input_name = match parse fragment conf ~ source with | exception exn -> if opts . format_invalid_files then ( match parse fragment conf ~ source ( : recover fragment source ) with | exception exn -> Error ( Invalid_source { exn } ) | parsed -> Format . fp... |
let parse_and_format fragment ? output_file ~ input_name ~ source conf opts = Ocaml_common . Location . input_name := input_name ; let open Result . Monad_infix in parse_result fragment conf opts ~ source ~ input_name >>= fun parsed -> format fragment ? output_file ~ input_name ~ prev_source : source ~ parsed conf opts |
module Config = struct type config = { generator_config : Michelson_generation . generator_config ; michelson_terms_file : string option ; } let default_config = { generator_config = Michelson_generation . default_generator_config ; michelson_terms_file = None ; } let config_encoding = let open Data_encoding in conv ( ... |
module Default_boilerplate = struct type workload = Translator_workload . t let workload_encoding = Translator_workload . encoding let workload_to_vector = Translator_workload . workload_to_sparse_vec let tags = [ Tags . translator ] let make_models t_kind code_or_data = [ ( " gas_translator_model " , Translator_model ... |
type phase = Workload_production | In_protocol | Global |
type error_kind = | Global_error of { benchmark_name : string ; workload : Tezos_base . TzPervasives . tztrace ; } | Bad_data of { benchmark_name : string ; micheline : Alpha_context . Script . expr ; expected_type : Alpha_context . Script . expr ; phase : phase ; } | Bad_code of { benchmark_name : string ; micheline :... |
let pp_phase fmtr ( phase : phase ) = match phase with | Workload_production -> Format . fprintf fmtr " workload production " | In_protocol -> Format . fprintf fmtr " in protocol " | Global -> Format . fprintf fmtr " global " |
let report_michelson_errors fmtr errs = Michelson_v1_error_reporter . report_errors ~ details : true ~ show_source : true fmtr errs |
let make_printable node = Micheline_printer . printable Michelson_v1_primitives . string_of_prim node |
let pp_error_kind fmtr ( error_kind : error_kind ) = match error_kind with | Global_error { benchmark_name ; workload } -> Format . open_vbox 1 ; Format . fprintf fmtr " Global error , " :@ ; Format . fprintf fmtr " benchmark = % s , " @ benchmark_name ; Format . fprintf fmtr " workload , " :@ ; report_michelson_errors... |
let ( ) = Printexc . register_printer ( function | Translator_benchmark_error err -> Some ( Format . asprintf " % a " pp_error_kind err ) | _ -> None ) |
let global_error benchmark_name workload = raise ( Translator_benchmark_error ( Global_error { benchmark_name ; workload } ) ) |
let bad_data benchmark_name micheline expected_type phase = raise ( Translator_benchmark_error ( Bad_data { benchmark_name ; micheline ; expected_type ; phase } ) ) |
let bad_code benchmark_name micheline expected_stack_type phase = raise ( Translator_benchmark_error ( Bad_code { benchmark_name ; micheline ; expected_stack_type ; phase } ) ) |
module Typechecking_data : Benchmark . S = struct include Config include Default_boilerplate let models = make_models Translator_workload . Parsing Translator_workload . Data let name = " TYPECHECKING_DATA " let info = " Benchmarking typechecking of data " let typechecking_data_benchmark rng_state ( node : Protocol . S... |
let ( ) = Registration_helpers . register ( module Typechecking_data ) |
module Unparsing_data : Benchmark . S = struct include Config include Default_boilerplate let models = make_models Translator_workload . Unparsing Translator_workload . Data let name = " UNPARSING_DATA " let info = " Benchmarking unparsing of data " let unparsing_data_benchmark rng_state ( node : Protocol . Script_repr... |
let ( ) = Registration_helpers . register ( module Unparsing_data ) |
module Typechecking_code : Benchmark . S = struct include Config include Default_boilerplate let models = make_models Translator_workload . Parsing Translator_workload . Code let name = " TYPECHECKING_CODE " let info = " Benchmarking typechecking of code " let typechecking_code_benchmark rng_state ( node : Protocol . S... |
let ( ) = Registration_helpers . register ( module Typechecking_code ) |
module Unparsing_code : Benchmark . S = struct include Config include Default_boilerplate let models = make_models Translator_workload . Unparsing Translator_workload . Code let name = " UNPARSING_CODE " let info = " Benchmarking unparsing of code " let unparsing_code_benchmark rng_state ( node : Protocol . Script_repr... |
let ( ) = Registration_helpers . register ( module Unparsing_code ) |
let rec check_printable_ascii v i = if Compare . Int . ( i < 0 ) then true else match v . [ i ] with | ' \ n ' | ' \ x20 ' . . ' \ x7E ' -> check_printable_ascii v ( i - 1 ) | _ -> false |
let check_printable_benchmark = let open Tezos_shell_benchmarks . Encoding_benchmarks_helpers in linear_shared ~ name " : CHECK_PRINTABLE " ~ generator ( : fun rng_state -> let open Base_samplers in let string = readable_ascii_string rng_state ~ size { : min = 1 ; max = 1024 } in ( string , { Shared_linear . bytes = St... |
let ( ) = Registration_helpers . register check_printable_benchmark |
module Merge_types : Benchmark . S = struct type config = { max_size : int } let config_encoding = let open Data_encoding in conv ( fun { max_size } -> max_size ) ( fun max_size -> { max_size } ) ( obj1 ( req " max_size " int31 ) ) let default_config = { max_size = 64 } type workload = Merge_types_workload of { nodes :... |
let ( ) = Registration_helpers . register ( module Merge_types ) |
let rec dummy_type_generator size = let open Script_ir_translator in let open Script_typed_ir in if size <= 1 then Ex_ty unit_t else match dummy_type_generator ( size - 2 ) with | Ex_ty r -> let l = unit_t in Ex_ty ( match pair_t ( - 1 ) l r with Error _ -> assert false | Ok t -> t ) |
let rec dummy_comparable_type_generator size = let open Script_ir_translator in let open Script_typed_ir in if size <= 0 then Ex_comparable_ty unit_key else match dummy_comparable_type_generator ( size - 2 ) with | Ex_comparable_ty r -> let l = unit_key in Ex_comparable_ty ( match pair_key ( - 1 ) l r with Error _ -> a... |
module Parse_type_shared = struct type config = { max_size : int } let default_config = { max_size = Constants_repr . michelson_maximum_type_size } let config_encoding = let open Data_encoding in conv ( fun { max_size } -> max_size ) ( fun max_size -> { max_size } ) ( obj1 ( req " max_size " int31 ) ) type workload = T... |
let parse_ty ctxt node = Script_ir_translator . parse_ty ctxt ~ legacy : true ~ allow_lazy_storage : true ~ allow_operation : true ~ allow_contract : true ~ allow_ticket : true node |
let unparse_ty ctxt ty = Script_ir_translator . unparse_ty ~ loc ( :- 1 ) ctxt ty |
module Parse_type_benchmark : Benchmark . S = struct include Parse_type_shared let name = " PARSE_TYPE " let info = " Benchmarking parse_ty " let make_bench rng_state config ( ) = let open Error_monad in ( Lwt_main . run ( Execution_context . make ~ rng_state ) >>? fun ( ctxt , _ ) -> let ctxt = Gas_helpers . set_limit... |
let ( ) = Registration_helpers . register ( module Parse_type_benchmark ) |
module Unparse_type_benchmark : Benchmark . S = struct include Parse_type_shared let name = " UNPARSE_TYPE " let info = " Benchmarking unparse_ty " let make_bench rng_state config ( ) = let open Error_monad in ( Lwt_main . run ( Execution_context . make ~ rng_state ) >>? fun ( ctxt , _ ) -> let ctxt = Gas_helpers . set... |
let ( ) = Registration_helpers . register ( module Unparse_type_benchmark ) |
module Unparse_comparable_type_benchmark : Benchmark . S = struct include Parse_type_shared let name = " UNPARSE_COMPARABLE_TYPE " let info = " Benchmarking unparse_comparable_ty " let make_bench rng_state config ( ) = let open Error_monad in let res = Lwt_main . run ( Execution_context . make ~ rng_state ) >>? fun ( c... |
let ( ) = Registration_helpers . register ( module Unparse_comparable_type_benchmark ) |
let gas_full t_kind code_or_data = let name = Format . asprintf " % a_ % a " Translator_workload . pp_kind t_kind Translator_workload . pp_code_or_data code_or_data in let intercept = Free_variable . of_string ( Format . asprintf " % s_const " name ) in let coeff = Free_variable . of_string ( Format . asprintf " % s_co... |
let size_full t_kind code_or_data = let name = Format . asprintf " % a_ % a " Translator_workload . pp_kind t_kind Translator_workload . pp_code_or_data code_or_data in let coeff1 = Free_variable . of_string ( Format . asprintf " % s_traversal " name ) in let coeff2 = Free_variable . of_string ( Format . asprintf " % s... |
let gas_based_model t_kind code_or_data = Model . make ~ conv ( : function | Translator_workload . Typechecker_workload { consumed ; _ } -> ( consumed , ( ) ) ) ~ model ( : gas_full t_kind code_or_data ) |
let size_based_model t_kind code_or_data = Model . make ~ conv ( : function | Translator_workload . Typechecker_workload { micheline_size ; _ } -> ( match micheline_size with | { traversal ; int_bytes ; string_bytes } -> ( traversal , ( int_bytes , ( string_bytes , ( ) ) ) ) ) ) ~ model ( : size_full t_kind code_or_dat... |
type kind = Parsing | Unparsing |
type code_or_data = Code | Data |
type t = | Typechecker_workload of { t_kind : kind ; code_or_data : code_or_data ; micheline_size : Size . micheline_size ; consumed : Size . t ; } |
let kind_encoding : kind Data_encoding . t = let open Data_encoding in def " kind_encoding " @@ string_enum [ ( " parsing " , Parsing ) ; ( " unparsing " , Unparsing ) ] |
let code_or_data_encoding : code_or_data Data_encoding . t = let open Data_encoding in def " code_or_data_encoding " @@ string_enum [ ( " code " , Code ) ; ( " data " , Data ) ] |
let encoding : t Data_encoding . t = let open Data_encoding in def " translator_trace_encoding " @@ conv ( function | Typechecker_workload { t_kind ; code_or_data ; micheline_size ; consumed } -> ( t_kind , code_or_data , micheline_size , consumed ) ) ( fun ( t_kind , code_or_data , micheline_size , consumed ) -> Typec... |
let pp_kind fmtr ( kind : kind ) = match kind with | Parsing -> Format . pp_print_string fmtr " Parsing " | Unparsing -> Format . pp_print_string fmtr " Unparsing " |
let pp_code_or_data fmtr ( x : code_or_data ) = match x with | Code -> Format . pp_print_string fmtr " Code " | Data -> Format . pp_print_string fmtr " Data " |
let pp fmtr ( trace : t ) = match trace with | Typechecker_workload { t_kind ; code_or_data ; micheline_size ; consumed } -> Format . fprintf fmtr " typechecker_trace { % a ; % a ; % a ; % a } " pp_kind t_kind pp_code_or_data code_or_data Size . pp_micheline_size micheline_size Size . pp consumed |
let workload_to_sparse_vec ( trace : t ) = let ( name , { Size . traversal ; int_bytes ; string_bytes } , consumed ) = match trace with | Typechecker_workload { t_kind ; code_or_data ; micheline_size ; consumed } -> let name = Format . asprintf " % a_ % a " pp_kind t_kind pp_code_or_data code_or_data in ( name , michel... |
let data_typechecker_workload ctxt t_kind micheline_node ex_ty = let open Protocol in match ex_ty with | Script_ir_translator . Ex_ty ty -> let ctxt = Gas_helpers . set_limit ctxt in Lwt_main . run ( Script_ir_translator . parse_data ctxt ~ legacy : false ~ allow_forged : false ty micheline_node |> Lwt . map Environmen... |
let code_typechecker_workload ( ctxt : Protocol . Alpha_context . context ) ( t_kind : kind ) ( code : Protocol . Alpha_context . Script . node ) ( bef : Protocol . Script_ir_translator . ex_stack_ty ) = let open Protocol in let ctxt = Gas_helpers . set_limit ctxt in let ( Script_ir_translator . Ex_stack_ty stack_ty ) ... |
let is_inline_attribute = function | { txt ( " = inline " " | ocaml . inline " ) } -> true | _ -> false |
let is_inlined_attribute = function | { txt ( " = inlined " " | ocaml . inlined " ) } -> true | { txt ( " = unrolled " " | ocaml . unrolled " ) } when Config . flambda -> true | _ -> false |
let is_specialise_attribute = function | { txt ( " = specialise " " | ocaml . specialise " ) } when Config . flambda -> true | _ -> false |
let is_specialised_attribute = function | { txt ( " = specialised " " | ocaml . specialised " ) } when Config . flambda -> true | _ -> false |
let is_local_attribute = function | { txt ( " = local " " | ocaml . local " ) } -> true | _ -> false |
let find_attribute p attributes = let inline_attribute , other_attributes = List . partition ( fun a -> p a . Parsetree . attr_name ) attributes in let attr = match inline_attribute with | [ ] -> None | [ attr ] -> Some attr | _ :: { Parsetree . attr_name = { txt ; loc } ; _ } :: _ -> Location . prerr_warning loc ( War... |
let is_unrolled = function | { txt " = unrolled " " | ocaml . unrolled " } -> true | { txt " = inline " " | ocaml . inline " " | inlined " " | ocaml . inlined " } -> false | _ -> assert false |
let get_id_payload = let open Parsetree in function | PStr [ ] -> Some " " | PStr [ { pstr_desc = Pstr_eval ( { pexp_desc } , [ ] ) } ] -> begin match pexp_desc with | Pexp_ident { txt = Longident . Lident id } -> Some id | _ -> None end | _ -> None |
let parse_id_payload txt loc ~ default ~ empty cases payload = let [ @ local ] warn ( ) = let ( %> ) f g x = g ( f x ) in let msg = cases |> List . map ( fst %> Printf . sprintf " ' % s ' " ) |> String . concat " , " |> Printf . sprintf " It must be either % s or empty " in Location . prerr_warning loc ( Warnings . Att... |
let parse_inline_attribute attr = match attr with | None -> Default_inline | Some { Parsetree . attr_name = { txt ; loc } as id ; attr_payload = payload } -> let open Parsetree in if is_unrolled id then begin let warning txt = Warnings . Attribute_payload ( txt , " It must be an integer literal " ) in match payload wit... |
let parse_specialise_attribute attr = match attr with | None -> Default_specialise | Some { Parsetree . attr_name = { txt ; loc } ; attr_payload = payload } -> parse_id_payload txt loc ~ default : Default_specialise ~ empty : Always_specialise [ " never " , Never_specialise ; " always " , Always_specialise ; ] payload |
let parse_local_attribute attr = match attr with | None -> Default_local | Some { Parsetree . attr_name = { txt ; loc } ; attr_payload = payload } -> parse_id_payload txt loc ~ default : Default_local ~ empty : Always_local [ " never " , Never_local ; " always " , Always_local ; " maybe " , Default_local ; ] payload |
let get_inline_attribute l = let attr , _ = find_attribute is_inline_attribute l in parse_inline_attribute attr |
let get_specialise_attribute l = let attr , _ = find_attribute is_specialise_attribute l in parse_specialise_attribute attr |
let get_local_attribute l = let attr , _ = find_attribute is_local_attribute l in parse_local_attribute attr |
let check_local_inline loc attr = match attr . local , attr . inline with | Always_local , ( Always_inline | Unroll _ ) -> Location . prerr_warning loc ( Warnings . Duplicated_attribute " local / inline " ) | _ -> ( ) |
let add_inline_attribute expr loc attributes = match expr , get_inline_attribute attributes with | expr , Default_inline -> expr | Lfunction ( { attr = { stub = false } as attr } as funct ) , inline -> begin match attr . inline with | Default_inline -> ( ) | Always_inline | Never_inline | Unroll _ -> Location . prerr_w... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.