develooper Front page | perl.cvs.parrot | Postings from January 2009

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

From:
jonathan
Date:
January 28, 2009 06:22
Subject:
[svn:parrot] r36090 - trunk/languages/perl6/src/classes
Message ID:
20090128142215.2F6D1CB9AE@x12.develooper.com
Author: jonathan
Date: Wed Jan 28 06:22:13 2009
New Revision: 36090

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

Log:
[rakudo] Auto-threading over the invocant for methods not defined in Junction.

Modified: trunk/languages/perl6/src/classes/ClassHOW.pir
==============================================================================
--- trunk/languages/perl6/src/classes/ClassHOW.pir	(original)
+++ trunk/languages/perl6/src/classes/ClassHOW.pir	Wed Jan 28 06:22:13 2009
@@ -144,9 +144,29 @@
     unless have_pmc_proxy goto error
     ($P0 :slurpy, $P1 :slurpy :named) = obj.name(pos_args :flat, name_args :flat :named)
     .return ($P0 :flat, $P1 :named :flat)
+  
   error:
+    # Error, unless invocant is a junction in which case we thread over it.
+    $I0 = isa obj, 'Junction'
+    if $I0 goto autothread_invocant
     $P0 = getattribute self, 'longname'
     'die'("Could not locate a method '", name, "' to invoke on class '", $P0, "'.")
+
+  autothread_invocant:
+    .local pmc values, values_it, res, res_list, type
+    res_list = 'list'()
+    values = obj.'!eigenstates'()
+    values_it = iter values
+  values_it_loop:
+    unless values_it goto values_it_loop_end
+    $P0 = shift values_it
+    $P1 = $P0.'HOW'()
+    res = $P1.'dispatch'($P0, name, pos_args :flat, name_args :flat :named)
+    push res_list, res
+    goto values_it_loop
+  values_it_loop_end:
+    type = obj.'!type'()
+    .tailcall '!MAKE_JUNCTION'(type, res_list)
 .end
 
 =back



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