File tree Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -152,32 +152,28 @@ def x{ body: => Unit / { literal, HexSplices } }: Int = {
152
152
// --------------------
153
153
// TODO could also be part of stream library
154
154
155
- /// Request padding to a multiple of fac, by calling gen for each
156
- effect pad[A](fac: Int){ gen: => A }: Unit
157
-
158
155
/// get current position in stream
159
156
effect getPos(): Int
160
157
161
158
/// Track position in stream, starting with init
162
159
/// Handles getPos and pad
163
- def tracking[A](init: Int){ body: => Unit / { emit[A], getPos, pad[A] } }: Unit / emit[A] = {
160
+ def tracking[A](init: Int){ body: => Unit / { emit[A], getPos } }: Unit / emit[A] = {
164
161
var n = init
165
162
try body()
166
163
with emit[A] { b => n = n + 1; resume(do emit[A](b)) }
167
164
with getPos{ resume(n) }
168
- with pad[A] { fac =>
169
- resume { {gen} =>
170
- while(mod(n, fac) != 0){
171
- do emit[A](gen())
172
- n = n + 1
173
- }
174
- }
165
+ }
166
+
167
+ /// Pad to a multiple of fac, by calling gen for each
168
+ def pad[A](fac: Int){ gen: => A }: Unit / {getPos, emit[A]} = {
169
+ while(mod(do getPos(), fac) != 0) {
170
+ do emit[A](gen())
175
171
}
176
172
}
177
173
178
174
/// Track how many bytes were emitted
179
175
/// Handles getPos and pad
180
- def tracking[A]{ body: => Unit / { emit[A], getPos, pad[A] } }: Unit / emit[A] =
176
+ def tracking[A]{ body: => Unit / { emit[A], getPos } }: Unit / emit[A] =
181
177
tracking[A](0){body}
182
178
183
179
// Sub-Byte
You can’t perform that action at this time.
0 commit comments