Commits

Devin Jeanpierre committed 91ea300

Dedicated 'cloneseek' method

Comments (0)

Files changed (1)

         """
         self.pc = pos
         return self
+    
+    def cloneseek(self, newpos):
+        """
+        return a new thread with positioned at `pos`, and the same saved state
+        as self.
+        """
+        new = PikeThread(newpos, self.saved.copy())
+        return new
 
 # hack hack hack
 CHAR_WORD = set(map(ord, string.lowercase + string.uppercase + '_'))
             self.add_thread(thread.seek(target))
         elif op.opcode == SPLIT:
             for arg in op.arguments:
-                self.add_thread(PikeThread(arg, saved.copy()))
+                self.add_thread(thread.cloneseek(arg))
         elif op.opcode in [START_SAVE, END_SAVE]:
             slot, = op.arguments