mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
Generate C code for "var x T = foo?()".
This commit is contained in:
1 parent
f6501ec2d9
commit
e6f5fd7f53
3 files changed
+37
-1
No files matched your search
@@ -883,7 +883,11 @@ func (g *gen) writeStatement(n *a.Node, depth uint32) error {
|
|||||||
|
|
||||||
case a.KVar:
|
case a.KVar:
|
||||||
n := n.Var()
|
n := n.Var()
|
||||||
// TODO: consider suspendible calls.
|
if v := n.Value(); v != nil {
|
||||||
|
if err := g.writeSuspendibles(v, depth); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
g.printf("%s%s = ", vPrefix, n.Name().String(g.tm))
|
g.printf("%s%s = ", vPrefix, n.Name().String(g.tm))
|
||||||
if v := n.Value(); v != nil {
|
if v := n.Value(); v != nil {
|
||||||
if err := g.writeExpr(v, replaceCallSuspendibles, parenthesesMandatory, 0); err != nil {
|
if err := g.writeExpr(v, replaceCallSuspendibles, parenthesesMandatory, 0); err != nil {
|
||||||
|
|||||||
@@ -285,6 +285,8 @@ puffs_gif_status puffs_gif_decoder_decode(puffs_gif_decoder* self,
|
|||||||
goto cleanup0;
|
goto cleanup0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t v_c;
|
||||||
|
|
||||||
if (a_src->ri >= a_src->wi) {
|
if (a_src->ri >= a_src->wi) {
|
||||||
status = a_src->closed ? puffs_gif_error_unexpected_eof
|
status = a_src->closed ? puffs_gif_error_unexpected_eof
|
||||||
: puffs_gif_status_short_read;
|
: puffs_gif_status_short_read;
|
||||||
@@ -313,6 +315,27 @@ puffs_gif_status puffs_gif_decoder_decode(puffs_gif_decoder* self,
|
|||||||
status = puffs_gif_error_bad_gif_header;
|
status = puffs_gif_error_bad_gif_header;
|
||||||
goto cleanup0;
|
goto cleanup0;
|
||||||
}
|
}
|
||||||
|
if (a_src->ri >= a_src->wi) {
|
||||||
|
status = a_src->closed ? puffs_gif_error_unexpected_eof
|
||||||
|
: puffs_gif_status_short_read;
|
||||||
|
goto cleanup0;
|
||||||
|
}
|
||||||
|
uint8_t t_4 = a_src->ptr[a_src->ri++];
|
||||||
|
v_c = t_4;
|
||||||
|
if ((v_c != 55) && (v_c != 57)) {
|
||||||
|
status = puffs_gif_error_bad_gif_header;
|
||||||
|
goto cleanup0;
|
||||||
|
}
|
||||||
|
if (a_src->ri >= a_src->wi) {
|
||||||
|
status = a_src->closed ? puffs_gif_error_unexpected_eof
|
||||||
|
: puffs_gif_status_short_read;
|
||||||
|
goto cleanup0;
|
||||||
|
}
|
||||||
|
uint8_t t_5 = a_src->ptr[a_src->ri++];
|
||||||
|
if (t_5 != 97) {
|
||||||
|
status = puffs_gif_error_bad_gif_header;
|
||||||
|
goto cleanup0;
|
||||||
|
}
|
||||||
|
|
||||||
cleanup0:
|
cleanup0:
|
||||||
self->private_impl.status = status;
|
self->private_impl.status = status;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be found
|
// Use of this source code is governed by a BSD-style license that can be found
|
||||||
// in the LICENSE file.
|
// in the LICENSE file.
|
||||||
|
|
||||||
|
// The GIF spec is https://www.w3.org/Graphics/GIF/spec-gif89a.txt
|
||||||
|
|
||||||
pub error "bad GIF header"
|
pub error "bad GIF header"
|
||||||
|
|
||||||
pub struct decoder?(
|
pub struct decoder?(
|
||||||
@@ -13,4 +15,11 @@ pub func decoder.decode?(dst ptr buf1, src ptr buf1)() {
|
|||||||
(in.src.read_u8?() != 0x46) or (in.src.read_u8?() != 0x38) {
|
(in.src.read_u8?() != 0x46) or (in.src.read_u8?() != 0x38) {
|
||||||
return error "bad GIF header"
|
return error "bad GIF header"
|
||||||
}
|
}
|
||||||
|
var c u8 = in.src.read_u8?()
|
||||||
|
if (c != 0x37) and (c != 0x39) {
|
||||||
|
return error "bad GIF header"
|
||||||
|
}
|
||||||
|
if in.src.read_u8?() != 0x61 {
|
||||||
|
return error "bad GIF header"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user