X Tutup
Skip to content

Commit dc7b54b

Browse files
committed
[dev.cc] cmd/internal/obj, cmd/internal/gc, new6g: reconvert
Reconvert using rsc.io/c2go rev 27b3f59. Changes to converter: - fatal does not return, so no fallthrough after fatal in switch - many more function results and variables identified as bool - simplification of negated boolean expressions Change-Id: I3bc67da5e46cb7ee613e230cf7e9533036cc870b Reviewed-on: https://go-review.googlesource.com/5171 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
1 parent 786825c commit dc7b54b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2410
-2509
lines changed

src/cmd/internal/gc/align.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func dowidth(t *Type) {
138138
if t.Width == -2 {
139139
lno = int(lineno)
140140
lineno = int32(t.Lineno)
141-
if !(t.Broke != 0) {
141+
if t.Broke == 0 {
142142
t.Broke = 1
143143
Yyerror("invalid recursive type %v", Tconv(t, 0))
144144
}
@@ -253,14 +253,14 @@ func dowidth(t *Type) {
253253
checkwidth(t.Down)
254254

255255
case TFORW: // should have been filled in
256-
if !(t.Broke != 0) {
256+
if t.Broke == 0 {
257257
Yyerror("invalid recursive type %v", Tconv(t, 0))
258258
}
259259
w = 1 // anything will do
260260

261261
// dummy type; should be replaced before use.
262262
case TANY:
263-
if !(Debug['A'] != 0) {
263+
if Debug['A'] == 0 {
264264
Fatal("dowidth any")
265265
}
266266
w = 1 // anything will do
@@ -294,7 +294,7 @@ func dowidth(t *Type) {
294294
checkwidth(t.Type)
295295
t.Align = uint8(Widthptr)
296296
} else if t.Bound == -100 {
297-
if !(t.Broke != 0) {
297+
if t.Broke == 0 {
298298
Yyerror("use of [...] array outside of array literal")
299299
t.Broke = 1
300300
}
@@ -394,7 +394,7 @@ func checkwidth(t *Type) {
394394
Fatal("checkwidth %v", Tconv(t, 0))
395395
}
396396

397-
if !(defercalc != 0) {
397+
if defercalc == 0 {
398398
dowidth(t)
399399
return
400400
}
@@ -427,7 +427,7 @@ func defercheckwidth() {
427427
func resumecheckwidth() {
428428
var l *TypeList
429429

430-
if !(defercalc != 0) {
430+
if defercalc == 0 {
431431
Fatal("resumecheckwidth")
432432
}
433433
for l = tlq; l != nil; l = tlq {

src/cmd/internal/gc/bits.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ bnot(Bits a)
6666
return c;
6767
}
6868
*/
69-
func bany(a *Bits) int {
69+
func bany(a *Bits) bool {
7070
var i int
7171

7272
for i = 0; i < BITS; i++ {
7373
if a.b[i] != 0 {
74-
return 1
74+
return true
7575
}
7676
}
77-
return 0
77+
return false
7878
}
7979

8080
/*
@@ -112,8 +112,8 @@ func blsh(n uint) Bits {
112112
return c
113113
}
114114

115-
func btest(a *Bits, n uint) int {
116-
return bool2int(a.b[n/64]&(1<<(n%64)) != 0)
115+
func btest(a *Bits, n uint) bool {
116+
return a.b[n/64]&(1<<(n%64)) != 0
117117
}
118118

119119
func biset(a *Bits, n uint) {
@@ -144,7 +144,7 @@ func Qconv(bits Bits, flag int) string {
144144

145145
first = 1
146146

147-
for bany(&bits) != 0 {
147+
for bany(&bits) {
148148
i = bnum(bits)
149149
if first != 0 {
150150
first = 0

src/cmd/internal/gc/bv.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ func bvnext(bv *Bvec, i int32) int {
120120
return int(i)
121121
}
122122

123-
func bvisempty(bv *Bvec) int {
123+
func bvisempty(bv *Bvec) bool {
124124
var i int32
125125

126126
for i = 0; i < bv.n; i += WORDBITS {
127127
if bv.b[i>>WORDSHIFT] != 0 {
128-
return 0
128+
return false
129129
}
130130
}
131-
return 1
131+
return true
132132
}
133133

134134
func bvnot(bv *Bvec) {

src/cmd/internal/gc/closure.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func typecheckclosure(func_ *Node, top int) {
9191

9292
for l = func_.Cvars; l != nil; l = l.Next {
9393
n = l.N.Closure
94-
if !(n.Captured != 0) {
94+
if n.Captured == 0 {
9595
n.Captured = 1
9696
if n.Decldepth == 0 {
9797
Fatal("typecheckclosure: var %v does not have decldepth assigned", Nconv(n, obj.FmtShort))
@@ -218,7 +218,7 @@ func capturevars(xfunc *Node) {
218218
v.Outerexpr = nil
219219

220220
// out parameters will be assigned to implicitly upon return.
221-
if outer.Class != PPARAMOUT && !(v.Closure.Addrtaken != 0) && !(v.Closure.Assigned != 0) && v.Type.Width <= 128 {
221+
if outer.Class != PPARAMOUT && v.Closure.Addrtaken == 0 && v.Closure.Assigned == 0 && v.Type.Width <= 128 {
222222
v.Byval = 1
223223
} else {
224224
v.Closure.Addrtaken = 1
@@ -351,7 +351,7 @@ func transformclosure(xfunc *Node) {
351351
cv = Nod(OCLOSUREVAR, nil, nil)
352352

353353
cv.Type = v.Type
354-
if !(v.Byval != 0) {
354+
if v.Byval == 0 {
355355
cv.Type = Ptrto(v.Type)
356356
}
357357
offset = Rnd(offset, int64(cv.Type.Align))
@@ -389,7 +389,7 @@ func transformclosure(xfunc *Node) {
389389
typechecklist(body, Etop)
390390
walkstmtlist(body)
391391
xfunc.Enter = body
392-
xfunc.Needctxt = uint8(bool2int(nvar > 0))
392+
xfunc.Needctxt = nvar > 0
393393
}
394394

395395
lineno = int32(lno)
@@ -430,7 +430,7 @@ func walkclosure(func_ *Node, init **NodeList) *Node {
430430
continue
431431
}
432432
typ1 = typenod(v.Type)
433-
if !(v.Byval != 0) {
433+
if v.Byval == 0 {
434434
typ1 = Nod(OIND, typ1, nil)
435435
}
436436
typ.List = list(typ.List, Nod(ODCLFIELD, newname(v.Sym), typ1))
@@ -594,7 +594,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node {
594594
// Declare and initialize variable holding receiver.
595595
body = nil
596596

597-
xfunc.Needctxt = 1
597+
xfunc.Needctxt = true
598598
cv = Nod(OCLOSUREVAR, nil, nil)
599599
cv.Xoffset = int64(Widthptr)
600600
cv.Type = rcvrtype
@@ -609,7 +609,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node {
609609
ptr.Used = 1
610610
ptr.Curfn = xfunc
611611
xfunc.Dcl = list(xfunc.Dcl, ptr)
612-
if Isptr[rcvrtype.Etype] != 0 || Isinter(rcvrtype) != 0 {
612+
if Isptr[rcvrtype.Etype] != 0 || Isinter(rcvrtype) {
613613
ptr.Ntype = typenod(rcvrtype)
614614
body = list(body, Nod(OAS, ptr, cv))
615615
} else {
@@ -652,7 +652,7 @@ func walkpartialcall(n *Node, init **NodeList) *Node {
652652
//
653653
// Like walkclosure above.
654654

655-
if Isinter(n.Left.Type) != 0 {
655+
if Isinter(n.Left.Type) {
656656
// Trigger panic for method on nil interface now.
657657
// Otherwise it happens in the wrapper and is confusing.
658658
n.Left = cheapexpr(n.Left, init)

0 commit comments

Comments
 (0)
X Tutup