text stringlengths 0 601k |
|---|
let force_decode_cost lexpr = Data_encoding . apply_lazy ~ fun_value ( : fun _ -> Gas_limit_repr . free ) ~ fun_bytes ( : fun b -> deserialization_cost_estimated_from_bytes ( Bytes . length b ) ) ~ fun_combine ( : fun _ _ -> Gas_limit_repr . free ) lexpr |
let stable_force_decode_cost lexpr = let has_bytes = Data_encoding . apply_lazy ~ fun_value ( : fun v -> ` Only_value v ) ~ fun_bytes ( : fun b -> ` Has_bytes b ) ~ fun_combine ( : fun _v b -> b ) lexpr in match has_bytes with | ` Has_bytes b -> deserialization_cost_estimated_from_bytes ( Bytes . length b ) | ` Only_va... |
let force_decode lexpr = match Data_encoding . force_decode lexpr with | Some v -> ok v | None -> error Lazy_script_decode |
let force_bytes_cost expr = Data_encoding . apply_lazy ~ fun_value ( : fun v -> serialization_cost ( expr_size v ) ) ~ fun_bytes ( : fun _ -> Gas_limit_repr . free ) ~ fun_combine ( : fun _ _ -> Gas_limit_repr . free ) expr |
let force_bytes expr = Error_monad . catch_f ( fun ( ) -> Data_encoding . force_bytes expr ) ( fun _ -> Lazy_script_decode ) |
let unit = Micheline . strip_locations ( Prim ( 0 , Michelson_v1_primitives . D_Unit , [ ] , [ ] ) ) |
let unit_parameter = lazy_expr unit |
let is_unit_parameter = let unit_bytes = Data_encoding . force_bytes unit_parameter in Data_encoding . apply_lazy ~ fun_value ( : fun v -> match Micheline . root v with | Prim ( _ , Michelson_v1_primitives . D_Unit , [ ] , [ ] ) -> true | _ -> false ) ~ fun_bytes ( : fun b -> Compare . Bytes . equal b unit_bytes ) ~ fu... |
let rec micheline_fold_aux node f acc k = match node with | Micheline . Int ( _ , _ ) -> k ( f acc node ) | Micheline . String ( _ , _ ) -> k ( f acc node ) | Micheline . Bytes ( _ , _ ) -> k ( f acc node ) | Micheline . Prim ( _ , _ , subterms , _ ) -> micheline_fold_nodes subterms f ( f acc node ) k | Micheline . Seq... |
let fold node init f = micheline_fold_aux node f init ( fun x -> x ) |
let micheline_nodes node = fold node 0 @@ fun n _ -> n + 1 |
let strip_locations_cost node = let nodes = micheline_nodes node in cost_micheline_strip_locations nodes |
let strip_annotations_cost node = let nodes = micheline_nodes node in cost_micheline_strip_annotations nodes |
module Script_repr_shared_config = struct type config = unit let config_encoding = Data_encoding . unit let default_config = ( ) type workload = { micheline_nodes : int } let workload_encoding = let open Data_encoding in conv ( fun { micheline_nodes } -> micheline_nodes ) ( fun micheline_nodes -> { micheline_nodes } ) ... |
module Sampler = Micheline_sampler . Make ( struct type prim = Michelson_v1_primitives . prim let sample_prim : Michelson_v1_primitives . prim Base_samplers . sampler = fun _rng_state -> I_ADD let sample_annots : string list Base_samplers . sampler = fun _rng_state -> [ ] let sample_string = Base_samplers . uniform_str... |
module Micheline_nodes_benchmark : Benchmark . S = struct include Script_repr_shared_config let name = " MICHELINE_NODES " let info = " Benchmarking the time it takes to compute the number of nodes of a \ Micheline term " let size_based_model = Model . make ~ conv ( : function { micheline_nodes } -> ( micheline_nodes ,... |
let ( ) = Registration_helpers . register ( module Micheline_nodes_benchmark ) |
module Script_repr_strip_annotations : Benchmark . S = struct include Script_repr_shared_config let name = " strip_annotations " let info = " Benchmarking Script_repr . strip_annotations " let strip_annotations_model = Model . ( make ~ conv ( : fun { micheline_nodes } -> ( micheline_nodes , ( ) ) ) ~ model ( : linear ~... |
let ( ) = Registration_helpers . register ( module Script_repr_strip_annotations ) |
let htl_expr = Hashtbl . create 64 |
let htl_used = Hashtbl . create 64 |
let htl_stri = Hashtbl . create 16 |
let foreign_used = ref false |
let c_source = ref None |
let clear ( ) = Hashtbl . clear htl_expr ; Hashtbl . clear htl_stri ; Hashtbl . clear htl_used ; foreign_used := false ; c_source := None |
type merlin_state = { hexpr : ( Marshal_types . id * Mparsetree . Ast_cur . Parsetree . expression ) list ; hstri : ( Marshal_types . id * Mparsetree . Ast_cur . Parsetree . structure_item ) list ; hused : ( int * unit ) list ; fused : bool ; } |
let merlin_save ( ) = { hexpr = CCHashtbl . Poly . to_list htl_expr ; hused = CCHashtbl . Poly . to_list htl_used ; hstri = CCHashtbl . Poly . to_list htl_stri ; fused = ! foreign_used ; } |
let merlin_restore { hexpr ; hused ; hstri ; fused } = let set htl l = Hashtbl . clear htl ; List . iter ( fun ( a , b ) -> Hashtbl . add htl a b ) l in set htl_expr hexpr ; set htl_used hused ; set htl_stri hstri ; foreign_used := fused |
let make x = Set_tag x |
let get ( Set_tag x ) = x |
let empty : type a . a comparable_ty -> a set = fun ty -> let module OPS : Boxed_set_OPS with type elt = a = Set . Make ( struct type t = a let compare = Script_comparable . compare_comparable ty end ) in Set_tag ( module struct type elt = a let elt_ty = ty module OPS = OPS let boxed = OPS . empty let size = 0 end ) |
let update : type a . a -> bool -> a set -> a set = fun v b ( Set_tag ( module Box ) ) -> Set_tag ( module struct type elt = a let elt_ty = Box . elt_ty module OPS = Box . OPS let boxed = if b then Box . OPS . add v Box . boxed else Box . OPS . remove v Box . boxed let size = let mem = Box . OPS . mem v Box . boxed in ... |
let mem : type elt . elt -> elt set -> bool = fun v ( Set_tag ( module Box ) ) -> Box . OPS . mem v Box . boxed |
let fold : type elt acc . ( elt -> acc -> acc ) -> elt set -> acc -> acc = fun f ( Set_tag ( module Box ) ) -> Box . OPS . fold f Box . boxed |
let size : type elt . elt set -> Script_int . n Script_int . num = fun ( Set_tag ( module Box ) ) -> Script_int . ( abs ( of_int Box . size ) ) |
type t = String_tag of repr [ @@ ocaml . unboxed ] |
type error += Non_printable_character of ( int * string ) |
let ( ) = let open Data_encoding in register_error_kind ` Permanent ~ id " : michelson_v1 . non_printable_character " ~ title " : Non printable character in a Michelson string " ~ description : " Michelson strings are only allowed to contain printable characters \ ( either the newline character or characters in the [ 3... |
let empty = String_tag " " |
let of_string v = let rec check_printable_ascii i = if Compare . Int . ( i < 0 ) then ok ( String_tag v ) else match v . [ i ] with | ' \ n ' | ' \ x20 ' . . ' \ x7E ' -> check_printable_ascii ( i - 1 ) | _ -> error @@ Non_printable_character ( i , v ) in check_printable_ascii ( String . length v - 1 ) |
let to_string ( String_tag s ) = s |
let compare ( String_tag x ) ( String_tag y ) = Compare . String . compare x y |
let length ( String_tag s ) = String . length s |
let concat_pair ( String_tag x ) ( String_tag y ) = String_tag ( x ^ y ) |
let concat l = let l = List . map ( fun ( String_tag s ) -> s ) l in String_tag ( String . concat " " l ) |
let sub ( String_tag s ) offset length = String_tag ( String . sub s offset length ) |
type callsite = | Toplevel : { storage_type : ' sto ty ; param_type : ' param ty ; entrypoints : ' param Script_typed_ir . entrypoints ; } -> callsite | View : callsite | Data : callsite |
type t = { callsite : callsite ; in_lambda : in_lambda } |
let init callsite = { callsite ; in_lambda = false } |
let toplevel ~ storage_type ~ param_type ~ entrypoints = init ( Toplevel { storage_type ; param_type ; entrypoints } ) |
let view = init View |
let data = init Data |
let add_lambda tc_context = { tc_context with in_lambda = true } |
let is_in_lambda { callsite = _ ; in_lambda } = in_lambda |
let check_not_in_view loc ~ legacy tc_context prim = match tc_context . callsite with | Toplevel _ | Data -> Result . return_unit | View when is_in_lambda tc_context || legacy -> Result . return_unit | View -> error Script_tc_errors . ( Forbidden_instr_in_context ( loc , View , prim ) ) |
type kind = Int_kind | String_kind | Bytes_kind | Prim_kind | Seq_kind |
type unparsed_stack_ty = Script . expr list |
type type_map = ( Script . location * ( unparsed_stack_ty * unparsed_stack_ty ) ) list |
type error += Invalid_arity of Script . location * prim * int * int |
type error += Invalid_seq_arity of Script . location * int * int |
type error += | Invalid_namespace of Script . location * prim * Michelson_v1_primitives . namespace * Michelson_v1_primitives . namespace |
type error += Invalid_primitive of Script . location * prim list * prim |
type error += Invalid_kind of Script . location * kind list * kind |
type error += Invalid_never_expr of Script . location |
type error += Missing_field of prim |
type error += Duplicate_field of Script . location * prim |
type error += Unexpected_lazy_storage of Script . location |
type error += Unexpected_operation of Script . location |
type error += Unexpected_contract of Script . location |
type error += No_such_entrypoint of Entrypoint . t |
type error += Duplicate_entrypoint of Entrypoint . t |
type error += Unreachable_entrypoint of prim list |
type error += Fail_not_in_tail_position of Script . location |
type error += | Undefined_binop : Script . location * prim * Script . expr * Script . expr -> error |
type error += Undefined_unop : Script . location * prim * Script . expr -> error |
type error += | Bad_return : Script . location * unparsed_stack_ty * Script . expr -> error |
type error += | Bad_stack : Script . location * prim * int * unparsed_stack_ty -> error |
type error += | Unmatched_branches : Script . location * unparsed_stack_ty * unparsed_stack_ty -> error |
type error += View_name_too_long of string |
type error += Bad_view_name of Script . location |
type error += | Ill_typed_view of { loc : Script . location ; actual : unparsed_stack_ty ; expected : unparsed_stack_ty ; } |
type error += Duplicated_view_name of Script . location |
type context_desc = Lambda | View |
type error += | Forbidden_instr_in_context of Script . location * context_desc * prim |
type error += Bad_stack_item of int |
type error += Unexpected_annotation of Script . location |
type error += Ungrouped_annotations of Script . location |
type error += Invalid_map_body : Script . location * unparsed_stack_ty -> error |
type error += Invalid_map_block_fail of Script . location |
type error += | Invalid_iter_body : Script . location * unparsed_stack_ty * unparsed_stack_ty -> error |
type error += Type_too_large : Script . location * int -> error |
type error += Pair_bad_argument of Script . location |
type error += Unpair_bad_argument of Script . location |
type error += Dup_n_bad_argument of Script . location |
type error += Dup_n_bad_stack of Script . location |
type error += | Invalid_constant : Script . location * Script . expr * Script . expr -> error |
type error += | Invalid_syntactic_constant : Script . location * Script . expr * string -> error |
type error += Invalid_contract of Script . location * Contract . t |
type error += Invalid_big_map of Script . location * Big_map . Id . t |
type error += Comparable_type_expected : Script . location * Script . expr -> error |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.