def execute(self, frame): stack = frame.operand_stack slot1 = stack.pop_slot() slot2 = stack.pop_slot() stack.push_slot(slot2) stack.push_slot(slot1) stack.push_slot(copy_slot(slot2)) stack.push_slot(copy_slot(slot1))
def clone_data(self): if not isinstance(self.data, Slots): new_data = list(self.data) return new_data else: new_data = Slots(len(self.data)) for i, slot in enumerate(self.data): new_data[i] = copy_slot(slot) return new_data
def execute(self, frame): stack = frame.operand_stack slot = stack.pop_slot() stack.push_slot(slot) # 采用自定义的对象深拷贝,复制slot stack.push_slot(copy_slot(slot))