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

[svn:parrot] r35821 - trunk/languages/perl6/src/builtins

From:
jonathan
Date:
January 20, 2009 09:51
Subject:
[svn:parrot] r35821 - trunk/languages/perl6/src/builtins
Message ID:
20090120175136.4A5CCCB9AE@x12.develooper.com
Author: jonathan
Date: Tue Jan 20 09:51:35 2009
New Revision: 35821

Modified:
   trunk/languages/perl6/src/builtins/guts.pir

Log:
[rakudo] Compose roles at class composition time, rather than as we encounter them.

Modified: trunk/languages/perl6/src/builtins/guts.pir
==============================================================================
--- trunk/languages/perl6/src/builtins/guts.pir	(original)
+++ trunk/languages/perl6/src/builtins/guts.pir	Tue Jan 20 09:51:35 2009
@@ -485,11 +485,13 @@
     # Parrot handles composing methods into roles, but we need to handle the
     # attribute composition ourselves.
     .local pmc roles, roles_it
-    roles = inspect metaclass, 'roles'
+    roles = getprop '@!roles', metaclass
+    if null roles goto roles_it_loop_end
     roles_it = iter roles
   roles_it_loop:
     unless roles_it goto roles_it_loop_end
     $P0 = shift roles_it
+    metaclass.'add_role'($P0)
     '!compose_role_attributes'(metaclass, $P0)
     goto roles_it_loop
   roles_it_loop_end:
@@ -558,8 +560,14 @@
     ##  select the correct role based upon any parameters
     $P0 = $P0.'!select'(pos_args :flat, named_args :flat :named)
 
-    ##  add it to the class.
-    metaclass.'add_role'($P0)
+    ##  add it to the composition list (we compose them at the end)
+    .local pmc role_list
+    role_list = getprop '@!roles', metaclass
+    unless null role_list goto have_role_list
+    role_list = new 'ResizablePMCArray'
+    setprop metaclass, '@!roles', role_list
+  have_role_list:
+    push role_list, $P0
 .end
 
 



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