develooper Front page | perl.cvs.parrot | Postings from December 2008

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

From:
pmichaud
Date:
December 30, 2008 18:44
Subject:
[svn:parrot] r34683 - trunk/languages/perl6/src/classes
Message ID:
20081231024413.7060ECB9FA@x12.develooper.com
Author: pmichaud
Date: Tue Dec 30 18:44:12 2008
New Revision: 34683

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

Log:
[rakudo]:  Enable whatever star meaning "full slice" (e.g. @a[*])


Modified: trunk/languages/perl6/src/classes/Positional.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Positional.pir	(original)
+++ trunk/languages/perl6/src/classes/Positional.pir	Tue Dec 30 18:44:12 2008
@@ -37,33 +37,48 @@
     args.'!flatten'()
     $I0 = args.'elems'()
     if $I0 != 1 goto slice
+    $P0 = args[0]
+    $I0 = isa $P0, ['Whatever']
+    if $I0 goto result_whatever
     $I0 = args[0]
     if $I0 >= 0 goto result_fetch
-    result = new 'Failure'
+    result = 'undef'()
     goto end
   result_fetch:
     result = self[$I0]
     unless null result goto end
-    result = new 'Failure'
+    result = 'undef'()
     self[$I0] = result
     goto end
+  result_whatever:
+    result = 'list'(self)
+    goto end
   slice:
-    result = new 'List'
+    result = new ['List']
   slice_loop:
     unless args goto slice_done
-    $I0 = shift args
-    if $I0 >= 0 goto slice_fetch
+    $P0 = shift args
+    $I0 = isa $P0, ['Whatever']
+    if $I0 goto slice_whatever
+    $I0 = $P0
+    if $I0 >= 0 goto slice_index
+  slice_negative:
     .local pmc elem
-    elem = new 'Failure'
+    elem = 'undef'()
     goto slice_elem
-  slice_fetch:
+  slice_index:
     elem = self[$I0]
     unless null elem goto slice_elem
-    elem = new 'Failure'
+    elem = 'undef'()
     self[$I0] = elem
   slice_elem:
     push result, elem
     goto slice_loop
+  slice_whatever:
+    ##  add all of the elements to the result
+    $I0 = elements result
+    splice result, self, $I0, 0
+    goto slice_loop
   slice_done:
   end:
     .return (result)



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About