(self, old: claripy.ast.BV, new: claripy.ast.BV)
Replaces all instances of expression `old` with expression `new`.

        :param old: A claripy expression. Must contain at least one named variable (to make it possible to use the
                    name index for speedup).
        :param new: The new variable to replace it with.
Replaces all instances of expression `old` with expression `new`.
Replaces all instances of expression old with expression new .
def replace_all(self, old: claripy.ast.BV, new: claripy.ast.BV):
        """
        Replaces all instances of expression `old` with expression `new`.

        :param old: A claripy expression. Must contain at least one named variable (to make it possible to use the
                    name index for speedup).
        :param new: The new variable to replace it with.
        """

        if options.REVERSE_MEMORY_NAME_MAP not in self.state.options:
            raise SimMemoryError("replace_all is not doable without a reverse name mapping. Please add "
                                 "sim_options.REVERSE_MEMORY_NAME_MAP to the state options")

        if not isinstance(old, claripy.ast.BV) or not isinstance(new, claripy.ast.BV):
            raise SimMemoryError("old and new arguments to replace_all() must be claripy.BV objects")

        if len(old.variables) == 0:
            raise SimMemoryError("old argument to replace_all() must have at least one named variable")

        # Computer an intersection between sets of memory addresses for each unique variable name. The eventual address
        # set contains all addresses whose memory objects we should update.
        addrs: Optional[Set] = None
        for v in old.variables:
            v: str
            if addrs is None:
                addrs = set(self.addrs_for_name(v))
            elif len(addrs) == 0:
                # It's a set and it's already empty
                # there is no way for it to go back...
                break
            else:
                addrs &= set(self.addrs_for_name(v))

        self._replace_all(addrs, old, new)
def replace_all ( self , old : claripy . ast . BV , new : claripy . ast . BV ) : if options . REVERSE_MEMORY_NAME_MAP not in self . state . options : raise SimMemoryError ( "replace_all is not doable without a reverse name mapping. Please add " "sim_options.REVERSE_MEMORY_NAME_MAP to the state options" ) if not isinstance ( old , claripy . ast . BV ) or not isinstance ( new , claripy . ast . BV ) : raise SimMemoryError ( "old and new arguments to replace_all() must be claripy.BV objects" ) if len ( old . variables ) == 0 : raise SimMemoryError ( "old argument to replace_all() must have at least one named variable" ) # Computer an intersection between sets of memory addresses for each unique variable name. The eventual address # set contains all addresses whose memory objects we should update. addrs : Optional [ Set ] = None for v in old . variables : v : str if addrs is None : addrs = set ( self . addrs_for_name ( v ) ) elif len ( addrs ) == 0 : # It's a set and it's already empty # there is no way for it to go back... break else : addrs &= set ( self . addrs_for_name ( v ) ) self . _replace_all ( addrs , old , new )