# Copyright 2008 Kevin Reid, under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ pragma.syntax("0.9") def ALL :DeepFrozen := EIO.getALL() def InStream :DeepFrozen := def trickleIn implements DeepFrozen { to run(underlying :InStream) { def one def zero var howMany := zero bind one() { howMany := zero; return 1 } bind zero() { howMany := one; return 0 } return def trickleIn implements InStream { to __printOn(out :TextWriter) { out.write("<-trickling-") out.printSame(underlying) } to getChunkType() :Guard { return underlying.getChunkType() } to fail(p) :void { underlying.fail(p) } to close() :void { underlying.close() } to takeAtMost(maximum :int) :any { if (0 <=> maximum) { return underlying <- takeAtMost(maximum) } else { return underlying <- takeAtMost(howMany()) } } } } }