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

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

Subject: [svn:parrot] r31366 - trunk/languages/perl6/src/classes
From:
Date: Tue, 23 Sep 2008 09:12:13 -0700 PDT
Newsgroups: perl.cvs.parrot

Author: moritz
Date: Tue Sep 23 09:12:13 2008
New Revision: 31366

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

Log:
[rakudo] implement Hash.pairs, cjfields++. Patch courtesy by Chris Fields.


Modified: trunk/languages/perl6/src/classes/Mapping.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Mapping.pir       (original)
+++ trunk/languages/perl6/src/classes/Mapping.pir       Tue Sep 23 09:12:13 2008
@@ -114,6 +114,29 @@
 .end
 
 
+=item pairs (method)
+
+Returns elements of hash as array of C<Pairs>
+
+=cut
+
+.sub 'pairs' :method :multi('Hash')
+    .local pmc iter
+    .local pmc rv
+    iter = new 'Iterator', self
+    rv   = 'list'()
+    $P3 = get_hll_global 'Perl6Pair'
+  loop:
+    unless iter goto end
+    $P1 = shift iter
+    $P2 = iter[$P1]
+    $P4 = $P3.'new'('key' => $P1, 'value' => $P2)
+    push rv, $P4
+    goto loop
+  end:
+    .return (rv)
+.end
+
 
 .sub 'keys' :method :multi('Hash')
     .local pmc iter
@@ -129,7 +152,6 @@
     .return (rv)
 .end
 
-
 .sub 'values' :method :multi('Hash')
     .local pmc iter
     .local pmc rv
@@ -180,9 +202,6 @@
 =cut
 
 
-
-=item pairs
-
 =item values
 
  multi Int|List Hash::keys ( %hash : MatchTest *@keytests )

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