mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Place some vars at the top of functions
This commit is contained in:
1 parent
87b8b44778
commit
bac74a830d
6 files changed
+15
-11
No files matched your search
@@ -248,7 +248,7 @@ func (h *resumabilityHelper) doAssign(r resumabilities, n *a.Assign, depth uint3
|
||||
// If the LHS is not a local variable (e.g. "this.foo[bar] = etc", or if
|
||||
// the LHS is implicitly also on the RHS (e.g. for a += or *= operator),
|
||||
// walk the LHS Expr.
|
||||
if n.LHS().Operator() != 0 || n.Operator() != t.IDEq {
|
||||
if n.LHS().Operator() != 0 || (n.Operator() != t.IDEq && n.Operator() != t.IDEqQuestion) {
|
||||
if err := h.doExpr(r, n.LHS()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -462,7 +462,7 @@ func (q *checker) bcheckAssignment1(lhs *a.Expr, lTyp *a.TypeExpr, op t.ID, rhs
|
||||
}
|
||||
|
||||
rb := bounds{}
|
||||
if op == t.IDEq {
|
||||
if op == t.IDEq || op == t.IDEqQuestion {
|
||||
rb, err = q.bcheckExpr(rhs, 0)
|
||||
} else {
|
||||
rb, err = q.bcheckExprBinaryOp(op.BinaryForm(), lhs, rhs, 0)
|
||||
|
||||
+1
-1
@@ -313,7 +313,7 @@ func (q *checker) tcheckAssign(n *a.Assign) error {
|
||||
lTyp := lhs.MType()
|
||||
rTyp := rhs.MType()
|
||||
|
||||
if n.Operator() == t.IDEq {
|
||||
if op := n.Operator(); op == t.IDEq || op == t.IDEqQuestion {
|
||||
return q.tcheckEq(0, lhs, lTyp, rhs, rTyp)
|
||||
}
|
||||
|
||||
|
||||
@@ -645,9 +645,6 @@ func (p *parser) parseStatement1() (*a.Node, error) {
|
||||
|
||||
op := p.peek1()
|
||||
if op.IsAssign() {
|
||||
if op == t.IDEqQuestion {
|
||||
return nil, fmt.Errorf(`parse: TODO: support "=?" without "var" at %s:%d`, p.filename, p.line())
|
||||
}
|
||||
p.src = p.src[1:]
|
||||
lhs = rhs
|
||||
if lhs.Effect() != 0 {
|
||||
|
||||
@@ -10453,6 +10453,10 @@ wuffs_zlib__decoder__decode(wuffs_zlib__decoder* self,
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
v_x = 0;
|
||||
v_checksum_got = 0;
|
||||
v_z = 0;
|
||||
v_checksum_want = 0;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
uint16_t t_0;
|
||||
@@ -10498,7 +10502,6 @@ wuffs_zlib__decoder__decode(wuffs_zlib__decoder* self,
|
||||
status = wuffs_zlib__error__bad_parity_check;
|
||||
goto exit;
|
||||
}
|
||||
v_checksum_got = 0;
|
||||
while (true) {
|
||||
wuffs_base__io_writer__set_mark(&a_dst, iop_a_dst);
|
||||
{
|
||||
|
||||
@@ -33,7 +33,12 @@ pub func decoder.set_ignore_checksum!(ic base.bool) {
|
||||
}
|
||||
|
||||
pub func decoder.decode!??(dst base.io_writer, src base.io_reader) {
|
||||
var x base.u16 = args.src.read_u16be!??()
|
||||
var x base.u16
|
||||
var checksum_got base.u32
|
||||
var z base.status
|
||||
var checksum_want base.u32
|
||||
|
||||
x = args.src.read_u16be!??()
|
||||
if ((x >> 8) & 0x0F) != 0x08 {
|
||||
return "?bad compression method"
|
||||
}
|
||||
@@ -48,10 +53,9 @@ pub func decoder.decode!??(dst base.io_writer, src base.io_reader) {
|
||||
}
|
||||
|
||||
// Decode and checksum the DEFLATE-encoded payload.
|
||||
var checksum_got base.u32
|
||||
while true {
|
||||
args.dst.set_mark!()
|
||||
var z base.status =? this.flate.decode!??(dst:args.dst, src:args.src)
|
||||
z =? this.flate.decode!??(dst:args.dst, src:args.src)
|
||||
if not this.ignore_checksum {
|
||||
checksum_got = this.checksum.update!(x:args.dst.since_mark())
|
||||
}
|
||||
@@ -60,7 +64,7 @@ pub func decoder.decode!??(dst base.io_writer, src base.io_reader) {
|
||||
}
|
||||
yield z
|
||||
}
|
||||
var checksum_want base.u32 = args.src.read_u32be!??()
|
||||
checksum_want = args.src.read_u32be!??()
|
||||
if (not this.ignore_checksum) and (checksum_got != checksum_want) {
|
||||
return "?bad checksum"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user