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

[svn:parrot] r34321 - in trunk/languages/perl6/src: builtins classes

From:
pmichaud
Date:
December 24, 2008 00:40
Subject:
[svn:parrot] r34321 - in trunk/languages/perl6/src: builtins classes
Message ID:
20081224084041.4954ECBA12@x12.develooper.com
Author: pmichaud
Date: Wed Dec 24 00:40:39 2008
New Revision: 34321

Modified:
   trunk/languages/perl6/src/builtins/any-list.pir
   trunk/languages/perl6/src/builtins/any-str.pir
   trunk/languages/perl6/src/classes/List.pir
   trunk/languages/perl6/src/classes/Mapping.pir

Log:
[rakudo]:  Clean up reverse methods and functions.


Modified: trunk/languages/perl6/src/builtins/any-list.pir
==============================================================================
--- trunk/languages/perl6/src/builtins/any-list.pir	(original)
+++ trunk/languages/perl6/src/builtins/any-list.pir	Wed Dec 24 00:40:39 2008
@@ -524,31 +524,6 @@
     .return(retv)
 .end
 
-=item reverse()
-
-=cut
-
-.namespace ['Any']
-.sub 'reverse' :method :multi(_)
-    .local pmc result, it
-    result = new 'List'
-    $P0 = self.'list'()
-    it = $P0.'iterator'()
-  loop:
-    unless it goto done
-    $P0 = shift it
-    unshift result, $P0
-    goto loop
-  done:
-    .return (result)
-.end
-
-.namespace []
-.sub 'reverse' :multi()
-    .param pmc values          :slurpy
-    .tailcall values.'reverse'()
-.end
-
 
 =item sort()
 

Modified: trunk/languages/perl6/src/builtins/any-str.pir
==============================================================================
--- trunk/languages/perl6/src/builtins/any-str.pir	(original)
+++ trunk/languages/perl6/src/builtins/any-str.pir	Wed Dec 24 00:40:39 2008
@@ -317,6 +317,28 @@
     .return(match)
 .end
 
+=item reverse
+
+=cut
+
+.namespace []
+.sub 'reverse' :multi()
+    .param pmc values          :slurpy
+    $I0 = elements values
+    unless $I0 == 1 goto reverse_list
+    .tailcall $P0.'reverse'()
+  reverse_list:
+    values.'!flatten'()
+    .tailcall values.'reverse'()
+.end
+
+.namespace ['Any']
+.sub 'reverse' :method
+    $P0 = self.'split'('')
+    $P0 = $P0.'reverse'()
+    .tailcall $P0.'join'('')
+.end
+
 =item rindex()
 
 =cut

Modified: trunk/languages/perl6/src/classes/List.pir
==============================================================================
--- trunk/languages/perl6/src/classes/List.pir	(original)
+++ trunk/languages/perl6/src/classes/List.pir	Wed Dec 24 00:40:39 2008
@@ -234,6 +234,21 @@
 .end
 
 
+.namespace ['List']
+.sub 'reverse' :method
+    .local pmc result, it
+    result = new 'List'
+    it = self.'iterator'()
+  loop:
+    unless it goto done
+    $P0 = shift it
+    unshift result, $P0
+    goto loop
+  done:
+    .return (result)
+.end
+
+
 =back
 
 =head2 Private methods

Modified: trunk/languages/perl6/src/classes/Mapping.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Mapping.pir	(original)
+++ trunk/languages/perl6/src/classes/Mapping.pir	Wed Dec 24 00:40:39 2008
@@ -18,7 +18,7 @@
     p6meta.'add_role'($P0, 'to'=>mappingproto)
     p6meta.'register'('Hash', 'parent'=>mappingproto, 'protoobject'=>mappingproto)
     $P0 = get_hll_namespace ['Mapping']
-    '!EXPORT'('keys,kv,values,reverse', $P0)
+    '!EXPORT'('keys,kv,values', $P0)
 .end
 
 =head2 Methods
@@ -208,7 +208,8 @@
 
 =cut
 
-.sub 'reverse' :method :multi('Hash')
+.namespace ['Mapping']
+.sub 'reverse' :method
     .local pmc it
     .local pmc rv
 



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