# New Ticket Created by "Olivier Mengué"
# Please include the string: [perl #55860]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=55860 >
Here a patch that implements 'perl' methods on Bool and Range objects.
Olivier Mengué (dolmen on CPAN/IRC)
Index: src/classes/Bool.pir
===================================================================
--- src/classes/Bool.pir (révision 28379)
+++ src/classes/Bool.pir (copie de travail)
@@ -53,6 +53,20 @@
.end
+=item perl()
+
+Returns a Perl representation of the Bool.
+
+=cut
+
+.sub 'perl' :method
+ unless self goto false
+ .return ("Bool::True")
+ false:
+ .return ("Bool::False")
+.end
+
+
# Local Variables:
# mode: pir
# fill-column: 100
Index: src/classes/Range.pir
===================================================================
--- src/classes/Range.pir (révision 28379)
+++ src/classes/Range.pir (copie de travail)
@@ -148,6 +148,35 @@
.return ($I0)
.end
+
+=item perl()
+
+Returns a Perl representation of the Range.
+
+=cut
+
+.sub 'perl' :method
+ .local string result, tmp
+ .local pmc from, fromexc, toexc, to
+ from = getattribute self, '$!from'
+ fromexc = getattribute self, '$!from_exclusive'
+ toexc = getattribute self, '$!to_exclusive'
+ to = getattribute self, '$!to'
+ result = from.'perl'()
+ unless fromexc goto dots
+ result .= '^'
+ dots:
+ result .= '..'
+ unless toexc goto end
+ result .= '^'
+ end:
+ tmp = to.'perl'()
+ result .= tmp
+ .return (result)
+.end
+
+
+
=back
=head2 Operators