Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file michelson_v1_stack.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2023 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)openTezos_michelineopenProtocolopenAlpha_contexttypeerror+=|Wrong_stack_itemofMicheline_parser.location*Micheline_printer.node|Wrong_stackofMicheline_parser.location*Micheline_printer.nodeletmicheline_printer_location_encoding:Micheline_printer.locationData_encoding.encoding=letopenData_encodinginconv(funloc->loc.Micheline_printer.comment)(funcomment->{comment})(optionstring)letmicheline_printer_node_encoding:Micheline_printer.nodeData_encoding.encoding=Micheline_encoding.table_encoding~variant:""micheline_printer_location_encodingData_encoding.stringlet()=letopenData_encodinginProtocol_client_context.register_error_kind`Permanent~id:"michelson.stack.wrong_stack_item"~title:"Wrong stack item"~description:"Failed to parse an item in a typed stack."~pp:(funppf(_loc,node)->Format.fprintfppf"Unexpected format for an item in a typed stack. Expected: Stack_elt \
<ty> <value>; got %a."Micheline_printer.print_expr_unwrappednode)(obj2(req"location"Micheline_parser.location_encoding)(req"node"micheline_printer_node_encoding))(functionWrong_stack_item(loc,node)->Some(loc,node)|_->None)(fun(loc,node)->Wrong_stack_item(loc,node));Protocol_client_context.register_error_kind`Permanent~id:"michelson.stack.wrong_stack"~title:"Wrong stack"~description:"Failed to parse a typed stack."~pp:(funppf(_loc,node)->Format.fprintfppf"Unexpected format for a typed stack. Expected a sequence of Stack_elt \
<ty> <value>; got %a."Micheline_printer.print_expr_unwrappednode)(obj2(req"location"Micheline_parser.location_encoding)(req"node"micheline_printer_node_encoding))(functionWrong_stack(loc,node)->Some(loc,node)|_->None)(fun(loc,node)->Wrong_stack(loc,node))letparse_expression~source(node:Micheline_parser.node):Script.exprtzresult=letopenResult_syntaxinletparsing_result=Michelson_v1_parser.expand_all~source~original:nodeinlet+parsed=Micheline_parser.no_parsing_errorparsing_resultinparsed.expandedletprintablenode=Micheline_printer.printableFun.id(Micheline.strip_locationsnode)letparse_stack_item~source=letopenResult_syntaxinfunction|Micheline.Prim(_loc,"Stack_elt",[ty;v],_annot)->let*ty=parse_expression~sourcetyinlet+v=parse_expression~sourcevin(ty,v)|e->error(Wrong_stack_item(Micheline.locatione,printablee))letparse_stack~source=function|Micheline.Seq(loc,l)ase->record_trace(Wrong_stack(loc,printablee))@@List.map_e(parse_stack_item~source)l|e->error(Wrong_stack(Micheline.locatione,printablee))