-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathslithIR.py
32 lines (23 loc) · 896 Bytes
/
slithIR.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import sys
from slither import Slither
if len(sys.argv) != 2:
print("python slithIR.py contract.sol")
sys.exit(-1)
# Init slither
slither = Slither(sys.argv[1])
# Iterate over all the contracts
for contract in slither.contracts:
# Iterate over all the functions
for function in contract.functions:
# Dont explore inherited functions
if function.contract_declarer == contract:
print(f"Function: {function.name}")
# Iterate over the nodes of the function
for node in function.nodes:
# Print the Solidity expression of the nodes
# And the SlithIR operations
if node.expression:
print(f"\tSolidity expression: {node.expression}")
print("\tSlithIR:")
for ir in node.irs:
print(f"\t\t\t{ir}")