Commit ec7c4945 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: remove typechecklist

Convert remaining uses to typecheckslice.

Passes toolstash -cmp.

Change-Id: I6ed0877386fb6c0b036e8ee5a228433343855abd
Reviewed-on: https://go-review.googlesource.com/20905
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarDave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent ad4c55c0
...@@ -282,7 +282,7 @@ func genhash(sym *Sym, t *Type) { ...@@ -282,7 +282,7 @@ func genhash(sym *Sym, t *Type) {
Curfn = fn Curfn = fn
fn.Func.Dupok = true fn.Func.Dupok = true
typecheck(&fn, Etop) typecheck(&fn, Etop)
typechecklist(fn.Nbody.Slice(), Etop) typecheckslice(fn.Nbody.Slice(), Etop)
Curfn = nil Curfn = nil
popdcl() popdcl()
testdclstack() testdclstack()
...@@ -475,7 +475,7 @@ func geneq(sym *Sym, t *Type) { ...@@ -475,7 +475,7 @@ func geneq(sym *Sym, t *Type) {
Curfn = fn Curfn = fn
fn.Func.Dupok = true fn.Func.Dupok = true
typecheck(&fn, Etop) typecheck(&fn, Etop)
typechecklist(fn.Nbody.Slice(), Etop) typecheckslice(fn.Nbody.Slice(), Etop)
Curfn = nil Curfn = nil
popdcl() popdcl()
testdclstack() testdclstack()
......
...@@ -109,7 +109,7 @@ func typecheckclosure(func_ *Node, top int) { ...@@ -109,7 +109,7 @@ func typecheckclosure(func_ *Node, top int) {
Curfn = func_ Curfn = func_
olddd := decldepth olddd := decldepth
decldepth = 1 decldepth = 1
typechecklist(func_.Nbody.Slice(), Etop) typecheckslice(func_.Nbody.Slice(), Etop)
decldepth = olddd decldepth = olddd
Curfn = oldfn Curfn = oldfn
} }
......
...@@ -75,7 +75,7 @@ func typecheckinl(fn *Node) { ...@@ -75,7 +75,7 @@ func typecheckinl(fn *Node) {
savefn := Curfn savefn := Curfn
Curfn = fn Curfn = fn
typechecklist(fn.Func.Inl.Slice(), Etop) typecheckslice(fn.Func.Inl.Slice(), Etop)
Curfn = savefn Curfn = savefn
safemode = save_safemode safemode = save_safemode
...@@ -955,7 +955,7 @@ func (subst *inlsubst) node(n *Node) *Node { ...@@ -955,7 +955,7 @@ func (subst *inlsubst) node(n *Node) *Node {
m.Ninit.Append(as) m.Ninit.Append(as)
} }
typechecklist(m.Ninit.Slice(), Etop) typecheckslice(m.Ninit.Slice(), Etop)
typecheck(&m, Etop) typecheck(&m, Etop)
// dump("Return after substitution", m); // dump("Return after substitution", m);
......
...@@ -392,7 +392,7 @@ func Main() { ...@@ -392,7 +392,7 @@ func Main() {
Curfn = xtop[i] Curfn = xtop[i]
decldepth = 1 decldepth = 1
saveerrors() saveerrors()
typechecklist(Curfn.Nbody.Slice(), Etop) typecheckslice(Curfn.Nbody.Slice(), Etop)
checkreturn(Curfn) checkreturn(Curfn)
if nerrors != 0 { if nerrors != 0 {
Curfn.Nbody.Set(nil) // type errors; do not compile Curfn.Nbody.Set(nil) // type errors; do not compile
......
...@@ -127,7 +127,7 @@ out: ...@@ -127,7 +127,7 @@ out:
} }
decldepth++ decldepth++
typechecklist(n.Nbody.Slice(), Etop) typecheckslice(n.Nbody.Slice(), Etop)
decldepth-- decldepth--
} }
...@@ -313,9 +313,9 @@ func walkrange(n *Node) { ...@@ -313,9 +313,9 @@ func walkrange(n *Node) {
} }
n.Op = OFOR n.Op = OFOR
typechecklist(init, Etop) typecheckslice(init, Etop)
n.Ninit.Append(init...) n.Ninit.Append(init...)
typechecklist(n.Left.Ninit.Slice(), Etop) typecheckslice(n.Left.Ninit.Slice(), Etop)
typecheck(&n.Left, Erv) typecheck(&n.Left, Erv)
typecheck(&n.Right, Etop) typecheck(&n.Right, Etop)
typecheckslice(body, Etop) typecheckslice(body, Etop)
...@@ -399,7 +399,7 @@ func memclrrange(n, v1, v2, a *Node) bool { ...@@ -399,7 +399,7 @@ func memclrrange(n, v1, v2, a *Node) bool {
n.Nbody.Append(v1) n.Nbody.Append(v1)
typecheck(&n.Left, Erv) typecheck(&n.Left, Erv)
typechecklist(n.Nbody.Slice(), Etop) typecheckslice(n.Nbody.Slice(), Etop)
walkstmt(&n) walkstmt(&n)
return true return true
} }
...@@ -12,7 +12,7 @@ func typecheckselect(sel *Node) { ...@@ -12,7 +12,7 @@ func typecheckselect(sel *Node) {
var def *Node var def *Node
lno := setlineno(sel) lno := setlineno(sel)
count := 0 count := 0
typechecklist(sel.Ninit.Slice(), Etop) typecheckslice(sel.Ninit.Slice(), Etop)
for _, n1 := range sel.List.Slice() { for _, n1 := range sel.List.Slice() {
count++ count++
ncase = n1 ncase = n1
...@@ -79,7 +79,7 @@ func typecheckselect(sel *Node) { ...@@ -79,7 +79,7 @@ func typecheckselect(sel *Node) {
} }
} }
typechecklist(ncase.Nbody.Slice(), Etop) typecheckslice(ncase.Nbody.Slice(), Etop)
} }
sel.Xoffset = int64(count) sel.Xoffset = int64(count)
......
...@@ -2009,7 +2009,7 @@ func genwrapper(rcvr *Type, method *Field, newnam *Sym, iface int) { ...@@ -2009,7 +2009,7 @@ func genwrapper(rcvr *Type, method *Field, newnam *Sym, iface int) {
fn.Func.Dupok = true fn.Func.Dupok = true
} }
typecheck(&fn, Etop) typecheck(&fn, Etop)
typechecklist(fn.Nbody.Slice(), Etop) typecheckslice(fn.Nbody.Slice(), Etop)
inlcalls(fn) inlcalls(fn)
escAnalyze([]*Node{fn}, false) escAnalyze([]*Node{fn}, false)
......
...@@ -58,7 +58,7 @@ type caseClause struct { ...@@ -58,7 +58,7 @@ type caseClause struct {
// typecheckswitch typechecks a switch statement. // typecheckswitch typechecks a switch statement.
func typecheckswitch(n *Node) { func typecheckswitch(n *Node) {
lno := lineno lno := lineno
typechecklist(n.Ninit.Slice(), Etop) typecheckslice(n.Ninit.Slice(), Etop)
var nilonly string var nilonly string
var top int var top int
...@@ -182,7 +182,7 @@ func typecheckswitch(n *Node) { ...@@ -182,7 +182,7 @@ func typecheckswitch(n *Node) {
} }
} }
typechecklist(ncase.Nbody.Slice(), Etop) typecheckslice(ncase.Nbody.Slice(), Etop)
} }
lineno = lno lineno = lno
......
...@@ -34,12 +34,6 @@ func resolve(n *Node) *Node { ...@@ -34,12 +34,6 @@ func resolve(n *Node) *Node {
return n return n
} }
func typechecklist(l []*Node, top int) {
for i := range l {
typecheck(&l[i], top)
}
}
func typecheckslice(l []*Node, top int) { func typecheckslice(l []*Node, top int) {
for i := range l { for i := range l {
typecheck(&l[i], top) typecheck(&l[i], top)
...@@ -1290,7 +1284,7 @@ OpSwitch: ...@@ -1290,7 +1284,7 @@ OpSwitch:
if n.List.Len() == 1 && !n.Isddd { if n.List.Len() == 1 && !n.Isddd {
typecheck(n.List.Addr(0), Erv|Efnstruct) typecheck(n.List.Addr(0), Erv|Efnstruct)
} else { } else {
typechecklist(n.List.Slice(), Erv) typecheckslice(n.List.Slice(), Erv)
} }
t := l.Type t := l.Type
if t == nil { if t == nil {
...@@ -1437,7 +1431,7 @@ OpSwitch: ...@@ -1437,7 +1431,7 @@ OpSwitch:
var r *Node var r *Node
var l *Node var l *Node
if n.List.Len() == 1 { if n.List.Len() == 1 {
typechecklist(n.List.Slice(), Efnstruct) typecheckslice(n.List.Slice(), Efnstruct)
if n.List.First().Op != OCALLFUNC && n.List.First().Op != OCALLMETH { if n.List.First().Op != OCALLFUNC && n.List.First().Op != OCALLMETH {
Yyerror("invalid operation: complex expects two arguments") Yyerror("invalid operation: complex expects two arguments")
n.Type = nil n.Type = nil
...@@ -1557,7 +1551,7 @@ OpSwitch: ...@@ -1557,7 +1551,7 @@ OpSwitch:
} }
ok |= Etop ok |= Etop
typechecklist(args.Slice(), Erv) typecheckslice(args.Slice(), Erv)
l := args.First() l := args.First()
r := args.Second() r := args.Second()
if l.Type != nil && l.Type.Etype != TMAP { if l.Type != nil && l.Type.Etype != TMAP {
...@@ -1581,7 +1575,7 @@ OpSwitch: ...@@ -1581,7 +1575,7 @@ OpSwitch:
if args.Len() == 1 && !n.Isddd { if args.Len() == 1 && !n.Isddd {
typecheck(args.Addr(0), Erv|Efnstruct) typecheck(args.Addr(0), Erv|Efnstruct)
} else { } else {
typechecklist(args.Slice(), Erv) typecheckslice(args.Slice(), Erv)
} }
t := args.First().Type t := args.First().Type
...@@ -1904,7 +1898,7 @@ OpSwitch: ...@@ -1904,7 +1898,7 @@ OpSwitch:
case OPRINT, OPRINTN: case OPRINT, OPRINTN:
ok |= Etop ok |= Etop
typechecklist(n.List.Slice(), Erv|Eindir) // Eindir: address does not escape typecheckslice(n.List.Slice(), Erv|Eindir) // Eindir: address does not escape
ls := n.List.Slice() ls := n.List.Slice()
for i1, n1 := range ls { for i1, n1 := range ls {
// Special case for print: int constant is int64, not int. // Special case for print: int constant is int64, not int.
...@@ -2047,7 +2041,7 @@ OpSwitch: ...@@ -2047,7 +2041,7 @@ OpSwitch:
case OFOR: case OFOR:
ok |= Etop ok |= Etop
typechecklist(n.Ninit.Slice(), Etop) typecheckslice(n.Ninit.Slice(), Etop)
decldepth++ decldepth++
typecheck(&n.Left, Erv) typecheck(&n.Left, Erv)
if n.Left != nil { if n.Left != nil {
...@@ -2057,13 +2051,13 @@ OpSwitch: ...@@ -2057,13 +2051,13 @@ OpSwitch:
} }
} }
typecheck(&n.Right, Etop) typecheck(&n.Right, Etop)
typechecklist(n.Nbody.Slice(), Etop) typecheckslice(n.Nbody.Slice(), Etop)
decldepth-- decldepth--
break OpSwitch break OpSwitch
case OIF: case OIF:
ok |= Etop ok |= Etop
typechecklist(n.Ninit.Slice(), Etop) typecheckslice(n.Ninit.Slice(), Etop)
typecheck(&n.Left, Erv) typecheck(&n.Left, Erv)
if n.Left != nil { if n.Left != nil {
t := n.Left.Type t := n.Left.Type
...@@ -2071,16 +2065,16 @@ OpSwitch: ...@@ -2071,16 +2065,16 @@ OpSwitch:
Yyerror("non-bool %v used as if condition", Nconv(n.Left, FmtLong)) Yyerror("non-bool %v used as if condition", Nconv(n.Left, FmtLong))
} }
} }
typechecklist(n.Nbody.Slice(), Etop) typecheckslice(n.Nbody.Slice(), Etop)
typechecklist(n.Rlist.Slice(), Etop) typecheckslice(n.Rlist.Slice(), Etop)
break OpSwitch break OpSwitch
case ORETURN: case ORETURN:
ok |= Etop ok |= Etop
if n.List.Len() == 1 { if n.List.Len() == 1 {
typechecklist(n.List.Slice(), Erv|Efnstruct) typecheckslice(n.List.Slice(), Erv|Efnstruct)
} else { } else {
typechecklist(n.List.Slice(), Erv) typecheckslice(n.List.Slice(), Erv)
} }
if Curfn == nil { if Curfn == nil {
Yyerror("return outside function") Yyerror("return outside function")
...@@ -2120,8 +2114,8 @@ OpSwitch: ...@@ -2120,8 +2114,8 @@ OpSwitch:
case OXCASE: case OXCASE:
ok |= Etop ok |= Etop
typechecklist(n.List.Slice(), Erv) typecheckslice(n.List.Slice(), Erv)
typechecklist(n.Nbody.Slice(), Etop) typecheckslice(n.Nbody.Slice(), Etop)
break OpSwitch break OpSwitch
case ODCLFUNC: case ODCLFUNC:
...@@ -3310,7 +3304,7 @@ func typecheckas2(n *Node) { ...@@ -3310,7 +3304,7 @@ func typecheckas2(n *Node) {
if cl > 1 && cr == 1 { if cl > 1 && cr == 1 {
typecheck(n.Rlist.Addr(0), Erv|Efnstruct) typecheck(n.Rlist.Addr(0), Erv|Efnstruct)
} else { } else {
typechecklist(n.Rlist.Slice(), Erv) typecheckslice(n.Rlist.Slice(), Erv)
} }
checkassignlist(n, n.List) checkassignlist(n, n.List)
......
...@@ -2022,7 +2022,7 @@ func walkprint(nn *Node, init *Nodes) *Node { ...@@ -2022,7 +2022,7 @@ func walkprint(nn *Node, init *Nodes) *Node {
calls = append(calls, mkcall("printunlock", nil, init)) calls = append(calls, mkcall("printunlock", nil, init))
typechecklist(calls, Etop) typecheckslice(calls, Etop)
walkexprlist(calls, init) walkexprlist(calls, init)
r = Nod(OEMPTY, nil, nil) r = Nod(OEMPTY, nil, nil)
...@@ -2890,7 +2890,7 @@ func appendslice(n *Node, init *Nodes) *Node { ...@@ -2890,7 +2890,7 @@ func appendslice(n *Node, init *Nodes) *Node {
l = append(ln.Slice(), nt) l = append(ln.Slice(), nt)
} }
typechecklist(l, Etop) typecheckslice(l, Etop)
walkstmtlist(l) walkstmtlist(l)
init.Append(l...) init.Append(l...)
return s return s
...@@ -2987,7 +2987,7 @@ func walkappend(n *Node, init *Nodes, dst *Node) *Node { ...@@ -2987,7 +2987,7 @@ func walkappend(n *Node, init *Nodes, dst *Node) *Node {
} }
} }
typechecklist(l, Etop) typecheckslice(l, Etop)
walkstmtlist(l) walkstmtlist(l)
init.Append(l...) init.Append(l...)
return ns return ns
...@@ -3053,7 +3053,7 @@ func copyany(n *Node, init *Nodes, runtimecall bool) *Node { ...@@ -3053,7 +3053,7 @@ func copyany(n *Node, init *Nodes, runtimecall bool) *Node {
nwid = Nod(OMUL, nwid, Nodintconst(nl.Type.Type.Width)) nwid = Nod(OMUL, nwid, Nodintconst(nl.Type.Type.Width))
l = append(l, mkcall1(fn, nil, init, nto, nfrm, nwid)) l = append(l, mkcall1(fn, nil, init, nto, nfrm, nwid))
typechecklist(l, Etop) typecheckslice(l, Etop)
walkstmtlist(l) walkstmtlist(l)
init.Append(l...) init.Append(l...)
return nlen return nlen
...@@ -4009,7 +4009,7 @@ func walkprintfunc(np **Node, init *Nodes) { ...@@ -4009,7 +4009,7 @@ func walkprintfunc(np **Node, init *Nodes) {
funcbody(fn) funcbody(fn)
typecheck(&fn, Etop) typecheck(&fn, Etop)
typechecklist(fn.Nbody.Slice(), Etop) typecheckslice(fn.Nbody.Slice(), Etop)
xtop = append(xtop, fn) xtop = append(xtop, fn)
Curfn = oldfn Curfn = oldfn
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment