1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2020 Metastate AG <hello@metastate.dev> *)(* *)(* 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. *)(* *)(*****************************************************************************)openAlpha_contextopenScript_typed_irletcompare_address(x,ex)(y,ey)=letlres=Contract.comparexyinifCompare.Int.(lres=0)thenCompare.String.compareexeyelselrestypecompare_comparable_cont=|Compare_comparable:'acomparable_ty*'a*'a*compare_comparable_cont->compare_comparable_cont|Compare_comparable_return:compare_comparable_contletcompare_comparable:typea.acomparable_ty->a->a->int=letreccompare_comparable:typea.acomparable_ty->compare_comparable_cont->a->a->int=funkindkxy->match(kind,x,y)with|(Unit_key_,(),())->(apply[@tailcall])0k|(Never_key_,_,_)->.|(Signature_key_,x,y)->(apply[@tailcall])(Signature.comparexy)k|(String_key_,x,y)->(apply[@tailcall])(Script_string.comparexy)k|(Bool_key_,x,y)->(apply[@tailcall])(Compare.Bool.comparexy)k|(Mutez_key_,x,y)->(apply[@tailcall])(Tez.comparexy)k|(Key_hash_key_,x,y)->(apply[@tailcall])(Signature.Public_key_hash.comparexy)k|(Key_key_,x,y)->(apply[@tailcall])(Signature.Public_key.comparexy)k|(Int_key_,x,y)->(apply[@tailcall])(Script_int.comparexy)k|(Nat_key_,x,y)->(apply[@tailcall])(Script_int.comparexy)k|(Timestamp_key_,x,y)->(apply[@tailcall])(Script_timestamp.comparexy)k|(Address_key_,x,y)->(apply[@tailcall])(compare_addressxy)k|(Bytes_key_,x,y)->(apply[@tailcall])(Compare.Bytes.comparexy)k|(Chain_id_key_,x,y)->(apply[@tailcall])(Chain_id.comparexy)k|(Pair_key((tl,_),(tr,_),_),(lx,rx),(ly,ry))->(compare_comparable[@tailcall])tl(Compare_comparable(tr,rx,ry,k))lxly|(Union_key((tl,_),_,_),Lx,Ly)->(compare_comparable[@tailcall])tlkxy|(Union_key_,L_,R_)->-1|(Union_key_,R_,L_)->1|(Union_key(_,(tr,_),_),Rx,Ry)->(compare_comparable[@tailcall])trkxy|(Option_key_,None,None)->(apply[@tailcall])0k|(Option_key_,None,Some_)->-1|(Option_key_,Some_,None)->1|(Option_key(t,_),Somex,Somey)->(compare_comparable[@tailcall])tkxyandapplyretk=match(ret,k)with|(0,Compare_comparable(ty,x,y,k))->(compare_comparable[@tailcall])tykxy|(0,Compare_comparable_return)->0|(ret,_)->(* ret <> 0, we perform an early exit *)ifCompare.Int.(ret>0)then1else-1infunt->compare_comparabletCompare_comparable_return[@@coq_axiom_with_reason"non top-level mutually recursive function"]