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

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

From:
jonathan
Date:
January 15, 2009 09:25
Subject:
[svn:parrot] r35596 - trunk/languages/perl6/src/builtins
Message ID:
20090115172435.31284CB9AE@x12.develooper.com
Author: jonathan
Date: Thu Jan 15 09:24:34 2009
New Revision: 35596

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

Log:
[rakudo] Rip out a chunk of duplicated code from a routine, calling the new (and correct) version instead. Also, make !keyword_has now just forward to !meta_attribute, in preparation for removing it proper.

Modified: trunk/languages/perl6/src/builtins/guts.pir
==============================================================================
--- trunk/languages/perl6/src/builtins/guts.pir	(original)
+++ trunk/languages/perl6/src/builtins/guts.pir	Thu Jan 15 09:24:34 2009
@@ -912,51 +912,10 @@
     'die'('does keyword can only be used with roles.')
   role_ok:
 
-    # Get Parrot to compose the role for us (handles the methods).
+    # Get Parrot to compose the role for us (handles the methods), then call
+    # attribute composer.
     addrole class, role
-
-    # Parrot doesn't handle composing the attributes; we do that here for now.
-    .local pmc role_attrs, class_attrs, ra_iter
-    .local string cur_attr
-    role_attrs = inspect role, "attributes"
-    class_attrs = inspect class, "attributes"
-    ra_iter = iter role_attrs
-  ra_iter_loop:
-    unless ra_iter goto ra_iter_loop_end
-    cur_attr = shift ra_iter
-
-    # Check that this attribute doesn't conflict with one already in the class.
-    $I0 = exists class_attrs[cur_attr]
-    unless $I0 goto no_conflict
-
-    # We have a name conflict. Let's compare the types. If they match, then we
-    # can merge the attributes.
-    .local pmc class_attr_type, role_attr_type
-    $P0 = class_attrs[cur_attr]
-    if null $P0 goto conflict
-    class_attr_type = $P0['type']
-    if null class_attr_type goto conflict
-    $P0 = role_attrs[cur_attr]
-    if null $P0 goto conflict
-    role_attr_type = $P0['type']
-    if null role_attr_type goto conflict
-    $I0 = '!SAMETYPE_EXACT'(class_attr_type, role_attr_type)
-    if $I0 goto merge
-
-  conflict:
-    $S0 = "Conflict of attribute '"
-    $S0 = concat cur_attr
-    $S0 = concat "' in composition of role '"
-    $S1 = role
-    $S0 = concat $S1
-    $S0 = concat "'"
-    'die'($S0)
-
-  no_conflict:
-    addattribute class, cur_attr
-  merge:
-    goto ra_iter_loop
-  ra_iter_loop_end:
+    '!compose_role_attributes'(class, role)
 .end
 
 
@@ -972,10 +931,9 @@
     .param pmc type     :optional
     .param int got_type :opt_flag
     if got_type goto with_type
-    class.'add_attribute'(attr_name)
-    .return ()
+    .tailcall '!meta_attribute'(class, attr_name, 'Perl6Scalar')
   with_type:
-    class.'add_attribute'(attr_name, type)
+    .tailcall '!meta_attribute'(class, attr_name, 'Perl6Scalar', 'type'=>type)
 .end
 
 



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