Skip to content

Commit

Permalink
Storage set_if_empty
Browse files Browse the repository at this point in the history
  • Loading branch information
virgil-serbanuta committed Sep 11, 2024
1 parent b212cb1 commit 31e98f4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions mx-rust-semantics/main/glue.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module MX-RUST-GLUE
...
</k>
<values> Values:Map => Values[ValueId <- V] </values>
requires ValueId >=Int 0
rule
(.K => mxRustEmptyValue(T))
Expand Down
33 changes: 33 additions & 0 deletions mx-rust-semantics/main/modules/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,38 @@ module MX-RUST-MODULES-STORAGE
...
</values>
rule
<k>
normalizedMethodCall
( #token("SingleValueMapper", "Identifier"):Identifier #as Type:Identifier
, #token("set_if_empty", "Identifier"):Identifier
, ( ptr(SelfId:Int)
, ptr(ValueId:Int)
, .NormalizedCallParams
)
)
=> MX#storageLoad(mxStringValue(StorageKey), rustDestination(-1, noType))
~> setIfEmpty
~> MX#storageStore(mxStringValue(StorageKey), wrappedRust(V))
...
</k>
<values>
SelfId |-> struct
( Type
, #token("storage_key", "Identifier"):Identifier |-> StorageKeyId:Int
_:Map
)
StorageKeyId |-> StorageKey:String
ValueId |-> V:Value
...
</values>
rule mxRustEmptyValue(noType) ~> storeHostValue(...) ~> setIfEmpty
=> .K
rule storeHostValue(... value: wrappedRust(_))
~> setIfEmpty ~> MX#storageStore(_)
=> .K
rule
<k>
normalizedMethodCall
Expand All @@ -75,6 +107,7 @@ module MX-RUST-MODULES-STORAGE
</values>
<next-value-id> NextId:Int => NextId +Int 1 </next-value-id>
syntax MxRustInstruction ::= "setIfEmpty"
endmodule
```
2 changes: 1 addition & 1 deletion mx-rust-semantics/main/representation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module MX-RUST-REPRESENTATION
| mxValueToRust(Type)
| mxRustLoadPtr(Int)
syntax MxRustType ::= "BigUint"
syntax MxRustType ::= "noType" | "BigUint"
syntax MxRustTypeOrError ::= MxRustType | SemanticsError
syntax Value ::= MxRustType
Expand Down

0 comments on commit 31e98f4

Please sign in to comment.