diff --git a/src/komet/kdist/soroban-semantics/host/map.md b/src/komet/kdist/soroban-semantics/host/map.md index e36304a..2a6da9a 100644 --- a/src/komet/kdist/soroban-semantics/host/map.md +++ b/src/komet/kdist/soroban-semantics/host/map.md @@ -60,6 +60,37 @@ module HOST-MAP ``` +## map_del + +```k + rule [hostfun-map-del]: + hostCall ( "m" , "2" , [ i64 i64 .ValTypes ] -> [ i64 .ValTypes ] ) + => loadObjectFull(HostVal(KEY)) + ~> loadObject(HostVal(M)) + ~> hostCallAux("m", "2") + ... + + + 0 |-> < i64 > M + 1 |-> < i64 > KEY + + + rule [hostCallAux-map-del]: + hostCallAux("m", "2") + => allocObject(ScMap( M [ KEY <- undef ] )) + ~> returnHostVal + ... + + ScMap(M) : KEY:ScVal : S => S + requires KEY in_keys(M) + + rule [hostCallAux-map-del-not-found]: + hostCallAux("m", "2") => trap ... + ScMap(M) : KEY:ScVal : S => S + requires notBool( KEY in_keys(M) ) + +``` + ## map_len ```k diff --git a/src/tests/integration/data/map.wast b/src/tests/integration/data/map.wast index ebb2697..bcc9996 100644 --- a/src/tests/integration/data/map.wast +++ b/src/tests/integration/data/map.wast @@ -120,4 +120,24 @@ callTx( U32(123) ) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; map_del +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +callTx( + Account(b"test-caller"), + Contract(b"test-sc"), + "del", + ListItem(ScMap( + Symbol(str("foo")) |-> U32(123) + Symbol(str("bar")) |-> Symbol(str("456")) + Symbol(str("baz")) |-> U128(789) + )) + ListItem(Symbol(str("foo"))), + ScMap( + Symbol(str("bar")) |-> Symbol(str("456")) + Symbol(str("baz")) |-> U128(789) + ) +) + setExitCode(0) \ No newline at end of file