Skip to content

Commit 249aca5

Browse files
hajimehoshimdempsky
authored andcommitted
cmd/compile/internal/gc: unexport or remove global functions
Change-Id: Ib2109ab773fbf2a35188300cf91a54735f75fc7c Reviewed-on: https://go-review.googlesource.com/36736 Reviewed-by: Matthew Dempsky <[email protected]>
1 parent 39651bb commit 249aca5

File tree

7 files changed

+29
-52
lines changed

7 files changed

+29
-52
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func genhash(sym *Sym, t *Type) {
186186
fmt.Printf("genhash %v %v\n", sym, t)
187187
}
188188

189-
lineno = MakePos(nil, 1, 0) // less confusing than end of input
189+
lineno = makePos(nil, 1, 0) // less confusing than end of input
190190
dclcontext = PEXTERN
191191
markdcl()
192192

@@ -364,7 +364,7 @@ func geneq(sym *Sym, t *Type) {
364364
fmt.Printf("geneq %v %v\n", sym, t)
365365
}
366366

367-
lineno = MakePos(nil, 1, 0) // less confusing than end of input
367+
lineno = makePos(nil, 1, 0) // less confusing than end of input
368368
dclcontext = PEXTERN
369369
markdcl()
370370

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
// TODO(gri) rename and eventually remove
1717
var lineno src.XPos
1818

19-
func MakePos(base *src.PosBase, line, col uint) src.XPos {
19+
func makePos(base *src.PosBase, line, col uint) src.XPos {
2020
return Ctxt.PosTable.XPos(src.MakePos(base, line, col))
2121
}
2222

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (p *noder) node() {
111111
// for fninit and set lineno to NoPos here.
112112
// TODO(gri) fix this once we switched permanently to the new
113113
// position information.
114-
lineno = MakePos(p.file.Pos().Base(), uint(p.file.Lines), 0)
114+
lineno = makePos(p.file.Pos().Base(), uint(p.file.Lines), 0)
115115

116116
clearImports()
117117
}
@@ -322,7 +322,7 @@ func (p *noder) funcDecl(fun *syntax.FuncDecl) *Node {
322322
yyerror("can only use //go:noescape with external func implementations")
323323
}
324324
f.Func.Pragma = pragma
325-
lineno = MakePos(fun.Pos().Base(), fun.EndLine, 0)
325+
lineno = makePos(fun.Pos().Base(), fun.EndLine, 0)
326326
f.Func.Endlineno = lineno
327327

328328
funcbody(f)
@@ -448,14 +448,14 @@ func (p *noder) expr(expr syntax.Expr) *Node {
448448
l[i] = p.wrapname(expr.ElemList[i], e)
449449
}
450450
n.List.Set(l)
451-
lineno = MakePos(expr.Pos().Base(), expr.EndLine, 0)
451+
lineno = makePos(expr.Pos().Base(), expr.EndLine, 0)
452452
return n
453453
case *syntax.KeyValueExpr:
454454
return p.nod(expr, OKEY, p.expr(expr.Key), p.wrapname(expr.Value, p.expr(expr.Value)))
455455
case *syntax.FuncLit:
456456
closurehdr(p.typeExpr(expr.Type))
457457
body := p.stmts(expr.Body)
458-
lineno = MakePos(expr.Pos().Base(), expr.EndLine, 0)
458+
lineno = makePos(expr.Pos().Base(), expr.EndLine, 0)
459459
return p.setlineno(expr, closurebody(body))
460460
case *syntax.ParenExpr:
461461
return p.nod(expr, OPAREN, p.expr(expr.X), nil)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ func genAsInitNoCheck(n *Node) bool {
14021402

14031403
nam.Xoffset += int64(array_nel) - int64(array_array)
14041404
var nod1 Node
1405-
Nodconst(&nod1, Types[TINT], nr.Type.NumElem())
1405+
nodconst(&nod1, Types[TINT], nr.Type.NumElem())
14061406
gdata(&nam, &nod1, Widthint)
14071407

14081408
nam.Xoffset += int64(array_cap) - int64(array_nel)

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

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ func nodfltconst(v *Mpflt) *Node {
440440
return c
441441
}
442442

443-
func Nodconst(n *Node, t *Type, v int64) {
443+
func nodconst(n *Node, t *Type, v int64) {
444444
*n = Node{}
445445
n.Op = OLITERAL
446446
n.Addable = true
@@ -1706,7 +1706,7 @@ func genwrapper(rcvr *Type, method *Field, newnam *Sym, iface int) {
17061706
fmt.Printf("genwrapper rcvrtype=%v method=%v newnam=%v\n", rcvr, method, newnam)
17071707
}
17081708

1709-
lineno = MakePos(src.NewFileBase("<autogenerated>", "<autogenerated>"), 1, 0)
1709+
lineno = makePos(src.NewFileBase("<autogenerated>", "<autogenerated>"), 1, 0)
17101710

17111711
dclcontext = PEXTERN
17121712
markdcl()
@@ -1956,29 +1956,6 @@ func implements(t, iface *Type, m, samename **Field, ptr *int) bool {
19561956
return true
19571957
}
19581958

1959-
// even simpler simtype; get rid of ptr, bool.
1960-
// assuming that the front end has rejected
1961-
// all the invalid conversions (like ptr -> bool)
1962-
func Simsimtype(t *Type) EType {
1963-
if t == nil {
1964-
return 0
1965-
}
1966-
1967-
et := simtype[t.Etype]
1968-
switch et {
1969-
case TPTR32:
1970-
et = TUINT32
1971-
1972-
case TPTR64:
1973-
et = TUINT64
1974-
1975-
case TBOOL:
1976-
et = TUINT8
1977-
}
1978-
1979-
return et
1980-
}
1981-
19821959
func listtreecopy(l []*Node, pos src.XPos) []*Node {
19831960
var out []*Node
19841961
for _, n := range l {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ OpSwitch:
13211321

13221322
// any side effects disappear; ignore init
13231323
var r Node
1324-
Nodconst(&r, Types[TUINTPTR], evalunsafe(n))
1324+
nodconst(&r, Types[TUINTPTR], evalunsafe(n))
13251325
r.Orig = n
13261326
n = &r
13271327

@@ -1376,7 +1376,7 @@ OpSwitch:
13761376
case TSTRING:
13771377
if Isconst(l, CTSTR) {
13781378
var r Node
1379-
Nodconst(&r, Types[TINT], int64(len(l.Val().U.(string))))
1379+
nodconst(&r, Types[TINT], int64(len(l.Val().U.(string))))
13801380
r.Orig = n
13811381
n = &r
13821382
}
@@ -1386,7 +1386,7 @@ OpSwitch:
13861386
break
13871387
}
13881388
var r Node
1389-
Nodconst(&r, Types[TINT], t.NumElem())
1389+
nodconst(&r, Types[TINT], t.NumElem())
13901390
r.Orig = n
13911391
n = &r
13921392
}

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ opswitch:
529529
}
530530
if t.IsArray() {
531531
safeexpr(n.Left, init)
532-
Nodconst(n, n.Type, t.NumElem())
532+
nodconst(n, n.Type, t.NumElem())
533533
n.Typecheck = 1
534534
}
535535

@@ -3445,7 +3445,7 @@ func walkdiv(n *Node, init *Nodes) *Node {
34453445
case TUINT8, TUINT16, TUINT32:
34463446
var nc Node
34473447

3448-
Nodconst(&nc, nl.Type, int64(m.Um))
3448+
nodconst(&nc, nl.Type, int64(m.Um))
34493449
n1 := nod(OHMUL, nl, &nc)
34503450
n1 = typecheck(n1, Erv)
34513451
if m.Ua != 0 {
@@ -3475,21 +3475,21 @@ func walkdiv(n *Node, init *Nodes) *Node {
34753475
// shift by m.s
34763476
var nc Node
34773477

3478-
Nodconst(&nc, Types[TUINT], int64(m.S))
3478+
nodconst(&nc, Types[TUINT], int64(m.S))
34793479
n = conv(nod(ORSH, n2, &nc), nl.Type)
34803480
} else {
34813481
// n = n1 >> m.s
34823482
var nc Node
34833483

3484-
Nodconst(&nc, Types[TUINT], int64(m.S))
3484+
nodconst(&nc, Types[TUINT], int64(m.S))
34853485
n = nod(ORSH, n1, &nc)
34863486
}
34873487

34883488
// n1 = nl * magic >> w
34893489
case TINT8, TINT16, TINT32:
34903490
var nc Node
34913491

3492-
Nodconst(&nc, nl.Type, m.Sm)
3492+
nodconst(&nc, nl.Type, m.Sm)
34933493
n1 := nod(OHMUL, nl, &nc)
34943494
n1 = typecheck(n1, Erv)
34953495
if m.Sm < 0 {
@@ -3500,13 +3500,13 @@ func walkdiv(n *Node, init *Nodes) *Node {
35003500
// shift by m.s
35013501
var ns Node
35023502

3503-
Nodconst(&ns, Types[TUINT], int64(m.S))
3503+
nodconst(&ns, Types[TUINT], int64(m.S))
35043504
n2 := conv(nod(ORSH, n1, &ns), nl.Type)
35053505

35063506
// add 1 iff n1 is negative.
35073507
var nneg Node
35083508

3509-
Nodconst(&nneg, Types[TUINT], int64(w)-1)
3509+
nodconst(&nneg, Types[TUINT], int64(w)-1)
35103510
n3 := nod(ORSH, nl, &nneg) // n4 = -1 iff n1 is negative.
35113511
n = nod(OSUB, n2, n3)
35123512

@@ -3523,7 +3523,7 @@ func walkdiv(n *Node, init *Nodes) *Node {
35233523
case 0:
35243524
if n.Op == OMOD {
35253525
// nl % 1 is zero.
3526-
Nodconst(n, n.Type, 0)
3526+
nodconst(n, n.Type, 0)
35273527
} else if s != 0 {
35283528
// divide by -1
35293529
n.Op = OMINUS
@@ -3542,7 +3542,7 @@ func walkdiv(n *Node, init *Nodes) *Node {
35423542
// nl & (2^pow-1) is (nl+1)%2^pow - 1.
35433543
var nc Node
35443544

3545-
Nodconst(&nc, Types[simtype[TUINT]], int64(w)-1)
3545+
nodconst(&nc, Types[simtype[TUINT]], int64(w)-1)
35463546
n1 := nod(ORSH, nl, &nc) // n1 = -1 iff nl < 0.
35473547
if pow == 1 {
35483548
n1 = typecheck(n1, Erv)
@@ -3552,14 +3552,14 @@ func walkdiv(n *Node, init *Nodes) *Node {
35523552
n2 := nod(OSUB, nl, n1)
35533553

35543554
var nc Node
3555-
Nodconst(&nc, nl.Type, 1)
3555+
nodconst(&nc, nl.Type, 1)
35563556
n3 := nod(OAND, n2, &nc)
35573557
n = nod(OADD, n3, n1)
35583558
} else {
35593559
// n = (nl+ε)&(nr-1) - ε where ε=2^pow-1 iff nl<0.
35603560
var nc Node
35613561

3562-
Nodconst(&nc, nl.Type, (1<<uint(pow))-1)
3562+
nodconst(&nc, nl.Type, (1<<uint(pow))-1)
35633563
n2 := nod(OAND, n1, &nc) // n2 = 2^pow-1 iff nl<0.
35643564
n2 = typecheck(n2, Erv)
35653565
n2 = cheapexpr(n2, init)
@@ -3576,7 +3576,7 @@ func walkdiv(n *Node, init *Nodes) *Node {
35763576
// if nl < 0, we want to add 2^n-1 first.
35773577
var nc Node
35783578

3579-
Nodconst(&nc, Types[simtype[TUINT]], int64(w)-1)
3579+
nodconst(&nc, Types[simtype[TUINT]], int64(w)-1)
35803580
n1 := nod(ORSH, nl, &nc) // n1 = -1 iff nl < 0.
35813581
if pow == 1 {
35823582
// nl+1 is nl-(-1)
@@ -3585,7 +3585,7 @@ func walkdiv(n *Node, init *Nodes) *Node {
35853585
// Do a logical right right on -1 to keep pow bits.
35863586
var nc Node
35873587

3588-
Nodconst(&nc, Types[simtype[TUINT]], int64(w)-int64(pow))
3588+
nodconst(&nc, Types[simtype[TUINT]], int64(w)-int64(pow))
35893589
n2 := nod(ORSH, conv(n1, nl.Type.toUnsigned()), &nc)
35903590
n.Left = nod(OADD, nl, conv(n2, nl.Type))
35913591
}
@@ -3594,7 +3594,7 @@ func walkdiv(n *Node, init *Nodes) *Node {
35943594
n.Op = ORSH
35953595

35963596
var n2 Node
3597-
Nodconst(&n2, Types[simtype[TUINT]], int64(pow))
3597+
nodconst(&n2, Types[simtype[TUINT]], int64(pow))
35983598
n.Right = &n2
35993599
n.Typecheck = 0
36003600
}
@@ -3610,12 +3610,12 @@ func walkdiv(n *Node, init *Nodes) *Node {
36103610
// n = nl & (nr-1)
36113611
n.Op = OAND
36123612

3613-
Nodconst(&nc, nl.Type, nr.Int64()-1)
3613+
nodconst(&nc, nl.Type, nr.Int64()-1)
36143614
} else {
36153615
// n = nl >> pow
36163616
n.Op = ORSH
36173617

3618-
Nodconst(&nc, Types[simtype[TUINT]], int64(pow))
3618+
nodconst(&nc, Types[simtype[TUINT]], int64(pow))
36193619
}
36203620

36213621
n.Typecheck = 0

0 commit comments

Comments
 (0)