From 7f0923a9cff1a4a0d474584c6c270cbd028f77c9 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Thu, 26 Apr 2018 11:24:27 +1000 Subject: [PATCH] Remove the unused `&^` AmpHat operator --- cmd/wuffs-c/internal/cgen/expr.go | 3 -- cmd/wuffs-c/internal/cgen/statement.go | 2 +- doc/changelog.md | 3 +- lang/ast/string.go | 1 - lang/check/bounds.go | 3 -- lang/check/type.go | 2 - lang/token/list.go | 70 +++++++++++--------------- 7 files changed, 33 insertions(+), 51 deletions(-) diff --git a/cmd/wuffs-c/internal/cgen/expr.go b/cmd/wuffs-c/internal/cgen/expr.go index 6a691d8e..b890eef6 100644 --- a/cmd/wuffs-c/internal/cgen/expr.go +++ b/cmd/wuffs-c/internal/cgen/expr.go @@ -517,7 +517,6 @@ func (g *gen) writeExprBinaryOp(b *buffer, n *a.Expr, rp replacementPolicy, pp p if err := g.writeExpr(b, n.LHS().Expr(), rp, parenthesesMandatory, depth); err != nil { return err } - // TODO: does KeyXBinaryAmpHat need special consideration? b.writes(opName) if err := g.writeExpr(b, n.RHS().Expr(), rp, parenthesesMandatory, depth); err != nil { return err @@ -681,7 +680,6 @@ var cOpNames = [256]string{ t.IDShiftLEq: " <<= ", t.IDShiftREq: " >>= ", t.IDAmpEq: " &= ", - t.IDAmpHatEq: " no_such_C_operator ", t.IDPipeEq: " |= ", t.IDHatEq: " ^= ", t.IDPercentEq: " %= ", @@ -703,7 +701,6 @@ var cOpNames = [256]string{ t.IDXBinaryShiftL: " << ", t.IDXBinaryShiftR: " >> ", t.IDXBinaryAmp: " & ", - t.IDXBinaryAmpHat: " no_such_C_operator ", t.IDXBinaryPipe: " | ", t.IDXBinaryHat: " ^ ", t.IDXBinaryPercent: " % ", diff --git a/cmd/wuffs-c/internal/cgen/statement.go b/cmd/wuffs-c/internal/cgen/statement.go index 302d9a02..f93d9e22 100644 --- a/cmd/wuffs-c/internal/cgen/statement.go +++ b/cmd/wuffs-c/internal/cgen/statement.go @@ -81,7 +81,7 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error { if err := g.writeExpr(b, n.LHS(), replaceCallSuspendibles, parenthesesMandatory, depth); err != nil { return err } - // TODO: `~sat+=`, `~sat-=` and `&^=` need special consideration. + // TODO: `~sat+=` and `~sat-=` need special consideration. op := n.Operator() opName := cOpNames[0xFF&op] if opName == "" { diff --git a/doc/changelog.md b/doc/changelog.md index ae292207..50536e09 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -12,6 +12,7 @@ - Let the `std/zlib` decoder ignore checksums. - Renamed `std/flate` to `std/deflate`. - Renamed `~+` to `~mod+`; added `~mod-`, `~sat+` and `~sat-`. +- Removed `&^`. - 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. @@ -27,7 +28,7 @@ - Added a stand-alone lang/interval package. - Added fuzz tests. - Added some Go and Rust benchmarks. -- Sped up the mimic\_deflate\_xxx benchmarks. +- Sped up the `mimic_deflate_xxx` benchmarks. ## 2017-11-16 diff --git a/lang/ast/string.go b/lang/ast/string.go index 36bdfd9a..695af92d 100644 --- a/lang/ast/string.go +++ b/lang/ast/string.go @@ -166,7 +166,6 @@ var opStrings = [256]string{ t.IDXBinaryShiftL: " << ", t.IDXBinaryShiftR: " >> ", t.IDXBinaryAmp: " & ", - t.IDXBinaryAmpHat: " &^ ", t.IDXBinaryPipe: " | ", t.IDXBinaryHat: " ^ ", t.IDXBinaryTildeModPlus: " ~mod+ ", diff --git a/lang/check/bounds.go b/lang/check/bounds.go index a1bcf533..2e131f16 100644 --- a/lang/check/bounds.go +++ b/lang/check/bounds.go @@ -1118,9 +1118,6 @@ func (q *checker) bcheckExprBinaryOp1(op t.ID, lhs *a.Expr, lMin *big.Int, lMax // conservative, but works fine in practice. return zero, bitMask(z.BitLen()), nil - case t.IDXBinaryAmpHat: - // TODO. - case t.IDXBinaryPercent: if lMin.Sign() < 0 { return nil, nil, fmt.Errorf("check: modulus op argument %q is possibly negative", lhs.Str(q.tm)) diff --git a/lang/check/type.go b/lang/check/type.go index b37cf6b2..d1286bf2 100644 --- a/lang/check/type.go +++ b/lang/check/type.go @@ -880,8 +880,6 @@ func evalConstValueBinaryOp(tm *t.Map, n *a.Expr, l *big.Int, r *big.Int) (*big. return big.NewInt(0).Rsh(l, uint(r.Uint64())), nil case t.IDXBinaryAmp: return big.NewInt(0).And(l, r), nil - case t.IDXBinaryAmpHat: - return big.NewInt(0).AndNot(l, r), nil case t.IDXBinaryPipe: return big.NewInt(0).Or(l, r), nil case t.IDXBinaryHat: diff --git a/lang/token/list.go b/lang/token/list.go index ef2ce3b9..fb86f8dc 100644 --- a/lang/token/list.go +++ b/lang/token/list.go @@ -203,14 +203,13 @@ const ( 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) - IDTildeSatPlusEq = ID(0x1E) - IDTildeSatMinusEq = ID(0x1F) + IDPipeEq = ID(0x18) + IDHatEq = ID(0x19) + IDPercentEq = ID(0x1A) + IDTildeModPlusEq = ID(0x1B) + IDTildeModMinusEq = ID(0x1C) + IDTildeSatPlusEq = ID(0x1D) + IDTildeSatMinusEq = ID(0x1E) ) const ( @@ -228,14 +227,13 @@ const ( 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) - IDTildeSatPlus = ID(0x2E) - IDTildeSatMinus = ID(0x2F) + IDPipe = ID(0x28) + IDHat = ID(0x29) + IDPercent = ID(0x2A) + IDTildeModPlus = ID(0x2B) + IDTildeModMinus = ID(0x2C) + IDTildeSatPlus = ID(0x2D) + IDTildeSatMinus = ID(0x2E) IDNotEq = ID(0x30) IDLessThan = ID(0x31) @@ -267,23 +265,22 @@ const ( IDXBinaryShiftL = ID(0x4C) IDXBinaryShiftR = ID(0x4D) IDXBinaryAmp = ID(0x4E) - IDXBinaryAmpHat = ID(0x4F) - IDXBinaryPipe = ID(0x50) - IDXBinaryHat = ID(0x51) - IDXBinaryPercent = ID(0x52) - IDXBinaryTildeModPlus = ID(0x53) - IDXBinaryTildeModMinus = ID(0x54) - IDXBinaryTildeSatPlus = ID(0x55) - IDXBinaryTildeSatMinus = ID(0x56) - IDXBinaryNotEq = ID(0x57) - IDXBinaryLessThan = ID(0x58) - IDXBinaryLessEq = ID(0x59) - IDXBinaryEqEq = ID(0x5A) - IDXBinaryGreaterEq = ID(0x5B) - IDXBinaryGreaterThan = ID(0x5C) - IDXBinaryAnd = ID(0x5D) - IDXBinaryOr = ID(0x5E) - IDXBinaryAs = ID(0x5F) + IDXBinaryPipe = ID(0x4F) + IDXBinaryHat = ID(0x50) + IDXBinaryPercent = ID(0x51) + IDXBinaryTildeModPlus = ID(0x52) + IDXBinaryTildeModMinus = ID(0x53) + IDXBinaryTildeSatPlus = ID(0x54) + IDXBinaryTildeSatMinus = ID(0x55) + IDXBinaryNotEq = ID(0x56) + IDXBinaryLessThan = ID(0x57) + IDXBinaryLessEq = ID(0x58) + IDXBinaryEqEq = ID(0x59) + IDXBinaryGreaterEq = ID(0x5A) + IDXBinaryGreaterThan = ID(0x5B) + IDXBinaryAnd = ID(0x5C) + IDXBinaryOr = ID(0x5D) + IDXBinaryAs = ID(0x5E) IDXAssociativePlus = ID(0x60) IDXAssociativeStar = ID(0x61) @@ -443,7 +440,6 @@ var builtInsByID = [nBuiltInIDs]string{ IDShiftLEq: "<<=", IDShiftREq: ">>=", IDAmpEq: "&=", - IDAmpHatEq: "&^=", IDPipeEq: "|=", IDHatEq: "^=", IDPercentEq: "%=", @@ -459,7 +455,6 @@ var builtInsByID = [nBuiltInIDs]string{ IDShiftL: "<<", IDShiftR: ">>", IDAmp: "&", - IDAmpHat: "&^", IDPipe: "|", IDHat: "^", IDPercent: "%", @@ -639,8 +634,6 @@ var lexers = [nBuiltInIDs][]suffixLexer{ {"", IDExclam}, }, '&': { - {"^=", IDAmpHatEq}, - {"^", IDAmpHat}, {"=", IDAmpEq}, {"", IDAmp}, }, @@ -714,7 +707,6 @@ var ambiguousForms = [nBuiltInIDs]ID{ IDXBinaryShiftL: IDShiftL, IDXBinaryShiftR: IDShiftR, IDXBinaryAmp: IDAmp, - IDXBinaryAmpHat: IDAmpHat, IDXBinaryPipe: IDPipe, IDXBinaryHat: IDHat, IDXBinaryPercent: IDPercent, @@ -783,7 +775,6 @@ var binaryForms = [nBuiltInIDs]ID{ IDShiftLEq: IDXBinaryShiftL, IDShiftREq: IDXBinaryShiftR, IDAmpEq: IDXBinaryAmp, - IDAmpHatEq: IDXBinaryAmpHat, IDPipeEq: IDXBinaryPipe, IDHatEq: IDXBinaryHat, IDPercentEq: IDXBinaryPercent, @@ -799,7 +790,6 @@ var binaryForms = [nBuiltInIDs]ID{ IDShiftL: IDXBinaryShiftL, IDShiftR: IDXBinaryShiftR, IDAmp: IDXBinaryAmp, - IDAmpHat: IDXBinaryAmpHat, IDPipe: IDXBinaryPipe, IDHat: IDXBinaryHat, IDPercent: IDXBinaryPercent,