Created
April 6, 2009 13:58
-
-
Save masak/90763 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git di | |
diff --git a/src/classes/IO.pir b/src/classes/IO.pir | |
index 2459c9c..de931b1 100644 | |
--- a/src/classes/IO.pir | |
+++ b/src/classes/IO.pir | |
@@ -14,7 +14,7 @@ This file implements the IO file handle class. | |
.sub '' :anon :init :load | |
.local pmc p6meta | |
p6meta = get_hll_global ['Perl6Object'], '$!P6META' | |
- $P0 = p6meta.'new_class'('IO', 'parent'=>'Any', 'attr'=>'$!PIO') | |
+ $P0 = p6meta.'new_class'('IO', 'parent'=>'Any', 'attr'=>'$!PIO $!ins') | |
$P0.'!MUTABLE'() | |
p6meta.'new_class'('IOIterator', 'parent'=>'Perl6Object', 'attr'=>'$!IO') | |
@@ -40,6 +40,18 @@ Reads a line from the file handle. | |
.return ($P0) | |
.end | |
+=item ins | |
+ | |
+Reports the number of records (usu. lines) read so far. | |
+ | |
+=cut | |
+ | |
+.sub 'ins' :method | |
+ $P0 = getattribute self, "$!ins" | |
+ $I0 = $P0 | |
+ .return ($I0) | |
+.end | |
+ | |
=back | |
@@ -77,9 +89,12 @@ Read a single line and return it. | |
.namespace ['IOIterator'] | |
.sub 'item' :method :vtable('shift_pmc') | |
- .local pmc pio, chomper | |
+ .local pmc pio, ins, chomper | |
$P0 = getattribute self, "$!IO" | |
pio = getattribute $P0, "$!PIO" | |
+ ins = getattribute $P0, "$!ins" | |
+ 'prefix:++'(ins) | |
+ setattribute $P0, "$!ins", ins | |
pio = '!DEREF'(pio) | |
$P0 = pio.'readline'() | |
chomper = get_hll_global 'chomp' | |
@@ -94,7 +109,7 @@ Read all of the lines and return them as a List. | |
.namespace ['IOIterator'] | |
.sub 'list' :method | |
- .local pmc pio, res, chomper | |
+ .local pmc pio, ins, res, chomper | |
$P0 = getattribute self, "$!IO" | |
pio = getattribute $P0, "$!PIO" | |
pio = '!DEREF'(pio) | |
@@ -102,6 +117,9 @@ Read all of the lines and return them as a List. | |
chomper = get_hll_global 'chomp' | |
loop: | |
+ ins = getattribute $P0, "$!ins" | |
+ 'prefix:++'(ins) | |
+ setattribute $P0, "$!ins", ins | |
$S0 = pio.'readline'() | |
if $S0 == '' goto done | |
$S0 = chomper($S0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment