Skip to content

Commit

Permalink
cmd/compile: bulk rename
Browse files Browse the repository at this point in the history
This change does a bulk rename of several identifiers in the compiler.
See #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 #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
Reviewed-on: https://go-review.googlesource.com/c/150140
Run-TryBot: Josh Bleecher Snyder <[email protected]>
Reviewed-by: Matthew Dempsky <[email protected]>
  • Loading branch information
josharian committed Nov 19, 2018
1 parent 404ab86 commit bc43889
Show file tree
Hide file tree
Showing 28 changed files with 709 additions and 709 deletions.
16 changes: 8 additions & 8 deletions src/cmd/compile/internal/gc/alg.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func genhash(sym *types.Sym, t *types.Type) {
// pure memory.
hashel := hashfor(t.Elem())

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

fn.Func.SetDupok(true)
fn = typecheck(fn, Etop)
fn = typecheck(fn, ctxStmt)

Curfn = fn
typecheckslice(fn.Nbody.Slice(), Etop)
typecheckslice(fn.Nbody.Slice(), ctxStmt)
Curfn = nil

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

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

fn.Func.SetDupok(true)
fn = typecheck(fn, Etop)
fn = typecheck(fn, ctxStmt)

Curfn = fn
typecheckslice(fn.Nbody.Slice(), Etop)
typecheckslice(fn.Nbody.Slice(), ctxStmt)
Curfn = nil

if debug_dclstack != 0 {
Expand Down Expand Up @@ -497,8 +497,8 @@ func eqfield(p *Node, q *Node, field *types.Sym) *Node {
func eqmem(p *Node, q *Node, field *types.Sym, size int64) *Node {
nx := nod(OADDR, nodSym(OXDOT, p, field), nil)
ny := nod(OADDR, nodSym(OXDOT, q, field), nil)
nx = typecheck(nx, Erv)
ny = typecheck(ny, Erv)
nx = typecheck(nx, ctxExpr)
ny = typecheck(ny, ctxExpr)

fn, needsize := eqmemfunc(size, nx.Type.Elem())
call := nod(OCALL, fn, nil)
Expand Down
18 changes: 9 additions & 9 deletions src/cmd/compile/internal/gc/closure.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func typecheckclosure(clo *Node, top int) {
xfunc.Func.Nname.Sym = closurename(Curfn)
disableExport(xfunc.Func.Nname.Sym)
declare(xfunc.Func.Nname, PFUNC)
xfunc = typecheck(xfunc, Etop)
xfunc = typecheck(xfunc, ctxStmt)

clo.Func.Ntype = typecheck(clo.Func.Ntype, Etype)
clo.Type = clo.Func.Ntype.Type
Expand All @@ -108,7 +108,7 @@ func typecheckclosure(clo *Node, top int) {
Curfn = xfunc
olddd := decldepth
decldepth = 1
typecheckslice(xfunc.Nbody.Slice(), Etop)
typecheckslice(xfunc.Nbody.Slice(), ctxStmt)
decldepth = olddd
Curfn = oldfn
}
Expand Down Expand Up @@ -199,7 +199,7 @@ func capturevars(xfunc *Node) {
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))
}

outer = typecheck(outer, Erv)
outer = typecheck(outer, ctxExpr)
clo.Func.Enter.Append(outer)
}

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

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

if len(body) > 0 {
typecheckslice(body, Etop)
typecheckslice(body, ctxStmt)
xfunc.Func.Enter.Set(body)
xfunc.Func.SetNeedctxt(true)
}
Expand Down Expand Up @@ -383,7 +383,7 @@ func walkclosure(clo *Node, init *Nodes) *Node {

typ := closureType(clo)

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

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

xfunc = typecheck(xfunc, Etop)
xfunc = typecheck(xfunc, ctxStmt)
sym.Def = asTypesNode(xfunc)
xtop = append(xtop, xfunc)
Curfn = savecurfn
Expand Down Expand Up @@ -516,7 +516,7 @@ func walkpartialcall(n *Node, init *Nodes) *Node {

typ := partialCallType(n)

clos := nod(OCOMPLIT, nil, nod(OIND, typenod(typ), nil))
clos := nod(OCOMPLIT, nil, nod(ODEREF, typenod(typ), nil))
clos.Esc = n.Esc
clos.Right.SetImplicit(true)
clos.List.Set2(nod(OCFUNC, n.Func.Nname, nil), n.Left)
Expand Down
16 changes: 8 additions & 8 deletions src/cmd/compile/internal/gc/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ func evconst(n *Node) {

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

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

case OMINUS:
case ONEG:
switch x.Ctype() {
case CTINT, CTRUNE:
x := x.U.(*Mpint)
Expand All @@ -900,7 +900,7 @@ func unaryOp(op Op, x Val, t *types.Type) Val {
return Val{U: u}
}

case OCOM:
case OBITNOT:
x := x.U.(*Mpint)

u := new(Mpint)
Expand Down Expand Up @@ -1024,9 +1024,9 @@ func idealkind(n *Node) Ctype {
case OADD,
OAND,
OANDNOT,
OCOM,
OBITNOT,
ODIV,
OMINUS,
ONEG,
OMOD,
OMUL,
OSUB,
Expand Down Expand Up @@ -1281,15 +1281,15 @@ func (n *Node) isGoConst() bool {
OAND,
OANDAND,
OANDNOT,
OCOM,
OBITNOT,
ODIV,
OEQ,
OGE,
OGT,
OLE,
OLSH,
OLT,
OMINUS,
ONEG,
OMOD,
OMUL,
ONE,
Expand Down
8 changes: 4 additions & 4 deletions src/cmd/compile/internal/gc/dcl.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func oldname(s *types.Sym) *Node {
c = newname(s)
c.SetClass(PAUTOHEAP)
c.SetIsClosureVar(true)
c.SetIsddd(n.Isddd())
c.SetIsDDD(n.IsDDD())
c.Name.Defn = n
c.SetAddable(false)

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

n.Right = newnamel(n.Pos, n.Sym)
n.Right.Name.Param.Ntype = n.Left
n.Right.SetIsddd(n.Isddd())
n.Right.SetIsDDD(n.IsDDD())
declare(n.Right, ctxt)

vargen++
Expand Down Expand Up @@ -488,7 +488,7 @@ func funcarg2(f *types.Field, ctxt Class) {
n := newnamel(f.Pos, f.Sym)
f.Nname = asTypesNode(n)
n.Type = f.Type
n.SetIsddd(f.Isddd())
n.SetIsDDD(f.IsDDD())
declare(n, ctxt)
}

Expand Down Expand Up @@ -628,7 +628,7 @@ func tofunargs(l []*Node, funarg types.Funarg) *types.Type {
fields := make([]*types.Field, len(l))
for i, n := range l {
f := structfield(n)
f.SetIsddd(n.Isddd())
f.SetIsDDD(n.IsDDD())
if n.Right != nil {
n.Right.Type = f.Type
f.Nname = asTypesNode(n.Right)
Expand Down
Loading

0 comments on commit bc43889

Please sign in to comment.