Moved most of bytecode_visitor.BytecodeFlowVisitor into a new parent class GenericFlowVisitor, which is a useful starting point for address-based flow visitors.
This commit is contained in:
parent
68030d51d1
commit
5f81cab357
1 changed files with 13 additions and 10 deletions
|
|
@ -190,7 +190,7 @@ class BasicBlockVisitor (BytecodeVisitor):
|
||||||
|
|
||||||
# ______________________________________________________________________
|
# ______________________________________________________________________
|
||||||
|
|
||||||
class BytecodeFlowVisitor (BytecodeVisitor):
|
class GenericFlowVisitor (BytecodeVisitor):
|
||||||
def visit (self, flow):
|
def visit (self, flow):
|
||||||
self.block_list = list(flow.keys())
|
self.block_list = list(flow.keys())
|
||||||
self.block_list.sort()
|
self.block_list.sort()
|
||||||
|
|
@ -209,15 +209,6 @@ class BytecodeFlowVisitor (BytecodeVisitor):
|
||||||
del self.block_list
|
del self.block_list
|
||||||
return self.exit_flow_object(flow)
|
return self.exit_flow_object(flow)
|
||||||
|
|
||||||
def visit_op (self, i, op, arg, *args, **kws):
|
|
||||||
new_args = []
|
|
||||||
for child_i, child_op, _, child_arg, child_args in args:
|
|
||||||
new_args.extend(self.visit_op(child_i, child_op, child_arg,
|
|
||||||
*child_args))
|
|
||||||
ret_val = super(BytecodeFlowVisitor, self).visit_op(i, op, arg,
|
|
||||||
*new_args)
|
|
||||||
return ret_val
|
|
||||||
|
|
||||||
def enter_flow_object (self, flow):
|
def enter_flow_object (self, flow):
|
||||||
self.new_flow = {}
|
self.new_flow = {}
|
||||||
|
|
||||||
|
|
@ -234,6 +225,18 @@ class BytecodeFlowVisitor (BytecodeVisitor):
|
||||||
|
|
||||||
# ______________________________________________________________________
|
# ______________________________________________________________________
|
||||||
|
|
||||||
|
class BytecodeFlowVisitor (GenericFlowVisitor):
|
||||||
|
def visit_op (self, i, op, arg, *args, **kws):
|
||||||
|
new_args = []
|
||||||
|
for child_i, child_op, _, child_arg, child_args in args:
|
||||||
|
new_args.extend(self.visit_op(child_i, child_op, child_arg,
|
||||||
|
*child_args))
|
||||||
|
ret_val = super(BytecodeFlowVisitor, self).visit_op(i, op, arg,
|
||||||
|
*new_args)
|
||||||
|
return ret_val
|
||||||
|
|
||||||
|
# ______________________________________________________________________
|
||||||
|
|
||||||
class BenignBytecodeVisitorMixin (object):
|
class BenignBytecodeVisitorMixin (object):
|
||||||
def _do_nothing (self, i, op, arg, *args, **kws):
|
def _do_nothing (self, i, op, arg, *args, **kws):
|
||||||
return [(i, op, self.opnames[op], arg, args)]
|
return [(i, op, self.opnames[op], arg, args)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue