Author: pmichaud
Date: Tue Nov 11 07:58:08 2008
New Revision: 32543

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

Log:
[rakudo]:  Revise r32528 so that Num::ACCEPTS (re)uses existing .ACCEPTS


Modified: trunk/languages/perl6/src/classes/Num.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Num.pir   (original)
+++ trunk/languages/perl6/src/classes/Num.pir   Tue Nov 11 07:58:08 2008
@@ -21,34 +21,25 @@
     p6meta.'register'('Float', 'parent'=>numproto, 'protoobject'=>numproto)
     
     # Override the proto's ACCEPT method so we also accept Ints.
-    .const 'Sub' $P0 = "custom_ACCEPTS"
-    $P1 = class numproto
+    .const 'Sub' $P0 = "Num::ACCEPTS"
+    $P1 = typeof numproto
     $P1.'add_method'('ACCEPTS', $P0)
 .end
 
-.sub 'custom_ACCEPTS' :anon :method
-    .param pmc topic
-    .local pmc topichow, topicwhat, parrotclass
 
-    topichow = topic.'HOW'()
-    topicwhat = topic.'WHAT'()
+.sub 'Num::ACCEPTS' :anon :method
+    .param pmc topic
 
-    # Check if we match Num type.
-    parrotclass = topichow.'get_parrotclass'(self)
-    $I0 = isa topicwhat, parrotclass
-    if $I0 goto end
-    $I0 = does topic, parrotclass
-    if $I0 goto end
+    ##  first, try our superclass .ACCEPTS
+    $P0 = get_hll_global 'Any'
+    $P1 = find_method $P0, 'ACCEPTS'
+    $I0 = self.$P1(topic)
+    unless $I0 goto try_int
+    .return ($I0)
 
-    # Check if we match Int type, which Num can also take.
+  try_int:
     $P0 = get_hll_global 'Int'
-    parrotclass = topichow.'get_parrotclass'($P0)
-    $I0 = isa topicwhat, parrotclass
-    if $I0 goto end
-    $I0 = does topic, parrotclass
-
-  end:
-    .return ($I0)
+    .tailcall $P0.'ACCEPTS'(topic)
 .end
 
 

Reply via email to