cvsuser 04/11/26 15:03:00
Modified: . MANIFEST
examples/streams Bytes.imc Combiner.imc Coroutine.imc
Filter.imc Include.imc SubCounter.imc
runtime/parrot/library/Stream Base.imc Combiner.imc
Coroutine.imc Filter.imc Lines.imc ParrotIO.imc
Replay.imc Sub.imc Writer.imc
t/library streams.t
Removed: runtime/parrot/library/Stream Buffer.imc
Log:
- updated the stream library WRT calling conventions
- removed unused/empty Stream::Buffer
- some minor improvments
Revision Changes Path
1.789 +0 -1 parrot/MANIFEST
Index: MANIFEST
===================================================================
RCS file: /cvs/public/parrot/MANIFEST,v
retrieving revision 1.788
retrieving revision 1.789
diff -u -r1.788 -r1.789
--- MANIFEST 23 Nov 2004 19:01:44 -0000 1.788
+++ MANIFEST 26 Nov 2004 23:02:55 -0000 1.789
@@ -2663,7 +2663,6 @@
runtime/parrot/library/SDL/StopWatch.imc [library]
runtime/parrot/library/SDL/Surface.imc [library]
runtime/parrot/library/Stream/Base.imc [library]
-runtime/parrot/library/Stream/Buffer.imc [library]
runtime/parrot/library/Stream/Combiner.imc [library]
runtime/parrot/library/Stream/Coroutine.imc [library]
runtime/parrot/library/Stream/Filter.imc [library]
1.3 +0 -1 parrot/examples/streams/Bytes.imc
Index: Bytes.imc
===================================================================
RCS file: /cvs/public/parrot/examples/streams/Bytes.imc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Bytes.imc 30 Oct 2004 16:25:27 -0000 1.2
+++ Bytes.imc 26 Nov 2004 23:02:58 -0000 1.3
@@ -68,7 +68,6 @@
=cut
.sub _hello method
-# self."write"( "hello123456789" )
self."write"( "hello" )
self."write"( "world!" )
self."write"( "parrot" )
1.3 +1 -3 parrot/examples/streams/Combiner.imc
Index: Combiner.imc
===================================================================
RCS file: /cvs/public/parrot/examples/streams/Combiner.imc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Combiner.imc 18 Nov 2004 14:10:32 -0000 1.2
+++ Combiner.imc 26 Nov 2004 23:02:58 -0000 1.3
@@ -122,9 +122,7 @@
str = strings[1]
concat ret, str
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return(ret)
.end
=back
1.3 +2 -6 parrot/examples/streams/Coroutine.imc
Index: Coroutine.imc
===================================================================
RCS file: /cvs/public/parrot/examples/streams/Coroutine.imc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Coroutine.imc 18 Nov 2004 14:10:32 -0000 1.2
+++ Coroutine.imc 26 Nov 2004 23:02:58 -0000 1.3
@@ -58,9 +58,7 @@
LOOP:
str = i
- .pcc_begin_yield
- .return str
- .pcc_end_yield
+ .yield(str)
inc i
if i < 10 goto LOOP
@@ -71,9 +69,7 @@
# in which case it doesn't matter what you are returning.
null str
- .pcc_begin_return
- .return str
- .pcc_end_return
+ .return(str)
.end
=back
1.3 +2 -9 parrot/examples/streams/Filter.imc
Index: Filter.imc
===================================================================
RCS file: /cvs/public/parrot/examples/streams/Filter.imc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Filter.imc 18 Nov 2004 14:10:32 -0000 1.2
+++ Filter.imc 26 Nov 2004 23:02:58 -0000 1.3
@@ -67,9 +67,6 @@
inc i
if i < 10 goto LOOP
-
- .pcc_begin_return
- .pcc_end_return
.end
=item _filter
@@ -96,15 +93,11 @@
concat str, " * 2 = "
concat str, tmp
- .pcc_begin_return
- .return str
- .pcc_end_return
+ .return(str)
SKIP:
null str
- .pcc_begin_return
- .return str
- .pcc_end_return
+ .return(str)
.end
=back
1.3 +0 -9 parrot/examples/streams/Include.imc
Index: Include.imc
===================================================================
RCS file: /cvs/public/parrot/examples/streams/Include.imc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Include.imc 18 Nov 2004 14:10:32 -0000 1.2
+++ Include.imc 26 Nov 2004 23:02:58 -0000 1.3
@@ -70,9 +70,6 @@
inc i
if i < 10 goto LOOP
-
- .pcc_begin_return
- .pcc_end_return
.end
=item _included
@@ -100,9 +97,6 @@
self."include"( temp )
self."write"( "world" )
-
- .pcc_begin_return
- .pcc_end_return
.end
=item _counter2
@@ -125,9 +119,6 @@
chr str, $I0
if str != "G" goto LOOP
-
- .pcc_begin_return
- .pcc_end_return
.end
=back
1.3 +0 -3 parrot/examples/streams/SubCounter.imc
Index: SubCounter.imc
===================================================================
RCS file: /cvs/public/parrot/examples/streams/SubCounter.imc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SubCounter.imc 18 Nov 2004 14:10:32 -0000 1.2
+++ SubCounter.imc 26 Nov 2004 23:02:58 -0000 1.3
@@ -56,9 +56,6 @@
inc i
if i < 10 goto LOOP
-
- .pcc_begin_return
- .pcc_end_return
.end
=back
1.4 +21 -32 parrot/runtime/parrot/library/Stream/Base.imc
Index: Base.imc
===================================================================
RCS file: /cvs/public/parrot/runtime/parrot/library/Stream/Base.imc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Base.imc 28 Oct 2004 07:59:24 -0000 1.3
+++ Base.imc 26 Nov 2004 23:02:59 -0000 1.4
@@ -26,7 +26,7 @@
.const int aIncludes = 1
.const int aBuffer = 2
-.sub __stream_base_onload prototyped, @LOAD
+.sub onload prototyped, @LOAD, @ANON
find_type $I0, "Stream::Base"
if $I0 > 1 goto END
@@ -60,11 +60,17 @@
.end
.sub setSource method
- .param pmc src
- newsub $P0, .Sub, __set_pmc
- $P0(src)
+ .param pmc source
+
+ classoffset $I0, self, "Stream::Base"
+ setattribute self, $I0, source
+ null source
.end
+=item close
+
+=cut
+
.sub close method
.local pmc temp
@@ -104,10 +110,12 @@
print "]\n"
branch LOOP
END:
- .pcc_begin_return
- .pcc_end_return
.end
+=item copyTo
+
+=cut
+
.sub copyTo method
.param pmc to
.local string str
@@ -121,8 +129,6 @@
print to, str
branch LOOP
END:
- .pcc_begin_return
- .pcc_end_return
.end
=item source = stream."source"()
@@ -142,9 +148,7 @@
add $I0, aSource
getattribute ret, self, $I0
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return(ret)
ERROR:
print "Stream::Base::source(): parameters passed\n"
end
@@ -172,13 +176,9 @@
$I0 = $P0."connected"()
unless $I0 goto NOT
SKIP:
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return(1)
NOT:
- .pcc_begin_return
- .return 0
- .pcc_end_return
+ .return(0)
.end
=item str = stream."read"()
@@ -216,9 +216,7 @@
isnull ret, INCLUDE_CHECK
DONE:
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return(ret)
INCLUDE_CHECK:
$I0 = includes
@@ -260,9 +258,6 @@
push includes, stream
self."flush"()
-
- .pcc_begin_return
- .pcc_end_return
.end
=item stream."flush"() (B<internal>)
@@ -290,9 +285,7 @@
i = self."write"( str )
CANT:
- .pcc_begin_return
- .return i
- .pcc_end_return
+ .return(i)
.end
=item stream."read_bytes"( number )
@@ -351,9 +344,7 @@
setattribute self, $I0, buffer
END:
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return(ret)
.end
=item stream."byte_buffer"() (B<internal>)
@@ -377,9 +368,7 @@
SET:
setattribute self, $I0, buf
END:
- .pcc_begin_return
- .return $P0
- .pcc_end_return
+ .return($P0)
.end
=back
1.4 +10 -24 parrot/runtime/parrot/library/Stream/Combiner.imc
Index: Combiner.imc
===================================================================
RCS file: /cvs/public/parrot/runtime/parrot/library/Stream/Combiner.imc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Combiner.imc 30 Oct 2004 15:36:05 -0000 1.3
+++ Combiner.imc 26 Nov 2004 23:02:59 -0000 1.4
@@ -22,7 +22,7 @@
=cut
-.sub __stream_combiner_onload @LOAD
+.sub onload @LOAD, @ANON
.local int i
.local pmc base
.local pmc comb
@@ -37,8 +37,6 @@
addattribute comb, "combiner"
END:
- .pcc_begin_return
- .pcc_end_return
.end
.sub _default_combiner
@@ -47,9 +45,7 @@
join ret, "", args
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return(ret)
.end
.include "iterator.pasm"
@@ -76,17 +72,15 @@
.param pmc _combiner
.local pmc ret
- classoffset I0, self, "Stream::Combiner"
+ classoffset $I0, self, "Stream::Combiner"
if argcP == 0 goto GET
- setattribute self, I0, _combiner
+ setattribute self, $I0, _combiner
ret = _combiner
branch END
GET:
- getattribute ret, self, I0
+ getattribute ret, self, $I0
END:
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return(ret)
.end
=item assign stream, source
@@ -138,14 +132,10 @@
if i goto LOOP
NOT_CONNECTED:
- .pcc_begin_return
- .return 0
- .pcc_end_return
+ .return(0)
IS_CONNECTED:
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return(1)
.end
=item source."rawRead"() (B<internal>)
@@ -196,16 +186,12 @@
getattribute combiner, self, i
ret = combiner( args )
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return(ret)
END_OF_STREAM:
self."close"()
null ret
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return(ret)
.end
=back
1.2 +4 -8 parrot/runtime/parrot/library/Stream/Coroutine.imc
Index: Coroutine.imc
===================================================================
RCS file: /cvs/public/parrot/runtime/parrot/library/Stream/Coroutine.imc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Coroutine.imc 25 May 2004 18:06:35 -0000 1.1
+++ Coroutine.imc 26 Nov 2004 23:02:59 -0000 1.2
@@ -20,7 +20,7 @@
=cut
-.sub __stream_coroutine_onload @LOAD
+.sub onload @LOAD, @ANON
.local pmc base
.local pmc coro
.local int i
@@ -34,8 +34,6 @@
subclass coro, base, "Stream::Coroutine"
END:
- .pcc_begin_return
- .pcc_end_return
.end
.namespace ["Stream::Coroutine"]
@@ -52,15 +50,13 @@
null str
coro = self."source"()
- typeof I0, coro
- if I0 == .PerlUndef goto END
+ typeof $I0, coro
+ if $I0 == .PerlUndef goto END
str = coro( self )
END:
- .pcc_begin_return
- .return str
- .pcc_end_return
+ .return(str)
.end
=back
1.4 +6 -12 parrot/runtime/parrot/library/Stream/Filter.imc
Index: Filter.imc
===================================================================
RCS file: /cvs/public/parrot/runtime/parrot/library/Stream/Filter.imc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Filter.imc 30 Oct 2004 15:36:05 -0000 1.3
+++ Filter.imc 26 Nov 2004 23:02:59 -0000 1.4
@@ -20,7 +20,7 @@
=cut
-.sub __stream_filter_onload @LOAD
+.sub onload @LOAD, @ANON
.local int i
.local pmc base
.local pmc filter
@@ -35,8 +35,6 @@
addattribute filter, "filter"
END:
- .pcc_begin_return
- .pcc_end_return
.end
.namespace ["Stream::Filter"]
@@ -52,16 +50,14 @@
.local pmc ret
ret = _filter
- classoffset I0, self, "Stream::Filter"
+ classoffset $I0, self, "Stream::Filter"
if argcP == 0 goto GET
- setattribute self, I0, _filter
+ setattribute self, $I0, _filter
branch END
GET:
- getattribute ret, self, I0
+ getattribute ret, self, $I0
END:
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return(ret)
.end
=item source."rawRead"() (B<internal>)
@@ -83,9 +79,7 @@
str = filter( str )
isnull str, REDO
END:
- .pcc_begin_return
- .return str
- .pcc_end_return
+ .return(str)
.end
=back
1.4 +22 -38 parrot/runtime/parrot/library/Stream/Lines.imc
Index: Lines.imc
===================================================================
RCS file: /cvs/public/parrot/runtime/parrot/library/Stream/Lines.imc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Lines.imc 30 Oct 2004 15:36:05 -0000 1.3
+++ Lines.imc 26 Nov 2004 23:02:59 -0000 1.4
@@ -22,7 +22,7 @@
.include "library/Data/Escape.imc"
-.sub __stream_lines_onload @LOAD
+.sub onload @LOAD, @ANON
.local int i
.local pmc base
.local pmc lines
@@ -44,12 +44,9 @@
.sub __init method
.local pmc temp
- classoffset I0, self, "Stream::Lines"
+ classoffset $I0, self, "Stream::Lines"
temp = new .PerlString
- setattribute self, I0, temp
-
- .pcc_begin_return
- .pcc_end_return
+ setattribute self, $I0, temp
.end
=item is = stream."connected"()
@@ -60,19 +57,15 @@
.sub connected method
# XXX: check if the buffer is empty if the source stream is not connected
- save I0
- classoffset I0, self, "Stream::Base"
- getattribute self, self, I0
- isnull self, NOT
- typeof I0, self
- if I0 == .PerlUndef goto NOT
- restore I0
- callmethod
-NOT:
- restore I0
- .pcc_begin_return
- .return 0
- .pcc_end_return
+ classoffset $I0, self, "Stream::Base"
+ getattribute $P0, self, $I0
+ isnull $P0, NOT_CONNECTED
+ typeof $I0, $P0
+ if $I0 == .PerlUndef goto NOT_CONNECTED
+ $I0 = $P0."connected"()
+ .return($I0)
+NOT_CONNECTED:
+ .return(0)
.end
=item is = stream."rawRead"() (B<internal>)
@@ -110,9 +103,7 @@
self."setBuffer"( buffer )
BUFFER_END:
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return(ret)
.end
=item is = stream."buffer"() (B<internal>)
@@ -125,14 +116,11 @@
.local pmc temp
.local string _buffer
- classoffset I0, self, "Stream::Lines"
- getattribute temp, self, I0
+ classoffset $I0, self, "Stream::Lines"
+ getattribute temp, self, $I0
_buffer = temp
- .pcc_begin_return
- .return temp
- .return _buffer
- .pcc_end_return
+ .return(temp,_buffer)
.end
=item is = stream."setBuffer"() (B<internal>)
@@ -147,8 +135,8 @@
new temp, .PerlString
temp = buffer
- classoffset I0, self, "Stream::Lines"
- setattribute self, I0, temp
+ classoffset $I0, self, "Stream::Lines"
+ setattribute self, $I0, temp
.end
=item stream."fillBuffer"() (B<internal>)
@@ -167,8 +155,8 @@
temp = self."source"()
str = temp."read"()
- classoffset I0, self, "Stream::Lines"
- getattribute temp, self, I0
+ classoffset $I0, self, "Stream::Lines"
+ getattribute temp, self, $I0
buffer = temp
code = 0
@@ -177,7 +165,7 @@
# concat to the buffer
concat buffer, str
temp = buffer
- setattribute self, I0, temp
+ setattribute self, $I0, temp
code = 1
END:
@@ -187,11 +175,7 @@
null buffer
null temp
NO_CLOSE:
- .pcc_begin_return
- .return temp
- .return buffer
- .return code
- .pcc_end_return
+ .return(temp, buffer, code)
.end
=back
1.2 +8 -14 parrot/runtime/parrot/library/Stream/ParrotIO.imc
Index: ParrotIO.imc
===================================================================
RCS file: /cvs/public/parrot/runtime/parrot/library/Stream/ParrotIO.imc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ParrotIO.imc 25 May 2004 18:06:35 -0000 1.1
+++ ParrotIO.imc 26 Nov 2004 23:02:59 -0000 1.2
@@ -20,7 +20,7 @@
=cut
-.sub __stream_parrotio_onload @LOAD
+.sub onload @LOAD, @ANON
.local int i
.local pmc base
.local pmc io
@@ -35,8 +35,6 @@
addattribute io, "blocksize"
END:
- .pcc_begin_return
- .pcc_end_return
.end
.namespace ["Stream::ParrotIO"]
@@ -71,21 +69,19 @@
.local pmc temp
.local int ret
- classoffset I0, self, "Stream::ParrotIO"
+ classoffset $I0, self, "Stream::ParrotIO"
if argcI == 0 goto GET
temp = new .PerlInt
temp = bs
- setattribute self, I0, temp
+ setattribute self, $I0, temp
branch RET
GET:
- getattribute temp, self, I0
+ getattribute temp, self, $I0
RET:
ret = temp
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return(ret)
.end
=item source."rawRead"() (B<internal>)
@@ -102,14 +98,12 @@
bs = self."blockSize"()
pio = self."source"()
read str, pio, bs
- length I0, str
- if I0 > 0 goto OK
+ length $I0, str
+ if $I0 > 0 goto OK
self."close"()
null str
OK:
- .pcc_begin_return
- .return str
- .pcc_end_return
+ .return(str)
.end
=back
1.3 +37 -15 parrot/runtime/parrot/library/Stream/Replay.imc
Index: Replay.imc
===================================================================
RCS file: /cvs/public/parrot/runtime/parrot/library/Stream/Replay.imc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Replay.imc 30 Oct 2004 16:25:40 -0000 1.2
+++ Replay.imc 26 Nov 2004 23:02:59 -0000 1.3
@@ -37,7 +37,7 @@
.namespace ["Stream::Replay"]
-.sub __onload @LOAD
+.sub onload @LOAD, @ANON
find_type $I0, "Stream::Replay"
if $I0 > 1 goto END
@@ -53,10 +53,15 @@
newclass $P0, "Stream::Replay::Buffer"
addattribute $P0, "strings"
addattribute $P0, "clones"
-
END:
.end
+=item __init
+
+...
+
+=cut
+
.sub __init method
.local pmc temp
@@ -67,6 +72,12 @@
setattribute self, $I0, temp
.end
+=item assign stream, source
+
+...
+
+=cut
+
.sub __set_pmc method
.param pmc val
.local pmc buffer
@@ -106,10 +117,15 @@
classoffset $I0, self, "Stream::Replay"
setattribute self, $I0, buffer
ASSIGN:
- $P0 = find_global "Stream::Base", "__set_pmc"
- $P0( val )
+ self."setSource"( val )
.end
+=item stream."rawRead"() (B<internal>)
+
+...
+
+=cut
+
.sub rawRead method
.local pmc source
.local pmc buffer
@@ -124,13 +140,18 @@
isnull buffer, END
inc $I0
getattribute pos, self, $I0
+
ret = buffer."read"( pos, source )
END:
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return(ret)
.end
+=item stream2 = clone stream
+
+...
+
+=cut
+
.sub __clone method
.local pmc ret
.local pmc temp
@@ -145,13 +166,10 @@
$P0 = clone $P0
ret."byte_buffer"( $P0 )
END:
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return(ret)
.end
-
.namespace ["Stream::Replay::Buffer"]
.sub __init method
@@ -168,6 +186,7 @@
.end
.sub compact method
+ # XXX check the begin of the queue for stale entries
noop
.end
@@ -178,6 +197,10 @@
.local pmc strings
.local pmc clones
+ null ret
+ typeof $I0, source
+ if $I0==.PerlUndef goto END
+
classoffset $I0, self, "Stream::Replay::Buffer"
getattribute strings, self, $I0
inc $I0
@@ -202,10 +225,9 @@
if $I0 <= 1 goto END
inc pos
push strings, ret
-END:
- .pcc_begin_return
- .return ret
- .pcc_end_return
+END:
+
+ .return(ret)
.end
.sub add method
1.7 +11 -23 parrot/runtime/parrot/library/Stream/Sub.imc
Index: Sub.imc
===================================================================
RCS file: /cvs/public/parrot/runtime/parrot/library/Stream/Sub.imc,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Sub.imc 18 Nov 2004 11:14:22 -0000 1.6
+++ Sub.imc 26 Nov 2004 23:02:59 -0000 1.7
@@ -9,8 +9,8 @@
=head1 SYNOPSIS
# create the stream
- find_type I0, "Stream::Sub"
- new stream, I0
+ find_type $I0, "Stream::Sub"
+ new stream, $I0
# set the source sub
newsub temp, .Sub, _test
@@ -52,7 +52,7 @@
=cut
-.sub __stream_sub_onload @LOAD
+.sub onload @LOAD, @ANON
.local int i
.local pmc base
.local pmc sub
@@ -67,8 +67,6 @@
addattribute sub, "write_cont"
END:
- .pcc_begin_return
- .pcc_end_return
.end
.namespace ["Stream::Sub"]
@@ -90,8 +88,8 @@
.local pmc _write
.local pmc ret
- classoffset I0, self, "Stream::Sub"
- getattribute _write, self, I0
+ classoffset $I0, self, "Stream::Sub"
+ getattribute _write, self, $I0
newsub ret, .Continuation, _sub_write_ret
assign self, ret
@@ -101,9 +99,7 @@
.pcc_call _write, ret
_sub_write_ret:
.pcc_end
-
- .pcc_begin_return
- .pcc_end_return
+
.end
=item source."rawRead"() (B<internal>)
@@ -131,26 +127,18 @@
self."setSource"( temp )
# write null-string to terminate the read request
+TERMINATED:
null str
self."write"( str )
-
- # should never be executed
- new temp, .Exception
- set temp["_message"], "fatal error in library/Streams/Sub.imc: rawRead()"
- throw temp
- end
+ # if we are here,
+ # someone tried to read again, just return null again
+ branch TERMINATED
END:
# return a null string to indicate end of stream
null str
- .pcc_begin_return
- .return str
- .pcc_end_return
-.end
-
-.sub __set_pointer method
- print "Stream::Sub::__set_pointer\n"
+ .return(str)
.end
=back
1.6 +15 -19 parrot/runtime/parrot/library/Stream/Writer.imc
Index: Writer.imc
===================================================================
RCS file: /cvs/public/parrot/runtime/parrot/library/Stream/Writer.imc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Writer.imc 18 Nov 2004 11:14:22 -0000 1.5
+++ Writer.imc 26 Nov 2004 23:02:59 -0000 1.6
@@ -9,8 +9,8 @@
=head1 SYNOPSIS
# create the stream
- find_type I0, "Stream::Writer"
- new stream, I0
+ find_type $I0, "Stream::Writer"
+ new stream, $I0
# set the source sub
newsub temp, .Sub, _reader
@@ -28,7 +28,7 @@
=head1 DESCRIPTION
=cut
-
+.include "interpinfo.pasm"
.namespace ["Stream::Writer"]
.sub __onload @LOAD
@@ -53,19 +53,23 @@
.sub _reader_stub method
.local pmc source
+ .local pmc mysub
+ #.local pmc myself
- getprop source, "CALL", P0 # XXX
+ interpinfo mysub, .INTERPINFO_CURRENT_SUB
+ #interpinfo myself, .INTERPINFO_CURRENT_OBJECT
+ getprop source, "CALL", mysub
source()
# close the source
source = find_global "Stream::Base", "close"
- P2 = self # XXX
- source()
+ self."setSource"()
# mark it as closed
classoffset $I0, self, "Stream::Writer"
inc $I0
.local pmc status
+ interpinfo self, .INTERPINFO_CURRENT_OBJECT
getattribute status, self, $I0
status = 0
.end
@@ -96,7 +100,6 @@
.end
.sub close method
- .local pmc super
.local string str
null str
@@ -116,9 +119,7 @@
inc $I0
getattribute status, self, $I0
ret = status
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return(ret)
.end
=item source."write"()
@@ -140,7 +141,6 @@
getattribute status, self, $I0
if status == 0 goto END
-
if status == 2 goto WRITE
status = 2
self."write"( "" )
@@ -158,8 +158,6 @@
source( str )
END:
- .pcc_begin_return
- .pcc_end_return
.end
=item source."rawRead"() (B<internal>)
@@ -188,17 +186,15 @@
.result str
.pcc_end
- .pcc_begin_return
- .return str
- .pcc_end_return
+ .return(str)
+
END_OF_STREAM:
null writer
classoffset $I0, self, "Stream::Writer"
setattribute self, $I0, writer
null str
- .pcc_begin_return
- .return str
- .pcc_end_return
+
+ .return(str)
.end
=back
1.6 +28 -47 parrot/t/library/streams.t
Index: streams.t
===================================================================
RCS file: /cvs/public/parrot/t/library/streams.t,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- streams.t 30 Oct 2004 16:25:34 -0000 1.5
+++ streams.t 26 Nov 2004 23:03:00 -0000 1.6
@@ -1,6 +1,6 @@
#! perl -w
# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-# $Id: streams.t,v 1.5 2004/10/30 16:25:34 jrieks Exp $
+# $Id: streams.t,v 1.6 2004/11/26 23:03:00 jrieks Exp $
=head1 NAME
@@ -18,15 +18,15 @@
use strict;
-my @streams = qw[Buffer Combiner Coroutine Filter Lines ParrotIO Replay Sub
Writer];
+my @streams = qw[Combiner Coroutine Filter Lines ParrotIO Replay Sub Writer];
-use Parrot::Test tests => 21;
+use Parrot::Test tests => 20;
use Test::More;
for my $a ( @streams ) {
#
-# 1..9
+# 1..8
#
output_is(<<"CODE", <<"OUT", "load and create a Stream::$a");
##PIR##
@@ -54,7 +54,7 @@
}
#
-# 10
+# 9
#
output_is(<<'CODE', <<'OUT', "Stream::Sub");
##PIR##
@@ -73,7 +73,13 @@
# dump the stream
stream."dump"()
-
+ # read again to see if read returns null
+ $S0 = stream."read"()
+ isnull $S0, OK
+ print "error: read returned '"
+ print $S0
+ print "' instead of (null)\n"
+OK:
print "done\n"
sweep 1
collect
@@ -96,7 +102,7 @@
OUT
#
-# 11
+# 10
#
output_is(<<'CODE', <<'OUT', "Stream::read_bytes");
##PIR##
@@ -174,7 +180,7 @@
OUT
#
-# 12
+# 11
#
output_is(<<'CODE', <<'OUT', "Stream::Combiner");
##PIR##
@@ -254,9 +260,7 @@
str = strings[1]
concat ret, str
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return(ret)
.end
CODE
read:[1 hello]
@@ -268,7 +272,7 @@
OUT
#
-# 13
+# 12
#
output_is(<<'CODE', <<'OUT', "Stream::Coroutine");
##PIR##
@@ -307,9 +311,7 @@
LOOP:
str = i
- .pcc_begin_yield
- .return str
- .pcc_end_yield
+ .yield(str)
inc i
if i < 10 goto LOOP
@@ -320,9 +322,7 @@
# in which case it doesn't matter what you are returning.
null str
- .pcc_begin_return
- .return str
- .pcc_end_return
+ .return(str)
.end
CODE
read:[0]
@@ -340,7 +340,7 @@
OUT
#
-# 14
+# 13
#
output_is(<<'CODE', <<'OUT', "Stream::ParrotIO");
##PIR##
@@ -703,7 +703,7 @@
OUT
#
-# 15
+# 14
#
output_is(<<'CODE', <<'OUT', "Stream::Filter");
##PIR##
@@ -754,9 +754,6 @@
inc i
if i < 10 goto LOOP
-
- .pcc_begin_return
- .pcc_end_return
.end
.sub _filter
@@ -774,15 +771,11 @@
concat str, " * 2 = "
concat str, tmp
- .pcc_begin_return
- .return str
- .pcc_end_return
+ .return(str)
SKIP:
null str
- .pcc_begin_return
- .return str
- .pcc_end_return
+ .return(str)
.end
CODE
read:[0 * 2 = 0]
@@ -799,7 +792,7 @@
OUT
#
-# 16
+# 15
#
output_is(<<'CODE', <<'OUT', "Stream::include");
##PIR##
@@ -854,9 +847,6 @@
inc i
if i < 10 goto LOOP
-
- .pcc_begin_return
- .pcc_end_return
.end
.sub _included method
@@ -875,9 +865,6 @@
self."include"( temp )
self."write"( "world" )
-
- .pcc_begin_return
- .pcc_end_return
.end
.sub _counter2 method
@@ -892,9 +879,6 @@
chr str, I0
if str != "G" goto LOOP
-
- .pcc_begin_return
- .pcc_end_return
.end
CODE
read:[0]
@@ -920,7 +904,7 @@
OUT
#
-# 17
+# 16
#
output_is(<<'CODE', <<'OUT', "Stream::Lines");
##PIR##
@@ -970,7 +954,7 @@
OUT
#
-# 18
+# 17
#
output_is(<<'CODE', <<'OUT', "Stream::ParrotIO");
##PIR##
@@ -1276,7 +1260,7 @@
OUT
#
-# 19
+# 18
#
output_is(<<'CODE', <<'OUT', "Stream::Replay");
##PIR##
@@ -1378,7 +1362,7 @@
#
-# 20
+# 19
#
output_is(<<'CODE', <<'OUT', "Stream::Sub");
##PIR##
@@ -1422,9 +1406,6 @@
inc i
if i < 10 goto LOOP
-
- .pcc_begin_return
- .pcc_end_return
.end
CODE
read:[0]
@@ -1442,7 +1423,7 @@
OUT
#
-# 21
+# 20
#
output_is(<<'CODE', <<'OUT', "Stream::Write");
##PIR##