mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
Move the "mark in.dst" into the flate decode loop.
This commit is contained in:
1 parent
c70fc8fcc6
commit
36f5ae9bf4
4 files changed
+9
-20
No files matched your search
@@ -69,8 +69,12 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
||||
return nil
|
||||
|
||||
case a.KIO:
|
||||
// TODO: the mark needs to apply on every (coroutine) call to the
|
||||
// function, not just when we execute this particular statement.
|
||||
// TODO: is a private_impl.mark the right representation? What if the
|
||||
// function is passed a (ptr writer1) instead of a (writer1)? Do we
|
||||
// still want to have that mark live outside of the function scope?
|
||||
//
|
||||
// TODO: remove this hard-coded hack for "mark in.dst".
|
||||
b.printf("%sdst.private_impl.mark = %swptr_dst;", aPrefix, bPrefix)
|
||||
return nil
|
||||
|
||||
case a.KIf:
|
||||
|
||||
@@ -117,18 +117,6 @@ func (g *gen) writeLoadDerivedVar(b *buffer, name t.ID, typ *a.TypeExpr, header
|
||||
|
||||
b.printf("%swptr_%s = %s%s.buf->ptr + %s%s.buf->wi;",
|
||||
bPrefix, nameStr, aPrefix, nameStr, aPrefix, nameStr)
|
||||
|
||||
// TODO: remove this hard-coded hack for "mark in.dst".
|
||||
//
|
||||
// TODO: is a private_impl.mark the right representation? What if the
|
||||
// function is passed a (ptr writer1) instead of a (writer1)? Do we
|
||||
// still want to have that mark live outside of the function scope?
|
||||
if header &&
|
||||
g.currFunk.astFunc.Receiver().String(g.tm) == "flate_decoder" &&
|
||||
g.currFunk.astFunc.Name().String(g.tm) == "decode" {
|
||||
b.printf("%s%s.private_impl.mark = %swptr_%s;", aPrefix, nameStr, bPrefix, nameStr)
|
||||
}
|
||||
|
||||
if header {
|
||||
b.printf("%swstart_%s = %swptr_%s;", bPrefix, nameStr, bPrefix, nameStr)
|
||||
}
|
||||
|
||||
+1
-1
@@ -817,7 +817,6 @@ puffs_flate__status puffs_flate__flate_decoder__decode(
|
||||
uint8_t* b_wend_dst = NULL;
|
||||
if (a_dst.buf) {
|
||||
b_wptr_dst = a_dst.buf->ptr + a_dst.buf->wi;
|
||||
a_dst.private_impl.mark = b_wptr_dst;
|
||||
b_wstart_dst = b_wptr_dst;
|
||||
b_wend_dst = b_wptr_dst;
|
||||
if (!a_dst.buf->closed) {
|
||||
@@ -843,6 +842,7 @@ puffs_flate__status puffs_flate__flate_decoder__decode(
|
||||
PUFFS_BASE__COROUTINE_SUSPENSION_POINT(0);
|
||||
|
||||
while (true) {
|
||||
a_dst.private_impl.mark = b_wptr_dst;
|
||||
PUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
if (a_dst.buf) {
|
||||
size_t n = b_wptr_dst - (a_dst.buf->ptr + a_dst.buf->wi);
|
||||
|
||||
@@ -116,12 +116,9 @@ pub struct flate_decoder?(
|
||||
)
|
||||
|
||||
pub func flate_decoder.decode?(dst writer1, src reader1)() {
|
||||
// TODO: when is the mark undone? Explicitly or implicitly? Right now, we
|
||||
// just assume that the mark is dropped at function end, since the arg is a
|
||||
// writer1 not a *writer1. Should we support nested marks? Should this be
|
||||
// "mark dst { etc }" that has a block and unmarks at the block end?
|
||||
mark in.dst
|
||||
while true {
|
||||
// TODO: this could be "in.dst.mark()" instead of a keyword.
|
||||
mark in.dst
|
||||
var z status = try this.decode_blocks?(dst:in.dst, src:in.src)
|
||||
if not z.is_suspension() {
|
||||
// TODO: rename "return" to "raise"?
|
||||
|
||||
Reference in new issue
Block a user