forked from enzymefinance/oyente
-
Notifications
You must be signed in to change notification settings - Fork 0
/
basicblock.py
53 lines (40 loc) · 1.37 KB
/
basicblock.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class BasicBlock:
def __init__(self, start_address, end_address):
self.start = start_address
self.end = end_address
self.instructions = [] # each instruction is a string
self.jump_target = 0
def get_start_address(self):
return self.start
def get_end_address(self):
return self.end
def add_instruction(self, instruction):
self.instructions.append(instruction)
def get_instructions(self):
return self.instructions
def set_block_type(self, type):
self.type = type
def get_block_type(self):
return self.type
def set_falls_to(self, address):
self.falls_to = address
def get_falls_to(self):
return self.falls_to
def set_jump_target(self, address):
if isinstance(address, (int, long)):
self.jump_target = address
else:
self.jump_target = -1
def get_jump_target(self):
return self.jump_target
def set_branch_expression(self, branch):
self.branch_expression = branch
def get_branch_expression(self):
return self.branch_expression
def display(self):
print "================"
print "start address: %d" % self.start
print "end address: %d" % self.end
print "end statement type: " + self.type
for instr in self.instructions:
print instr