Skip to content

Commit

Permalink
Rename NormalizedCallParams (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
virgil-serbanuta authored Sep 23, 2024
1 parent 067c58f commit 0daa578
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion mx-rust-semantics/main/modules/biguint.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module MX-RUST-MODULES-BIGUINT
( #token("BigUint", "Identifier"):Identifier
, #token("from", "Identifier"):Identifier
, ( ptr(ValueId:Int)
, .NormalizedCallParams
, .PtrList
)
)
// TODO: Should check that V >= 0
Expand Down
8 changes: 4 additions & 4 deletions mx-rust-semantics/main/modules/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module MX-RUST-MODULES-STORAGE
, #token("new", "Identifier"):Identifier
, ( ptr(KeyId:Int)
, ptr(ResultTypeId:Int)
, .NormalizedCallParams
, .PtrList
)
)
=> mxRustNewValue
Expand All @@ -32,7 +32,7 @@ module MX-RUST-MODULES-STORAGE
, #token("set", "Identifier"):Identifier
, ( ptr(SelfId:Int)
, ptr(ValueId:Int)
, .NormalizedCallParams
, .PtrList
)
)
=> rustValuesToMx((V, .ValueList), (mxStringValue(StorageKey), .MxValueList)) ~> MX#storageStore
Expand All @@ -56,7 +56,7 @@ module MX-RUST-MODULES-STORAGE
, #token("set_if_empty", "Identifier"):Identifier
, ( ptr(SelfId:Int)
, ptr(ValueId:Int)
, .NormalizedCallParams
, .PtrList
)
)
=> MX#storageLoad(mxStringValue(StorageKey), rustDestination(-1, noType))
Expand Down Expand Up @@ -89,7 +89,7 @@ module MX-RUST-MODULES-STORAGE
( #token("SingleValueMapper", "Identifier"):Identifier #as Type:Identifier
, #token("get", "Identifier"):Identifier
, ( ptr(SelfId:Int)
, .NormalizedCallParams
, .PtrList
)
)
=> MX#storageLoad(mxStringValue(StorageKey), rustDestination(NextId, ResultType))
Expand Down
8 changes: 4 additions & 4 deletions rust-semantics/execution/calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ module RUST-CALLS
// https://doc.rust-lang.org/stable/reference/expressions/method-call-expr.html
syntax Instruction ::= "clearLocalState"
| setArgs(NormalizedCallParams, NormalizedFunctionParameterList)
| setArgs(PtrList, NormalizedFunctionParameterList)
rule
<k>
normalizedMethodCall(
TraitName:TypePath,
MethodName:Identifier,
Args:NormalizedCallParams
Args:PtrList
) => pushLocalState
~> clearLocalState
~> setArgs(Args, Params)
Expand All @@ -42,12 +42,12 @@ module RUST-CALLS
<locals> _ => .Map </locals>
rule setArgs
( (CP:Ptr, CPs:NormalizedCallParams)
( (CP:Ptr, CPs:PtrList)
, (P:NormalizedFunctionParameter, Ps:NormalizedFunctionParameterList)
)
=> setArg(CP, P) ~> setArgs(CPs, Ps)
rule setArgs(.NormalizedCallParams, .NormalizedFunctionParameterList) => .K
rule setArgs(.PtrList, .NormalizedFunctionParameterList) => .K
syntax Instruction ::= setArg(Ptr, NormalizedFunctionParameter)
Expand Down
28 changes: 14 additions & 14 deletions rust-semantics/expression/calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ module RUST-EXPRESSION-CALLS
( traitName: TypePath
, method: Identifier
, params: CallParamsList
, reversedNormalizedParams: NormalizedCallParams
, reversedNormalizedParams: PtrList
)
syntax Instruction ::= staticMethodCall
( traitName: TypePath
, method: Identifier
, params: CallParamsList
, reversedNormalizedParams: NormalizedCallParams
, reversedNormalizedParams: PtrList
)
syntax Instruction ::= reverseNormalizeParams
( params: CallParamsList
, reversedNormalizedParams: NormalizedCallParams
, reversedNormalizedParams: PtrList
)
syntax NormalizedCallParams ::= reverse(NormalizedCallParams, NormalizedCallParams) [function, total]
rule reverse(.NormalizedCallParams, R:NormalizedCallParams) => R
rule reverse((P, Ps:NormalizedCallParams), R:NormalizedCallParams) => reverse(Ps, (P, R))
syntax PtrList ::= reverse(PtrList, PtrList) [function, total]
rule reverse(.PtrList, R:PtrList) => R
rule reverse((P, Ps:PtrList), R:PtrList) => reverse(Ps, (P, R))
rule SelfName:Expression . MethodName:Identifier ( )
=> methodCall(... self: SelfName, method: MethodName, params: .CallParamsList)
Expand All @@ -41,7 +41,7 @@ module RUST-EXPRESSION-CALLS
( .K
=> reverseNormalizeParams
(... params: Args
, reversedNormalizedParams: P, .NormalizedCallParams
, reversedNormalizedParams: P, .PtrList
)
~> TraitName
)
Expand All @@ -58,7 +58,7 @@ module RUST-EXPRESSION-CALLS
rule
( reverseNormalizeParams
(... params: .CallParamsList
, reversedNormalizedParams: Args:NormalizedCallParams
, reversedNormalizedParams: Args:PtrList
)
~> TraitName:TypePath
~> methodCall
Expand All @@ -70,19 +70,19 @@ module RUST-EXPRESSION-CALLS
=> normalizedMethodCall
( TraitName
, MethodName
, reverse(Args, .NormalizedCallParams)
, reverse(Args, .PtrList)
)
rule reverseNormalizeParams
(... params: (ptrValue(ptr(_) #as P:Ptr, _:Value) , Cps:CallParamsList) => Cps
, reversedNormalizedParams: Args:NormalizedCallParams
, reversedNormalizedParams: Args:PtrList
=> P, Args
)
rule
<k>
reverseNormalizeParams
(... params: (ptrValue(null, V:Value) , Cps:CallParamsList) => Cps
, reversedNormalizedParams: Args:NormalizedCallParams
, reversedNormalizedParams: Args:PtrList
=> ptr(NextId), Args
)
...
Expand All @@ -103,7 +103,7 @@ module RUST-EXPRESSION-CALLS
( .K
=> reverseNormalizeParams
(... params: Args
, reversedNormalizedParams: .NormalizedCallParams
, reversedNormalizedParams: .PtrList
)
)
~> staticMethodCall
Expand All @@ -116,7 +116,7 @@ module RUST-EXPRESSION-CALLS
rule
( reverseNormalizeParams
(... params: .CallParamsList
, reversedNormalizedParams: Args:NormalizedCallParams
, reversedNormalizedParams: Args:PtrList
)
~> staticMethodCall
(... trait: TraitName:TypePath
Expand All @@ -127,7 +127,7 @@ module RUST-EXPRESSION-CALLS
=> normalizedMethodCall
( TraitName
, MethodName
, reverse(Args, .NormalizedCallParams)
, reverse(Args, .PtrList)
)
// Apparently contexts need the type of the HOLE to be K, and I'm not sure
Expand Down
4 changes: 2 additions & 2 deletions rust-semantics/representation.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ module RUST-REPRESENTATION
syntax NormalizedFunctionParameter ::= ValueName ":" Type
syntax NormalizedFunctionParameterList ::= List{NormalizedFunctionParameter, ","}
syntax NormalizedCallParams ::=List{Ptr, ","}
syntax PtrList ::=List{Ptr, ","}
syntax Instruction ::= normalizedMethodCall(TypePath, Identifier, NormalizedCallParams)
syntax Instruction ::= normalizedMethodCall(TypePath, Identifier, PtrList)
| implicitCastTo(Type)
| methodCall
( self: Expression
Expand Down
8 changes: 4 additions & 4 deletions rust-semantics/test/execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ module RUST-EXECUTION-TEST
rule
<k>
call P:TypePath . Name:Identifier
=> buildTestMethodCall(P, Name, .NormalizedCallParams, paramsLength(Params))
=> buildTestMethodCall(P, Name, .PtrList, paramsLength(Params))
...
</k>
<trait-path> P </trait-path>
<method-name> Name </method-name>
<method-params> Params </method-params>
syntax TestExecution ::= buildTestMethodCall(TypePath, Identifier, NormalizedCallParams, Int)
syntax TestExecution ::= buildTestMethodCall(TypePath, Identifier, PtrList, Int)
rule
<k>
buildTestMethodCall(
_TraitName:TypePath,
_MethodName:Identifier,
Args:NormalizedCallParams => (ValueId , Args),
Args:PtrList => (ValueId , Args),
ParamCount:Int => ParamCount -Int 1
)
...
Expand All @@ -70,7 +70,7 @@ module RUST-EXECUTION-TEST
buildTestMethodCall(
TraitName:TypePath,
MethodName:Identifier,
Args:NormalizedCallParams,
Args:PtrList,
0
) => normalizedMethodCall(TraitName, MethodName, Args)
Expand Down

0 comments on commit 0daa578

Please sign in to comment.