Commit 63142027 authored by Matthew Dempsky's avatar Matthew Dempsky

cmd: collapse internal/obj/fmt.go into compile/internal/gc/fmt.go

The obj.Fmt* values are only used by gc/fmt.go, so just move them
there. Also, add comments documenting the correspondance between
FmtFoo names and their flag characters to make understanding the
existing documentation slightly less confusing.

While here, add a new FmtFlag named type to represent these values.

Change-Id: I9631214b892557d094823f1ac575d0c43a84007b
Reviewed-on: https://go-review.googlesource.com/20717
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 8e7072ca
......@@ -40,7 +40,7 @@ func defframe(ptxt *obj.Prog) {
gc.Fatalf("needzero class %d", n.Class)
}
if n.Type.Width%int64(gc.Widthptr) != 0 || n.Xoffset%int64(gc.Widthptr) != 0 || n.Type.Width == 0 {
gc.Fatalf("var %v has size %d offset %d", gc.Nconv(n, obj.FmtLong), int(n.Type.Width), int(n.Xoffset))
gc.Fatalf("var %v has size %d offset %d", gc.Nconv(n, gc.FmtLong), int(n.Type.Width), int(n.Xoffset))
}
if lo != hi && n.Xoffset+n.Type.Width >= lo-int64(2*gc.Widthreg) {
......
......@@ -178,7 +178,7 @@ func bignodes() {
*/
func gmove(f *gc.Node, t *gc.Node) {
if gc.Debug['M'] != 0 {
fmt.Printf("gmove %v -> %v\n", gc.Nconv(f, obj.FmtLong), gc.Nconv(t, obj.FmtLong))
fmt.Printf("gmove %v -> %v\n", gc.Nconv(f, gc.FmtLong), gc.Nconv(t, gc.FmtLong))
}
ft := gc.Simsimtype(f.Type)
......@@ -229,7 +229,7 @@ func gmove(f *gc.Node, t *gc.Node) {
switch uint32(ft)<<16 | uint32(tt) {
default:
gc.Fatalf("gmove %v -> %v", gc.Tconv(f.Type, obj.FmtLong), gc.Tconv(t.Type, obj.FmtLong))
gc.Fatalf("gmove %v -> %v", gc.Tconv(f.Type, gc.FmtLong), gc.Tconv(t.Type, gc.FmtLong))
/*
* integer copy and truncate
......
......@@ -34,7 +34,7 @@ func defframe(ptxt *obj.Prog) {
gc.Fatalf("needzero class %d", n.Class)
}
if n.Type.Width%int64(gc.Widthptr) != 0 || n.Xoffset%int64(gc.Widthptr) != 0 || n.Type.Width == 0 {
gc.Fatalf("var %v has size %d offset %d", gc.Nconv(n, obj.FmtLong), int(n.Type.Width), int(n.Xoffset))
gc.Fatalf("var %v has size %d offset %d", gc.Nconv(n, gc.FmtLong), int(n.Type.Width), int(n.Xoffset))
}
if lo != hi && n.Xoffset+n.Type.Width >= lo-int64(2*gc.Widthptr) {
// merge with range we already have
......
......@@ -43,7 +43,7 @@ func defframe(ptxt *obj.Prog) {
gc.Fatalf("needzero class %d", n.Class)
}
if n.Type.Width%int64(gc.Widthptr) != 0 || n.Xoffset%int64(gc.Widthptr) != 0 || n.Type.Width == 0 {
gc.Fatalf("var %v has size %d offset %d", gc.Nconv(n, obj.FmtLong), int(n.Type.Width), int(n.Xoffset))
gc.Fatalf("var %v has size %d offset %d", gc.Nconv(n, gc.FmtLong), int(n.Type.Width), int(n.Xoffset))
}
if lo != hi && n.Xoffset+n.Type.Width >= lo-int64(2*gc.Widthreg) {
......
......@@ -137,7 +137,7 @@ func ginscmp(op gc.Op, t *gc.Type, n1, n2 *gc.Node, likely int) *obj.Prog {
*/
func gmove(f *gc.Node, t *gc.Node) {
if gc.Debug['M'] != 0 {
fmt.Printf("gmove %v -> %v\n", gc.Nconv(f, obj.FmtLong), gc.Nconv(t, obj.FmtLong))
fmt.Printf("gmove %v -> %v\n", gc.Nconv(f, gc.FmtLong), gc.Nconv(t, gc.FmtLong))
}
ft := int(gc.Simsimtype(f.Type))
......@@ -214,7 +214,7 @@ func gmove(f *gc.Node, t *gc.Node) {
switch uint32(ft)<<16 | uint32(tt) {
default:
gc.Fatalf("gmove %v -> %v", gc.Tconv(f.Type, obj.FmtLong), gc.Tconv(t.Type, obj.FmtLong))
gc.Fatalf("gmove %v -> %v", gc.Tconv(f.Type, gc.FmtLong), gc.Tconv(t.Type, gc.FmtLong))
/*
* integer copy and truncate
......
......@@ -4,8 +4,6 @@
package gc
import "cmd/internal/obj"
// machine size and rounding alignment is dictated around
// the size of a pointer, set in betypeinit (see ../amd64/galign.go).
var defercalc int
......@@ -74,7 +72,7 @@ func widstruct(errtype *Type, t *Type, o int64, flag int) int64 {
}
o += w
if o >= Thearch.MAXWIDTH {
Yyerror("type %v too large", Tconv(errtype, obj.FmtLong))
Yyerror("type %v too large", Tconv(errtype, FmtLong))
o = 8 // small but nonzero
}
}
......@@ -248,7 +246,7 @@ func dowidth(t *Type) {
if t.Type.Width != 0 {
cap := (uint64(Thearch.MAXWIDTH) - 1) / uint64(t.Type.Width)
if uint64(t.Bound) > cap {
Yyerror("type %v larger than address space", Tconv(t, obj.FmtLong))
Yyerror("type %v larger than address space", Tconv(t, FmtLong))
}
}
......
......@@ -336,7 +336,7 @@ func Export(out *obj.Biobuf, trace bool) int {
}
for _, f := range p.inlined {
if p.trace {
p.tracef("{ %s }\n", Hconv(f.Inl, obj.FmtSharp))
p.tracef("{ %s }\n", Hconv(f.Inl, FmtSharp))
}
p.nodeList(f.Inl)
if p.trace {
......
......@@ -361,7 +361,7 @@ func cgen_wb(n, res *Node, wb bool) {
default:
Dump("cgen", n)
Dump("cgen-res", res)
Fatalf("cgen: unknown op %v", Nconv(n, obj.FmtShort|obj.FmtSign))
Fatalf("cgen: unknown op %v", Nconv(n, FmtShort|FmtSign))
case OOROR, OANDAND,
OEQ, ONE,
......@@ -592,7 +592,7 @@ func cgen_wb(n, res *Node, wb bool) {
break
}
Fatalf("cgen: OLEN: unknown type %v", Tconv(nl.Type, obj.FmtLong))
Fatalf("cgen: OLEN: unknown type %v", Tconv(nl.Type, FmtLong))
case OCAP:
if Istype(nl.Type, TCHAN) {
......@@ -630,7 +630,7 @@ func cgen_wb(n, res *Node, wb bool) {
break
}
Fatalf("cgen: OCAP: unknown type %v", Tconv(nl.Type, obj.FmtLong))
Fatalf("cgen: OCAP: unknown type %v", Tconv(nl.Type, FmtLong))
case OADDR:
if n.Bounded { // let race detector avoid nil checks
......@@ -1541,7 +1541,7 @@ func Agen(n *Node, res *Node) {
switch n.Op {
default:
Fatalf("agen: unknown op %v", Nconv(n, obj.FmtShort|obj.FmtSign))
Fatalf("agen: unknown op %v", Nconv(n, FmtShort|FmtSign))
case OCALLMETH:
cgen_callmeth(n, 0)
......@@ -1856,7 +1856,7 @@ func bgenx(n, res *Node, wantTrue bool, likely int, to *obj.Prog) {
case OLITERAL:
// n is a constant.
if !Isconst(n, CTBOOL) {
Fatalf("bgen: non-bool const %v\n", Nconv(n, obj.FmtLong))
Fatalf("bgen: non-bool const %v\n", Nconv(n, FmtLong))
}
if genval {
Cgen(Nodbool(wantTrue == n.Val().U.(bool)), res)
......
......@@ -5,7 +5,6 @@
package gc
import (
"cmd/internal/obj"
"fmt"
)
......@@ -80,7 +79,7 @@ func typecheckclosure(func_ *Node, top int) {
if !n.Name.Captured {
n.Name.Captured = true
if n.Name.Decldepth == 0 {
Fatalf("typecheckclosure: var %v does not have decldepth assigned", Nconv(n, obj.FmtShort))
Fatalf("typecheckclosure: var %v does not have decldepth assigned", Nconv(n, FmtShort))
}
// Ignore assignments to the variable in straightline code
......@@ -165,7 +164,7 @@ func closurename(n *Node) *Sym {
n.Func.Outerfunc.Func.Closgen++
gen = n.Func.Outerfunc.Func.Closgen
} else {
Fatalf("closurename called for %v", Nconv(n, obj.FmtShort))
Fatalf("closurename called for %v", Nconv(n, FmtShort))
}
n.Sym = Lookupf("%s.%s%d", outer, prefix, gen)
return n.Sym
......@@ -487,9 +486,9 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node {
rcvrtype := fn.Left.Type
if exportname(meth.Sym.Name) {
p = fmt.Sprintf("(%v).%s-fm", Tconv(rcvrtype, obj.FmtLeft|obj.FmtShort), meth.Sym.Name)
p = fmt.Sprintf("(%v).%s-fm", Tconv(rcvrtype, FmtLeft|FmtShort), meth.Sym.Name)
} else {
p = fmt.Sprintf("(%v).(%v)-fm", Tconv(rcvrtype, obj.FmtLeft|obj.FmtShort), Sconv(meth.Sym, obj.FmtLeft))
p = fmt.Sprintf("(%v).(%v)-fm", Tconv(rcvrtype, FmtLeft|FmtShort), Sconv(meth.Sym, FmtLeft))
}
basetype := rcvrtype
if Isptr[rcvrtype.Etype] {
......
......@@ -362,7 +362,7 @@ func toflt(v Val) Val {
f := newMpflt()
mpmovefltflt(f, &v.U.(*Mpcplx).Real)
if mpcmpfltc(&v.U.(*Mpcplx).Imag, 0) != 0 {
Yyerror("constant %v%vi truncated to real", Fconv(&v.U.(*Mpcplx).Real, obj.FmtSharp), Fconv(&v.U.(*Mpcplx).Imag, obj.FmtSharp|obj.FmtSign))
Yyerror("constant %v%vi truncated to real", Fconv(&v.U.(*Mpcplx).Real, FmtSharp), Fconv(&v.U.(*Mpcplx).Imag, FmtSharp|FmtSign))
}
v.U = f
}
......@@ -385,17 +385,17 @@ func toint(v Val) Val {
if f.Val.IsInt() {
msg = "constant %v overflows integer"
}
Yyerror(msg, Fconv(f, obj.FmtSharp))
Yyerror(msg, Fconv(f, FmtSharp))
}
v.U = i
case CTCPLX:
i := new(Mpint)
if mpmovefltfix(i, &v.U.(*Mpcplx).Real) < 0 {
Yyerror("constant %v%vi truncated to integer", Fconv(&v.U.(*Mpcplx).Real, obj.FmtSharp), Fconv(&v.U.(*Mpcplx).Imag, obj.FmtSharp|obj.FmtSign))
Yyerror("constant %v%vi truncated to integer", Fconv(&v.U.(*Mpcplx).Real, FmtSharp), Fconv(&v.U.(*Mpcplx).Imag, FmtSharp|FmtSign))
}
if mpcmpfltc(&v.U.(*Mpcplx).Imag, 0) != 0 {
Yyerror("constant %v%vi truncated to real", Fconv(&v.U.(*Mpcplx).Real, obj.FmtSharp), Fconv(&v.U.(*Mpcplx).Imag, obj.FmtSharp|obj.FmtSign))
Yyerror("constant %v%vi truncated to real", Fconv(&v.U.(*Mpcplx).Real, FmtSharp), Fconv(&v.U.(*Mpcplx).Imag, FmtSharp|FmtSign))
}
v.U = i
}
......@@ -1280,7 +1280,7 @@ func defaultlit(np **Node, t *Type) {
Yyerror("defaultlit: unknown literal: %v", n)
case CTxxx:
Fatalf("defaultlit: idealkind is CTxxx: %v", Nconv(n, obj.FmtSign))
Fatalf("defaultlit: idealkind is CTxxx: %v", Nconv(n, FmtSign))
case CTBOOL:
t1 := Types[TBOOL]
......@@ -1487,7 +1487,7 @@ func (n *Node) Convconst(con *Node, t *Type) {
var i int64
switch n.Val().Ctype() {
default:
Fatalf("convconst ctype=%d %v", n.Val().Ctype(), Tconv(t, obj.FmtLong))
Fatalf("convconst ctype=%d %v", n.Val().Ctype(), Tconv(t, FmtLong))
case CTINT, CTRUNE:
i = Mpgetfix(n.Val().U.(*Mpint))
......@@ -1524,7 +1524,7 @@ func (n *Node) Convconst(con *Node, t *Type) {
return
}
Fatalf("convconst %v constant", Tconv(t, obj.FmtLong))
Fatalf("convconst %v constant", Tconv(t, FmtLong))
}
// complex multiply v *= rv
......
......@@ -1221,15 +1221,15 @@ func methodsym(nsym *Sym, t0 *Type, iface int) *Sym {
if (spkg == nil || nsym.Pkg != spkg) && !exportname(nsym.Name) {
if t0.Sym == nil && Isptr[t0.Etype] {
p = fmt.Sprintf("(%v).%s.%s%s", Tconv(t0, obj.FmtLeft|obj.FmtShort), nsym.Pkg.Prefix, nsym.Name, suffix)
p = fmt.Sprintf("(%v).%s.%s%s", Tconv(t0, FmtLeft|FmtShort), nsym.Pkg.Prefix, nsym.Name, suffix)
} else {
p = fmt.Sprintf("%v.%s.%s%s", Tconv(t0, obj.FmtLeft|obj.FmtShort), nsym.Pkg.Prefix, nsym.Name, suffix)
p = fmt.Sprintf("%v.%s.%s%s", Tconv(t0, FmtLeft|FmtShort), nsym.Pkg.Prefix, nsym.Name, suffix)
}
} else {
if t0.Sym == nil && Isptr[t0.Etype] {
p = fmt.Sprintf("(%v).%s%s", Tconv(t0, obj.FmtLeft|obj.FmtShort), nsym.Name, suffix)
p = fmt.Sprintf("(%v).%s%s", Tconv(t0, FmtLeft|FmtShort), nsym.Name, suffix)
} else {
p = fmt.Sprintf("%v.%s%s", Tconv(t0, obj.FmtLeft|obj.FmtShort), nsym.Name, suffix)
p = fmt.Sprintf("%v.%s%s", Tconv(t0, FmtLeft|FmtShort), nsym.Name, suffix)
}
}
......@@ -1339,7 +1339,7 @@ func addmethod(msym *Sym, t *Type, tpkg *Pkg, local, nointerface bool) {
// Should have picked off all the reasons above,
// but just in case, fall back to generic error.
Yyerror("invalid receiver type %v (%v / %v)", pa, Tconv(pa, obj.FmtLong), Tconv(t, obj.FmtLong))
Yyerror("invalid receiver type %v (%v / %v)", pa, Tconv(pa, FmtLong), Tconv(t, FmtLong))
return
}
......@@ -1383,7 +1383,7 @@ func addmethod(msym *Sym, t *Type, tpkg *Pkg, local, nointerface bool) {
// during import unexported method names should be in the type's package
if tpkg != nil && f.Sym != nil && !exportname(f.Sym.Name) && f.Sym.Pkg != tpkg {
Fatalf("imported method name %v in wrong package %s\n", Sconv(f.Sym, obj.FmtSign), tpkg.Name)
Fatalf("imported method name %v in wrong package %s\n", Sconv(f.Sym, FmtSign), tpkg.Name)
}
if d == nil {
......
This diff is collapsed.
......@@ -235,9 +235,9 @@ func dumpexportconst(s *Sym) {
dumpexporttype(t)
if t != nil && !isideal(t) {
exportf("\tconst %v %v = %v\n", Sconv(s, obj.FmtSharp), Tconv(t, obj.FmtSharp), Vconv(n.Val(), obj.FmtSharp))
exportf("\tconst %v %v = %v\n", Sconv(s, FmtSharp), Tconv(t, FmtSharp), Vconv(n.Val(), FmtSharp))
} else {
exportf("\tconst %v = %v\n", Sconv(s, obj.FmtSharp), Vconv(n.Val(), obj.FmtSharp))
exportf("\tconst %v = %v\n", Sconv(s, FmtSharp), Vconv(n.Val(), FmtSharp))
}
}
......@@ -261,14 +261,14 @@ func dumpexportvar(s *Sym) {
}
// NOTE: The space after %#S here is necessary for ld's export data parser.
exportf("\tfunc %v %v { %v }\n", Sconv(s, obj.FmtSharp), Tconv(t, obj.FmtShort|obj.FmtSharp), Hconv(n.Func.Inl, obj.FmtSharp|obj.FmtBody))
exportf("\tfunc %v %v { %v }\n", Sconv(s, FmtSharp), Tconv(t, FmtShort|FmtSharp), Hconv(n.Func.Inl, FmtSharp|FmtBody))
reexportdeplist(n.Func.Inl)
} else {
exportf("\tfunc %v %v\n", Sconv(s, obj.FmtSharp), Tconv(t, obj.FmtShort|obj.FmtSharp))
exportf("\tfunc %v %v\n", Sconv(s, FmtSharp), Tconv(t, FmtShort|FmtSharp))
}
} else {
exportf("\tvar %v %v\n", Sconv(s, obj.FmtSharp), Tconv(t, obj.FmtSharp))
exportf("\tvar %v %v\n", Sconv(s, FmtSharp), Tconv(t, FmtSharp))
}
}
......@@ -319,7 +319,7 @@ func dumpexporttype(t *Type) {
}
sort.Sort(methodbyname(m))
exportf("\ttype %v %v\n", Sconv(t.Sym, obj.FmtSharp), Tconv(t, obj.FmtSharp|obj.FmtLong))
exportf("\ttype %v %v\n", Sconv(t.Sym, FmtSharp), Tconv(t, FmtSharp|FmtLong))
for _, f := range m {
if f.Nointerface {
exportf("\t//go:nointerface\n")
......@@ -331,10 +331,10 @@ func dumpexporttype(t *Type) {
if Debug['l'] < 2 {
typecheckinl(f.Type.Nname)
}
exportf("\tfunc %v %v %v { %v }\n", Tconv(f.Type.Recvs(), obj.FmtSharp), Sconv(f.Sym, obj.FmtShort|obj.FmtByte|obj.FmtSharp), Tconv(f.Type, obj.FmtShort|obj.FmtSharp), Hconv(f.Type.Nname.Func.Inl, obj.FmtSharp))
exportf("\tfunc %v %v %v { %v }\n", Tconv(f.Type.Recvs(), FmtSharp), Sconv(f.Sym, FmtShort|FmtByte|FmtSharp), Tconv(f.Type, FmtShort|FmtSharp), Hconv(f.Type.Nname.Func.Inl, FmtSharp))
reexportdeplist(f.Type.Nname.Func.Inl)
} else {
exportf("\tfunc %v %v %v\n", Tconv(f.Type.Recvs(), obj.FmtSharp), Sconv(f.Sym, obj.FmtShort|obj.FmtByte|obj.FmtSharp), Tconv(f.Type, obj.FmtShort|obj.FmtSharp))
exportf("\tfunc %v %v %v\n", Tconv(f.Type.Recvs(), FmtSharp), Sconv(f.Sym, FmtShort|FmtByte|FmtSharp), Tconv(f.Type, FmtShort|FmtSharp))
}
}
}
......@@ -552,7 +552,7 @@ func importvar(s *Sym, t *Type) {
declare(n, PEXTERN)
if Debug['E'] != 0 {
fmt.Printf("import var %v %v\n", s, Tconv(t, obj.FmtLong))
fmt.Printf("import var %v %v\n", s, Tconv(t, FmtLong))
}
}
......@@ -573,11 +573,11 @@ func importtype(pt *Type, t *Type) {
declare(n, PEXTERN)
checkwidth(pt)
} else if !Eqtype(pt.Orig, t) {
Yyerror("inconsistent definition for type %v during import\n\t%v (in %q)\n\t%v (in %q)", pt.Sym, Tconv(pt, obj.FmtLong), pt.Sym.Importdef.Path, Tconv(t, obj.FmtLong), importpkg.Path)
Yyerror("inconsistent definition for type %v during import\n\t%v (in %q)\n\t%v (in %q)", pt.Sym, Tconv(pt, FmtLong), pt.Sym.Importdef.Path, Tconv(t, FmtLong), importpkg.Path)
}
if Debug['E'] != 0 {
fmt.Printf("import type %v %v\n", pt, Tconv(t, obj.FmtLong))
fmt.Printf("import type %v %v\n", pt, Tconv(t, FmtLong))
}
}
......@@ -593,7 +593,7 @@ func dumpasmhdr() {
}
switch n.Op {
case OLITERAL:
fmt.Fprintf(b, "#define const_%s %v\n", n.Sym.Name, Vconv(n.Val(), obj.FmtSharp))
fmt.Fprintf(b, "#define const_%s %v\n", n.Sym.Name, Vconv(n.Val(), FmtSharp))
case OTYPE:
t := n.Type
......
This diff is collapsed.
......@@ -638,7 +638,7 @@ func gen(n *Node) {
switch n.Op {
default:
Fatalf("gen: unknown op %v", Nconv(n, obj.FmtShort|obj.FmtSign))
Fatalf("gen: unknown op %v", Nconv(n, FmtShort|FmtSign))
case OCASE,
OFALL,
......
......@@ -425,7 +425,7 @@ func Naddr(a *obj.Addr, n *Node) {
}
switch n.Val().Ctype() {
default:
Fatalf("naddr: const %v", Tconv(n.Type, obj.FmtLong))
Fatalf("naddr: const %v", Tconv(n.Type, FmtLong))
case CTFLT:
a.Type = obj.TYPE_FCONST
......
......@@ -28,7 +28,6 @@
package gc
import (
"cmd/internal/obj"
"fmt"
)
......@@ -43,7 +42,7 @@ func fnpkg(fn *Node) *Pkg {
rcvr = rcvr.Type
}
if rcvr.Sym == nil {
Fatalf("receiver with no sym: [%v] %v (%v)", fn.Sym, Nconv(fn, obj.FmtLong), rcvr)
Fatalf("receiver with no sym: [%v] %v (%v)", fn.Sym, Nconv(fn, FmtLong), rcvr)
}
return rcvr.Sym.Pkg
}
......@@ -68,7 +67,7 @@ func typecheckinl(fn *Node) {
}
if Debug['m'] > 2 {
fmt.Printf("typecheck import [%v] %v { %v }\n", fn.Sym, Nconv(fn, obj.FmtLong), Hconv(fn.Func.Inl, obj.FmtSharp))
fmt.Printf("typecheck import [%v] %v { %v }\n", fn.Sym, Nconv(fn, FmtLong), Hconv(fn.Func.Inl, FmtSharp))
}
save_safemode := safemode
......@@ -92,7 +91,7 @@ func caninl(fn *Node) {
Fatalf("caninl %v", fn)
}
if fn.Func.Nname == nil {
Fatalf("caninl no nname %v", Nconv(fn, obj.FmtSign))
Fatalf("caninl no nname %v", Nconv(fn, FmtSign))
}
// If marked "go:noinline", don't inline
......@@ -148,7 +147,7 @@ func caninl(fn *Node) {
fn.Type.Nname = fn.Func.Nname
if Debug['m'] > 1 {
fmt.Printf("%v: can inline %v as: %v { %v }\n", fn.Line(), Nconv(fn.Func.Nname, obj.FmtSharp), Tconv(fn.Type, obj.FmtSharp), Hconv(fn.Func.Nname.Func.Inl, obj.FmtSharp))
fmt.Printf("%v: can inline %v as: %v { %v }\n", fn.Line(), Nconv(fn.Func.Nname, FmtSharp), Tconv(fn.Type, FmtSharp), Hconv(fn.Func.Nname.Func.Inl, FmtSharp))
} else if Debug['m'] != 0 {
fmt.Printf("%v: can inline %v\n", fn.Line(), fn.Func.Nname)
}
......@@ -191,10 +190,10 @@ func ishairy(n *Node, budget *int) bool {
// Call is okay if inlinable and we have the budget for the body.
case OCALLMETH:
if n.Left.Type == nil {
Fatalf("no function type for [%p] %v\n", n.Left, Nconv(n.Left, obj.FmtSign))
Fatalf("no function type for [%p] %v\n", n.Left, Nconv(n.Left, FmtSign))
}
if n.Left.Type.Nname == nil {
Fatalf("no function definition for [%p] %v\n", n.Left.Type, Tconv(n.Left.Type, obj.FmtSign))
Fatalf("no function definition for [%p] %v\n", n.Left.Type, Tconv(n.Left.Type, FmtSign))
}
if len(n.Left.Type.Nname.Func.Inl.Slice()) != 0 {
*budget -= int(n.Left.Type.Nname.Func.InlCost)
......@@ -303,7 +302,7 @@ func inlconv2expr(np **Node) {
// statements.
func inlconv2list(n *Node) []*Node {
if n.Op != OINLCALL || n.Rlist.Len() == 0 {
Fatalf("inlconv2list %v\n", Nconv(n, obj.FmtSign))
Fatalf("inlconv2list %v\n", Nconv(n, FmtSign))
}
s := n.Rlist.Slice()
......@@ -453,7 +452,7 @@ func inlnode(np **Node) {
switch n.Op {
case OCALLFUNC:
if Debug['m'] > 3 {
fmt.Printf("%v:call to func %v\n", n.Line(), Nconv(n.Left, obj.FmtSign))
fmt.Printf("%v:call to func %v\n", n.Line(), Nconv(n.Left, FmtSign))
}
if n.Left.Func != nil && len(n.Left.Func.Inl.Slice()) != 0 { // normal case
mkinlcall(np, n.Left, n.Isddd)
......@@ -465,16 +464,16 @@ func inlnode(np **Node) {
case OCALLMETH:
if Debug['m'] > 3 {
fmt.Printf("%v:call to meth %v\n", n.Line(), Nconv(n.Left.Right, obj.FmtLong))
fmt.Printf("%v:call to meth %v\n", n.Line(), Nconv(n.Left.Right, FmtLong))
}
// typecheck should have resolved ODOTMETH->type, whose nname points to the actual function.
if n.Left.Type == nil {
Fatalf("no function type for [%p] %v\n", n.Left, Nconv(n.Left, obj.FmtSign))
Fatalf("no function type for [%p] %v\n", n.Left, Nconv(n.Left, FmtSign))
}
if n.Left.Type.Nname == nil {
Fatalf("no function definition for [%p] %v\n", n.Left.Type, Tconv(n.Left.Type, obj.FmtSign))
Fatalf("no function definition for [%p] %v\n", n.Left.Type, Tconv(n.Left.Type, FmtSign))
}
mkinlcall(np, n.Left.Type.Nname, n.Isddd)
......@@ -533,13 +532,13 @@ func mkinlcall1(np **Node, fn *Node, isddd bool) {
// Bingo, we have a function node, and it has an inlineable body
if Debug['m'] > 1 {
fmt.Printf("%v: inlining call to %v %v { %v }\n", n.Line(), fn.Sym, Tconv(fn.Type, obj.FmtSharp), Hconv(fn.Func.Inl, obj.FmtSharp))
fmt.Printf("%v: inlining call to %v %v { %v }\n", n.Line(), fn.Sym, Tconv(fn.Type, FmtSharp), Hconv(fn.Func.Inl, FmtSharp))
} else if Debug['m'] != 0 {
fmt.Printf("%v: inlining call to %v\n", n.Line(), fn)
}
if Debug['m'] > 2 {
fmt.Printf("%v: Before inlining: %v\n", n.Line(), Nconv(n, obj.FmtSign))
fmt.Printf("%v: Before inlining: %v\n", n.Line(), Nconv(n, FmtSign))
}
ninit := n.Ninit
......@@ -601,10 +600,10 @@ func mkinlcall1(np **Node, fn *Node, isddd bool) {
Fatalf("missing inlvar for %v\n", t.Nname)
}
if n.Left.Left == nil {
Fatalf("method call without receiver: %v", Nconv(n, obj.FmtSign))
Fatalf("method call without receiver: %v", Nconv(n, FmtSign))
}
if t == nil {
Fatalf("method call unknown receiver type: %v", Nconv(n, obj.FmtSign))
Fatalf("method call unknown receiver type: %v", Nconv(n, FmtSign))
}
as := Nod(OAS, tinlvar(t), n.Left.Left)
if as != nil {
......@@ -660,7 +659,7 @@ func mkinlcall1(np **Node, fn *Node, isddd bool) {
if fn.Type.Thistuple != 0 && n.Left.Op != ODOTMETH {
// non-method call to method
if n.List.Len() == 0 {
Fatalf("non-method call to method without first arg: %v", Nconv(n, obj.FmtSign))
Fatalf("non-method call to method without first arg: %v", Nconv(n, FmtSign))
}
// append receiver inlvar to LHS.
......@@ -670,7 +669,7 @@ func mkinlcall1(np **Node, fn *Node, isddd bool) {
Fatalf("missing inlvar for %v\n", t.Nname)
}
if t == nil {
Fatalf("method call unknown receiver type: %v", Nconv(n, obj.FmtSign))
Fatalf("method call unknown receiver type: %v", Nconv(n, FmtSign))
}
as.List.Append(tinlvar(t))
li++
......@@ -730,7 +729,7 @@ func mkinlcall1(np **Node, fn *Node, isddd bool) {
}
if li < n.List.Len() || t != nil {
Fatalf("arg count mismatch: %v vs %v\n", Tconv(fn.Type.Params(), obj.FmtSharp), Hconv(n.List, obj.FmtComma))
Fatalf("arg count mismatch: %v vs %v\n", Tconv(fn.Type.Params(), FmtSharp), Hconv(n.List, FmtComma))
}
}
......@@ -821,7 +820,7 @@ func mkinlcall1(np **Node, fn *Node, isddd bool) {
fn.Func.Inl.Set(body)
if Debug['m'] > 2 {
fmt.Printf("%v: After inlining %v\n\n", n.Line(), Nconv(*np, obj.FmtSign))
fmt.Printf("%v: After inlining %v\n\n", n.Line(), Nconv(*np, FmtSign))
}
}
......@@ -830,7 +829,7 @@ func mkinlcall1(np **Node, fn *Node, isddd bool) {
// PPARAM's, PAUTOS and PPARAMOUTs of the called function.
func inlvar(var_ *Node) *Node {
if Debug['m'] > 3 {
fmt.Printf("inlvar %v\n", Nconv(var_, obj.FmtSign))
fmt.Printf("inlvar %v\n", Nconv(var_, FmtSign))
}
n := newname(var_.Sym)
......@@ -915,13 +914,13 @@ func (subst *inlsubst) node(n *Node) *Node {
case ONAME:
if n.Name.Inlvar != nil { // These will be set during inlnode
if Debug['m'] > 2 {
fmt.Printf("substituting name %v -> %v\n", Nconv(n, obj.FmtSign), Nconv(n.Name.Inlvar, obj.FmtSign))
fmt.Printf("substituting name %v -> %v\n", Nconv(n, FmtSign), Nconv(n.Name.Inlvar, FmtSign))
}
return n.Name.Inlvar
}
if Debug['m'] > 2 {
fmt.Printf("not substituting name %v\n", Nconv(n, obj.FmtSign))
fmt.Printf("not substituting name %v\n", Nconv(n, FmtSign))
}
return n
......@@ -971,7 +970,7 @@ func (subst *inlsubst) node(n *Node) *Node {
m.Ninit.Set(nil)
if n.Op == OCLOSURE {
Fatalf("cannot inline function containing closure: %v", Nconv(n, obj.FmtSign))
Fatalf("cannot inline function containing closure: %v", Nconv(n, FmtSign))
}
m.Left = subst.node(n.Left)
......
......@@ -6,7 +6,6 @@ package gc
import (
"cmd/compile/internal/big"
"cmd/internal/obj"
"fmt"
"math"
)
......@@ -209,8 +208,8 @@ func (f *Mpflt) String() string {
return Fconv(f, 0)
}
func Fconv(fvp *Mpflt, flag int) string {
if flag&obj.FmtSharp == 0 {
func Fconv(fvp *Mpflt, flag FmtFlag) string {
if flag&FmtSharp == 0 {
return fvp.Val.Text('b', 0)
}
......@@ -222,7 +221,7 @@ func Fconv(fvp *Mpflt, flag int) string {
if f.Sign() < 0 {
sign = "-"
f = new(big.Float).Abs(f)
} else if flag&obj.FmtSign != 0 {
} else if flag&FmtSign != 0 {
sign = "+"
}
......
......@@ -6,7 +6,6 @@ package gc
import (
"cmd/compile/internal/big"
"cmd/internal/obj"
"fmt"
)
......@@ -309,8 +308,8 @@ func (x *Mpint) String() string {
return Bconv(x, 0)
}
func Bconv(xval *Mpint, flag int) string {
if flag&obj.FmtSharp != 0 {
func Bconv(xval *Mpint, flag FmtFlag) string {
if flag&FmtSharp != 0 {
return fmt.Sprintf("%#x", &xval.Val)
}
return xval.Val.String()
......
......@@ -90,7 +90,7 @@ func gvardefx(n *Node, as obj.As) {
Fatalf("gvardef nil")
}
if n.Op != ONAME {
Yyerror("gvardef %v; %v", Oconv(n.Op, obj.FmtSharp), n)
Yyerror("gvardef %v; %v", Oconv(n.Op, FmtSharp), n)
return
}
......
......@@ -1241,7 +1241,7 @@ func livenessepilogue(lv *Liveness) {
if !n.Name.Needzero {
n.Name.Needzero = true
if debuglive >= 1 {
Warnl(p.Lineno, "%v: %v is ambiguously live", Curfn.Func.Nname, Nconv(n, obj.FmtLong))
Warnl(p.Lineno, "%v: %v is ambiguously live", Curfn.Func.Nname, Nconv(n, FmtLong))
}
// Record in 'ambiguous' bitmap.
......@@ -1337,7 +1337,7 @@ func livenessepilogue(lv *Liveness) {
}
n := lv.vars[j]
if n.Class != PPARAM {
yyerrorl(p.Lineno, "internal error: %v %v recorded as live on entry, p.Pc=%v", Curfn.Func.Nname, Nconv(n, obj.FmtLong), p.Pc)
yyerrorl(p.Lineno, "internal error: %v %v recorded as live on entry, p.Pc=%v", Curfn.Func.Nname, Nconv(n, FmtLong), p.Pc)
}
}
}
......
......@@ -718,7 +718,7 @@ func mergetemp(firstp *obj.Prog) {
nfree := len(bystart)
for _, v := range bystart {
if debugmerge > 0 && Debug['v'] != 0 {
fmt.Printf("consider %v: removed=%t\n", Nconv(v.node, obj.FmtSharp), v.removed)
fmt.Printf("consider %v: removed=%t\n", Nconv(v.node, FmtSharp), v.removed)
}
if v.removed {
......@@ -733,7 +733,7 @@ func mergetemp(firstp *obj.Prog) {
}
if debugmerge > 0 && Debug['v'] != 0 {
fmt.Printf("consider %v: removed=%t nfree=%d nvar=%d\n", Nconv(v.node, obj.FmtSharp), v.removed, nfree, len(bystart))
fmt.Printf("consider %v: removed=%t nfree=%d nvar=%d\n", Nconv(v.node, FmtSharp), v.removed, nfree, len(bystart))
}
// Find old temp to reuse if possible.
......@@ -742,7 +742,7 @@ func mergetemp(firstp *obj.Prog) {
for j := nfree; j < len(inuse); j++ {
v1 := inuse[j]
if debugmerge > 0 && Debug['v'] != 0 {
fmt.Printf("consider %v: maybe %v: type=%v,%v addrtaken=%v,%v\n", Nconv(v.node, obj.FmtSharp), Nconv(v1.node, obj.FmtSharp), t, v1.node.Type, v.node.Addrtaken, v1.node.Addrtaken)
fmt.Printf("consider %v: maybe %v: type=%v,%v addrtaken=%v,%v\n", Nconv(v.node, FmtSharp), Nconv(v1.node, FmtSharp), t, v1.node.Type, v.node.Addrtaken, v1.node.Addrtaken)
}
// Require the types to match but also require the addrtaken bits to match.
......@@ -778,7 +778,7 @@ func mergetemp(firstp *obj.Prog) {
if debugmerge > 0 && Debug['v'] != 0 {
fmt.Printf("%v [%d - %d]\n", Curfn.Func.Nname.Sym, len(vars), nkill)
for _, v := range vars {
fmt.Printf("var %v %v %d-%d", Nconv(v.node, obj.FmtSharp), v.node.Type, v.start, v.end)
fmt.Printf("var %v %v %d-%d", Nconv(v.node, FmtSharp), v.node.Type, v.start, v.end)
if v.addr {
fmt.Printf(" addr=true")
}
......@@ -786,7 +786,7 @@ func mergetemp(firstp *obj.Prog) {
fmt.Printf(" removed=true")
}
if v.merge != nil {
fmt.Printf(" merge %v", Nconv(v.merge.node, obj.FmtSharp))
fmt.Printf(" merge %v", Nconv(v.merge.node, FmtSharp))
}
if v.start == v.end && v.def != nil {
fmt.Printf(" %v", v.def.Prog)
......
......@@ -4,8 +4,6 @@
package gc
import "cmd/internal/obj"
// range
func typecheckrange(n *Node) {
var toomany int
......@@ -48,7 +46,7 @@ func typecheckrange(n *Node) {
toomany = 0
switch t.Etype {
default:
Yyerror("cannot range over %v", Nconv(n.Right, obj.FmtLong))
Yyerror("cannot range over %v", Nconv(n.Right, FmtLong))
goto out
case TARRAY:
......@@ -104,7 +102,7 @@ func typecheckrange(n *Node) {
if v1.Name != nil && v1.Name.Defn == n {
v1.Type = t1
} else if v1.Type != nil && assignop(t1, v1.Type, &why) == 0 {
Yyerror("cannot assign type %v to %v in range%s", t1, Nconv(v1, obj.FmtLong), why)
Yyerror("cannot assign type %v to %v in range%s", t1, Nconv(v1, FmtLong), why)
}
checkassign(n, v1)
}
......@@ -113,7 +111,7 @@ func typecheckrange(n *Node) {
if v2.Name != nil && v2.Name.Defn == n {
v2.Type = t2
} else if v2.Type != nil && assignop(t2, v2.Type, &why) == 0 {
Yyerror("cannot assign type %v to %v in range%s", t2, Nconv(v2, obj.FmtLong), why)
Yyerror("cannot assign type %v to %v in range%s", t2, Nconv(v2, FmtLong), why)
}
checkassign(n, v2)
}
......
......@@ -757,7 +757,7 @@ func dcommontype(s *Sym, ot int, t *Type) int {
}
ot = dsymptr(s, ot, gcsym, 0) // gcdata
p := Tconv(t, obj.FmtLeft|obj.FmtUnsigned)
p := Tconv(t, FmtLeft|FmtUnsigned)
// If we're writing out type T,
// we are very likely to write out type *T as well.
......@@ -777,13 +777,13 @@ func dcommontype(s *Sym, ot int, t *Type) int {
}
func typesym(t *Type) *Sym {
return Pkglookup(Tconv(t, obj.FmtLeft), typepkg)
return Pkglookup(Tconv(t, FmtLeft), typepkg)
}
// tracksym returns the symbol for tracking use of field/method f, assumed
// to be a member of struct/interface type t.
func tracksym(t *Type, f *Field) *Sym {
return Pkglookup(Tconv(t, obj.FmtLeft)+"."+f.Sym.Name, trackpkg)
return Pkglookup(Tconv(t, FmtLeft)+"."+f.Sym.Name, trackpkg)
}
func typelinksym(t *Type) *Sym {
......@@ -796,7 +796,7 @@ func typelinksym(t *Type) *Sym {
// ensure the types appear sorted by their string field. 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 := Tconv(t, obj.FmtLeft|obj.FmtUnsigned) + "\t" + Tconv(t, obj.FmtLeft)
p := Tconv(t, FmtLeft|FmtUnsigned) + "\t" + Tconv(t, FmtLeft)
s := Pkglookup(p, typelinkpkg)
......@@ -806,7 +806,7 @@ func typelinksym(t *Type) *Sym {
}
func typesymprefix(prefix string, t *Type) *Sym {
p := prefix + "." + Tconv(t, obj.FmtLeft)
p := prefix + "." + Tconv(t, FmtLeft)
s := Pkglookup(p, typepkg)
//print("algsym: %s -> %+S\n", p, s);
......
......@@ -392,10 +392,10 @@ func mkvar(f *Flow, a *obj.Addr) Bits {
if nvar >= NVAR {
if Debug['w'] > 1 && node != nil {
Fatalf("variable not optimized: %v", Nconv(node, obj.FmtSharp))
Fatalf("variable not optimized: %v", Nconv(node, FmtSharp))
}
if Debug['v'] > 0 {
Warn("variable not optimized: %v", Nconv(node, obj.FmtSharp))
Warn("variable not optimized: %v", Nconv(node, FmtSharp))
}
// If we're not tracking a word in a variable, mark the rest as
......@@ -487,7 +487,7 @@ func mkvar(f *Flow, a *obj.Addr) Bits {
}
if Debug['R'] != 0 {
fmt.Printf("bit=%2d et=%v w=%d+%d %v %v flag=%d\n", i, Econv(et), o, w, Nconv(node, obj.FmtSharp), Ctxt.Dconv(a), v.addr)
fmt.Printf("bit=%2d et=%v w=%d+%d %v %v flag=%d\n", i, Econv(et), o, w, Nconv(node, FmtSharp), Ctxt.Dconv(a), v.addr)
}
Ostats.Nvar++
......
......@@ -5,7 +5,6 @@
package gc
import (
"cmd/internal/obj"
"fmt"
)
......@@ -202,7 +201,7 @@ func init2(n *Node, out *[]*Node) {
}
if n.Op == ONAME && n.Ninit.Len() != 0 {
Fatalf("name %v with ninit: %v\n", n.Sym, Nconv(n, obj.FmtSign))
Fatalf("name %v with ninit: %v\n", n.Sym, Nconv(n, FmtSign))
}
init1(n, out)
......
......@@ -839,11 +839,11 @@ func assignop(src *Type, dst *Type, why *string) Op {
} else if have != nil && have.Sym == missing.Sym && have.Nointerface {
*why = fmt.Sprintf(":\n\t%v does not implement %v (%v method is marked 'nointerface')", src, dst, missing.Sym)
} else if have != nil && have.Sym == missing.Sym {
*why = fmt.Sprintf(":\n\t%v does not implement %v (wrong type for %v method)\n"+"\t\thave %v%v\n\t\twant %v%v", src, dst, missing.Sym, have.Sym, Tconv(have.Type, obj.FmtShort|obj.FmtByte), missing.Sym, Tconv(missing.Type, obj.FmtShort|obj.FmtByte))
*why = fmt.Sprintf(":\n\t%v does not implement %v (wrong type for %v method)\n"+"\t\thave %v%v\n\t\twant %v%v", src, dst, missing.Sym, have.Sym, Tconv(have.Type, FmtShort|FmtByte), missing.Sym, Tconv(missing.Type, FmtShort|FmtByte))
} else if ptr != 0 {
*why = fmt.Sprintf(":\n\t%v does not implement %v (%v method has pointer receiver)", src, dst, missing.Sym)
} else if have != nil {
*why = fmt.Sprintf(":\n\t%v does not implement %v (missing %v method)\n"+"\t\thave %v%v\n\t\twant %v%v", src, dst, missing.Sym, have.Sym, Tconv(have.Type, obj.FmtShort|obj.FmtByte), missing.Sym, Tconv(missing.Type, obj.FmtShort|obj.FmtByte))
*why = fmt.Sprintf(":\n\t%v does not implement %v (missing %v method)\n"+"\t\thave %v%v\n\t\twant %v%v", src, dst, missing.Sym, have.Sym, Tconv(have.Type, FmtShort|FmtByte), missing.Sym, Tconv(missing.Type, FmtShort|FmtByte))
} else {
*why = fmt.Sprintf(":\n\t%v does not implement %v (missing %v method)", src, dst, missing.Sym)
}
......@@ -1047,7 +1047,7 @@ func assignconvfn(n *Node, t *Type, context func() 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), t, context(), why)
Yyerror("cannot use %v as type %v in %s%s", Nconv(n, FmtLong), t, context(), why)
op = OCONV
}
......@@ -1234,10 +1234,10 @@ func typehash(t *Type) uint32 {
// hide method receiver from Tpretty
t.Thistuple = 0
p = Tconv(t, obj.FmtLeft|obj.FmtUnsigned)
p = Tconv(t, FmtLeft|FmtUnsigned)
t.Thistuple = 1
} else {
p = Tconv(t, obj.FmtLeft|obj.FmtUnsigned)
p = Tconv(t, FmtLeft|FmtUnsigned)
}
//print("typehash: %s\n", p);
......
......@@ -5,7 +5,6 @@
package gc
import (
"cmd/internal/obj"
"sort"
"strconv"
)
......@@ -71,7 +70,7 @@ func typecheckswitch(n *Node) {
typecheck(&n.Left.Right, Erv)
t = n.Left.Right.Type
if t != nil && t.Etype != TINTER {
Yyerror("cannot type switch on non-interface value %v", Nconv(n.Left.Right, obj.FmtLong))
Yyerror("cannot type switch on non-interface value %v", Nconv(n.Left.Right, FmtLong))
}
} else {
// expression switch
......@@ -87,13 +86,13 @@ func typecheckswitch(n *Node) {
var badtype *Type
switch {
case !okforeq[t.Etype]:
Yyerror("cannot switch on %v", Nconv(n.Left, obj.FmtLong))
Yyerror("cannot switch on %v", Nconv(n.Left, FmtLong))
case t.Etype == TARRAY && !Isfixedarray(t):
nilonly = "slice"
case t.Etype == TARRAY && Isfixedarray(t) && algtype1(t, nil) == ANOEQ:
Yyerror("cannot switch on %v", Nconv(n.Left, obj.FmtLong))
Yyerror("cannot switch on %v", Nconv(n.Left, FmtLong))
case t.Etype == TSTRUCT && algtype1(t, &badtype) == ANOEQ:
Yyerror("cannot switch on %v (struct containing %v cannot be compared)", Nconv(n.Left, obj.FmtLong), badtype)
Yyerror("cannot switch on %v (struct containing %v cannot be compared)", Nconv(n.Left, FmtLong), badtype)
case t.Etype == TFUNC:
nilonly = "func"
case t.Etype == TMAP:
......@@ -141,7 +140,7 @@ func typecheckswitch(n *Node) {
case nilonly != "" && !isnil(n1):
Yyerror("invalid case %v in switch (can only compare %s %v to nil)", n1, nilonly, n.Left)
case Isinter(t) && !Isinter(n1.Type) && algtype1(n1.Type, nil) == ANOEQ:
Yyerror("invalid case %v in switch (incomparable type)", Nconv(n1, obj.FmtLong))
Yyerror("invalid case %v in switch (incomparable type)", Nconv(n1, FmtLong))
}
// type switch
......@@ -151,15 +150,15 @@ func typecheckswitch(n *Node) {
switch {
case n1.Op == OLITERAL && Istype(n1.Type, TNIL):
case n1.Op != OTYPE && n1.Type != nil: // should this be ||?
Yyerror("%v is not a type", Nconv(n1, obj.FmtLong))
Yyerror("%v is not a type", Nconv(n1, FmtLong))
// reset to original type
n1 = n.Left.Right
ls[i1] = n1
case n1.Type.Etype != TINTER && t.Etype == TINTER && !implements(n1.Type, t, &missing, &have, &ptr):
if have != nil && !missing.Broke && !have.Broke {
Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (wrong type for %v method)\n\thave %v%v\n\twant %v%v", Nconv(n.Left.Right, obj.FmtLong), n1.Type, missing.Sym, have.Sym, Tconv(have.Type, obj.FmtShort), missing.Sym, Tconv(missing.Type, obj.FmtShort))
Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (wrong type for %v method)\n\thave %v%v\n\twant %v%v", Nconv(n.Left.Right, FmtLong), n1.Type, missing.Sym, have.Sym, Tconv(have.Type, FmtShort), missing.Sym, Tconv(missing.Type, FmtShort))
} else if !missing.Broke {
Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (missing %v method)", Nconv(n.Left.Right, obj.FmtLong), n1.Type, missing.Sym)
Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (missing %v method)", Nconv(n.Left.Right, FmtLong), n1.Type, missing.Sym)
}
}
}
......
......@@ -475,7 +475,7 @@ OpSwitch:
if !Isptr[t.Etype] {
if top&(Erv|Etop) != 0 {
Yyerror("invalid indirect of %v", Nconv(n.Left, obj.FmtLong))
Yyerror("invalid indirect of %v", Nconv(n.Left, FmtLong))
n.Type = nil
return
}
......@@ -846,7 +846,7 @@ OpSwitch:
}
if n.Type.Etype != TFUNC || n.Type.Thistuple != 1 {
Yyerror("type %v has no method %v", n.Left.Type, Sconv(n.Right.Sym, obj.FmtShort))
Yyerror("type %v has no method %v", n.Left.Type, Sconv(n.Right.Sym, FmtShort))
n.Type = nil
n.Type = nil
return
......@@ -950,11 +950,11 @@ OpSwitch:
var ptr int
if !implements(n.Type, t, &missing, &have, &ptr) {
if have != nil && have.Sym == missing.Sym {
Yyerror("impossible type assertion:\n\t%v does not implement %v (wrong type for %v method)\n"+"\t\thave %v%v\n\t\twant %v%v", n.Type, t, missing.Sym, have.Sym, Tconv(have.Type, obj.FmtShort|obj.FmtByte), missing.Sym, Tconv(missing.Type, obj.FmtShort|obj.FmtByte))
Yyerror("impossible type assertion:\n\t%v does not implement %v (wrong type for %v method)\n"+"\t\thave %v%v\n\t\twant %v%v", n.Type, t, missing.Sym, have.Sym, Tconv(have.Type, FmtShort|FmtByte), missing.Sym, Tconv(missing.Type, FmtShort|FmtByte))
} else if ptr != 0 {
Yyerror("impossible type assertion:\n\t%v does not implement %v (%v method has pointer receiver)", n.Type, t, missing.Sym)
} else if have != nil {
Yyerror("impossible type assertion:\n\t%v does not implement %v (missing %v method)\n"+"\t\thave %v%v\n\t\twant %v%v", n.Type, t, missing.Sym, have.Sym, Tconv(have.Type, obj.FmtShort|obj.FmtByte), missing.Sym, Tconv(missing.Type, obj.FmtShort|obj.FmtByte))
Yyerror("impossible type assertion:\n\t%v does not implement %v (missing %v method)\n"+"\t\thave %v%v\n\t\twant %v%v", n.Type, t, missing.Sym, have.Sym, Tconv(have.Type, FmtShort|FmtByte), missing.Sym, Tconv(missing.Type, FmtShort|FmtByte))
} else {
Yyerror("impossible type assertion:\n\t%v does not implement %v (missing %v method)", n.Type, t, missing.Sym)
}
......@@ -1428,7 +1428,7 @@ OpSwitch:
break OpSwitch
badcall1:
Yyerror("invalid argument %v for %v", Nconv(n.Left, obj.FmtLong), Oconv(n.Op, 0))
Yyerror("invalid argument %v for %v", Nconv(n.Left, FmtLong), Oconv(n.Op, 0))
n.Type = nil
return
......@@ -1561,7 +1561,7 @@ OpSwitch:
l := args.First()
r := args.Second()
if l.Type != nil && l.Type.Etype != TMAP {
Yyerror("first argument to delete must be map; have %v", Tconv(l.Type, obj.FmtLong))
Yyerror("first argument to delete must be map; have %v", Tconv(l.Type, FmtLong))
n.Type = nil
return
}
......@@ -1605,7 +1605,7 @@ OpSwitch:
return
}
Yyerror("first argument to append must be slice; have %v", Tconv(t, obj.FmtLong))
Yyerror("first argument to append must be slice; have %v", Tconv(t, FmtLong))
n.Type = nil
return
}
......@@ -1688,25 +1688,25 @@ OpSwitch:
if Eqtype(n.Left.Type.Type, bytetype) {
break OpSwitch
}
Yyerror("arguments to copy have different element types: %v and string", Tconv(n.Left.Type, obj.FmtLong))
Yyerror("arguments to copy have different element types: %v and string", Tconv(n.Left.Type, FmtLong))
n.Type = nil
return
}
if !Isslice(n.Left.Type) || !Isslice(n.Right.Type) {
if !Isslice(n.Left.Type) && !Isslice(n.Right.Type) {
Yyerror("arguments to copy must be slices; have %v, %v", Tconv(n.Left.Type, obj.FmtLong), Tconv(n.Right.Type, obj.FmtLong))
Yyerror("arguments to copy must be slices; have %v, %v", Tconv(n.Left.Type, FmtLong), Tconv(n.Right.Type, FmtLong))
} else if !Isslice(n.Left.Type) {
Yyerror("first argument to copy should be slice; have %v", Tconv(n.Left.Type, obj.FmtLong))
Yyerror("first argument to copy should be slice; have %v", Tconv(n.Left.Type, FmtLong))
} else {
Yyerror("second argument to copy should be slice or string; have %v", Tconv(n.Right.Type, obj.FmtLong))
Yyerror("second argument to copy should be slice or string; have %v", Tconv(n.Right.Type, FmtLong))
}
n.Type = nil
return
}
if !Eqtype(n.Left.Type.Type, n.Right.Type.Type) {
Yyerror("arguments to copy have different element types: %v and %v", Tconv(n.Left.Type, obj.FmtLong), Tconv(n.Right.Type, obj.FmtLong))
Yyerror("arguments to copy have different element types: %v and %v", Tconv(n.Left.Type, FmtLong), Tconv(n.Right.Type, FmtLong))
n.Type = nil
return
}
......@@ -1727,7 +1727,7 @@ OpSwitch:
n.Op = convertop(t, n.Type, &why)
if n.Op == 0 {
if n.Diag == 0 && !n.Type.Broke {
Yyerror("cannot convert %v to type %v%s", Nconv(n.Left, obj.FmtLong), n.Type, why)
Yyerror("cannot convert %v to type %v%s", Nconv(n.Left, FmtLong), n.Type, why)
n.Diag = 1
}
......@@ -2053,7 +2053,7 @@ OpSwitch:
if n.Left != nil {
t := n.Left.Type
if t != nil && t.Etype != TBOOL {
Yyerror("non-bool %v used as for condition", Nconv(n.Left, obj.FmtLong))
Yyerror("non-bool %v used as for condition", Nconv(n.Left, FmtLong))
}
}
typecheck(&n.Right, Etop)
......@@ -2068,7 +2068,7 @@ OpSwitch:
if n.Left != nil {
t := n.Left.Type
if t != nil && t.Etype != TBOOL {
Yyerror("non-bool %v used as if condition", Nconv(n.Left, obj.FmtLong))
Yyerror("non-bool %v used as if condition", Nconv(n.Left, FmtLong))
}
}
typechecklist(n.Nbody.Slice(), Etop)
......@@ -2422,7 +2422,7 @@ func looktypedot(n *Node, t *Type, dostrcmp int) bool {
// disallow T.m if m requires *T receiver
if Isptr[f2.Type.Recv().Type.Etype] && !Isptr[t.Etype] && f2.Embedded != 2 && !isifacemethod(f2.Type) {
Yyerror("invalid method expression %v (needs pointer receiver: (*%v).%v)", n, t, Sconv(f2.Sym, obj.FmtShort))
Yyerror("invalid method expression %v (needs pointer receiver: (*%v).%v)", n, t, Sconv(f2.Sym, FmtShort))
return false
}
......@@ -2516,7 +2516,7 @@ func lookdot(n *Node, t *Type, dostrcmp int) *Field {
n.Left.Implicit = true
typecheck(&n.Left, Etype|Erv)
} else if tt.Etype == Tptr && tt.Type.Etype == Tptr && Eqtype(derefall(tt), derefall(rcvr)) {
Yyerror("calling method %v with receiver %v requires explicit dereference", n.Right, Nconv(n.Left, obj.FmtLong))
Yyerror("calling method %v with receiver %v requires explicit dereference", n.Right, Nconv(n.Left, FmtLong))
for tt.Etype == Tptr {
// Stop one level early for method with pointer receiver.
if rcvr.Etype == Tptr && tt.Type.Etype != Tptr {
......@@ -3288,7 +3288,7 @@ func checkassignto(src *Type, dst *Node) {
var why string
if assignop(src, dst.Type, &why) == 0 {
Yyerror("cannot assign %v to %v in multiple assignment%s", src, Nconv(dst, obj.FmtLong), why)
Yyerror("cannot assign %v to %v in multiple assignment%s", src, Nconv(dst, FmtLong), why)
return
}
}
......@@ -3709,7 +3709,7 @@ func typecheckdef(n *Node) *Node {
}
if !isideal(e.Type) && !Eqtype(t, e.Type) {
Yyerror("cannot use %v as type %v in const initializer", Nconv(e, obj.FmtLong), t)
Yyerror("cannot use %v as type %v in const initializer", Nconv(e, FmtLong), t)
goto ret
}
......
......@@ -4,8 +4,6 @@
package gc
import "cmd/internal/obj"
// unsafenmagic rewrites calls to package unsafe's functions into constants.
func unsafenmagic(nn *Node) *Node {
fn := nn.Left
......@@ -84,7 +82,7 @@ func unsafenmagic(nn *Node) *Node {
v += r1.Xoffset
default:
Dump("unsafenmagic", r)
Fatalf("impossible %v node after dot insertion", Oconv(r1.Op, obj.FmtSharp))
Fatalf("impossible %v node after dot insertion", Oconv(r1.Op, FmtSharp))
goto bad
}
}
......
......@@ -185,7 +185,7 @@ func walkstmt(np **Node) {
ORECOVER,
OGETG:
if n.Typecheck == 0 {
Fatalf("missing typecheck: %v", Nconv(n, obj.FmtSign))
Fatalf("missing typecheck: %v", Nconv(n, FmtSign))
}
init := n.Ninit
n.Ninit.Set(nil)
......@@ -199,7 +199,7 @@ func walkstmt(np **Node) {
// the value received.
case ORECV:
if n.Typecheck == 0 {
Fatalf("missing typecheck: %v", Nconv(n, obj.FmtSign))
Fatalf("missing typecheck: %v", Nconv(n, FmtSign))
}
init := n.Ninit
n.Ninit.Set(nil)
......@@ -349,7 +349,7 @@ func walkstmt(np **Node) {
}
if n.Op == ONAME {
Fatalf("walkstmt ended up with name: %v", Nconv(n, obj.FmtSign))
Fatalf("walkstmt ended up with name: %v", Nconv(n, FmtSign))
}
*np = n
......@@ -484,14 +484,14 @@ func walkexpr(np **Node, init *Nodes) {
}
if n.Typecheck != 1 {
Fatalf("missed typecheck: %v\n", Nconv(n, obj.FmtSign))
Fatalf("missed typecheck: %v\n", Nconv(n, FmtSign))
}
opswitch:
switch n.Op {
default:
Dump("walk", n)
Fatalf("walkexpr: switch 1 unknown op %v", Nconv(n, obj.FmtShort|obj.FmtSign))
Fatalf("walkexpr: switch 1 unknown op %v", Nconv(n, FmtShort|FmtSign))
case OTYPE,
ONONAME,
......@@ -1005,7 +1005,7 @@ opswitch:
ll = append(ll, typename(n.Type))
}
if !Isinter(n.Left.Type) && !isnilinter(n.Type) {
sym := Pkglookup(Tconv(n.Left.Type, obj.FmtLeft)+"."+Tconv(n.Type, obj.FmtLeft), itabpkg)
sym := Pkglookup(Tconv(n.Left.Type, FmtLeft)+"."+Tconv(n.Type, FmtLeft), itabpkg)
if sym.Def == nil {
l := Nod(ONAME, nil, nil)
l.Sym = sym
......@@ -1675,7 +1675,7 @@ func ascompatee(op Op, nl, nr []*Node, init *Nodes) []*Node {
var nln, nrn Nodes
nln.Set(nl)
nrn.Set(nr)
Yyerror("error in shape across %v %v %v / %d %d [%s]", Hconv(nln, obj.FmtSign), Oconv(op, 0), Hconv(nrn, obj.FmtSign), len(nl), len(nr), Curfn.Func.Nname.Sym.Name)
Yyerror("error in shape across %v %v %v / %d %d [%s]", Hconv(nln, FmtSign), Oconv(op, 0), Hconv(nrn, FmtSign), len(nl), len(nr), Curfn.Func.Nname.Sym.Name)
}
return nn
}
......@@ -2302,7 +2302,7 @@ func reorder3(all []*Node) []*Node {
switch l.Op {
default:
Fatalf("reorder3 unexpected lvalue %v", Oconv(l.Op, obj.FmtSharp))
Fatalf("reorder3 unexpected lvalue %v", Oconv(l.Op, FmtSharp))
case ONAME:
break
......
......@@ -36,7 +36,7 @@ func defframe(ptxt *obj.Prog) {
gc.Fatalf("needzero class %d", n.Class)
}
if n.Type.Width%int64(gc.Widthptr) != 0 || n.Xoffset%int64(gc.Widthptr) != 0 || n.Type.Width == 0 {
gc.Fatalf("var %v has size %d offset %d", gc.Nconv(n, obj.FmtLong), int(n.Type.Width), int(n.Xoffset))
gc.Fatalf("var %v has size %d offset %d", gc.Nconv(n, gc.FmtLong), int(n.Type.Width), int(n.Xoffset))
}
if lo != hi && n.Xoffset+n.Type.Width >= lo-int64(2*gc.Widthreg) {
......
......@@ -218,7 +218,7 @@ func bignodes() {
*/
func gmove(f *gc.Node, t *gc.Node) {
if gc.Debug['M'] != 0 {
fmt.Printf("gmove %v -> %v\n", gc.Nconv(f, obj.FmtLong), gc.Nconv(t, obj.FmtLong))
fmt.Printf("gmove %v -> %v\n", gc.Nconv(f, gc.FmtLong), gc.Nconv(t, gc.FmtLong))
}
ft := int(gc.Simsimtype(f.Type))
......@@ -296,7 +296,7 @@ func gmove(f *gc.Node, t *gc.Node) {
switch uint32(ft)<<16 | uint32(tt) {
default:
gc.Fatalf("gmove %v -> %v", gc.Tconv(f.Type, obj.FmtLong), gc.Tconv(t.Type, obj.FmtLong))
gc.Fatalf("gmove %v -> %v", gc.Tconv(f.Type, gc.FmtLong), gc.Tconv(t.Type, gc.FmtLong))
/*
* integer copy and truncate
......
......@@ -36,7 +36,7 @@ func defframe(ptxt *obj.Prog) {
gc.Fatalf("needzero class %d", n.Class)
}
if n.Type.Width%int64(gc.Widthptr) != 0 || n.Xoffset%int64(gc.Widthptr) != 0 || n.Type.Width == 0 {
gc.Fatalf("var %v has size %d offset %d", gc.Nconv(n, obj.FmtLong), int(n.Type.Width), int(n.Xoffset))
gc.Fatalf("var %v has size %d offset %d", gc.Nconv(n, gc.FmtLong), int(n.Type.Width), int(n.Xoffset))
}
if lo != hi && n.Xoffset+n.Type.Width >= lo-int64(2*gc.Widthreg) {
......
......@@ -175,7 +175,7 @@ func bignodes() {
*/
func gmove(f *gc.Node, t *gc.Node) {
if gc.Debug['M'] != 0 {
fmt.Printf("gmove %v -> %v\n", gc.Nconv(f, obj.FmtLong), gc.Nconv(t, obj.FmtLong))
fmt.Printf("gmove %v -> %v\n", gc.Nconv(f, gc.FmtLong), gc.Nconv(t, gc.FmtLong))
}
ft := int(gc.Simsimtype(f.Type))
......@@ -261,7 +261,7 @@ func gmove(f *gc.Node, t *gc.Node) {
switch uint32(ft)<<16 | uint32(tt) {
default:
gc.Fatalf("gmove %v -> %v", gc.Tconv(f.Type, obj.FmtLong), gc.Tconv(t.Type, obj.FmtLong))
gc.Fatalf("gmove %v -> %v", gc.Tconv(f.Type, gc.FmtLong), gc.Tconv(t.Type, gc.FmtLong))
/*
* integer copy and truncate
......
......@@ -34,7 +34,7 @@ func defframe(ptxt *obj.Prog) {
gc.Fatalf("needzero class %d", n.Class)
}
if n.Type.Width%int64(gc.Widthptr) != 0 || n.Xoffset%int64(gc.Widthptr) != 0 || n.Type.Width == 0 {
gc.Fatalf("var %v has size %d offset %d", gc.Nconv(n, obj.FmtLong), int(n.Type.Width), int(n.Xoffset))
gc.Fatalf("var %v has size %d offset %d", gc.Nconv(n, gc.FmtLong), int(n.Type.Width), int(n.Xoffset))
}
if lo != hi && n.Xoffset+n.Type.Width == lo-int64(2*gc.Widthptr) {
// merge with range we already have
......
......@@ -1603,7 +1603,7 @@ hardmem:
// should not happen
fatal:
gc.Fatalf("gmove %v -> %v", gc.Nconv(f, obj.FmtLong), gc.Nconv(t, obj.FmtLong))
gc.Fatalf("gmove %v -> %v", gc.Nconv(f, gc.FmtLong), gc.Nconv(t, gc.FmtLong))
return
}
......
/*
* The authors of this software are Rob Pike and Ken Thompson.
* Copyright (c) 2002 by Lucent Technologies.
* Permission to use, copy, modify, and distribute this software for any
* purpose without fee is hereby granted, provided that this entire notice
* is included in all copies of any software which is or includes a copy
* or modification of this software and in all copies of the supporting
* documentation for such software.
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
*/
package obj
const (
FmtWidth = 1 << iota
FmtLeft
FmtSharp
FmtSign
FmtUnsigned
FmtShort
FmtLong
FmtComma
FmtByte
FmtBody // for printing export bodies
)
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