angr/storage/paged_memory.py
def replace_all(self, old, new):
        """
        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")

        # Compute an intersection between sets of memory objects for each unique variable name. The eventual memory
        # object set contains all memory objects that we should update.
        memory_objects = None
        for v in old.variables:
            if memory_objects is None:
                memory_objects = self.memory_objects_for_name(v)
            elif len(memory_objects) == 0:
                # It's a set and it's already empty
                # there is no way for it to go back...
                break
            else:
                memory_objects &= self.memory_objects_for_name(v)

        replaced_objects_cache = { }
        for mo in memory_objects:
            replaced_object = None

            if mo.object in replaced_objects_cache:
                if mo.object is not replaced_objects_cache[mo.object]:
                    replaced_object = replaced_objects_cache[mo.object]

            else:
                replaced_object = mo.object.replace(old, new)
                replaced_objects_cache[mo.object] = replaced_object
                if mo.object is replaced_object:
                    # The replace does not really occur
                    replaced_object = None

            if replaced_object is not None:
                self.replace_memory_object(mo, replaced_object)

        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, new):
        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")
        memory_objects = None
        for v in old.variables:
            if memory_objects is None:
                memory_objects = self.memory_objects_for_name(v)
            elif len(memory_objects) == 0:
                break
            else:
                memory_objects &= self.memory_objects_for_name(v)
        replaced_objects_cache = { }
        for mo in memory_objects:
            replaced_object = None
            if mo.object in replaced_objects_cache:
                if mo.object is not replaced_objects_cache[mo.object]:
                    replaced_object = replaced_objects_cache[mo.object]
            else:
                replaced_object = mo.object.replace(old, new)
                replaced_objects_cache[mo.object] = replaced_object
                if mo.object is replaced_object:
                    replaced_object = None
            if replaced_object is not None:
                self.replace_memory_object(mo, replaced_object)
def replace_all ( self , old , new ) : 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" ) memory_objects = None for v in old . variables : if memory_objects is None : memory_objects = self . memory_objects_for_name ( v ) elif len ( memory_objects ) == 0 : break else : memory_objects &= self . memory_objects_for_name ( v ) replaced_objects_cache = { } for mo in memory_objects : replaced_object = None if mo . object in replaced_objects_cache : if mo . object is not replaced_objects_cache [ mo . object ] : replaced_object = replaced_objects_cache [ mo . object ] else : replaced_object = mo . object . replace ( old , new ) replaced_objects_cache [ mo . object ] = replaced_object if mo . object is replaced_object : replaced_object = None if replaced_object is not None : self . replace_memory_object ( mo , replaced_object )
Replaces all instances of expression `old` with expression `new`.
Replaces all instances of expression ` old ` with expression ` new ` .
"""
        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.
        """ # Compute an intersection between sets of memory objects for each unique variable name. The eventual memory # object set contains all memory objects that we should update. # It's a set and it's already empty # there is no way for it to go back... # The replace does not really occur
self
old
A claripy expression. Must contain at least one named variable (to make it possible to use the
name index for speedup).
A claripy expression . Must contain at least one named variable ( to make it possible to use the name index for speedup ) .
new
The new variable to replace it with.
The new variable to replace it with .