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

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

From:
pmichaud
Date:
December 20, 2008 03:12
Subject:
[svn:parrot] r34137 - trunk/languages/perl6/src/classes
Message ID:
20081220111243.5558CCBA12@x12.develooper.com
Author: pmichaud
Date: Sat Dec 20 03:12:42 2008
New Revision: 34137

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

Log:
[rakudo]: Distinguish array from hash access (resolves RT #60732).


Modified: trunk/languages/perl6/src/classes/Associative.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Associative.pir	(original)
+++ trunk/languages/perl6/src/classes/Associative.pir	Sat Dec 20 03:12:42 2008
@@ -51,7 +51,7 @@
     .local pmc elem
     elem = self[$S0]
     unless null elem goto slice_elem
-    elem = new 'Failure'
+    elem = 'undef'()
     self[$S0] = elem
   slice_elem:
     push result, elem
@@ -67,11 +67,14 @@
     .param pmc args    :slurpy
     .param pmc options :slurpy :named
     $I0 = can invocant, 'postcircumfix:{ }'
-    unless $I0 goto foreign
-    .tailcall invocant.'postcircumfix:{ }'(args :flat, options :flat :named)
+    if $I0 goto object_method
+    $I0 = isa invocant, 'Perl6Object'
+    if $I0 goto object_method
   foreign:
     $P0 = get_hll_global ['Associative'], 'postcircumfix:{ }'
     .tailcall $P0(invocant, args :flat, options :flat :named)
+  object_method:
+    .tailcall invocant.'postcircumfix:{ }'(args :flat, options :flat :named)
 .end
 
 =back

Modified: trunk/languages/perl6/src/classes/Mapping.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Mapping.pir	(original)
+++ trunk/languages/perl6/src/classes/Mapping.pir	Sat Dec 20 03:12:42 2008
@@ -16,6 +16,8 @@
     .local pmc p6meta, mappingproto
     p6meta = get_hll_global ['Perl6Object'], '$!P6META'
     mappingproto = p6meta.'new_class'('Mapping', 'parent'=>'Hash Any')
+    $P0 = get_hll_global 'Associative'
+    p6meta.'add_role'($P0, 'to'=>mappingproto)
     p6meta.'register'('Hash', 'parent'=>mappingproto, 'protoobject'=>mappingproto)
     $P0 = get_hll_namespace ['Mapping']
     '!EXPORT'('keys,kv,values,reverse', $P0)

Modified: trunk/languages/perl6/src/classes/Positional.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Positional.pir	(original)
+++ trunk/languages/perl6/src/classes/Positional.pir	Sat Dec 20 03:12:42 2008
@@ -13,9 +13,6 @@
 .sub '' :anon :load :init
     .local pmc positional
     positional = '!keyword_role'('Positional')
-
-    $P0 = get_hll_namespace ['Positional']
-    '!EXPORT'('postcircumfix:[ ]', $P0)
 .end
 
 =head2 Operators
@@ -29,7 +26,7 @@
 =cut
 
 .namespace ['Positional']
-.sub 'postcircumfix:[ ]' :method :multi(_, _)
+.sub 'postcircumfix:[ ]' :method
     .param pmc args            :slurpy
     .param pmc options         :slurpy :named
     .local pmc result
@@ -54,7 +51,7 @@
     .local pmc elem
     elem = self[$I0]
     unless null elem goto slice_elem
-    elem = new 'Failure'
+    elem = 'undef'()
     self[$I0] = elem
   slice_elem:
     push result, elem
@@ -64,6 +61,22 @@
     .return (result)
 .end
 
+.namespace []
+.sub 'postcircumfix:[ ]'
+    .param pmc invocant
+    .param pmc args    :slurpy
+    .param pmc options :slurpy :named
+    $I0 = can invocant, 'postcircumfix:[ ]'
+    if $I0 goto object_method
+    $I0 = isa invocant, 'Perl6Object'
+    if $I0 goto object_method
+  foreign:
+    $P0 = get_hll_global ['Positional'], 'postcircumfix:[ ]'
+    .tailcall $P0(invocant, args :flat, options :flat :named)
+  object_method:
+    .tailcall invocant.'postcircumfix:[ ]'(args :flat, options :flat :named)
+.end
+
 =back
 
 =cut



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