github.com/datachainlab/burrow@v0.25.0/execution/solidity/strange_loop.sol (about) 1 pragma solidity ^0.5.4; 2 3 contract StrangeLoop { 4 int top = 23; 5 int bottom = 34; 6 int depth = 17; 7 bool down = true; 8 // indexed puts it in topic 9 event ChangeLevel( 10 bytes32 indexed direction, 11 int indexed newDepth); 12 13 function UpsieDownsie() public returns (int i) { 14 i = depth; 15 if (down) { 16 if (depth < bottom) { 17 depth++; 18 emit ChangeLevel("Upsie!", depth); 19 i = depth; 20 this.UpsieDownsie(); 21 } else { 22 down = false; 23 i = depth; 24 this.UpsieDownsie(); 25 } 26 } else if (depth > top) { 27 depth--; 28 emit ChangeLevel("Downsie!", depth); 29 i = depth; 30 this.UpsieDownsie(); 31 } else { 32 down = true; 33 i = depth; 34 return 0; 35 } 36 } 37 }