Skip to content

Commit

Permalink
use #log to log events rather than a cell
Browse files Browse the repository at this point in the history
  • Loading branch information
dwightguth committed Sep 11, 2024
1 parent eea9f8c commit ac95dc6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/solidity.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ module SOLIDITY-CONFIGURATION
<contract-storage> .Map </contract-storage>
</live-contract>
</live-contracts>
<events> .List </events>
<next-address> 2p160 </next-address>
</exec>
</solidity>
Expand Down
14 changes: 12 additions & 2 deletions src/statement.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
module SOLIDITY-STATEMENT
imports SOLIDITY-CONFIGURATION
imports private SOLIDITY-EXPRESSION
imports private STRING-BUFFER
imports private K-IO
// expression statement
rule _:TypedVal ; => .K
Expand Down Expand Up @@ -52,10 +54,18 @@ module SOLIDITY-STATEMENT
<store> S => S [ !I <- default(T) ] </store>
// emit statement
rule <k> emit X:Id ( ARGS ) ; => .K ...</k>
<events>... .List => ListItem(event(X, ARGS)) </events>
rule <k> emit X:Id ( ARGS ) ; => #log(Event2String(ARGS, ((.StringBuffer +String Id2String(X)) +String "("))) ...</k>
requires isKResult(ARGS)
syntax String ::= Event2String(CallArgumentList, StringBuffer) [function]
rule Event2String(.CallArgumentList, SB) => StringBuffer2String(SB +String ")")
rule Event2String(v(V:MInt{112}, _), SB) => Event2String(.CallArgumentList, SB +String Int2String(MInt2Unsigned(V)))
rule Event2String(v(V:MInt{160}, _), SB) => Event2String(.CallArgumentList, SB +String Int2String(MInt2Unsigned(V)))
rule Event2String(v(V:MInt{256}, _), SB) => Event2String(.CallArgumentList, SB +String Int2String(MInt2Unsigned(V)))
rule Event2String(v(V:MInt{112}, _), ARGS, SB) => Event2String(ARGS, (SB +String Int2String(MInt2Unsigned(V))) +String ", ") [owise]
rule Event2String(v(V:MInt{160}, _), ARGS, SB) => Event2String(ARGS, (SB +String Int2String(MInt2Unsigned(V))) +String ", ") [owise]
rule Event2String(v(V:MInt{256}, _), ARGS, SB) => Event2String(ARGS, (SB +String Int2String(MInt2Unsigned(V))) +String ", ") [owise]
// if statement
rule if ( v(true, bool ) ) S => S
rule if ( v(false, bool ) ) _ => .K
Expand Down

0 comments on commit ac95dc6

Please sign in to comment.