Author: jonathan
Date: Tue Jul 29 13:48:18 2008
New Revision: 29862

Modified:
   trunk/languages/perl6/ROADMAP
   trunk/languages/perl6/src/classes/Range.pir

Log:
[rakudo] Make range smart-matching accept the same or equivalent range as well 
as a single value within the range.

Modified: trunk/languages/perl6/ROADMAP
==============================================================================
--- trunk/languages/perl6/ROADMAP       (original)
+++ trunk/languages/perl6/ROADMAP       Tue Jul 29 13:48:18 2008
@@ -40,7 +40,6 @@
 
 * Implement whatever (*) in array indexing: @foo[*-1]
 * Implement Rat data type
-* Range smart-matching should accept the same or equivalent range
 * Implement infinite ranges
 * Implement return type co-ercion ("as") and constraint ("of")
 * Fix issues with Int type constraint when we get an Integer PMC back, and

Modified: trunk/languages/perl6/src/classes/Range.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Range.pir (original)
+++ trunk/languages/perl6/src/classes/Range.pir Tue Jul 29 13:48:18 2008
@@ -50,17 +50,35 @@
 
 =item ACCEPTS(topic)
 
-Determines if topic is within the range.
+Determines if topic is within the range or equal to the range.
 
 =cut
 
 .sub 'ACCEPTS' :method
     .param pmc topic
 
+    $I0 = isa topic, 'Range'
+    unless $I0 goto value_in_range_check
+    $I0 = self.'from'()
+    $I1 = topic.'from'()
+    if $I0 != $I1 goto false
+    $I0 = self.'to'()
+    $I1 = topic.'to'()
+    if $I0 != $I1 goto false
+    $P0 = getattribute self, "$!from_exclusive"
+    $P1 = getattribute topic, "$!from_exclusive"
+    if $P0 != $P1 goto false
+    $P0 = getattribute self, "$!to_exclusive"
+    $P1 = getattribute topic, "$!to_exclusive"
+    if $P0 != $P1 goto false
+    goto true
+
+  value_in_range_check:
     $I0 = self.'!from_test'(topic)
     unless $I0 goto false
     $I0 = self.'!to_test'(topic)
     unless $I0 goto false
+
   true:
     $P0 = get_hll_global ['Bool'], 'True'
     .return ($P0)

Reply via email to