Skip to content

Commit 5e64391

Browse files
committed
cmd/compile: bulk rename
This change does a bulk rename of several identifiers in the compiler. See golang#27167 and https://docs.google.com/document/d/19_ExiylD9MRfeAjKIfEsMU1_RGhuxB9sA0b5Zv7byVI/ for context and for discussion of these particular renames. Commands run to generate this change: gorename -from '"cmd/compile/internal/gc".OPROC' -to OGO gorename -from '"cmd/compile/internal/gc".OCOM' -to OBITNOT gorename -from '"cmd/compile/internal/gc".OMINUS' -to ONEG gorename -from '"cmd/compile/internal/gc".OIND' -to ODEREF gorename -from '"cmd/compile/internal/gc".OARRAYBYTESTR' -to OBYTES2STR gorename -from '"cmd/compile/internal/gc".OARRAYBYTESTRTMP' -to OBYTES2STRTMP gorename -from '"cmd/compile/internal/gc".OARRAYRUNESTR' -to ORUNES2STR gorename -from '"cmd/compile/internal/gc".OSTRARRAYBYTE' -to OSTR2BYTES gorename -from '"cmd/compile/internal/gc".OSTRARRAYBYTETMP' -to OSTR2BYTESTMP gorename -from '"cmd/compile/internal/gc".OSTRARRAYRUNE' -to OSTR2RUNES gorename -from '"cmd/compile/internal/gc".Etop' -to ctxStmt gorename -from '"cmd/compile/internal/gc".Erv' -to ctxExpr gorename -from '"cmd/compile/internal/gc".Ecall' -to ctxCallee gorename -from '"cmd/compile/internal/gc".Efnstruct' -to ctxMultiOK gorename -from '"cmd/compile/internal/gc".Easgn' -to ctxAssign gorename -from '"cmd/compile/internal/gc".Ecomplit' -to ctxCompLit Not altered: parameters and local variables (mostly in typecheck.go) named top, which should probably now be called ctx (and which should probably have a named type). Also not altered: Field called Top in gc.Func. gorename -from '"cmd/compile/internal/gc".Node.Isddd' -to IsDDD gorename -from '"cmd/compile/internal/gc".Node.SetIsddd' -to SetIsDDD gorename -from '"cmd/compile/internal/gc".nodeIsddd' -to nodeIsDDD gorename -from '"cmd/compile/internal/types".Field.Isddd' -to IsDDD gorename -from '"cmd/compile/internal/types".Field.SetIsddd' -to SetIsDDD gorename -from '"cmd/compile/internal/types".fieldIsddd' -to fieldIsDDD Not altered: function gc.hasddd, params and local variables called isddd Also not altered: fmt.go prints nodes using "isddd(%v)". cd cmd/compile/internal/gc; go generate I then manually found impacted comments using exact string match and fixed them up by hand. The comment changes were trivial. Passes toolstash-check. Fixes golang#27167. If this experiment is deemed a success, we will open a new tracking issue for renames to do at the end of the 1.13 cycles. Change-Id: I2dc541533d2ab0d06cb3d31d65df205ecfb151e8
1 parent 310f2e2 commit 5e64391

28 files changed

+709
-709
lines changed

src/cmd/compile/internal/gc/alg.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func genhash(sym *types.Sym, t *types.Type) {
217217
// pure memory.
218218
hashel := hashfor(t.Elem())
219219

220-
n := nod(ORANGE, nil, nod(OIND, np, nil))
220+
n := nod(ORANGE, nil, nod(ODEREF, np, nil))
221221
ni := newname(lookup("i"))
222222
ni.Type = types.Types[TINT]
223223
n.List.Set1(ni)
@@ -290,10 +290,10 @@ func genhash(sym *types.Sym, t *types.Type) {
290290
funcbody()
291291

292292
fn.Func.SetDupok(true)
293-
fn = typecheck(fn, Etop)
293+
fn = typecheck(fn, ctxStmt)
294294

295295
Curfn = fn
296-
typecheckslice(fn.Nbody.Slice(), Etop)
296+
typecheckslice(fn.Nbody.Slice(), ctxStmt)
297297
Curfn = nil
298298

299299
if debug_dclstack != 0 {
@@ -375,7 +375,7 @@ func geneq(sym *types.Sym, t *types.Type) {
375375
// pure memory. Even if we unrolled the range loop,
376376
// each iteration would be a function call, so don't bother
377377
// unrolling.
378-
nrange := nod(ORANGE, nil, nod(OIND, np, nil))
378+
nrange := nod(ORANGE, nil, nod(ODEREF, np, nil))
379379

380380
ni := newname(lookup("i"))
381381
ni.Type = types.Types[TINT]
@@ -465,10 +465,10 @@ func geneq(sym *types.Sym, t *types.Type) {
465465
funcbody()
466466

467467
fn.Func.SetDupok(true)
468-
fn = typecheck(fn, Etop)
468+
fn = typecheck(fn, ctxStmt)
469469

470470
Curfn = fn
471-
typecheckslice(fn.Nbody.Slice(), Etop)
471+
typecheckslice(fn.Nbody.Slice(), ctxStmt)
472472
Curfn = nil
473473

474474
if debug_dclstack != 0 {
@@ -497,8 +497,8 @@ func eqfield(p *Node, q *Node, field *types.Sym) *Node {
497497
func eqmem(p *Node, q *Node, field *types.Sym, size int64) *Node {
498498
nx := nod(OADDR, nodSym(OXDOT, p, field), nil)
499499
ny := nod(OADDR, nodSym(OXDOT, q, field), nil)
500-
nx = typecheck(nx, Erv)
501-
ny = typecheck(ny, Erv)
500+
nx = typecheck(nx, ctxExpr)
501+
ny = typecheck(ny, ctxExpr)
502502

503503
fn, needsize := eqmemfunc(size, nx.Type.Elem())
504504
call := nod(OCALL, fn, nil)

src/cmd/compile/internal/gc/closure.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func typecheckclosure(clo *Node, top int) {
9393
xfunc.Func.Nname.Sym = closurename(Curfn)
9494
disableExport(xfunc.Func.Nname.Sym)
9595
declare(xfunc.Func.Nname, PFUNC)
96-
xfunc = typecheck(xfunc, Etop)
96+
xfunc = typecheck(xfunc, ctxStmt)
9797

9898
clo.Func.Ntype = typecheck(clo.Func.Ntype, Etype)
9999
clo.Type = clo.Func.Ntype.Type
@@ -108,7 +108,7 @@ func typecheckclosure(clo *Node, top int) {
108108
Curfn = xfunc
109109
olddd := decldepth
110110
decldepth = 1
111-
typecheckslice(xfunc.Nbody.Slice(), Etop)
111+
typecheckslice(xfunc.Nbody.Slice(), ctxStmt)
112112
decldepth = olddd
113113
Curfn = oldfn
114114
}
@@ -199,7 +199,7 @@ func capturevars(xfunc *Node) {
199199
Warnl(v.Pos, "%v capturing by %s: %v (addr=%v assign=%v width=%d)", name, how, v.Sym, outermost.Addrtaken(), outermost.Assigned(), int32(v.Type.Width))
200200
}
201201

202-
outer = typecheck(outer, Erv)
202+
outer = typecheck(outer, ctxExpr)
203203
clo.Func.Enter.Append(outer)
204204
}
205205

@@ -214,7 +214,7 @@ func transformclosure(xfunc *Node) {
214214
lineno = xfunc.Pos
215215
clo := xfunc.Func.Closure
216216

217-
if clo.Func.Top&Ecall != 0 {
217+
if clo.Func.Top&ctxCallee != 0 {
218218
// If the closure is directly called, we transform it to a plain function call
219219
// with variables passed as args. This avoids allocation of a closure object.
220220
// Here we do only a part of the transformation. Walk of OCALLFUNC(OCLOSURE)
@@ -305,7 +305,7 @@ func transformclosure(xfunc *Node) {
305305
}
306306

307307
if len(body) > 0 {
308-
typecheckslice(body, Etop)
308+
typecheckslice(body, ctxStmt)
309309
xfunc.Func.Enter.Set(body)
310310
xfunc.Func.SetNeedctxt(true)
311311
}
@@ -383,7 +383,7 @@ func walkclosure(clo *Node, init *Nodes) *Node {
383383

384384
typ := closureType(clo)
385385

386-
clos := nod(OCOMPLIT, nil, nod(OIND, typenod(typ), nil))
386+
clos := nod(OCOMPLIT, nil, nod(ODEREF, typenod(typ), nil))
387387
clos.Esc = clo.Esc
388388
clos.Right.SetImplicit(true)
389389
clos.List.Set(append([]*Node{nod(OCFUNC, xfunc.Func.Nname, nil)}, clo.Func.Enter.Slice()...))
@@ -467,7 +467,7 @@ func makepartialcall(fn *Node, t0 *types.Type, meth *types.Sym) *Node {
467467

468468
call := nod(OCALL, nodSym(OXDOT, ptr, meth), nil)
469469
call.List.Set(paramNnames(tfn.Type))
470-
call.SetIsddd(tfn.Type.IsVariadic())
470+
call.SetIsDDD(tfn.Type.IsVariadic())
471471
if t0.NumResults() != 0 {
472472
n := nod(ORETURN, nil, nil)
473473
n.List.Set1(call)
@@ -478,7 +478,7 @@ func makepartialcall(fn *Node, t0 *types.Type, meth *types.Sym) *Node {
478478
xfunc.Nbody.Set(body)
479479
funcbody()
480480

481-
xfunc = typecheck(xfunc, Etop)
481+
xfunc = typecheck(xfunc, ctxStmt)
482482
sym.Def = asTypesNode(xfunc)
483483
xtop = append(xtop, xfunc)
484484
Curfn = savecurfn
@@ -516,7 +516,7 @@ func walkpartialcall(n *Node, init *Nodes) *Node {
516516

517517
typ := partialCallType(n)
518518

519-
clos := nod(OCOMPLIT, nil, nod(OIND, typenod(typ), nil))
519+
clos := nod(OCOMPLIT, nil, nod(ODEREF, typenod(typ), nil))
520520
clos.Esc = n.Esc
521521
clos.Right.SetImplicit(true)
522522
clos.List.Set2(nod(OCFUNC, n.Func.Nname, nil), n.Left)

src/cmd/compile/internal/gc/const.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ func evconst(n *Node) {
588588

589589
// Pick off just the opcodes that can be constant evaluated.
590590
switch op := n.Op; op {
591-
case OPLUS, OMINUS, OCOM, ONOT:
591+
case OPLUS, ONEG, OBITNOT, ONOT:
592592
if nl.Op == OLITERAL {
593593
setconst(n, unaryOp(op, nl.Val(), n.Type))
594594
}
@@ -623,7 +623,7 @@ func evconst(n *Node) {
623623
setconst(n, convlit1(nl, n.Type, true, false).Val())
624624
}
625625

626-
case OARRAYBYTESTR:
626+
case OBYTES2STR:
627627
// string([]byte(nil)) or string([]rune(nil))
628628
if nl.Op == OLITERAL && nl.Val().Ctype() == CTNIL {
629629
setconst(n, Val{U: ""})
@@ -873,7 +873,7 @@ func unaryOp(op Op, x Val, t *types.Type) Val {
873873
return x
874874
}
875875

876-
case OMINUS:
876+
case ONEG:
877877
switch x.Ctype() {
878878
case CTINT, CTRUNE:
879879
x := x.U.(*Mpint)
@@ -900,7 +900,7 @@ func unaryOp(op Op, x Val, t *types.Type) Val {
900900
return Val{U: u}
901901
}
902902

903-
case OCOM:
903+
case OBITNOT:
904904
x := x.U.(*Mpint)
905905

906906
u := new(Mpint)
@@ -1024,9 +1024,9 @@ func idealkind(n *Node) Ctype {
10241024
case OADD,
10251025
OAND,
10261026
OANDNOT,
1027-
OCOM,
1027+
OBITNOT,
10281028
ODIV,
1029-
OMINUS,
1029+
ONEG,
10301030
OMOD,
10311031
OMUL,
10321032
OSUB,
@@ -1281,15 +1281,15 @@ func (n *Node) isGoConst() bool {
12811281
OAND,
12821282
OANDAND,
12831283
OANDNOT,
1284-
OCOM,
1284+
OBITNOT,
12851285
ODIV,
12861286
OEQ,
12871287
OGE,
12881288
OGT,
12891289
OLE,
12901290
OLSH,
12911291
OLT,
1292-
OMINUS,
1292+
ONEG,
12931293
OMOD,
12941294
OMUL,
12951295
ONE,

src/cmd/compile/internal/gc/dcl.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ func oldname(s *types.Sym) *Node {
283283
c = newname(s)
284284
c.SetClass(PAUTOHEAP)
285285
c.SetIsClosureVar(true)
286-
c.SetIsddd(n.Isddd())
286+
c.SetIsDDD(n.IsDDD())
287287
c.Name.Defn = n
288288
c.SetAddable(false)
289289

@@ -455,7 +455,7 @@ func funcarg(n *Node, ctxt Class) {
455455

456456
n.Right = newnamel(n.Pos, n.Sym)
457457
n.Right.Name.Param.Ntype = n.Left
458-
n.Right.SetIsddd(n.Isddd())
458+
n.Right.SetIsDDD(n.IsDDD())
459459
declare(n.Right, ctxt)
460460

461461
vargen++
@@ -488,7 +488,7 @@ func funcarg2(f *types.Field, ctxt Class) {
488488
n := newnamel(f.Pos, f.Sym)
489489
f.Nname = asTypesNode(n)
490490
n.Type = f.Type
491-
n.SetIsddd(f.Isddd())
491+
n.SetIsDDD(f.IsDDD())
492492
declare(n, ctxt)
493493
}
494494

@@ -628,7 +628,7 @@ func tofunargs(l []*Node, funarg types.Funarg) *types.Type {
628628
fields := make([]*types.Field, len(l))
629629
for i, n := range l {
630630
f := structfield(n)
631-
f.SetIsddd(n.Isddd())
631+
f.SetIsDDD(n.IsDDD())
632632
if n.Right != nil {
633633
n.Right.Type = f.Type
634634
f.Nname = asTypesNode(n.Right)

0 commit comments

Comments
 (0)