(self)
return replaced
Fold expressions: Fold assigned expressions that are only used once.
Fold expressions: Fold assigned expressions that are only used once.
Fold expressions : Fold assigned expressions that are only used once .
def _fold_exprs(self):
        """
        Fold expressions: Fold assigned expressions that are only used once.
        """

        # propagator
        propagator = self._compute_propagation()
        replacements = propagator.replacements

        # take replacements and rebuild the corresponding blocks
        replacements_by_block_addrs_and_idx = defaultdict(dict)
        for codeloc, reps in replacements.items():
            if reps:
                replacements_by_block_addrs_and_idx[(codeloc.block_addr, codeloc.block_idx)][codeloc] = reps

        if not replacements_by_block_addrs_and_idx:
            return False

        blocks_by_addr_and_idx = dict(((node.addr, node.idx), node) for node in self.func_graph.nodes())

        replaced = False
        for (block_addr, block_idx), reps in replacements_by_block_addrs_and_idx.items():
            block = blocks_by_addr_and_idx[(block_addr, block_idx)]
            r, new_block = BlockSimplifier._replace_and_build(block, reps)
            replaced |= r
            self.blocks[block] = new_block

        if replaced:
            # blocks have been rebuilt - expression propagation results are no longer reliable
            self._clear_cache()
        return replaced
def _fold_exprs ( self ) : # propagator propagator = self . _compute_propagation ( ) replacements = propagator . replacements # take replacements and rebuild the corresponding blocks replacements_by_block_addrs_and_idx = defaultdict ( dict ) for codeloc , reps in replacements . items ( ) : if reps : replacements_by_block_addrs_and_idx [ ( codeloc . block_addr , codeloc . block_idx ) ] [ codeloc ] = reps if not replacements_by_block_addrs_and_idx : return False blocks_by_addr_and_idx = dict ( ( ( node . addr , node . idx ) , node ) for node in self . func_graph . nodes ( ) ) replaced = False for ( block_addr , block_idx ) , reps in replacements_by_block_addrs_and_idx . items ( ) : block = blocks_by_addr_and_idx [ ( block_addr , block_idx ) ] r , new_block = BlockSimplifier . _replace_and_build ( block , reps ) replaced |= r self . blocks [ block ] = new_block if replaced : # blocks have been rebuilt - expression propagation results are no longer reliable self . _clear_cache ( ) return replaced