# Copyright 2007-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 deBytecodeKit :DeepFrozen := def DataEBuild :DeepFrozen := any def dataEBuildCoding implements DeepFrozen, ExitViaHere { # implements Binary to asType() { return DataEBuild } to writingTo(out) { # , schedule return def writer(value :DataEBuild) { var done := false try { def subB := deBytecodeKit.makeStreamBuilder(out) /** limited-duration builder so we don't hand out eternal authority to our stream */ def dwBuilder { match msg { if (done) { throw(`builder for $value past its dynamic extent`) } else { E.callWithPair(subB, msg) } } } value(dwBuilder) } finally { done := true } } } to takingFrom(ins, schedule) { return def taker() :DataEBuild { def storage := deBytecodeKit.recognizeStream(ins, deBytecodeKit.makeBuilder()) return fn b { deBytecodeKit.recognize(storage, b) } } } }