Commit c8198344 authored by Russ Cox's avatar Russ Cox

cmd/internal/gc: fmt.Sprintf elimination and minor cleanup

Change-Id: Iaf5a7d25e6308b32c17a38afbbd46befa17aa3a4
Reviewed-on: https://go-review.googlesource.com/7629Reviewed-by: 's avatarRob Pike <r@golang.org>
parent d7f6d46c
......@@ -58,16 +58,8 @@ func (b *bulkBvec) next() Bvec {
/* difference */
func bvandnot(dst Bvec, src1 Bvec, src2 Bvec) {
var i int32
var w int32
if dst.n != src1.n || dst.n != src2.n {
Fatal("bvand: lengths %d, %d, and %d are not equal", dst.n, src1.n, src2.n)
}
i = 0
w = 0
for ; i < dst.n; i, w = i+WORDBITS, w+1 {
dst.b[w] = src1.b[w] &^ src2.b[w]
for i, x := range src1.b {
dst.b[i] = x &^ src2.b[i]
}
}
......@@ -152,11 +144,8 @@ func bvisempty(bv Bvec) bool {
}
func bvnot(bv Bvec) {
var i int32
var w int32
i = 0
w = 0
i := int32(0)
w := int32(0)
for ; i < bv.n; i, w = i+WORDBITS, w+1 {
bv.b[w] = ^bv.b[w]
}
......@@ -164,31 +153,15 @@ func bvnot(bv Bvec) {
/* union */
func bvor(dst Bvec, src1 Bvec, src2 Bvec) {
var i int32
var w int32
if dst.n != src1.n || dst.n != src2.n {
Fatal("bvor: lengths %d, %d, and %d are not equal", dst.n, src1.n, src2.n)
}
i = 0
w = 0
for ; i < dst.n; i, w = i+WORDBITS, w+1 {
dst.b[w] = src1.b[w] | src2.b[w]
for i, x := range src1.b {
dst.b[i] = x | src2.b[i]
}
}
/* intersection */
func bvand(dst Bvec, src1 Bvec, src2 Bvec) {
var i int32
var w int32
if dst.n != src1.n || dst.n != src2.n {
Fatal("bvor: lengths %d, %d, and %d are not equal", dst.n, src1.n, src2.n)
}
i = 0
w = 0
for ; i < dst.n; i, w = i+WORDBITS, w+1 {
dst.b[w] = src1.b[w] & src2.b[w]
for i, x := range src1.b {
dst.b[i] = x & src2.b[i]
}
}
......
......@@ -1470,14 +1470,17 @@ func funccompile(n *Node) {
}
func funcsym(s *Sym) *Sym {
p := fmt.Sprintf("%s·f", s.Name)
s1 := Pkglookup(p, s.Pkg)
if s.Fsym != nil {
return s.Fsym
}
s1 := Pkglookup(s.Name+"·f", s.Pkg)
if s1.Def == nil {
s1.Def = newname(s1)
s1.Def.Shortname = newname(s)
funcsyms = list(funcsyms, s1.Def)
}
s.Fsym = s1
return s1
}
......@@ -436,9 +436,6 @@ func esclist(e *EscState, l *NodeList, up *Node) {
}
func esc(e *EscState, n *Node, up *Node) {
var ll *NodeList
var lr *NodeList
if n == nil {
return
}
......@@ -457,7 +454,7 @@ func esc(e *EscState, n *Node, up *Node) {
// must happen before processing of switch body,
// so before recursion.
if n.Op == OSWITCH && n.Ntest != nil && n.Ntest.Op == OTYPESW {
for ll = n.List; ll != nil; ll = ll.Next { // cases
for ll := n.List; ll != nil; ll = ll.Next { // cases
// ll->n->nname is the variable per case
if ll.N.Nname != nil {
......@@ -522,7 +519,7 @@ func esc(e *EscState, n *Node, up *Node) {
case OSWITCH:
if n.Ntest != nil && n.Ntest.Op == OTYPESW {
for ll = n.List; ll != nil; ll = ll.Next { // cases
for ll := n.List; ll != nil; ll = ll.Next { // cases
// ntest->right is the argument of the .(type),
// ll->n->nname is the variable per case
......@@ -574,8 +571,8 @@ func esc(e *EscState, n *Node, up *Node) {
case OAS2: // x,y = a,b
if count(n.List) == count(n.Rlist) {
ll = n.List
lr = n.Rlist
ll := n.List
lr := n.Rlist
for ; ll != nil; ll, lr = ll.Next, lr.Next {
escassign(e, ll.N, lr.N)
}
......@@ -602,7 +599,7 @@ func esc(e *EscState, n *Node, up *Node) {
escassign(e, &e.theSink, n.Left.Left)
escassign(e, &e.theSink, n.Left.Right) // ODDDARG for call
for ll = n.Left.List; ll != nil; ll = ll.Next {
for ll := n.Left.List; ll != nil; ll = ll.Next {
escassign(e, &e.theSink, ll.N)
}
......@@ -613,8 +610,9 @@ func esc(e *EscState, n *Node, up *Node) {
// esccall already done on n->rlist->n. tie it's escretval to n->list
case OAS2FUNC: // x,y = f()
lr = n.Rlist.N.Escretval
lr := n.Rlist.N.Escretval
var ll *NodeList
for ll = n.List; lr != nil && ll != nil; lr, ll = lr.Next, ll.Next {
escassign(e, ll.N, lr.N)
}
......@@ -623,7 +621,7 @@ func esc(e *EscState, n *Node, up *Node) {
}
case ORETURN:
ll = n.List
ll := n.List
if count(n.List) == 1 && Curfn.Type.Outtuple > 1 {
// OAS2FUNC in disguise
// esccall already done on n->list->n
......@@ -631,7 +629,7 @@ func esc(e *EscState, n *Node, up *Node) {
ll = n.List.N.Escretval
}
for lr = Curfn.Dcl; lr != nil && ll != nil; lr = lr.Next {
for lr := Curfn.Dcl; lr != nil && ll != nil; lr = lr.Next {
if lr.N.Op != ONAME || lr.N.Class != PPARAMOUT {
continue
}
......@@ -649,7 +647,7 @@ func esc(e *EscState, n *Node, up *Node) {
case OAPPEND:
if !n.Isddd {
for ll = n.List.Next; ll != nil; ll = ll.Next {
for ll := n.List.Next; ll != nil; ll = ll.Next {
escassign(e, &e.theSink, ll.N) // lose track of assign to dereference
}
}
......@@ -666,19 +664,19 @@ func esc(e *EscState, n *Node, up *Node) {
n.Escloopdepth = e.loopdepth
// Values make it to memory, lose track.
for ll = n.List; ll != nil; ll = ll.Next {
for ll := n.List; ll != nil; ll = ll.Next {
escassign(e, &e.theSink, ll.N.Right)
}
} else {
// Link values to array.
for ll = n.List; ll != nil; ll = ll.Next {
for ll := n.List; ll != nil; ll = ll.Next {
escassign(e, n, ll.N.Right)
}
}
// Link values to struct.
case OSTRUCTLIT:
for ll = n.List; ll != nil; ll = ll.Next {
for ll := n.List; ll != nil; ll = ll.Next {
escassign(e, n, ll.N.Right)
}
......@@ -704,7 +702,7 @@ func esc(e *EscState, n *Node, up *Node) {
n.Escloopdepth = e.loopdepth
// Keys and values make it to memory, lose track.
for ll = n.List; ll != nil; ll = ll.Next {
for ll := n.List; ll != nil; ll = ll.Next {
escassign(e, &e.theSink, ll.N.Left)
escassign(e, &e.theSink, ll.N.Right)
}
......@@ -713,7 +711,7 @@ func esc(e *EscState, n *Node, up *Node) {
case OCLOSURE:
var a *Node
var v *Node
for ll = n.Cvars; ll != nil; ll = ll.Next {
for ll := n.Cvars; ll != nil; ll = ll.Next {
v = ll.N
if v.Op == OXXX { // unnamed out argument; see dcl.c:/^funcargs
continue
......@@ -953,9 +951,7 @@ func escassign(e *EscState, dst *Node, src *Node) {
}
func escassignfromtag(e *EscState, note *string, dsts *NodeList, src *Node) int {
var em int
em = parsetag(note)
em := parsetag(note)
if em == EscUnknown {
escassign(e, &e.theSink, src)
......@@ -992,8 +988,6 @@ func escassignfromtag(e *EscState, note *string, dsts *NodeList, src *Node) int
// different for methods vs plain functions and for imported vs
// this-package
func esccall(e *EscState, n *Node, up *Node) {
var ll *NodeList
var lr *NodeList
var fntype *Type
var fn *Node
......@@ -1017,7 +1011,7 @@ func esccall(e *EscState, n *Node, up *Node) {
fntype = n.Left.Type
}
ll = n.List
ll := n.List
if n.List != nil && n.List.Next == nil {
a := n.List.N
if a.Type.Etype == TSTRUCT && a.Type.Funarg != 0 { // f(g()).
......@@ -1033,7 +1027,7 @@ func esccall(e *EscState, n *Node, up *Node) {
}
// set up out list on this call node
for lr = fn.Ntype.Rlist; lr != nil; lr = lr.Next {
for lr := fn.Ntype.Rlist; lr != nil; lr = lr.Next {
n.Escretval = list(n.Escretval, lr.N.Left) // type.rlist -> dclfield -> ONAME (PPARAMOUT)
}
......@@ -1043,7 +1037,7 @@ func esccall(e *EscState, n *Node, up *Node) {
}
var src *Node
for lr = fn.Ntype.List; ll != nil && lr != nil; ll, lr = ll.Next, lr.Next {
for lr := fn.Ntype.List; ll != nil && lr != nil; ll, lr = ll.Next, lr.Next {
src = ll.N
if lr.N.Isddd && !n.Isddd {
// Introduce ODDDARG node to represent ... allocation.
......
This diff is collapsed.
......@@ -126,6 +126,7 @@ type Sym struct {
Lastlineno int32 // last declaration for diagnostic
Origpkg *Pkg // original package for . import
Lsym *obj.LSym
Fsym *Sym // funcsym
}
type Type struct {
......
......@@ -15,7 +15,7 @@ import (
func mpcmpfixflt(a *Mpint, b *Mpflt) int {
var c Mpflt
buf := fmt.Sprintf("%v", Bconv(a, 0))
buf := Bconv(a, 0)
mpatoflt(&c, buf)
return mpcmpfltflt(&c, b)
}
......@@ -23,7 +23,7 @@ func mpcmpfixflt(a *Mpint, b *Mpflt) int {
func mpcmpfltfix(a *Mpflt, b *Mpint) int {
var c Mpflt
buf := fmt.Sprintf("%v", Bconv(b, 0))
buf := Bconv(b, 0)
mpatoflt(&c, buf)
return mpcmpfltflt(a, &c)
}
......
......@@ -7,6 +7,7 @@ package gc
import (
"cmd/internal/obj"
"fmt"
"strconv"
)
/*
......@@ -155,16 +156,18 @@ func Linksym(s *Sym) *obj.LSym {
if s.Lsym != nil {
return s.Lsym
}
var name string
if isblanksym(s) {
s.Lsym = obj.Linklookup(Ctxt, "_", 0)
name = "_"
} else if s.Linkname != "" {
s.Lsym = obj.Linklookup(Ctxt, s.Linkname, 0)
name = s.Linkname
} else {
p := fmt.Sprintf("%s.%s", s.Pkg.Prefix, s.Name)
s.Lsym = obj.Linklookup(Ctxt, p, 0)
name = s.Pkg.Prefix + "." + s.Name
}
return s.Lsym
ls := obj.Linklookup(Ctxt, name, 0)
s.Lsym = ls
return ls
}
func duintxx(s *Sym, off int, v uint64, wid int) int {
......@@ -211,7 +214,7 @@ func stringsym(s string) *Sym {
// small strings get named by their contents,
// so that multiple modules using the same string
// can share it.
symname = fmt.Sprintf("%q", s)
symname = strconv.Quote(s)
pkg = gostringpkg
}
......
......@@ -477,7 +477,7 @@ func dimportpath(p *Pkg) {
dimportpath_gopkg.Name = "go"
}
nam := fmt.Sprintf("importpath.%s.", p.Prefix)
nam := "importpath." + p.Prefix + "."
n := Nod(ONAME, nil, nil)
n.Sym = Pkglookup(nam, dimportpath_gopkg)
......@@ -808,7 +808,7 @@ func dcommontype(s *Sym, ot int, t *Type) int {
ot = duintptr(s, ot, 0)
}
p := fmt.Sprintf("%v", Tconv(t, obj.FmtLeft|obj.FmtUnsigned))
p := Tconv(t, obj.FmtLeft|obj.FmtUnsigned)
//print("dcommontype: %s\n", p);
ot = dgostringptr(s, ot, p) // string
......@@ -825,19 +825,11 @@ func dcommontype(s *Sym, ot int, t *Type) int {
}
func typesym(t *Type) *Sym {
p := fmt.Sprintf("%v", Tconv(t, obj.FmtLeft))
s := Pkglookup(p, typepkg)
//print("typesym: %s -> %+S\n", p, s);
return s
return Pkglookup(Tconv(t, obj.FmtLeft), typepkg)
}
func tracksym(t *Type) *Sym {
p := fmt.Sprintf("%v.%s", Tconv(t.Outer, obj.FmtLeft), t.Sym.Name)
s := Pkglookup(p, trackpkg)
return s
return Pkglookup(Tconv(t.Outer, obj.FmtLeft)+"."+t.Sym.Name, trackpkg)
}
func typelinksym(t *Type) *Sym {
......@@ -849,7 +841,7 @@ func typelinksym(t *Type) *Sym {
// disambiguate. The names are a little long but they are
// discarded by the linker and do not end up in the symbol
// table of the final binary.
p := fmt.Sprintf("%v/%v", Tconv(t, obj.FmtLeft|obj.FmtUnsigned), Tconv(t, obj.FmtLeft))
p := Tconv(t, obj.FmtLeft|obj.FmtUnsigned) + "/" + Tconv(t, obj.FmtLeft)
s := Pkglookup(p, typelinkpkg)
......@@ -859,7 +851,7 @@ func typelinksym(t *Type) *Sym {
}
func typesymprefix(prefix string, t *Type) *Sym {
p := fmt.Sprintf("%s.%v", prefix, Tconv(t, obj.FmtLeft))
p := prefix + "." + Tconv(t, obj.FmtLeft)
s := Pkglookup(p, typepkg)
//print("algsym: %s -> %+S\n", p, s);
......@@ -900,7 +892,7 @@ func typename(t *Type) *Node {
}
func weaktypesym(t *Type) *Sym {
p := fmt.Sprintf("%v", Tconv(t, obj.FmtLeft))
p := Tconv(t, obj.FmtLeft)
s := Pkglookup(p, weaktypepkg)
//print("weaktypesym: %s -> %+S\n", p, s);
......@@ -962,9 +954,6 @@ func isreflexive(t *Type) bool {
}
func dtypesym(t *Type) *Sym {
var n int
var t1 *Type
// Replace byte, rune aliases with real type.
// They've been separate internally to make error messages
// better, but we have to merge them in the reflect tables.
......@@ -1048,16 +1037,16 @@ ok:
ot = duintptr(s, ot, uint64(t.Chan))
case TFUNC:
for t1 = getthisx(t).Type; t1 != nil; t1 = t1.Down {
for t1 := getthisx(t).Type; t1 != nil; t1 = t1.Down {
dtypesym(t1.Type)
}
isddd := false
for t1 = getinargx(t).Type; t1 != nil; t1 = t1.Down {
for t1 := getinargx(t).Type; t1 != nil; t1 = t1.Down {
isddd = t1.Isddd
dtypesym(t1.Type)
}
for t1 = getoutargx(t).Type; t1 != nil; t1 = t1.Down {
for t1 := getoutargx(t).Type; t1 != nil; t1 = t1.Down {
dtypesym(t1.Type)
}
......@@ -1069,7 +1058,7 @@ ok:
ot = int(Rnd(int64(ot), int64(Widthptr)))
ot = dsymptr(s, ot, s, ot+2*(Widthptr+2*Widthint))
n = t.Thistuple + t.Intuple
n := t.Thistuple + t.Intuple
ot = duintxx(s, ot, uint64(n), Widthint)
ot = duintxx(s, ot, uint64(n), Widthint)
ot = dsymptr(s, ot, s, ot+1*(Widthptr+2*Widthint)+n*Widthptr)
......@@ -1077,22 +1066,22 @@ ok:
ot = duintxx(s, ot, uint64(t.Outtuple), Widthint)
// slice data
for t1 = getthisx(t).Type; t1 != nil; t1 = t1.Down {
for t1 := getthisx(t).Type; t1 != nil; t1 = t1.Down {
ot = dsymptr(s, ot, dtypesym(t1.Type), 0)
n++
}
for t1 = getinargx(t).Type; t1 != nil; t1 = t1.Down {
for t1 := getinargx(t).Type; t1 != nil; t1 = t1.Down {
ot = dsymptr(s, ot, dtypesym(t1.Type), 0)
n++
}
for t1 = getoutargx(t).Type; t1 != nil; t1 = t1.Down {
for t1 := getoutargx(t).Type; t1 != nil; t1 = t1.Down {
ot = dsymptr(s, ot, dtypesym(t1.Type), 0)
n++
}
case TINTER:
m := imethods(t)
n = 0
n := 0
for a := m; a != nil; a = a.link {
dtypesym(a.type_)
n++
......@@ -1164,9 +1153,9 @@ ok:
// ../../runtime/type.go:/StructType
// for security, only the exported fields.
case TSTRUCT:
n = 0
n := 0
for t1 = t.Type; t1 != nil; t1 = t1.Down {
for t1 := t.Type; t1 != nil; t1 = t1.Down {
dtypesym(t1.Type)
n++
}
......@@ -1176,7 +1165,7 @@ ok:
ot = dsymptr(s, ot, s, ot+Widthptr+2*Widthint)
ot = duintxx(s, ot, uint64(n), Widthint)
ot = duintxx(s, ot, uint64(n), Widthint)
for t1 = t.Type; t1 != nil; t1 = t1.Down {
for t1 := t.Type; t1 != nil; t1 = t1.Down {
// ../../runtime/type.go:/structField
if t1.Sym != nil && t1.Embedded == 0 {
ot = dgostringptr(s, ot, t1.Sym.Name)
......@@ -1479,11 +1468,9 @@ func proggenskip(g *ProgGen, off int64, v int64) {
// Emit insArray instruction.
func proggenarray(g *ProgGen, len int64) {
var i int32
proggendataflush(g)
proggenemit(g, obj.InsArray)
for i = 0; i < int32(Widthptr); i, len = i+1, len>>8 {
for i := int32(0); i < int32(Widthptr); i, len = i+1, len>>8 {
proggenemit(g, uint8(len))
}
}
......
......@@ -243,8 +243,7 @@ func mkvar(f *Flow, a *obj.Addr) Bits {
}
}
var node *Node
node, _ = a.Node.(*Node)
node, _ := a.Node.(*Node)
if node == nil || node.Op != ONAME || node.Orig == nil {
return zbits
}
......
......@@ -291,7 +291,9 @@ func LookupBytes(name []byte) *Sym {
var initSyms []*Sym
var nopkg = new(Pkg)
var nopkg = &Pkg{
Syms: make(map[string]*Sym),
}
func (pkg *Pkg) Lookup(name string) *Sym {
if pkg == nil {
......@@ -306,12 +308,9 @@ func (pkg *Pkg) Lookup(name string) *Sym {
Pkg: pkg,
Lexical: LNAME,
}
if s.Name == "init" {
if name == "init" {
initSyms = append(initSyms, s)
}
if pkg.Syms == nil {
pkg.Syms = make(map[string]*Sym)
}
pkg.Syms[name] = s
return s
}
......@@ -1028,16 +1027,13 @@ func eqtype1(t1 *Type, t2 *Type, assumed_equal *TypePairList) bool {
t1 = t1.Type
t2 = t2.Type
for ; t1 != nil && t2 != nil; t1, t2 = t1.Down, t2.Down {
var ta *Type
var tb *Type
if t1.Etype != TSTRUCT || t2.Etype != TSTRUCT {
Fatal("func missing struct: %v %v", Tconv(t1, 0), Tconv(t2, 0))
}
// Loop over fields in structs, ignoring argument names.
ta = t1.Type
tb = t2.Type
ta := t1.Type
tb := t2.Type
for ; ta != nil && tb != nil; ta, tb = ta.Down, tb.Down {
if ta.Etype != TFIELD || tb.Etype != TFIELD {
Fatal("func struct missing field: %v %v", Tconv(ta, 0), Tconv(tb, 0))
......@@ -1320,8 +1316,12 @@ func convertop(src *Type, dst *Type, why *string) int {
return 0
}
// Convert node n for assignment to type t.
func assignconv(n *Node, t *Type, context string) *Node {
return assignconvfn(n, t, func() string { return context })
}
// Convert node n for assignment to type t.
func assignconvfn(n *Node, t *Type, context func() string) *Node {
if n == nil || n.Type == nil || n.Type.Broke != 0 {
return n
}
......@@ -1357,7 +1357,7 @@ func assignconv(n *Node, t *Type, context string) *Node {
var why string
op := assignop(n.Type, t, &why)
if op == 0 {
Yyerror("cannot use %v as type %v in %s%s", Nconv(n, obj.FmtLong), Tconv(t, 0), context, why)
Yyerror("cannot use %v as type %v in %s%s", Nconv(n, obj.FmtLong), Tconv(t, 0), context(), why)
op = OCONV
}
......@@ -1570,10 +1570,10 @@ func typehash(t *Type) uint32 {
// hide method receiver from Tpretty
t.Thistuple = 0
p = fmt.Sprintf("%v", Tconv(t, obj.FmtLeft|obj.FmtUnsigned))
p = Tconv(t, obj.FmtLeft|obj.FmtUnsigned)
t.Thistuple = 1
} else {
p = fmt.Sprintf("%v", Tconv(t, obj.FmtLeft|obj.FmtUnsigned))
p = Tconv(t, obj.FmtLeft|obj.FmtUnsigned)
}
//print("typehash: %s\n", p);
......@@ -3457,6 +3457,7 @@ func mkpkg(path string) *Pkg {
p := new(Pkg)
p.Path = path
p.Prefix = pathtoprefix(path)
p.Syms = make(map[string]*Sym)
pkgMap[path] = p
pkgs = append(pkgs, p)
return p
......
......@@ -1362,9 +1362,7 @@ OpSwitch:
}
}
descbuf := fmt.Sprintf("argument to %v", Nconv(n.Left, 0))
desc := descbuf
typecheckaste(OCALL, n.Left, n.Isddd, getinargx(t), n.List, desc)
typecheckaste(OCALL, n.Left, n.Isddd, getinargx(t), n.List, func() string { return fmt.Sprintf("argument to %v", Nconv(n.Left, 0)) })
ok |= Etop
if t.Outtuple == 0 {
break OpSwitch
......@@ -2127,7 +2125,7 @@ OpSwitch:
if Curfn.Type.Outnamed != 0 && n.List == nil {
break OpSwitch
}
typecheckaste(ORETURN, nil, false, getoutargx(Curfn.Type), n.List, "return argument")
typecheckaste(ORETURN, nil, false, getoutargx(Curfn.Type), n.List, func() string { return "return argument" })
break OpSwitch
case ORETJMP:
......@@ -2604,7 +2602,7 @@ func downcount(t *Type) int {
/*
* typecheck assignment: type list = expression list
*/
func typecheckaste(op int, call *Node, isddd bool, tstruct *Type, nl *NodeList, desc string) {
func typecheckaste(op int, call *Node, isddd bool, tstruct *Type, nl *NodeList, desc func() string) {
var t *Type
var n *Node
var n1 int
......@@ -2641,7 +2639,7 @@ func typecheckaste(op int, call *Node, isddd bool, tstruct *Type, nl *NodeList,
if call != nil {
Yyerror("cannot use %v as type %v in argument to %v%s", Tconv(tn.Type, 0), Tconv(tl.Type.Type, 0), Nconv(call, 0), why)
} else {
Yyerror("cannot use %v as type %v in %s%s", Tconv(tn.Type, 0), Tconv(tl.Type.Type, 0), desc, why)
Yyerror("cannot use %v as type %v in %s%s", Tconv(tn.Type, 0), Tconv(tl.Type.Type, 0), desc(), why)
}
}
}
......@@ -2656,7 +2654,7 @@ func typecheckaste(op int, call *Node, isddd bool, tstruct *Type, nl *NodeList,
if call != nil {
Yyerror("cannot use %v as type %v in argument to %v%s", Tconv(tn.Type, 0), Tconv(tl.Type, 0), Nconv(call, 0), why)
} else {
Yyerror("cannot use %v as type %v in %s%s", Tconv(tn.Type, 0), Tconv(tl.Type, 0), desc, why)
Yyerror("cannot use %v as type %v in %s%s", Tconv(tn.Type, 0), Tconv(tl.Type, 0), desc(), why)
}
}
......@@ -2708,7 +2706,7 @@ func typecheckaste(op int, call *Node, isddd bool, tstruct *Type, nl *NodeList,
n = nl.N
setlineno(n)
if n.Type != nil {
nl.N = assignconv(n, t, desc)
nl.N = assignconvfn(n, t, desc)
}
goto out
}
......@@ -2717,7 +2715,7 @@ func typecheckaste(op int, call *Node, isddd bool, tstruct *Type, nl *NodeList,
n = nl.N
setlineno(nl.N)
if n.Type != nil {
nl.N = assignconv(n, t.Type, desc)
nl.N = assignconvfn(n, t.Type, desc)
}
}
......@@ -2730,7 +2728,7 @@ func typecheckaste(op int, call *Node, isddd bool, tstruct *Type, nl *NodeList,
n = nl.N
setlineno(n)
if n.Type != nil {
nl.N = assignconv(n, t, desc)
nl.N = assignconvfn(n, t, desc)
}
nl = nl.Next
}
......@@ -3395,10 +3393,7 @@ func checkassignto(src *Type, dst *Node) {
}
func typecheckas2(n *Node) {
var ll *NodeList
var lr *NodeList
for ll = n.List; ll != nil; ll = ll.Next {
for ll := n.List; ll != nil; ll = ll.Next {
// delicate little dance.
ll.N = resolve(ll.N)
......@@ -3420,8 +3415,8 @@ func typecheckas2(n *Node) {
var r *Node
if cl == cr {
// easy
ll = n.List
lr = n.Rlist
ll := n.List
lr := n.Rlist
for ; ll != nil; ll, lr = ll.Next, lr.Next {
if ll.N.Type != nil && lr.N.Type != nil {
lr.N = assignconv(lr.N, ll.N.Type, "assignment")
......@@ -3457,7 +3452,7 @@ func typecheckas2(n *Node) {
n.Op = OAS2FUNC
var s Iter
t := Structfirst(&s, &r.Type)
for ll = n.List; ll != nil; ll = ll.Next {
for ll := n.List; ll != nil; ll = ll.Next {
if t.Type != nil && ll.N.Type != nil {
checkassignto(t.Type, ll.N)
}
......@@ -3516,7 +3511,7 @@ mismatch:
out:
n.Typecheck = 1
for ll = n.List; ll != nil; ll = ll.Next {
for ll := n.List; ll != nil; ll = ll.Next {
if ll.N.Typecheck == 0 {
typecheck(&ll.N, Erv|Easgn)
}
......
......@@ -948,7 +948,7 @@ func walkexpr(np **Node, init **NodeList) {
ll = list(ll, typename(n.Type))
}
if !Isinter(n.Left.Type) && !isnilinter(n.Type) {
sym := Pkglookup(fmt.Sprintf("%v.%v", Tconv(n.Left.Type, obj.FmtLeft), Tconv(n.Type, obj.FmtLeft)), itabpkg)
sym := Pkglookup(Tconv(n.Left.Type, obj.FmtLeft)+"."+Tconv(n.Type, obj.FmtLeft), itabpkg)
if sym.Def == nil {
l := Nod(ONAME, nil, nil)
l.Sym = sym
......@@ -1631,9 +1631,6 @@ func ascompatee1(op int, l *Node, r *Node, init **NodeList) *Node {
}
func ascompatee(op int, nl *NodeList, nr *NodeList, init **NodeList) *NodeList {
var ll *NodeList
var lr *NodeList
/*
* check assign expression list to
* a expression list. called in
......@@ -1641,16 +1638,16 @@ func ascompatee(op int, nl *NodeList, nr *NodeList, init **NodeList) *NodeList {
*/
// ensure order of evaluation for function calls
for ll = nl; ll != nil; ll = ll.Next {
for ll := nl; ll != nil; ll = ll.Next {
ll.N = safeexpr(ll.N, init)
}
for lr = nr; lr != nil; lr = lr.Next {
for lr := nr; lr != nil; lr = lr.Next {
lr.N = safeexpr(lr.N, init)
}
var nn *NodeList
ll = nl
lr = nr
ll := nl
lr := nr
for ; ll != nil && lr != nil; ll, lr = ll.Next, lr.Next {
// Do not generate 'x = x' during return. See issue 4014.
if op == ORETURN && ll.N == lr.N {
......@@ -1798,7 +1795,7 @@ func dumptypes(nl **Type, what string) string {
} else {
fmt_ += ", "
}
fmt_ += fmt.Sprintf("%v", Tconv(l, 0))
fmt_ += Tconv(l, 0)
}
if first != 0 {
......@@ -1820,7 +1817,7 @@ func dumpnodetypes(l *NodeList, what string) string {
} else {
fmt_ += ", "
}
fmt_ += fmt.Sprintf("%v", Tconv(r.Type, 0))
fmt_ += Tconv(r.Type, 0)
}
if first != 0 {
......
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