Skip to content

Commit c501ec0

Browse files
Allow tracking with a given start position
1 parent c4e6485 commit c501ec0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libraries/common/binstream.effekt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ def x{ body: => Unit / { literal, HexSplices } }: Int = {
140140
// --------------------
141141
effect pad[A](fac: Int){ gen: => A }: Unit
142142
effect getPos(): Int
143-
def tracking[A]{ body: => Unit / { emit[A], getPos, pad[A] } }: Unit / emit[A] = {
144-
var n = 0
143+
def tracking[A](init: Int){ body: => Unit / { emit[A], getPos, pad[A] } }: Unit / emit[A] = {
144+
var n = init
145145
try body()
146146
with emit[A] { b => n = n + 1; resume(do emit[A](b)) }
147147
with getPos{ resume(n) }
@@ -154,6 +154,8 @@ def tracking[A]{ body: => Unit / { emit[A], getPos, pad[A] } }: Unit / emit[A] =
154154
}
155155
}
156156
}
157+
def tracking[A]{ body: => Unit / { emit[A], getPos, pad[A] } }: Unit / emit[A] =
158+
tracking[A](0){body}
157159

158160
// Sub-Byte
159161
// ========

0 commit comments

Comments
 (0)