mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 08:38:14 +01:00
Apply io_limit to original not just derived vars
This commit is contained in:
1 parent
d655f51dae
commit
43a74d6b81
2 files changed
+29
-18
No files matched your search
+23
-18
@@ -228,22 +228,22 @@ func (g *gen) writeStatementIOBind(b *buffer, n *a.IOBind, depth uint32) error {
|
||||
ioBindNum := g.currFunk.ioBinds
|
||||
g.currFunk.ioBinds++
|
||||
|
||||
e := n.IO()
|
||||
prefix := vPrefix
|
||||
if e.Operator() != 0 {
|
||||
prefix = aPrefix
|
||||
}
|
||||
cTyp, end, qualifier := "reader", "meta.wi", "const "
|
||||
if e.MType().QID()[1] == t.IDIOWriter {
|
||||
cTyp, end, qualifier = "writer", "data.len", ""
|
||||
}
|
||||
name := e.Ident().Str(g.tm)
|
||||
|
||||
// TODO: do these variables need to be func-scoped (bigger scope)
|
||||
// instead of block-scoped (smaller scope) if the coro_susp_point
|
||||
// switch can jump past this initialization??
|
||||
b.writes("{\n")
|
||||
{
|
||||
e := n.IO()
|
||||
prefix := vPrefix
|
||||
if e.Operator() != 0 {
|
||||
prefix = aPrefix
|
||||
}
|
||||
cTyp, qualifier := "reader", "const "
|
||||
if e.MType().QID()[1] == t.IDIOWriter {
|
||||
cTyp, qualifier = "writer", ""
|
||||
}
|
||||
name := e.Ident().Str(g.tm)
|
||||
|
||||
if n.Keyword() == t.IDIOBind {
|
||||
b.printf("wuffs_base__io_buffer* %s%d_%s%s = %s%s;\n",
|
||||
oPrefix, ioBindNum, prefix, name,
|
||||
@@ -284,6 +284,11 @@ func (g *gen) writeStatementIOBind(b *buffer, n *a.IOBind, depth uint32) error {
|
||||
return err
|
||||
}
|
||||
b.writes(");\n")
|
||||
b.printf("if (%s%s) {\n%s%s->%s = ((size_t)(%s%s%s - %s%s->data.ptr));\n}\n",
|
||||
prefix, name,
|
||||
prefix, name, end,
|
||||
io2Prefix, prefix, name,
|
||||
prefix, name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,13 +299,6 @@ func (g *gen) writeStatementIOBind(b *buffer, n *a.IOBind, depth uint32) error {
|
||||
}
|
||||
|
||||
{
|
||||
e := n.IO()
|
||||
prefix := vPrefix
|
||||
if e.Operator() != 0 {
|
||||
prefix = aPrefix
|
||||
}
|
||||
name := e.Ident().Str(g.tm)
|
||||
|
||||
if n.Keyword() == t.IDIOBind {
|
||||
b.printf("%s%s = %s%d_%s%s;\n",
|
||||
prefix, name,
|
||||
@@ -318,6 +316,13 @@ func (g *gen) writeStatementIOBind(b *buffer, n *a.IOBind, depth uint32) error {
|
||||
b.printf("%s%s%s = %s%d_%s%s%s;\n",
|
||||
io2Prefix, prefix, name,
|
||||
oPrefix, ioBindNum, io2Prefix, prefix, name)
|
||||
if n.Keyword() == t.IDIOLimit {
|
||||
b.printf("if (%s%s) {\n%s%s->%s = ((size_t)(%s%s%s - %s%s->data.ptr));\n}\n",
|
||||
prefix, name,
|
||||
prefix, name, end,
|
||||
io2Prefix, prefix, name,
|
||||
prefix, name)
|
||||
}
|
||||
}
|
||||
b.writes("}\n")
|
||||
return nil
|
||||
|
||||
@@ -30550,6 +30550,9 @@ wuffs_png__decoder__decode_frame(
|
||||
const uint8_t *o_1_io2_a_src = io2_a_src;
|
||||
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
|
||||
self->private_impl.f_chunk_length);
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
v_w_mark = ((uint64_t)(iop_v_w - io0_v_w));
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
{
|
||||
@@ -30567,6 +30570,9 @@ wuffs_png__decoder__decode_frame(
|
||||
wuffs_base__u64__sat_sub_indirect(&self->private_impl.f_chunk_length, wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))));
|
||||
wuffs_base__u64__sat_add_indirect(&self->private_impl.f_workbuf_wi, wuffs_base__io__count_since(v_w_mark, ((uint64_t)(iop_v_w - io0_v_w))));
|
||||
io2_a_src = o_1_io2_a_src;
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
v_w = o_0_v_w;
|
||||
iop_v_w = o_0_iop_v_w;
|
||||
|
||||
Reference in new issue
Block a user