Author: jonathan
Date: Fri Jan 16 03:46:09 2009
New Revision: 35622
Added:
trunk/languages/perl6/src/classes/ClassHOW.pir (contents, props changed)
Modified:
trunk/languages/perl6/src/classes/Any.pir
Log:
[rakudo] Implement .does method (Any delegates to the metaclass, and we have the implementation there).
Modified: trunk/languages/perl6/src/classes/Any.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Any.pir (original)
+++ trunk/languages/perl6/src/classes/Any.pir Fri Jan 16 03:46:09 2009
@@ -43,6 +43,16 @@
.tailcall $P0.'isa'(self, x)
.end
+=item does($x)
+
+=cut
+
+.sub 'does' :method
+ .param pmc x
+ $P0 = self.'HOW'()
+ .tailcall $P0.'isa'(self, x)
+.end
+
=back
=cut
Added: trunk/languages/perl6/src/classes/ClassHOW.pir
==============================================================================
--- (empty file)
+++ trunk/languages/perl6/src/classes/ClassHOW.pir Fri Jan 16 03:46:09 2009
@@ -0,0 +1,45 @@
+## $Id$
+
+=head1 TITLE
+
+ClassHOW - default metaclass
+
+=head1 DESCRIPTION
+
+This file for now actually just adds a method or two into P6metaclass. In the
+long run, we probably need to subclass that, and make sure we have all of the
+methods in here that are defined in the HOW API.
+
+=head2 Methods on P6metaclass
+
+=over
+
+=item does(self, role)
+
+Tests role membership.
+
+=cut
+
+.namespace ['P6metaclass']
+.sub 'does' :method
+ .param pmc obj
+ .param pmc type
+
+ # Check if we have a Perl6Role - needs special handling.
+ $I0 = isa type, 'Perl6Role'
+ unless $I0 goto not_p6role
+ .tailcall type.'ACCEPTS'(obj)
+ not_p6role:
+ $I0 = does obj, type
+ .tailcall 'prefix:?'($I0)
+.end
+
+=back
+
+=cut
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir: