uroboros-diversification/src/analysis/visit.py
def update_instrs(self):
        """
        do the real modification on instructions list
        Note:
            1. before doing the modification, self.instrs_update needs to be arranged in order, see self.update_process
            2. after doing the modification, the self.instrs_update needs to be cleared, see self.update_process
        """
        def same(loc1, loc2):
            return loc1.loc_addr == loc2.loc_addr

        if len(self.instrs_update) == 0:
            return self.instrs

        global count
        count += 1
        # print 'update instructions times: %d' % count
        acc = []

        iu_idx = 0
        i_idx = 0
        begin_no_change_idx = -1
        while iu_idx < len(self.instrs_update):
            if i_idx >= len(self.instrs):
                assert False, 'error in update_instrs'
            else:
                h = self.instrs[i_idx]
                i, loc1, ty, i_s = self.instrs_update[iu_idx]
                loc2 = get_loc(h)
                if same(loc1, loc2):
                    if begin_no_change_idx >= 0:
                        acc.extend(self.instrs[begin_no_change_idx:i_idx])
                        begin_no_change_idx = -1
                    if ty == instr_update.REPLACE:
                        h_s = pp_print_instr(h)
                        if i_s == h_s:
                            self.instrs[i_idx] = i
                            iu_idx += 1
                        else:
                            i_idx += 1
                            acc.append(h)
                    elif ty == instr_update.INSERT:
                        acc.append(i)
                        iu_idx += 1
                    elif ty == instr_update.APPEND:
                        acc.append(h)
                        i_idx += 1
                        # to append following instructions
                        while ty == instr_update.APPEND and same(loc1, loc2):
                            acc.append(i)
                            iu_idx += 1
                            if iu_idx < len(self.instrs_update):
                                i, loc1, ty, i_s = self.instrs_update[iu_idx]
                            else:
                                ty = None
                else:
                    if begin_no_change_idx < 0:
                        begin_no_change_idx = i_idx
                    i_idx += 1
        if begin_no_change_idx >= 0:
            acc.extend(self.instrs[begin_no_change_idx:])
        else:
            acc.extend(self.instrs[i_idx:])
        return acc

        do the real modification on instructions list
        Note:
            1. before doing the modification, self.instrs_update needs to be arranged in order, see self.update_process
            2. after doing the modification, the self.instrs_update needs to be cleared, see self.update_process
        
do the real modification on instructions list
Note:
1. before doing the modification, self.instrs_update needs to be arranged in order, see self.update_process
2. after doing the modification, the self.instrs_update needs to be cleared, see self.update_process
do the real modification on instructions list Note : 1 . before doing the modification self . instrs_update needs to be arranged in order see self . update_process 2 . after doing the modification the self . instrs_update needs to be cleared see self . update_process
def update_instrs(self):
        def same(loc1, loc2):
            return loc1.loc_addr == loc2.loc_addr
        if len(self.instrs_update) == 0:
            return self.instrs
        global count
        count += 1
        acc = []
        iu_idx = 0
        i_idx = 0
        begin_no_change_idx = -1
        while iu_idx < len(self.instrs_update):
            if i_idx >= len(self.instrs):
                assert False, 'error in update_instrs'
            else:
                h = self.instrs[i_idx]
                i, loc1, ty, i_s = self.instrs_update[iu_idx]
                loc2 = get_loc(h)
                if same(loc1, loc2):
                    if begin_no_change_idx >= 0:
                        acc.extend(self.instrs[begin_no_change_idx:i_idx])
                        begin_no_change_idx = -1
                    if ty == instr_update.REPLACE:
                        h_s = pp_print_instr(h)
                        if i_s == h_s:
                            self.instrs[i_idx] = i
                            iu_idx += 1
                        else:
                            i_idx += 1
                            acc.append(h)
                    elif ty == instr_update.INSERT:
                        acc.append(i)
                        iu_idx += 1
                    elif ty == instr_update.APPEND:
                        acc.append(h)
                        i_idx += 1
                        while ty == instr_update.APPEND and same(loc1, loc2):
                            acc.append(i)
                            iu_idx += 1
                            if iu_idx < len(self.instrs_update):
                                i, loc1, ty, i_s = self.instrs_update[iu_idx]
                            else:
                                ty = None
                else:
                    if begin_no_change_idx < 0:
                        begin_no_change_idx = i_idx
                    i_idx += 1
        if begin_no_change_idx >= 0:
            acc.extend(self.instrs[begin_no_change_idx:])
        else:
            acc.extend(self.instrs[i_idx:])
        return acc
def update_instrs ( self ) : def same ( loc1 , loc2 ) : return loc1 . loc_addr == loc2 . loc_addr if len ( self . instrs_update ) == 0 : return self . instrs global count count += 1 acc = [ ] iu_idx = 0 i_idx = 0 begin_no_change_idx = - 1 while iu_idx < len ( self . instrs_update ) : if i_idx >= len ( self . instrs ) : assert False , 'error in update_instrs' else : h = self . instrs [ i_idx ] i , loc1 , ty , i_s = self . instrs_update [ iu_idx ] loc2 = get_loc ( h ) if same ( loc1 , loc2 ) : if begin_no_change_idx >= 0 : acc . extend ( self . instrs [ begin_no_change_idx : i_idx ] ) begin_no_change_idx = - 1 if ty == instr_update . REPLACE : h_s = pp_print_instr ( h ) if i_s == h_s : self . instrs [ i_idx ] = i iu_idx += 1 else : i_idx += 1 acc . append ( h ) elif ty == instr_update . INSERT : acc . append ( i ) iu_idx += 1 elif ty == instr_update . APPEND : acc . append ( h ) i_idx += 1 while ty == instr_update . APPEND and same ( loc1 , loc2 ) : acc . append ( i ) iu_idx += 1 if iu_idx < len ( self . instrs_update ) : i , loc1 , ty , i_s = self . instrs_update [ iu_idx ] else : ty = None else : if begin_no_change_idx < 0 : begin_no_change_idx = i_idx i_idx += 1 if begin_no_change_idx >= 0 : acc . extend ( self . instrs [ begin_no_change_idx : ] ) else : acc . extend ( self . instrs [ i_idx : ] ) return acc
do the real modification on instructions list
Note:
1. before doing the modification, self.instrs_update needs to be arranged in order, see self.update_process
2. after doing the modification, the self.instrs_update needs to be cleared, see self.update_process
do the real modification on instructions list Note : 1 . before doing the modification self . instrs_update needs to be arranged in order see self . update_process 2 . after doing the modification the self . instrs_update needs to be cleared see self . update_process
"""
        do the real modification on instructions list
        Note:
            1. before doing the modification, self.instrs_update needs to be arranged in order, see self.update_process
            2. after doing the modification, the self.instrs_update needs to be cleared, see self.update_process
        """ # print 'update instructions times: %d' % count # to append following instructions
self