Skip to content

Commit

Permalink
adding example
Browse files Browse the repository at this point in the history
  • Loading branch information
tutugordillo committed Oct 22, 2024
1 parent cf47642 commit a65937c
Show file tree
Hide file tree
Showing 3 changed files with 249 additions and 0 deletions.
135 changes: 135 additions & 0 deletions examples/if/if-asm-solc.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
".code": [
{
"begin": 64,
"end": 70,
"name": "PUSH",
"source": -1,
"value": "101"
},
{
"begin": 58,
"end": 62,
"name": "PUSH",
"source": -1,
"value": "1"
},
{
"begin": 51,
"end": 71,
"name": "SSTORE",
"source": -1
},
{
"begin": 100,
"end": 101,
"name": "PUSH",
"source": -1,
"value": "0"
},
{
"begin": 87,
"end": 102,
"name": "CALLDATALOAD",
"source": -1
},
{
"begin": 84,
"end": 127,
"name": "PUSH [tag]",
"source": -1,
"value": "1"
},
{
"begin": 84,
"end": 127,
"name": "JUMPI",
"source": -1
},
{
"begin": 27,
"end": 176,
"name": "tag",
"source": -1,
"value": "2"
},
{
"begin": 27,
"end": 176,
"name": "JUMPDEST",
"source": -1
},
{
"begin": 154,
"end": 159,
"name": "PUSH",
"source": -1,
"value": "3"
},
{
"begin": 140,
"end": 160,
"name": "DUP1",
"source": -1
},
{
"begin": 140,
"end": 160,
"name": "SSTORE",
"source": -1
},
{
"begin": 27,
"end": 176,
"name": "STOP",
"source": -1
},
{
"begin": 103,
"end": 127,
"name": "tag",
"source": -1,
"value": "1"
},
{
"begin": 103,
"end": 127,
"name": "JUMPDEST",
"source": -1
},
{
"begin": 118,
"end": 124,
"name": "PUSH",
"source": -1,
"value": "202"
},
{
"begin": 112,
"end": 116,
"name": "PUSH",
"source": -1,
"value": "2"
},
{
"begin": 105,
"end": 125,
"name": "SSTORE",
"source": -1
},
{
"begin": 103,
"end": 127,
"name": "PUSH [tag]",
"source": -1,
"value": "2"
},
{
"begin": 103,
"end": 127,
"name": "JUMP",
"source": -1
}
],
"sourceList": []
}
77 changes: 77 additions & 0 deletions examples/if/if.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"object": {
"blocks": [
{
"exit": {
"cond": "v3",
"targets": [
"Block2",
"Block1"
],
"type": "ConditionalJump"
},
"id": "Block0",
"instructions": [
{
"in": [
"0x0101",
"0x01"
],
"op": "sstore",
"out": []
},
{
"in": [
"0x00"
],
"op": "calldataload",
"out": [
"v3"
]
}
],
"type": "BuiltinCall"
},
{
"exit": {
"type": "MainExit"
},
"id": "Block2",
"instructions": [
{
"in": [
"0x03",
"0x03"
],
"op": "sstore",
"out": []
}
],
"type": "BuiltinCall"
},
{
"exit": {
"targets": [
"Block2"
],
"type": "Jump"
},
"id": "Block1",
"instructions": [
{
"in": [
"0x0202",
"0x02"
],
"op": "sstore",
"out": []
}
],
"type": "BuiltinCall"
}
],
"functions": {}
},
"subObjects": {},
"type": "Object"
}
37 changes: 37 additions & 0 deletions examples/if/if.yul
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
sstore(0x01, 0x0101)
if calldataload(0) {
sstore(0x02, 0x0202)
}
sstore(0x03, 0x003)
}
// ----
// digraph CFG {
// nodesep=0.7;
// node[shape=box];
//
// Entry [label="Entry"];
// Entry -> Block0;
// Block0 [label="\
// sstore: [ 0x0101 0x01 ] => [ ]\l\
// calldataload: [ 0x00 ] => [ TMP[calldataload, 0] ]\l\
// "];
// Block0 -> Block0Exit;
// Block0Exit [label="{ TMP[calldataload, 0]| { <0> Zero | <1> NonZero }}" shape=Mrecord];
// Block0Exit:0 -> Block1;
// Block0Exit:1 -> Block2;
//
// Block1 [label="\
// sstore: [ 0x03 0x03 ] => [ ]\l\
// "];
// Block1Exit [label="MainExit"];
// Block1 -> Block1Exit;
//
// Block2 [label="\
// sstore: [ 0x0202 0x02 ] => [ ]\l\
// "];
// Block2 -> Block2Exit [arrowhead=none];
// Block2Exit [label="Jump" shape=oval];
// Block2Exit -> Block1;
//
// }

0 comments on commit a65937c

Please sign in to comment.