Author: jonathan
Date: Wed Aug 20 15:55:39 2008
New Revision: 30409
Modified:
branches/lazyrakudo/languages/perl6/src/classes/Array.pir
branches/lazyrakudo/languages/perl6/src/classes/Hash.pir
branches/lazyrakudo/languages/perl6/src/classes/List.pir
branches/lazyrakudo/languages/perl6/src/classes/Range.pir
branches/lazyrakudo/languages/perl6/src/parser/actions.pm
Log:
[rakudo] Another range of assorted fixes, getting us passing a little more of
spectest_regression in the lazy branch.
Modified: branches/lazyrakudo/languages/perl6/src/classes/Array.pir
==============================================================================
--- branches/lazyrakudo/languages/perl6/src/classes/Array.pir (original)
+++ branches/lazyrakudo/languages/perl6/src/classes/Array.pir Wed Aug 20
15:55:39 2008
@@ -77,6 +77,19 @@
.end
+=item new
+
+Instantiates a new array. (Overridden as default .new method does the wrong
+thing with our attributes.)
+
+=cut
+
+.sub 'new' :method
+ $P0 = new 'Perl6Array'
+ .return ($P0)
+.end
+
+
=item item()
Return Array in item context (i.e., self)
Modified: branches/lazyrakudo/languages/perl6/src/classes/Hash.pir
==============================================================================
--- branches/lazyrakudo/languages/perl6/src/classes/Hash.pir (original)
+++ branches/lazyrakudo/languages/perl6/src/classes/Hash.pir Wed Aug 20
15:55:39 2008
@@ -22,11 +22,13 @@
.sub 'hash'
.param pmc args :slurpy
.param pmc hash :slurpy :named
- args.'!flatten'()
+ .local pmc result
+ $P0 = get_hll_global 'list'
+ result = $P0(args)
unless hash goto hash_done
- unshift args, hash
+ unshift result, hash
hash_done:
- .return args.'hash'()
+ .return result.'hash'()
.end
Modified: branches/lazyrakudo/languages/perl6/src/classes/List.pir
==============================================================================
--- branches/lazyrakudo/languages/perl6/src/classes/List.pir (original)
+++ branches/lazyrakudo/languages/perl6/src/classes/List.pir Wed Aug 20
15:55:39 2008
@@ -38,10 +38,24 @@
listproto = p6meta.'register'($P0, 'parent'=>'Any')
$P0 = get_hll_namespace ['List']
+ '!EXPORT'('keys values', $P0)
#'!EXPORT'('first grep keys kv map pairs reduce values', $P0)
.end
+=item new
+
+Instantiates a new array. (Overridden as default .new method does the wrong
+thing with our attributes.)
+
+=cut
+
+.sub 'new' :method
+ $P0 = new 'Perl6Array'
+ .return ($P0)
+.end
+
+
=item clone() (vtable method)
Return a clone of this list. (Clones its elements also.)
@@ -435,7 +449,14 @@
=cut
.sub 'get_string' :vtable :method
- $S0 = join ' ', self
+ # Need to evaluate all of the list.
+ $I0 = self.'elems'()
+ dec $I0
+ self.'!evaluate_upto'($I0)
+
+ # Now join fully evaluated part.
+ $P0 = getattribute self, "@!evaluated"
+ $S0 = join ' ', $P0
.return ($S0)
.end
@@ -503,6 +524,25 @@
.end
+=item keys()
+
+Returns a List containing the keys of the invocant.
+
+=cut
+
+.sub 'keys' :method :multi(ResizablePMCArray)
+ $I0 = self.'elems'()
+ dec $I0
+ $P0 = 'infix:..'(0, $I0)
+ .return $P0.'list'()
+.end
+
+.sub 'keys' :multi()
+ .param pmc values :slurpy
+ .return values.'keys'()
+.end
+
+
=back
=head2 Methods added to ResizablePMCArray
@@ -541,6 +581,20 @@
.end
+=item keys()
+
+Returns a List containing the keys of the invocant.
+
+=cut
+
+.sub 'keys' :method
+ $I0 = elements self
+ dec $I0
+ $P0 = 'infix:..'(0, $I0)
+ .return $P0.'list'()
+.end
+
+
=item !flatten()
Flatten the invocant, as in list context. This doesn't make the list eager,
@@ -753,25 +807,6 @@
.end
-=item keys()
-
-Returns a List containing the keys of the invocant.
-
-=cut
-
-.sub 'keys' :method :multi(ResizablePMCArray)
- $I0 = self.'elems'()
- dec $I0
- $P0 = 'infix:..'(0, $I0)
- .return $P0.'list'()
-.end
-
-.sub 'keys' :multi()
- .param pmc values :slurpy
- .return values.'keys'()
-.end
-
-
=item kv()
Return items in invocant as 2-element (index, value) lists.
Modified: branches/lazyrakudo/languages/perl6/src/classes/Range.pir
==============================================================================
--- branches/lazyrakudo/languages/perl6/src/classes/Range.pir (original)
+++ branches/lazyrakudo/languages/perl6/src/classes/Range.pir Wed Aug 20
15:55:39 2008
@@ -164,22 +164,14 @@
=item list()
-Generate the Range in list context. Currently we generate all
-of the elements in the range; when we have lazy lists we can
-just return a clone of the Range.
+Generate the Range in list context (a list containing the range).
=cut
.sub 'list' :method
- .local pmc range_it, result
- range_it = self.'iterator'()
- result = new 'List'
- range_loop:
- unless range_it goto range_end
- $P0 = shift range_it
- push result, $P0
- goto range_loop
- range_end:
+ $P0 = get_hll_global 'list'
+ .local pmc result
+ result = $P0(self)
.return (result)
.end
Modified: branches/lazyrakudo/languages/perl6/src/parser/actions.pm
==============================================================================
--- branches/lazyrakudo/languages/perl6/src/parser/actions.pm (original)
+++ branches/lazyrakudo/languages/perl6/src/parser/actions.pm Wed Aug 20
15:55:39 2008
@@ -3127,7 +3127,7 @@
}
# Now go through what signature and extract what to declare.
- my @result := list();
+ my @result := Array.new();
my $first := 1;
for @($sig_setup) {
if $first {