當前位置: 首頁>>代碼示例>>Python>>正文


Python DiGraph.predecessors方法代碼示例

本文整理匯總了Python中miasm2.core.graph.DiGraph.predecessors方法的典型用法代碼示例。如果您正苦於以下問題:Python DiGraph.predecessors方法的具體用法?Python DiGraph.predecessors怎麽用?Python DiGraph.predecessors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在miasm2.core.graph.DiGraph的用法示例。


在下文中一共展示了DiGraph.predecessors方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ira_regs_ids

# 需要導入模塊: from miasm2.core.graph import DiGraph [as 別名]
# 或者: from miasm2.core.graph.DiGraph import predecessors [as 別名]

#.........這裏部分代碼省略.........
        """Print each triplet contained in a set
        @v_set: set containing triplets elements
        """
        for p in v_set:
            print "    (%s, %s, %s)" % p

    def dump_bloc_state(self, irb):
        print "*" * 80
        for k, irs in enumerate(irb.irs):
            for i in xrange(len(irs)):
                print 5 * "-"
                print "instr", k, irs[i]
                print 5 * "-"
                for v in self.ira_regs_ids():
                    if irb.cur_reach[k][v]:
                        print "REACH[%d][%s]" % (k, v)
                        self.print_set(irb.cur_reach[k][v])
                    if irb.cur_kill[k][v]:
                        print "KILL[%d][%s]" % (k, v)
                        self.print_set(irb.cur_kill[k][v])
                    if irb.defout[k][v]:
                        print "DEFOUT[%d][%s]" % (k, v)
                        self.print_set(irb.defout[k][v])

    def compute_reach_block(self, irb):
        """Variable influence computation for a single block
        @irb: irbloc instance
        PRE: init_reach()
        """

        reach_block = {key: value.copy() for key, value in irb.cur_reach[0].iteritems()}

        # Compute reach from predecessors
        for n_pred in self.g.predecessors(irb.label):
            p_block = self.blocs[n_pred]

            # Handle each register definition
            for c_reg in self.ira_regs_ids():
                # REACH(n) = U[p in pred] DEFOUT(p) U REACH(p)\KILL(p)
                pred_through = p_block.defout[-1][c_reg].union(
                    p_block.cur_reach[-1][c_reg].difference(p_block.cur_kill[-1][c_reg])
                )
                reach_block[c_reg].update(pred_through)

        # If a predecessor has changed
        if reach_block != irb.cur_reach[0]:
            irb.cur_reach[0] = reach_block
            for c_reg in self.ira_regs_ids():
                if irb.defout[0][c_reg]:
                    # KILL(n) = DEFOUT(n) ? REACH(n)\DEFOUT(n) : EMPTY
                    irb.cur_kill[0][c_reg].update(reach_block[c_reg].difference(irb.defout[0][c_reg]))

        # Compute reach and kill for block's instructions
        for i in xrange(1, len(irb.irs)):
            for c_reg in self.ira_regs_ids():
                # REACH(n) = U[p in pred] DEFOUT(p) U REACH(p)\KILL(p)
                pred_through = irb.defout[i - 1][c_reg].union(
                    irb.cur_reach[i - 1][c_reg].difference(irb.cur_kill[i - 1][c_reg])
                )
                irb.cur_reach[i][c_reg].update(pred_through)
                if irb.defout[i][c_reg]:
                    # KILL(n) = DEFOUT(n) ? REACH(n)\DEFOUT(n) : EMPTY
                    irb.cur_kill[i][c_reg].update(irb.cur_reach[i][c_reg].difference(irb.defout[i][c_reg]))

    def _test_kill_reach_fix(self):
        """Return True iff a fixed point has been reached during reach
開發者ID:CaineQT,項目名稱:miasm,代碼行數:70,代碼來源:analysis.py


注:本文中的miasm2.core.graph.DiGraph.predecessors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。