Static Analyzer for Solidity
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
slither/examples/scripts/convert_to_ir.py

30 lines
744 B

import sys
from slither.slither import Slither
from slither.slithir.convert import convert_expression
if len(sys.argv) != 2:
4 years ago
print("python function_called.py functions_called.sol")
sys.exit(-1)
# Init slither
slither = Slither(sys.argv[1])
# Get the contract
contracts = slither.get_contract_from_name("Test")
assert len(contracts) == 1
contract = contracts[0]
# Get the variable
4 years ago
test = contract.get_function_from_signature("one()")
4 years ago
assert test
nodes = test.nodes
for node in nodes:
if node.expression:
4 years ago
print("Expression:\n\t{}".format(node.expression))
irs = convert_expression(node.expression, node)
4 years ago
print("IR expressions:")
for ir in irs:
4 years ago
print("\t{}".format(ir))
print()