perl.cvs.parrot
[Top] [All Lists]

[svn:parrot] r28129 - trunk/languages/perl6/src/classes

Subject: [svn:parrot] r28129 - trunk/languages/perl6/src/classes
From:
Date: Fri, 6 Jun 2008 06:05:05 -0700 PDT
Newsgroups: perl.cvs.parrot

Author: pmichaud
Date: Fri Jun  6 06:05:05 2008
New Revision: 28129

Modified:
   trunk/languages/perl6/src/classes/Range.pir

Log:
[rakudo]:
* Handling cloning of ranges (RT#55400, bacek++)
* Patch courtesy Vasily Chekalkin <bacek  at bacek.com>
* Minor modifications by Pm


Modified: trunk/languages/perl6/src/classes/Range.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Range.pir (original)
+++ trunk/languages/perl6/src/classes/Range.pir Fri Jun  6 06:05:05 2008
@@ -53,11 +53,12 @@
 =cut
 
 .sub 'list' :method
-    .local pmc res, cur_val
+    .local pmc res, cur_val, it
+    it = clone self
     res = new 'List'
   it_loop:
-    unless self goto it_loop_end
-    cur_val = shift self
+    unless it goto it_loop_end
+    cur_val = shift it
     push res, cur_val
     goto it_loop
   it_loop_end:
@@ -112,16 +113,33 @@
 .end
 
 
-=item get_iter (vtable)
+=item iterator()   (vtable 'get_iter')
 
-Just returns this Range itself, since a Range is an iterator.
+Since Range is already an iterator, just return a clone
+of self.
 
 =cut
 
-.sub get_iter :method :vtable
-    .return (self)
+.sub 'iterator' :method :vtable('get_iter')
+    $P0 = clone self
+    .return ($P0)
 .end
 
+=item clone (vtable)
+
+Clone it self
+
+=cut
+
+.sub 'clone' :method :vtable
+    .local pmc from, to, retv
+    $P0 = self.'from'()
+    from = clone $P0
+    $P0 = self.'to'()
+    to = clone $P0
+    retv = 'infix:..'(from, to)
+    .return (retv)
+.end
 
 =item shift_pmc (vtable)
 

<Prev in Thread] Current Thread [Next in Thread>
  • [svn:parrot] r28129 - trunk/languages/perl6/src/classes, pmichaud <=