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

[svn:parrot] r33683 - in branches/assign/languages/perl6/src: builtins classes

From:
pmichaud
Date:
December 8, 2008 18:18
Subject:
[svn:parrot] r33683 - in branches/assign/languages/perl6/src: builtins classes
Message ID:
20081209021811.6E5F3CB9AF@x12.develooper.com
Author: pmichaud
Date: Mon Dec  8 18:18:10 2008
New Revision: 33683

Modified:
   branches/assign/languages/perl6/src/builtins/assign.pir
   branches/assign/languages/perl6/src/classes/Array.pir
   branches/assign/languages/perl6/src/classes/List.pir

Log:
[rakudo]:  More assignment branch cleanups.


Modified: branches/assign/languages/perl6/src/builtins/assign.pir
==============================================================================
--- branches/assign/languages/perl6/src/builtins/assign.pir	(original)
+++ branches/assign/languages/perl6/src/builtins/assign.pir	Mon Dec  8 18:18:10 2008
@@ -62,8 +62,7 @@
     .local pmc list, it
     ## empty the array
     assign cont, 0
-    source = source.'list'()
-    source.'!flatten'()
+    source = 'list'(source)
     it = iter source
   array_loop:
     unless it goto array_done

Modified: branches/assign/languages/perl6/src/classes/Array.pir
==============================================================================
--- branches/assign/languages/perl6/src/classes/Array.pir	(original)
+++ branches/assign/languages/perl6/src/classes/Array.pir	Mon Dec  8 18:18:10 2008
@@ -14,39 +14,84 @@
     arrayproto.'!MUTABLE'()
 
     $P0 = get_hll_namespace ['Perl6Array']
-    '!EXPORT'('pop push shift unshift', 'from'=>$P0)
+    '!EXPORT'('delete exists pop push shift unshift', 'from'=>$P0)
 .end
 
-=head2 Context methods
+=head2 Methods
 
 =over
 
-=item item()
+=item delete
 
-Return Array in item context (i.e., self)
+Remove items from an array. 
 
 =cut
 
 .namespace ['Perl6Array']
-.sub 'item' :method
-    .return (self)
+.sub 'delete' :method :multi(Perl6Array)
+    .param pmc indices :slurpy
+    .local pmc result
+    result = new 'List'
+    null $P99
+
+    indices.'!flatten'()
+  indices_loop:
+    unless indices goto indices_end
+    $I0 = shift indices
+    $P0 = self[$I0]
+    push result, $P0
+    self[$I0] = $P99
+
+  shorten:
+    $I0 = self.'elems'()
+    dec $I0
+  shorten_loop:
+    if $I0 < 0 goto shorten_end
+    $P0 = self[$I0]
+    unless null $P0 goto shorten_end
+    delete self[$I0]
+    dec $I0
+    goto shorten_loop
+  shorten_end:
+    goto indices_loop
+
+  indices_end:
+    .return (result)
 .end
 
-=back
 
-=head2 Coercion methods
+=item exists(indices :slurpy)
+
+Return true if the elements at C<indices> have been assigned to.
 
-=over
+=cut
 
-=item Array
+.sub 'exists' :method :multi(Perl6Array)
+    .param pmc indices :slurpy
+    .local int test
+
+    test = 0
+  indices_loop:
+    unless indices goto indices_end
+    $I0 = shift indices
+    test = exists self[$I0]
+    if test goto indices_loop
+  indices_end:
+    .tailcall 'prefix:?'(test)
+.end
 
-.sub 'Array' :method
+
+=item item()
+
+Return Array in item context (i.e., self)
+
+=cut
+
+.namespace ['Perl6Array']
+.sub 'item' :method
     .return (self)
 .end
 
-=back
-
-=head2 Methods
 
 =item pop()
 
@@ -127,9 +172,27 @@
 .namespace []
 .sub 'circumfix:[ ]'
     .param pmc values          :slurpy
-    .tailcall values.'Array'()
+    .tailcall values.'Scalar'()
 .end
 
+=back
+
+=head2 Coercion methods
+
+=over
+
+=item Array
+
+=cut
+
+.sub 'Array' :method
+    .return (self)
+.end
+
+=back
+
+=cut
+
 # Local Variables:
 #   mode: pir
 #   fill-column: 100

Modified: branches/assign/languages/perl6/src/classes/List.pir
==============================================================================
--- branches/assign/languages/perl6/src/classes/List.pir	(original)
+++ branches/assign/languages/perl6/src/classes/List.pir	Mon Dec  8 18:18:10 2008
@@ -14,7 +14,7 @@
     p6meta.'register'('ResizablePMCArray', 'parent'=>listproto, 'protoobject'=>listproto)
 
     $P0 = get_hll_namespace ['List']
-#    '!EXPORT'('first grep keys kv map pairs reduce values', $P0)
+    '!EXPORT'('first grep keys kv map pairs reduce values', $P0)
 .end
 
 =head2 Methods



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