Skip to content

Commit

Permalink
use #log to log events rather than a cell (#29)
Browse files Browse the repository at this point in the history
* use #log to log events rather than a cell

* update tests

* update tests
  • Loading branch information
dwightguth authored Sep 11, 2024
1 parent 53aacb1 commit 672411a
Show file tree
Hide file tree
Showing 18 changed files with 15,209 additions and 15,241 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ test-aave:
test-regression: ${REGRESSION_TESTS}

$(REGRESSION_TESTS): %.out: %.sol %.txn %.ref $(SEMANTICS_FILE_NAME)-kompiled/timestamp
ulimit -s 65536 && bin/krun-sol $*.sol $*.txn > $*.out
ulimit -s 65536 && bin/krun-sol $*.sol $*.txn > $*.out 2>&1
diff -U3 -w $*.ref $*.out

test-examples: ${EXAMPLE_TESTS}

.SECONDEXPANSION:
$(EXAMPLE_TESTS): %.out: $$(subst $(TRANSACTIONS_DIR), $(EXAMPLES_DIR), $$(@D)).sol %.txn %.ref $(SEMANTICS_FILE_NAME)-kompiled/timestamp
ulimit -s 65536 && bin/krun-sol $< $*.txn > $*.out
ulimit -s 65536 && bin/krun-sol $< $*.txn > $*.out 2>&1
diff -U3 -w $*.ref $*.out
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
3 changes: 0 additions & 3 deletions test/regression/arithmetic.ref
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@
</contract-storage>
</live-contract>
</live-contracts>
<events>
.List
</events>
<next-address>
3p160
</next-address>
Expand Down
3 changes: 0 additions & 3 deletions test/regression/arraystestcontract.ref
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@
</contract-storage>
</live-contract>
</live-contracts>
<events>
.List
</events>
<next-address>
3p160
</next-address>
Expand Down
3 changes: 0 additions & 3 deletions test/regression/block.ref
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@
</contract-storage>
</live-contract>
</live-contracts>
<events>
.List
</events>
<next-address>
3p160
</next-address>
Expand Down
3 changes: 0 additions & 3 deletions test/regression/boolean.ref
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@
</contract-storage>
</live-contract>
</live-contracts>
<events>
.List
</events>
<next-address>
3p160
</next-address>
Expand Down
3 changes: 0 additions & 3 deletions test/regression/contract.ref
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,6 @@
</contract-storage>
</live-contract>
</live-contracts>
<events>
.List
</events>
<next-address>
3p160
</next-address>
Expand Down
4 changes: 1 addition & 3 deletions test/regression/emit.ref
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Approval(1, 0, 2)
<solidity>
<k>
.K
Expand Down Expand Up @@ -113,9 +114,6 @@
</contract-storage>
</live-contract>
</live-contracts>
<events>
ListItem ( event (... name: Approval , args: v ( 1p160 , address ) , v ( 0p160 , address ) , v ( 2p160 , address ) , .TypedVals ) )
</events>
<next-address>
3p160
</next-address>
Expand Down
3 changes: 0 additions & 3 deletions test/regression/eventtestcontract.ref
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,6 @@
</contract-storage>
</live-contract>
</live-contracts>
<events>
.List
</events>
<next-address>
3p160
</next-address>
Expand Down
3 changes: 0 additions & 3 deletions test/regression/for.ref
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@
</contract-storage>
</live-contract>
</live-contracts>
<events>
.List
</events>
<next-address>
3p160
</next-address>
Expand Down
3 changes: 0 additions & 3 deletions test/regression/function.ref
Original file line number Diff line number Diff line change
Expand Up @@ -2181,9 +2181,6 @@
</contract-storage>
</live-contract>
</live-contracts>
<events>
.List
</events>
<next-address>
11p160
</next-address>
Expand Down
3 changes: 0 additions & 3 deletions test/regression/if.ref
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@
</contract-storage>
</live-contract>
</live-contracts>
<events>
.List
</events>
<next-address>
3p160
</next-address>
Expand Down
3 changes: 0 additions & 3 deletions test/regression/increment.ref
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@
</contract-storage>
</live-contract>
</live-contracts>
<events>
.List
</events>
<next-address>
3p160
</next-address>
Expand Down
3 changes: 0 additions & 3 deletions test/regression/mapstestcontract.ref
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@
</contract-storage>
</live-contract>
</live-contracts>
<events>
.List
</events>
<next-address>
3p160
</next-address>
Expand Down
Loading

0 comments on commit 672411a

Please sign in to comment.