From a698b47cb6235678a03415ec6e697363de6b6388 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Thu, 26 Apr 2018 10:05:19 +1000 Subject: [PATCH] Rename `~+` to `~mod+`; add `~mod-`. --- cmd/wuffs-c/internal/cgen/expr.go | 70 +++---- doc/changelog.md | 1 + gen/c/std/deflate.c | 2 +- gen/c/std/gzip.c | 22 +-- lang/ast/string.go | 41 +++-- lang/check/bounds.go | 16 +- lang/check/type.go | 8 +- lang/token/list.go | 253 ++++++++++++++------------ std/deflate/decode_huffman_slow.wuffs | 4 +- std/gzip/decode_gzip.wuffs | 3 +- std/zlib/common_adler32.wuffs | 4 +- 11 files changed, 218 insertions(+), 206 deletions(-) diff --git a/cmd/wuffs-c/internal/cgen/expr.go b/cmd/wuffs-c/internal/cgen/expr.go index c1acd808..d501e7c2 100644 --- a/cmd/wuffs-c/internal/cgen/expr.go +++ b/cmd/wuffs-c/internal/cgen/expr.go @@ -628,19 +628,20 @@ var cTypeNames = [...]string{ } var cOpNames = [256]string{ - t.IDEq: " = ", - t.IDPlusEq: " += ", - t.IDMinusEq: " -= ", - t.IDStarEq: " *= ", - t.IDSlashEq: " /= ", - t.IDShiftLEq: " <<= ", - t.IDShiftREq: " >>= ", - t.IDAmpEq: " &= ", - t.IDAmpHatEq: " no_such_amp_hat_C_operator ", - t.IDPipeEq: " |= ", - t.IDHatEq: " ^= ", - t.IDPercentEq: " %= ", - t.IDTildePlusEq: " += ", + t.IDEq: " = ", + t.IDPlusEq: " += ", + t.IDMinusEq: " -= ", + t.IDStarEq: " *= ", + t.IDSlashEq: " /= ", + t.IDShiftLEq: " <<= ", + t.IDShiftREq: " >>= ", + t.IDAmpEq: " &= ", + t.IDAmpHatEq: " no_such_amp_hat_C_operator ", + t.IDPipeEq: " |= ", + t.IDHatEq: " ^= ", + t.IDPercentEq: " %= ", + t.IDTildeModPlusEq: " += ", + t.IDTildeModMinusEq: " -= ", t.IDXUnaryPlus: " + ", t.IDXUnaryMinus: " - ", @@ -648,27 +649,28 @@ var cOpNames = [256]string{ t.IDXUnaryRef: " & ", t.IDXUnaryDeref: " * ", - t.IDXBinaryPlus: " + ", - t.IDXBinaryMinus: " - ", - t.IDXBinaryStar: " * ", - t.IDXBinarySlash: " / ", - t.IDXBinaryShiftL: " << ", - t.IDXBinaryShiftR: " >> ", - t.IDXBinaryAmp: " & ", - t.IDXBinaryAmpHat: " no_such_amp_hat_C_operator ", - t.IDXBinaryPipe: " | ", - t.IDXBinaryHat: " ^ ", - t.IDXBinaryPercent: " % ", - t.IDXBinaryNotEq: " != ", - t.IDXBinaryLessThan: " < ", - t.IDXBinaryLessEq: " <= ", - t.IDXBinaryEqEq: " == ", - t.IDXBinaryGreaterEq: " >= ", - t.IDXBinaryGreaterThan: " > ", - t.IDXBinaryAnd: " && ", - t.IDXBinaryOr: " || ", - t.IDXBinaryAs: " no_such_as_C_operator ", - t.IDXBinaryTildePlus: " + ", + t.IDXBinaryPlus: " + ", + t.IDXBinaryMinus: " - ", + t.IDXBinaryStar: " * ", + t.IDXBinarySlash: " / ", + t.IDXBinaryShiftL: " << ", + t.IDXBinaryShiftR: " >> ", + t.IDXBinaryAmp: " & ", + t.IDXBinaryAmpHat: " no_such_amp_hat_C_operator ", + t.IDXBinaryPipe: " | ", + t.IDXBinaryHat: " ^ ", + t.IDXBinaryPercent: " % ", + t.IDXBinaryTildeModPlus: " + ", + t.IDXBinaryTildeModMinus: " - ", + t.IDXBinaryNotEq: " != ", + t.IDXBinaryLessThan: " < ", + t.IDXBinaryLessEq: " <= ", + t.IDXBinaryEqEq: " == ", + t.IDXBinaryGreaterEq: " >= ", + t.IDXBinaryGreaterThan: " > ", + t.IDXBinaryAnd: " && ", + t.IDXBinaryOr: " || ", + t.IDXBinaryAs: " no_such_as_C_operator ", t.IDXAssociativePlus: " + ", t.IDXAssociativeStar: " * ", diff --git a/doc/changelog.md b/doc/changelog.md index 68c2eee1..1e201503 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -11,6 +11,7 @@ - Spun `std/zlib` out of `std/flate`. - Let the `std/zlib` decoder ignore checksums. - Renamed `std/flate` to `std/deflate`. +- Renamed `~+` to `~mod+`; add `~mod-`. - Renamed `[N] T` and `[] T` types to `array[N] T` and `slice T`. - Renamed `iterate.N` to `iterate[N]`. - Renamed `buf1`, `reader1`, etc to `io_buffer`, `io_reader`, etc. diff --git a/gen/c/std/deflate.c b/gen/c/std/deflate.c index 874163b1..caecee1a 100644 --- a/gen/c/std/deflate.c +++ b/gen/c/std/deflate.c @@ -3540,7 +3540,7 @@ static wuffs_deflate__status wuffs_deflate__decoder__decode_huffman_slow( goto label_6_break; } v_hlen -= v_n_copied; - v_hdist = (v_hdist + v_n_copied); + v_hdist += v_n_copied; status = WUFFS_DEFLATE__SUSPENSION_SHORT_WRITE; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(10); } diff --git a/gen/c/std/gzip.c b/gen/c/std/gzip.c index 9aa6bf0f..a799b915 100644 --- a/gen/c/std/gzip.c +++ b/gen/c/std/gzip.c @@ -2079,18 +2079,16 @@ wuffs_gzip__status wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self, ? (size_t)(b_wptr_dst - a_dst.private_impl.mark) : 0, })); - v_decoded_length_got = - (v_decoded_length_got + - ((uint32_t)(( - ((uint64_t)(((wuffs_base__slice_u8){ - .ptr = a_dst.private_impl.mark, - .len = a_dst.private_impl.mark - ? (size_t)(b_wptr_dst - - a_dst.private_impl.mark) - : 0, - }) - .len)) & - 4294967295)))); + v_decoded_length_got += ((uint32_t)(( + ((uint64_t)( + ((wuffs_base__slice_u8){ + .ptr = a_dst.private_impl.mark, + .len = a_dst.private_impl.mark + ? (size_t)(b_wptr_dst - a_dst.private_impl.mark) + : 0, + }) + .len)) & + 4294967295))); } if (v_z == 0) { goto label_2_break; diff --git a/lang/ast/string.go b/lang/ast/string.go index 2e533094..c4ac0b91 100644 --- a/lang/ast/string.go +++ b/lang/ast/string.go @@ -159,26 +159,27 @@ var opStrings = [256]string{ t.IDXUnaryRef: "ref ", t.IDXUnaryDeref: "deref ", - t.IDXBinaryPlus: " + ", - t.IDXBinaryMinus: " - ", - t.IDXBinaryStar: " * ", - t.IDXBinarySlash: " / ", - t.IDXBinaryShiftL: " << ", - t.IDXBinaryShiftR: " >> ", - t.IDXBinaryAmp: " & ", - t.IDXBinaryAmpHat: " &^ ", - t.IDXBinaryPipe: " | ", - t.IDXBinaryHat: " ^ ", - t.IDXBinaryNotEq: " != ", - t.IDXBinaryLessThan: " < ", - t.IDXBinaryLessEq: " <= ", - t.IDXBinaryEqEq: " == ", - t.IDXBinaryGreaterEq: " >= ", - t.IDXBinaryGreaterThan: " > ", - t.IDXBinaryAnd: " and ", - t.IDXBinaryOr: " or ", - t.IDXBinaryAs: " as ", - t.IDXBinaryTildePlus: " ~+ ", + t.IDXBinaryPlus: " + ", + t.IDXBinaryMinus: " - ", + t.IDXBinaryStar: " * ", + t.IDXBinarySlash: " / ", + t.IDXBinaryShiftL: " << ", + t.IDXBinaryShiftR: " >> ", + t.IDXBinaryAmp: " & ", + t.IDXBinaryAmpHat: " &^ ", + t.IDXBinaryPipe: " | ", + t.IDXBinaryHat: " ^ ", + t.IDXBinaryTildeModPlus: " ~mod+ ", + t.IDXBinaryTildeModMinus: " ~mod- ", + t.IDXBinaryNotEq: " != ", + t.IDXBinaryLessThan: " < ", + t.IDXBinaryLessEq: " <= ", + t.IDXBinaryEqEq: " == ", + t.IDXBinaryGreaterEq: " >= ", + t.IDXBinaryGreaterThan: " > ", + t.IDXBinaryAnd: " and ", + t.IDXBinaryOr: " or ", + t.IDXBinaryAs: " as ", t.IDXAssociativePlus: " + ", t.IDXAssociativeStar: " * ", diff --git a/lang/check/bounds.go b/lang/check/bounds.go index db77307a..2d0396cc 100644 --- a/lang/check/bounds.go +++ b/lang/check/bounds.go @@ -1122,14 +1122,7 @@ func (q *checker) bcheckExprBinaryOp1(op t.ID, lhs *a.Expr, lMin *big.Int, lMax } return zero, big.NewInt(0).Sub(rMax, one), nil - case t.IDXBinaryNotEq, t.IDXBinaryLessThan, t.IDXBinaryLessEq, t.IDXBinaryEqEq, - t.IDXBinaryGreaterEq, t.IDXBinaryGreaterThan, t.IDXBinaryAnd, t.IDXBinaryOr: - return zero, one, nil - - case t.IDXBinaryAs: - // Unreachable, as this is checked by the caller. - - case t.IDXBinaryTildePlus: + case t.IDXBinaryTildeModPlus, t.IDXBinaryTildeModMinus: typ := lhs.MType() if typ.IsIdeal() { typ = rhs.MType() @@ -1138,6 +1131,13 @@ func (q *checker) bcheckExprBinaryOp1(op t.ID, lhs *a.Expr, lMin *big.Int, lMax b := numTypeBounds[qid[1]] return b[0], b[1], nil } + + case t.IDXBinaryNotEq, t.IDXBinaryLessThan, t.IDXBinaryLessEq, t.IDXBinaryEqEq, + t.IDXBinaryGreaterEq, t.IDXBinaryGreaterThan, t.IDXBinaryAnd, t.IDXBinaryOr: + return zero, one, nil + + case t.IDXBinaryAs: + // Unreachable, as this is checked by the caller. } return nil, nil, fmt.Errorf("check: unrecognized token (0x%X) for bcheckExprBinaryOp", op) } diff --git a/lang/check/type.go b/lang/check/type.go index 4cb7b8df..4287169b 100644 --- a/lang/check/type.go +++ b/lang/check/type.go @@ -282,7 +282,7 @@ func (q *checker) tcheckAssign(n *a.Assign) error { n.Operator().Str(q.tm), rhs.Str(q.tm), rTyp.Str(q.tm)) } return nil - case t.IDTildePlusEq: + case t.IDTildeModPlusEq, t.IDTildeModMinusEq: if !lTyp.IsUnsignedInteger() { return fmt.Errorf("check: assignment %q: %q, of type %q, does not have unsigned integer type", n.Operator().Str(q.tm), lhs.Str(q.tm), lTyp.Str(q.tm)) @@ -810,7 +810,7 @@ func (q *checker) tcheckExprBinaryOp(n *a.Expr, depth uint32) error { } switch op { - case t.IDXBinaryTildePlus: + case t.IDXBinaryTildeModPlus, t.IDXBinaryTildeModMinus: typ := lTyp if typ.IsIdeal() { typ = rTyp @@ -890,6 +890,8 @@ func evalConstValueBinaryOp(tm *t.Map, n *a.Expr, l *big.Int, r *big.Int) (*big. return nil, fmt.Errorf("check: division by zero in const expression %q", n.Str(tm)) } return big.NewInt(0).Mod(l, r), nil + case t.IDXBinaryTildeModPlus, t.IDXBinaryTildeModMinus: + return nil, fmt.Errorf("check: cannot apply tilde-operators to ideal numbers") case t.IDXBinaryNotEq: return btoi(l.Cmp(r) != 0), nil case t.IDXBinaryLessThan: @@ -906,8 +908,6 @@ func evalConstValueBinaryOp(tm *t.Map, n *a.Expr, l *big.Int, r *big.Int) (*big. return btoi((l.Sign() != 0) && (r.Sign() != 0)), nil case t.IDXBinaryOr: return btoi((l.Sign() != 0) || (r.Sign() != 0)), nil - case t.IDXBinaryTildePlus: - return nil, fmt.Errorf("check: cannot apply ~+ operator to ideal numbers") } return nil, fmt.Errorf("check: unrecognized token (0x%02X) for evalConstValueBinaryOp", n.Operator()) } diff --git a/lang/token/list.go b/lang/token/list.go index 7148aebb..21b47f48 100644 --- a/lang/token/list.go +++ b/lang/token/list.go @@ -195,19 +195,20 @@ const ( minAssign = 0x10 maxAssign = 0x1F - IDEq = ID(0x10) - IDPlusEq = ID(0x11) - IDMinusEq = ID(0x12) - IDStarEq = ID(0x13) - IDSlashEq = ID(0x14) - IDShiftLEq = ID(0x15) - IDShiftREq = ID(0x16) - IDAmpEq = ID(0x17) - IDAmpHatEq = ID(0x18) - IDPipeEq = ID(0x19) - IDHatEq = ID(0x1A) - IDPercentEq = ID(0x1B) - IDTildePlusEq = ID(0x1C) + IDEq = ID(0x10) + IDPlusEq = ID(0x11) + IDMinusEq = ID(0x12) + IDStarEq = ID(0x13) + IDSlashEq = ID(0x14) + IDShiftLEq = ID(0x15) + IDShiftREq = ID(0x16) + IDAmpEq = ID(0x17) + IDAmpHatEq = ID(0x18) + IDPipeEq = ID(0x19) + IDHatEq = ID(0x1A) + IDPercentEq = ID(0x1B) + IDTildeModPlusEq = ID(0x1C) + IDTildeModMinusEq = ID(0x1D) ) const ( @@ -218,18 +219,19 @@ const ( maxXOp = 0x6F maxOp = 0x6F - IDPlus = ID(0x21) - IDMinus = ID(0x22) - IDStar = ID(0x23) - IDSlash = ID(0x24) - IDShiftL = ID(0x25) - IDShiftR = ID(0x26) - IDAmp = ID(0x27) - IDAmpHat = ID(0x28) - IDPipe = ID(0x29) - IDHat = ID(0x2A) - IDPercent = ID(0x2B) - IDTildePlus = ID(0x2C) + IDPlus = ID(0x21) + IDMinus = ID(0x22) + IDStar = ID(0x23) + IDSlash = ID(0x24) + IDShiftL = ID(0x25) + IDShiftR = ID(0x26) + IDAmp = ID(0x27) + IDAmpHat = ID(0x28) + IDPipe = ID(0x29) + IDHat = ID(0x2A) + IDPercent = ID(0x2B) + IDTildeModPlus = ID(0x2C) + IDTildeModMinus = ID(0x2D) IDNotEq = ID(0x30) IDLessThan = ID(0x31) @@ -255,27 +257,28 @@ const ( IDXUnaryRef = ID(0x43) IDXUnaryDeref = ID(0x44) - IDXBinaryPlus = ID(0x48) - IDXBinaryMinus = ID(0x49) - IDXBinaryStar = ID(0x4A) - IDXBinarySlash = ID(0x4B) - IDXBinaryShiftL = ID(0x4C) - IDXBinaryShiftR = ID(0x4D) - IDXBinaryAmp = ID(0x4E) - IDXBinaryAmpHat = ID(0x4F) - IDXBinaryPipe = ID(0x50) - IDXBinaryHat = ID(0x51) - IDXBinaryPercent = ID(0x52) - IDXBinaryNotEq = ID(0x53) - IDXBinaryLessThan = ID(0x54) - IDXBinaryLessEq = ID(0x55) - IDXBinaryEqEq = ID(0x56) - IDXBinaryGreaterEq = ID(0x57) - IDXBinaryGreaterThan = ID(0x58) - IDXBinaryAnd = ID(0x59) - IDXBinaryOr = ID(0x5A) - IDXBinaryAs = ID(0x5B) - IDXBinaryTildePlus = ID(0x5C) + IDXBinaryPlus = ID(0x48) + IDXBinaryMinus = ID(0x49) + IDXBinaryStar = ID(0x4A) + IDXBinarySlash = ID(0x4B) + IDXBinaryShiftL = ID(0x4C) + IDXBinaryShiftR = ID(0x4D) + IDXBinaryAmp = ID(0x4E) + IDXBinaryAmpHat = ID(0x4F) + IDXBinaryPipe = ID(0x50) + IDXBinaryHat = ID(0x51) + IDXBinaryPercent = ID(0x52) + IDXBinaryNotEq = ID(0x53) + IDXBinaryLessThan = ID(0x54) + IDXBinaryLessEq = ID(0x55) + IDXBinaryEqEq = ID(0x56) + IDXBinaryGreaterEq = ID(0x57) + IDXBinaryGreaterThan = ID(0x58) + IDXBinaryAnd = ID(0x59) + IDXBinaryOr = ID(0x5A) + IDXBinaryAs = ID(0x5B) + IDXBinaryTildeModPlus = ID(0x5C) + IDXBinaryTildeModMinus = ID(0x5D) IDXAssociativePlus = ID(0x60) IDXAssociativeStar = ID(0x61) @@ -427,32 +430,34 @@ var builtInsByID = [nBuiltInIDs]string{ IDSemicolon: ";", IDDollar: "$", - IDEq: "=", - IDPlusEq: "+=", - IDMinusEq: "-=", - IDStarEq: "*=", - IDSlashEq: "/=", - IDShiftLEq: "<<=", - IDShiftREq: ">>=", - IDAmpEq: "&=", - IDAmpHatEq: "&^=", - IDPipeEq: "|=", - IDHatEq: "^=", - IDPercentEq: "%=", - IDTildePlusEq: "~+=", + IDEq: "=", + IDPlusEq: "+=", + IDMinusEq: "-=", + IDStarEq: "*=", + IDSlashEq: "/=", + IDShiftLEq: "<<=", + IDShiftREq: ">>=", + IDAmpEq: "&=", + IDAmpHatEq: "&^=", + IDPipeEq: "|=", + IDHatEq: "^=", + IDPercentEq: "%=", + IDTildeModPlusEq: "~mod+=", + IDTildeModMinusEq: "~mod-=", - IDPlus: "+", - IDMinus: "-", - IDStar: "*", - IDSlash: "/", - IDShiftL: "<<", - IDShiftR: ">>", - IDAmp: "&", - IDAmpHat: "&^", - IDPipe: "|", - IDHat: "^", - IDPercent: "%", - IDTildePlus: "~+", + IDPlus: "+", + IDMinus: "-", + IDStar: "*", + IDSlash: "/", + IDShiftL: "<<", + IDShiftR: ">>", + IDAmp: "&", + IDAmpHat: "&^", + IDPipe: "|", + IDHat: "^", + IDPercent: "%", + IDTildeModPlus: "~mod+", + IDTildeModMinus: "~mod-", IDNotEq: "!=", IDLessThan: "<", @@ -675,8 +680,10 @@ var lexers = [nBuiltInIDs][]suffixLexer{ {"", IDGreaterThan}, }, '~': { - {"+=", IDTildePlusEq}, - {"+", IDTildePlus}, + {"mod+=", IDTildeModPlusEq}, + {"mod+", IDTildeModPlus}, + {"mod-=", IDTildeModMinusEq}, + {"mod-", IDTildeModMinus}, }, } @@ -687,27 +694,28 @@ var ambiguousForms = [nBuiltInIDs]ID{ IDXUnaryRef: IDRef, IDXUnaryDeref: IDDeref, - IDXBinaryPlus: IDPlus, - IDXBinaryMinus: IDMinus, - IDXBinaryStar: IDStar, - IDXBinarySlash: IDSlash, - IDXBinaryShiftL: IDShiftL, - IDXBinaryShiftR: IDShiftR, - IDXBinaryAmp: IDAmp, - IDXBinaryAmpHat: IDAmpHat, - IDXBinaryPipe: IDPipe, - IDXBinaryHat: IDHat, - IDXBinaryPercent: IDPercent, - IDXBinaryNotEq: IDNotEq, - IDXBinaryLessThan: IDLessThan, - IDXBinaryLessEq: IDLessEq, - IDXBinaryEqEq: IDEqEq, - IDXBinaryGreaterEq: IDGreaterEq, - IDXBinaryGreaterThan: IDGreaterThan, - IDXBinaryAnd: IDAnd, - IDXBinaryOr: IDOr, - IDXBinaryAs: IDAs, - IDXBinaryTildePlus: IDTildePlus, + IDXBinaryPlus: IDPlus, + IDXBinaryMinus: IDMinus, + IDXBinaryStar: IDStar, + IDXBinarySlash: IDSlash, + IDXBinaryShiftL: IDShiftL, + IDXBinaryShiftR: IDShiftR, + IDXBinaryAmp: IDAmp, + IDXBinaryAmpHat: IDAmpHat, + IDXBinaryPipe: IDPipe, + IDXBinaryHat: IDHat, + IDXBinaryPercent: IDPercent, + IDXBinaryNotEq: IDNotEq, + IDXBinaryLessThan: IDLessThan, + IDXBinaryLessEq: IDLessEq, + IDXBinaryEqEq: IDEqEq, + IDXBinaryGreaterEq: IDGreaterEq, + IDXBinaryGreaterThan: IDGreaterThan, + IDXBinaryAnd: IDAnd, + IDXBinaryOr: IDOr, + IDXBinaryAs: IDAs, + IDXBinaryTildeModPlus: IDTildeModPlus, + IDXBinaryTildeModMinus: IDTildeModMinus, IDXAssociativePlus: IDPlus, IDXAssociativeStar: IDStar, @@ -753,30 +761,34 @@ var unaryForms = [nBuiltInIDs]ID{ } var binaryForms = [nBuiltInIDs]ID{ - IDPlusEq: IDXBinaryPlus, - IDMinusEq: IDXBinaryMinus, - IDStarEq: IDXBinaryStar, - IDSlashEq: IDXBinarySlash, - IDShiftLEq: IDXBinaryShiftL, - IDShiftREq: IDXBinaryShiftR, - IDAmpEq: IDXBinaryAmp, - IDAmpHatEq: IDXBinaryAmpHat, - IDPipeEq: IDXBinaryPipe, - IDHatEq: IDXBinaryHat, - IDPercentEq: IDXBinaryPercent, - IDTildePlusEq: IDXBinaryTildePlus, + IDPlusEq: IDXBinaryPlus, + IDMinusEq: IDXBinaryMinus, + IDStarEq: IDXBinaryStar, + IDSlashEq: IDXBinarySlash, + IDShiftLEq: IDXBinaryShiftL, + IDShiftREq: IDXBinaryShiftR, + IDAmpEq: IDXBinaryAmp, + IDAmpHatEq: IDXBinaryAmpHat, + IDPipeEq: IDXBinaryPipe, + IDHatEq: IDXBinaryHat, + IDPercentEq: IDXBinaryPercent, + IDTildeModPlusEq: IDXBinaryTildeModPlus, + IDTildeModMinusEq: IDXBinaryTildeModMinus, + + IDPlus: IDXBinaryPlus, + IDMinus: IDXBinaryMinus, + IDStar: IDXBinaryStar, + IDSlash: IDXBinarySlash, + IDShiftL: IDXBinaryShiftL, + IDShiftR: IDXBinaryShiftR, + IDAmp: IDXBinaryAmp, + IDAmpHat: IDXBinaryAmpHat, + IDPipe: IDXBinaryPipe, + IDHat: IDXBinaryHat, + IDPercent: IDXBinaryPercent, + IDTildeModPlus: IDXBinaryTildeModPlus, + IDTildeModMinus: IDXBinaryTildeModMinus, - IDPlus: IDXBinaryPlus, - IDMinus: IDXBinaryMinus, - IDStar: IDXBinaryStar, - IDSlash: IDXBinarySlash, - IDShiftL: IDXBinaryShiftL, - IDShiftR: IDXBinaryShiftR, - IDAmp: IDXBinaryAmp, - IDAmpHat: IDXBinaryAmpHat, - IDPipe: IDXBinaryPipe, - IDHat: IDXBinaryHat, - IDPercent: IDXBinaryPercent, IDNotEq: IDXBinaryNotEq, IDLessThan: IDXBinaryLessThan, IDLessEq: IDXBinaryLessEq, @@ -786,7 +798,6 @@ var binaryForms = [nBuiltInIDs]ID{ IDAnd: IDXBinaryAnd, IDOr: IDXBinaryOr, IDAs: IDXBinaryAs, - IDTildePlus: IDXBinaryTildePlus, } var associativeForms = [nBuiltInIDs]ID{ @@ -795,9 +806,9 @@ var associativeForms = [nBuiltInIDs]ID{ IDAmp: IDXAssociativeAmp, IDPipe: IDXAssociativePipe, IDHat: IDXAssociativeHat, - IDAnd: IDXAssociativeAnd, - IDOr: IDXAssociativeOr, - // TODO: IDTildePlus? + // TODO: IDTildeModPlus, IDTildeModMinus? + IDAnd: IDXAssociativeAnd, + IDOr: IDXAssociativeOr, } var isOpen = [...]bool{ diff --git a/std/deflate/decode_huffman_slow.wuffs b/std/deflate/decode_huffman_slow.wuffs index aabe5cf4..06b06fbe 100644 --- a/std/deflate/decode_huffman_slow.wuffs +++ b/std/deflate/decode_huffman_slow.wuffs @@ -214,7 +214,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader)() } if n_copied > 0 { hlen -= n_copied - hdist = (hdist ~+ n_copied) & 0x7FFF + hdist = (hdist ~mod+ n_copied) & 0x7FFF if hdist == 0 { // Wrap around the this.history ringbuffer. break @@ -233,7 +233,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader)() break } hlen -= n_copied - hdist = hdist ~+ n_copied + hdist ~mod+= n_copied // TODO: "closed for writes" instead? yield suspension "short write" } diff --git a/std/gzip/decode_gzip.wuffs b/std/gzip/decode_gzip.wuffs index fc57efae..99464e7a 100644 --- a/std/gzip/decode_gzip.wuffs +++ b/std/gzip/decode_gzip.wuffs @@ -96,8 +96,7 @@ pub func decoder.decode?(dst base.io_writer, src base.io_reader)() { var z base.status = try this.flate.decode?(dst:in.dst, src:in.src) if not this.ignore_checksum { checksum_got = this.checksum.update(x:in.dst.since_mark()) - decoded_length_got = decoded_length_got ~+ - ((in.dst.since_mark().length() & 0xFFFFFFFF) as base.u32) + decoded_length_got ~mod+= ((in.dst.since_mark().length() & 0xFFFFFFFF) as base.u32) } if z.is_ok() { break diff --git a/std/zlib/common_adler32.wuffs b/std/zlib/common_adler32.wuffs index 5651e250..28fccd53 100644 --- a/std/zlib/common_adler32.wuffs +++ b/std/zlib/common_adler32.wuffs @@ -33,8 +33,8 @@ pri func adler32.update(x slice base.u8)(checksum base.u32) { } iterate[8](p ptr base.u8:in.x) { - s1 ~+= deref p as base.u32 - s2 ~+= s1 + s1 ~mod+= deref p as base.u32 + s2 ~mod+= s1 } s1 %= 65521