本文整理匯總了Python中miasm2.core.graph.DiGraph.reachable_parents方法的典型用法代碼示例。如果您正苦於以下問題:Python DiGraph.reachable_parents方法的具體用法?Python DiGraph.reachable_parents怎麽用?Python DiGraph.reachable_parents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類miasm2.core.graph.DiGraph
的用法示例。
在下文中一共展示了DiGraph.reachable_parents方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: sort_dst
# 需要導入模塊: from miasm2.core.graph import DiGraph [as 別名]
# 或者: from miasm2.core.graph.DiGraph import reachable_parents [as 別名]
#.........這裏部分代碼省略.........
def test_in_out_fix(self):
"""Return True iff a fixed point has been reached during liveness
analysis"""
fixed = True
for node in self.g.nodes():
if node not in self.blocs:
# leaf has lost her son
continue
irb = self.blocs[node]
if irb.c_in != irb.l_in or irb.c_out != irb.l_out:
fixed = False
irb.l_in = [set(x) for x in irb.c_in]
irb.l_out = [set(x) for x in irb.c_out]
return fixed
def fill_missing_son_c_in(self):
"""Find nodes with missing sons in graph, and add virtual link to all
written variables of all parents.
PRE: gen_graph() and get_rw()"""
for node in self.g.nodes():
if node not in self.blocs:
continue
self.blocs[node].c_out_missing = set()
has_all_son = True
for node_son in self.g.successors(node):
if node_son not in self.blocs:
has_all_son = False
break
if has_all_son:
continue
parents = self.g.reachable_parents(node)
for parent in parents:
irb = self.blocs[parent]
for var_w in irb.w:
self.blocs[node].c_out_missing.update(var_w)
def compute_dead(self):
"""Iterate liveness analysis until a fixed point is reached.
PRE: gen_graph()
"""
it = 0
fixed_point = False
log.debug('iteration...')
while not fixed_point:
log.debug(it)
it += 1
for n in self.g.nodes():
if n not in self.blocs:
# leaf has lost her son
continue
irb = self.blocs[n]
self.compute_in_out(irb)
fixed_point = self.test_in_out_fix()
def dead_simp(self):
"""This function is used to analyse relation of a * complete function *
This mean the blocs under study represent a solid full function graph.
Ref: CS 5470 Compiler Techniques and Principles (Liveness
analysis/Dataflow equations)