Skip to content

Commit

Permalink
Default storage values
Browse files Browse the repository at this point in the history
  • Loading branch information
Virgil Serbanuta authored and virgil-serbanuta committed Sep 11, 2024
1 parent 708d1ea commit b212cb1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
14 changes: 13 additions & 1 deletion mx-rust-semantics/main/glue.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,26 @@ module MX-RUST-GLUE
rule
<k>
storeHostValue
(... destination: rustDestination(ValueId)
(... destination: rustDestination(ValueId, _:MxRustType)
, value: wrappedRust(V:Value)
)
=> .K
...
</k>
<values> Values:Map => Values[ValueId <- V] </values>
rule
(.K => mxRustEmptyValue(T))
~> storeHostValue
(... destination: rustDestination(_, T:MxRustType)
, value: mxWrappedEmpty
)
rule
(ptrValue(_, V:Value) => .K)
~> storeHostValue
(... value: mxWrappedEmpty => wrappedRust(V)
)
rule
<k>
mxRustLoadPtr(P:Int) => ptrValue(ptr(P), V)
Expand Down
2 changes: 2 additions & 0 deletions mx-rust-semantics/main/modules/biguint.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ module MX-RUST-MODULES-BIGUINT
)
)
rule mxRustEmptyValue(BigUint) => mxRustBigIntNew(0)
endmodule
```
4 changes: 3 additions & 1 deletion mx-rust-semantics/main/modules/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,19 @@ module MX-RUST-MODULES-STORAGE
, .NormalizedCallParams
)
)
=> MX#storageLoad(mxStringValue(StorageKey), rustDestination(NextId))
=> MX#storageLoad(mxStringValue(StorageKey), rustDestination(NextId, ResultType))
~> mxRustLoadPtr(NextId)
...
</k>
<values>
SelfId |-> struct
( Type
, #token("storage_key", "Identifier"):Identifier |-> StorageKeyId:Int
#token("result_type", "Identifier"):Identifier |-> ResultTypeId:Int
_:Map
)
StorageKeyId |-> StorageKey:String
ResultTypeId |-> ResultType:MxRustType
...
</values>
<next-value-id> NextId:Int => NextId +Int 1 </next-value-id>
Expand Down
3 changes: 2 additions & 1 deletion mx-rust-semantics/main/representation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module MX-RUST-REPRESENTATION
syntax MxRustInstruction ::= "mxRustPreprocessTraits"
| mxRustPreprocessMethods(TypePath)
| mxRustNewValue(ValueOrError)
| mxRustEmptyValue(MxRustType)
| mxValueToRust(Type)
| mxRustLoadPtr(Int)
Expand All @@ -21,7 +22,7 @@ module MX-RUST-REPRESENTATION
syntax Expression ::= concatString(Expression, Expression) [seqstrict]
| toString(Expression) [strict]
syntax MxValue ::= rustDestination(Int)
syntax MxValue ::= rustDestination(Int, MxRustType)
endmodule
```
6 changes: 3 additions & 3 deletions mx-semantics/test/execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module MX-TEST-EXECUTION-PARSING-SYNTAX
| setCallee(String)
| addAccount(String)
| setBalance(account:String, token:String, nonce:Int, value:Int)
| setStorage(account:String, key:String, value:MxValue)
| setStorage(account:String, key:String, value:MxWrappedValue)
| setBlockTimestamp(Int)
| setMockCode(String, MxValue)
Expand Down Expand Up @@ -238,7 +238,7 @@ module MX-ACCOUNTS-TEST
<k> setStorage
(... account: Account:String
, key: Key:String
, value: Value:MxValue
, value: Value:MxWrappedValue
) => .K
...
</k>
Expand All @@ -251,7 +251,7 @@ module MX-ACCOUNTS-TEST
<k> setStorage
(... account: Account:String
, key: Key:String
, value: Value:MxValue
, value: Value:MxWrappedValue
) => .K
...
</k>
Expand Down

0 comments on commit b212cb1

Please sign in to comment.