default:
gc.Dump("f", f)
gc.Dump("t", t)
- gc.Fatalf("gmove %v -> %v", gc.Tconv(f.Type, gc.FmtLong), gc.Tconv(t.Type, gc.FmtLong))
+ gc.Fatalf("gmove %2v -> %2v", f.Type, t.Type)
/*
* integer copy and truncate
switch uint32(ft)<<16 | uint32(tt) {
default:
- gc.Fatalf("gmove %v -> %v", gc.Tconv(f.Type, gc.FmtLong), gc.Tconv(t.Type, gc.FmtLong))
+ gc.Fatalf("gmove %2v -> %2v", f.Type, t.Type)
/*
* integer copy and truncate
}
o += w
if o >= Thearch.MAXWIDTH {
- Yyerror("type %v too large", Tconv(errtype, FmtLong))
+ Yyerror("type %2v too large", errtype)
o = 8 // small but nonzero
}
}
if t.Elem().Width != 0 {
cap := (uint64(Thearch.MAXWIDTH) - 1) / uint64(t.Elem().Width)
if uint64(t.NumElem()) > cap {
- Yyerror("type %v larger than address space", Tconv(t, FmtLong))
+ Yyerror("type %2v larger than address space", t)
}
}
w = t.NumElem() * t.Elem().Width
p.typ(t.Elem())
default:
- Fatalf("exporter: unexpected type: %s (Etype = %d)", Tconv(t, 0), t.Etype)
+ Fatalf("exporter: unexpected type: %s (Etype = %d)", t, t.Etype)
}
}
pt := pair.pt
t := pair.t
if !Eqtype(pt.Orig, t) {
- formatErrorf("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)
+ formatErrorf("inconsistent definition for type %v during import\n\t%2v (in %q)\n\t%2v (in %q)", pt.Sym, pt, pt.Sym.Importdef.Path, t, importpkg.Path)
}
}
}
}
if Debug['E'] != 0 {
- fmt.Printf("import type %v %v\n", pt, Tconv(t, FmtLong))
+ fmt.Printf("import type %v %2v\n", pt, t)
}
}
break
}
- Fatalf("cgen: OLEN: unknown type %v", Tconv(nl.Type, FmtLong))
+ Fatalf("cgen: OLEN: unknown type %2v", nl.Type)
case OCAP:
if nl.Type.IsChan() {
break
}
- Fatalf("cgen: OCAP: unknown type %v", Tconv(nl.Type, FmtLong))
+ Fatalf("cgen: OCAP: unknown type %2v", nl.Type)
case OADDR:
if n.Bounded { // let race detector avoid nil checks
rcvrtype := fn.Left.Type
if exportname(meth.Name) {
- p = fmt.Sprintf("(%v).%s-fm", Tconv(rcvrtype, FmtLeft|FmtShort), meth.Name)
+ p = fmt.Sprintf("(%-1v).%s-fm", rcvrtype, meth.Name)
} else {
- p = fmt.Sprintf("(%v).(%v)-fm", Tconv(rcvrtype, FmtLeft|FmtShort), sconv(meth, FmtLeft))
+ p = fmt.Sprintf("(%-1v).(%v)-fm", rcvrtype, sconv(meth, FmtLeft))
}
basetype := rcvrtype
if rcvrtype.IsPtr() {
var i int64
switch n.Val().Ctype() {
default:
- Fatalf("convconst ctype=%d %v", n.Val().Ctype(), Tconv(t, FmtLong))
+ Fatalf("convconst ctype=%d %2v", n.Val().Ctype(), t)
case CTINT, CTRUNE:
i = n.Int64()
return
}
- Fatalf("convconst %v constant", Tconv(t, FmtLong))
+ Fatalf("convconst %2v constant", t)
}
// complex multiply v *= rv
if (spkg == nil || nsym.Pkg != spkg) && !exportname(nsym.Name) {
if t0.Sym == nil && t0.IsPtr() {
- p = fmt.Sprintf("(%v).%s.%s%s", Tconv(t0, FmtLeft|FmtShort), nsym.Pkg.Prefix, nsym.Name, suffix)
+ p = fmt.Sprintf("(%-1v).%s.%s%s", t0, nsym.Pkg.Prefix, nsym.Name, suffix)
} else {
- p = fmt.Sprintf("%v.%s.%s%s", Tconv(t0, FmtLeft|FmtShort), nsym.Pkg.Prefix, nsym.Name, suffix)
+ p = fmt.Sprintf("%-1v.%s.%s%s", t0, nsym.Pkg.Prefix, nsym.Name, suffix)
}
} else {
if t0.Sym == nil && t0.IsPtr() {
- p = fmt.Sprintf("(%v).%s%s", Tconv(t0, FmtLeft|FmtShort), nsym.Name, suffix)
+ p = fmt.Sprintf("(%-1v).%s%s", t0, nsym.Name, suffix)
} else {
- p = fmt.Sprintf("%v.%s%s", Tconv(t0, FmtLeft|FmtShort), nsym.Name, suffix)
+ p = fmt.Sprintf("%-1v.%s%s", t0, nsym.Name, suffix)
}
}
default:
// 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, FmtLong), Tconv(t, FmtLong))
+ Yyerror("invalid receiver type %v (%2v / %2v)", pa, pa, t)
}
return
}
declare(n, PEXTERN)
if Debug['E'] != 0 {
- fmt.Printf("import var %v %v\n", s, Tconv(t, FmtLong))
+ fmt.Printf("import var %v %2v\n", s, t)
}
}
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, FmtLong), pt.Sym.Importdef.Path, Tconv(t, FmtLong), importpkg.Path)
+ Yyerror("inconsistent definition for type %v during import\n\t%2v (in %q)\n\t%2v (in %q)", pt.Sym, pt, pt.Sym.Importdef.Path, t, importpkg.Path)
}
if Debug['E'] != 0 {
- fmt.Printf("import type %v %v\n", pt, Tconv(t, FmtLong))
+ fmt.Printf("import type %v %2v\n", pt, t)
}
}
TBLANK: "blank",
}
-func (p *printer) typefmt(t *Type, flag FmtFlag) *printer {
+func (t *Type) typefmt(s fmt.State, flag FmtFlag) {
if t == nil {
- return p.s("<T>")
+ fmt.Fprint(s, "<T>")
+ return
}
if t == bytetype || t == runetype {
// in %-T mode collapse rune and byte with their originals.
if fmtmode != FTypeId {
- return p.sconv(t.Sym, FmtShort)
+ fmt.Fprintf(s, "%1v", t.Sym)
+ return
}
t = Types[t.Etype]
}
if t == errortype {
- return p.s("error")
+ fmt.Fprint(s, "error")
+ return
}
// Unless the 'l' flag was specified, if the type has a name, just print that name.
case FTypeId:
if flag&FmtShort != 0 {
if t.Vargen != 0 {
- return p.f("%v·%d", sconv(t.Sym, FmtShort), t.Vargen)
+ fmt.Fprintf(s, "%v·%d", sconv(t.Sym, FmtShort), t.Vargen)
+ return
}
- return p.sconv(t.Sym, FmtShort)
+ fmt.Fprint(s, sconv(t.Sym, FmtShort))
+ return
}
if flag&FmtUnsigned != 0 {
- return p.sconv(t.Sym, FmtUnsigned)
+ fmt.Fprint(s, sconv(t.Sym, FmtUnsigned))
+ return
}
if t.Sym.Pkg == localpkg && t.Vargen != 0 {
- return p.f("%v·%d", t.Sym, t.Vargen)
+ fmt.Fprintf(s, "%v·%d", t.Sym, t.Vargen)
+ return
}
}
- return p.sconv(t.Sym, 0)
+ fmt.Fprint(s, sconv(t.Sym, 0))
+ return
}
if int(t.Etype) < len(basicnames) && basicnames[t.Etype] != "" {
if fmtmode == FErr && (t == idealbool || t == idealstring) {
- p.s("untyped ")
+ fmt.Fprint(s, "untyped ")
}
- return p.s(basicnames[t.Etype])
+ fmt.Fprint(s, basicnames[t.Etype])
+ return
}
if fmtmode == FDbg {
fmtmode = 0
- p.s(t.Etype.String()).s("-").typefmt(t, flag)
+ fmt.Fprintf(s, "%v-", t.Etype)
+ t.typefmt(s, flag)
fmtmode = FDbg
- return p
+ return
}
switch t.Etype {
case TPTR32, TPTR64:
if fmtmode == FTypeId && (flag&FmtShort != 0) {
- return p.s("*" + Tconv(t.Elem(), FmtShort))
+ fmt.Fprintf(s, "*%1v", t.Elem())
+ return
}
- return p.s("*" + t.Elem().String())
+ fmt.Fprint(s, "*"+t.Elem().String())
+ return
case TARRAY:
if t.isDDDArray() {
- return p.s("[...]" + t.Elem().String())
+ fmt.Fprint(s, "[...]"+t.Elem().String())
+ return
}
- return p.f("[%d]%v", t.NumElem(), t.Elem())
+ fmt.Fprintf(s, "[%d]%v", t.NumElem(), t.Elem())
+ return
case TSLICE:
- return p.s("[]" + t.Elem().String())
+ fmt.Fprint(s, "[]"+t.Elem().String())
+ return
case TCHAN:
switch t.ChanDir() {
case Crecv:
- return p.s("<-chan " + t.Elem().String())
+ fmt.Fprint(s, "<-chan "+t.Elem().String())
+ return
case Csend:
- return p.s("chan<- " + t.Elem().String())
+ fmt.Fprint(s, "chan<- "+t.Elem().String())
+ return
}
if t.Elem() != nil && t.Elem().IsChan() && t.Elem().Sym == nil && t.Elem().ChanDir() == Crecv {
- return p.s("chan (" + t.Elem().String() + ")")
+ fmt.Fprint(s, "chan ("+t.Elem().String()+")")
+ return
}
- return p.s("chan " + t.Elem().String())
+ fmt.Fprint(s, "chan "+t.Elem().String())
+ return
case TMAP:
- return p.s("map[" + t.Key().String() + "]" + t.Val().String())
+ fmt.Fprint(s, "map["+t.Key().String()+"]"+t.Val().String())
+ return
case TINTER:
- p.s("interface {")
+ fmt.Fprint(s, "interface {")
for i, f := range t.Fields().Slice() {
if i != 0 {
- p.s(";")
+ fmt.Fprint(s, ";")
}
- p.s(" ")
+ fmt.Fprint(s, " ")
switch {
case f.Sym == nil:
// Check first that a symbol is defined for this type.
// Wrong interface definitions may have types lacking a symbol.
break
case exportname(f.Sym.Name):
- p.sconv(f.Sym, FmtShort)
+ fmt.Fprint(s, sconv(f.Sym, FmtShort))
default:
- p.sconv(f.Sym, FmtUnsigned)
+ fmt.Fprint(s, sconv(f.Sym, FmtUnsigned))
}
- p.Tconv(f.Type, FmtShort)
+ fmt.Fprintf(s, "%1v", f.Type)
}
if t.NumFields() != 0 {
- p.s(" ")
+ fmt.Fprint(s, " ")
}
- return p.s("}")
+ fmt.Fprint(s, "}")
+ return
case TFUNC:
if flag&FmtShort != 0 {
// no leading func
} else {
if t.Recv() != nil {
- p.s("method")
- p.Tconv(t.Recvs(), 0)
- p.s(" ")
+ fmt.Fprintf(s, "method %v ", t.Recvs())
}
- p.s("func")
+ fmt.Fprint(s, "func")
}
- p.Tconv(t.Params(), 0)
+ fmt.Fprintf(s, "%v", t.Params())
switch t.Results().NumFields() {
case 0:
// nothing to do
case 1:
- p.s(" ")
- p.Tconv(t.Results().Field(0).Type, 0) // struct->field->field's type
+ fmt.Fprintf(s, " %v", t.Results().Field(0).Type) // struct->field->field's type
default:
- p.s(" ")
- p.Tconv(t.Results(), 0)
+ fmt.Fprintf(s, " %v", t.Results())
}
- return p
+ return
case TSTRUCT:
if m := t.StructType().Map; m != nil {
// Format the bucket struct for map[x]y as map.bucket[x]y.
// This avoids a recursive print that generates very long names.
if mt.Bucket == t {
- return p.s("map.bucket[" + m.Key().String() + "]" + m.Val().String())
+ fmt.Fprint(s, "map.bucket["+m.Key().String()+"]"+m.Val().String())
+ return
}
if mt.Hmap == t {
- return p.s("map.hdr[" + m.Key().String() + "]" + m.Val().String())
+ fmt.Fprint(s, "map.hdr["+m.Key().String()+"]"+m.Val().String())
+ return
}
if mt.Hiter == t {
- return p.s("map.iter[" + m.Key().String() + "]" + m.Val().String())
+ fmt.Fprint(s, "map.iter["+m.Key().String()+"]"+m.Val().String())
+ return
}
Yyerror("unknown internal map type")
}
if t.IsFuncArgStruct() {
- p.s("(")
+ fmt.Fprint(s, "(")
var flag1 FmtFlag
if fmtmode == FTypeId || fmtmode == FErr { // no argument names on function signature, and no "noescape"/"nosplit" tags
flag1 = FmtShort
}
for i, f := range t.Fields().Slice() {
if i != 0 {
- p.s(", ")
+ fmt.Fprint(s, ", ")
}
- p.s(Fldconv(f, flag1))
+ fmt.Fprint(s, Fldconv(f, flag1))
}
- p.s(")")
+ fmt.Fprint(s, ")")
} else {
- p.s("struct {")
+ fmt.Fprint(s, "struct {")
for i, f := range t.Fields().Slice() {
if i != 0 {
- p.s(";")
+ fmt.Fprint(s, ";")
}
- p.s(" ")
- p.s(Fldconv(f, FmtLong))
+ fmt.Fprint(s, " ")
+ fmt.Fprint(s, Fldconv(f, FmtLong))
}
if t.NumFields() != 0 {
- p.s(" ")
+ fmt.Fprint(s, " ")
}
- p.s("}")
+ fmt.Fprint(s, "}")
}
- return p
+ return
case TFORW:
if t.Sym != nil {
- return p.s("undefined " + t.Sym.String())
+ fmt.Fprint(s, "undefined "+t.Sym.String())
+ return
}
- return p.s("undefined")
+ fmt.Fprint(s, "undefined")
+ return
case TUNSAFEPTR:
- return p.s("unsafe.Pointer")
+ fmt.Fprint(s, "unsafe.Pointer")
+ return
case TDDDFIELD:
- return p.f("%v <%v> %v", t.Etype, t.Sym, t.DDDField())
+ fmt.Fprintf(s, "%v <%v> %v", t.Etype, t.Sym, t.DDDField())
+ return
case Txxx:
- return p.s("Txxx")
+ fmt.Fprint(s, "Txxx")
+ return
}
// Don't know how to handle - fall back to detailed prints.
- return p.f("%v <%v> %v", t.Etype, t.Sym, t.Elem())
+ fmt.Fprintf(s, "%v <%v> %v", t.Etype, t.Sym, t.Elem())
}
// Statements which may be rendered with a simplestmt as init.
if n.Type == nil && n.Sym != nil {
return p.sconv(n.Sym, 0)
}
- return p.Tconv(n.Type, 0)
+ return p.f("%v", n.Type)
case OTARRAY:
if n.Left != nil {
return p
}
-func (t *Type) Print(p *printer) {
- p.Tconv(t, 0)
-}
-
-var _ Printable = new(Type) // verify Type implements Printable
-
func (t *Type) String() string {
- return Tconv(t, 0)
+ return fmt.Sprint(t)
}
func Fldconv(f *Field, flag FmtFlag) string {
var typ string
if f.Isddd {
- typ = "..." + Tconv(f.Type.Elem(), 0)
+ typ = fmt.Sprintf("...%v", f.Type.Elem())
} else {
- typ = Tconv(f.Type, 0)
+ typ = fmt.Sprintf("%v", f.Type)
}
str := typ
return str
}
+func (t *Type) Format(s fmt.State, format rune) {
+ switch format {
+ case 's', 'v':
+ t.tconv(s)
+
+ default:
+ fmt.Fprintf(s, "%%!%c(*Type=%p)", format, t)
+ }
+}
+
// Fmt "%T": types.
// Flags: 'l' print definition, not name
// 'h' omit 'func' and receiver from function types, short type names
// 'u' package name, not prefix (FTypeId mode, sticky)
-func Tconv(t *Type, flag FmtFlag) string {
- return new(printer).Tconv(t, flag).String()
-}
+func (t *Type) tconv(s fmt.State) {
+ flag := fmtFlag(s)
-func (p *printer) Tconv(t *Type, flag FmtFlag) *printer {
if t == nil {
- return p.s("<T>")
+ fmt.Fprint(s, "<T>")
+ return
}
if t.Trecur > 4 {
- return p.s("<...>")
+ fmt.Fprint(s, "<...>")
+ return
}
t.Trecur++
flag |= FmtUnsigned
}
- p.typefmt(t, flag)
+ t.typefmt(s, flag)
if fmtmode == FTypeId && (sf&FmtUnsigned != 0) {
fmtpkgpfx--
flag = sf
fmtmode = sm
t.Trecur--
-
- return p
}
func (n *Node) Print(p *printer) {
visitComponents(nl.Type, 0, func(t *Type, offset int64) bool {
if wb && Simtype[t.Etype] == Tptr && t != itable {
if ptrType != nil {
- Fatalf("componentgen_wb %v", Tconv(nl.Type, 0))
+ Fatalf("componentgen_wb %v", nl.Type)
}
ptrType = t
ptrOffset = offset
}
switch u := n.Val().U.(type) {
default:
- Fatalf("naddr: const %v", Tconv(n.Type, FmtLong))
+ Fatalf("naddr: const %2v", n.Type)
case *Mpflt:
a.Type = obj.TYPE_FCONST
fn.Type.SetNname(n)
if Debug['m'] > 1 {
- fmt.Printf("%v: can inline %v as: %v { %v }\n", fn.Line(), Nconv(n, FmtSharp), Tconv(fn.Type, FmtSharp), hconv(n.Func.Inl, FmtSharp))
+ fmt.Printf("%v: can inline %v as: %#v { %v }\n", fn.Line(), Nconv(n, FmtSharp), fn.Type, hconv(n.Func.Inl, FmtSharp))
} else if Debug['m'] != 0 {
fmt.Printf("%v: can inline %v\n", fn.Line(), n)
}
Fatalf("no function type for [%p] %v\n", n.Left, Nconv(n.Left, FmtSign))
}
if t.Nname() == nil {
- Fatalf("no function definition for [%p] %v\n", t, Tconv(t, FmtSign))
+ Fatalf("no function definition for [%p] %+v\n", t, t)
}
if inlfn := t.Nname().Func; inlfn.Inl.Len() != 0 {
*budget -= inlfn.InlCost
}
if n.Left.Type.Nname() == nil {
- Fatalf("no function definition for [%p] %v\n", n.Left.Type, Tconv(n.Left.Type, FmtSign))
+ Fatalf("no function definition for [%p] %+v\n", n.Left.Type, n.Left.Type)
}
n = mkinlcall(n, n.Left.Type.Nname(), n.Isddd)
// 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, FmtSharp), hconv(fn.Func.Inl, FmtSharp))
+ fmt.Printf("%v: inlining call to %v %#v { %v }\n", n.Line(), fn.Sym, fn.Type, hconv(fn.Func.Inl, FmtSharp))
} else if Debug['m'] != 0 {
fmt.Printf("%v: inlining call to %v\n", n.Line(), fn)
}
}
if li < n.List.Len() || t != nil {
- Fatalf("arg count mismatch: %v vs %v\n", Tconv(fn.Type.Params(), FmtSharp), hconv(n.List, FmtComma))
+ Fatalf("arg count mismatch: %#v vs %v\n", fn.Type.Params(), hconv(n.List, FmtComma))
}
}
}
exported := false
- p := Tconv(t, FmtLeft|FmtUnsigned)
+ p := fmt.Sprintf("%- v", t)
// If we're writing out type T,
// we are very likely to write out type *T as well.
// Use the string "*T"[1:] for "T", so that the two
}
func typesym(t *Type) *Sym {
- return Pkglookup(Tconv(t, FmtLeft), typepkg)
+ return Pkglookup(fmt.Sprintf("%-v", t), 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, FmtLeft)+"."+f.Sym.Name, trackpkg)
+ return Pkglookup(fmt.Sprintf("%-v.%s", t, f.Sym.Name), trackpkg)
}
func typelinkLSym(t *Type) *obj.LSym {
- name := "go.typelink." + Tconv(t, FmtLeft) // complete, unambiguous type name
+ name := fmt.Sprintf("go.typelink.%-v", t) // complete, unambiguous type name
return obj.Linklookup(Ctxt, name, 0)
}
func typesymprefix(prefix string, t *Type) *Sym {
- p := prefix + "." + Tconv(t, FmtLeft)
+ p := fmt.Sprintf("%s.%-v", prefix, t)
s := Pkglookup(p, typepkg)
//print("algsym: %s -> %+S\n", p, s);
if t == nil || (t.IsPtr() && t.Elem() == nil) || t.IsUntyped() {
Fatalf("itabname %v", t)
}
- s := Pkglookup(Tconv(t, FmtLeft)+","+Tconv(itype, FmtLeft), itabpkg)
+ s := Pkglookup(fmt.Sprintf("%-v,%-v", t, itype), itabpkg)
if s.Def == nil {
n := newname(s)
n.Type = Types[TUINT8]
// method functions. None are allocated on heap, so we can use obj.NOPTR.
ggloblsym(i.sym, int32(o), int16(obj.DUPOK|obj.NOPTR))
- ilink := Pkglookup(Tconv(i.t, FmtLeft)+","+Tconv(i.itype, FmtLeft), itablinkpkg)
+ ilink := Pkglookup(fmt.Sprintf("%-v,%-v", i.t, i.itype), itablinkpkg)
dsymptr(ilink, 0, i.sym, 0)
ggloblsym(ilink, int32(Widthptr), int16(obj.DUPOK|obj.RODATA))
}
} 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, FmtShort|FmtByte), missing.Sym, Tconv(missing.Type, FmtShort|FmtByte))
+ *why = fmt.Sprintf(":\n\t%v does not implement %v (wrong type for %v method)\n"+"\t\thave %v%01v\n\t\twant %v%01v", src, dst, missing.Sym, have.Sym, have.Type, missing.Sym, missing.Type)
} 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, FmtShort|FmtByte), missing.Sym, Tconv(missing.Type, FmtShort|FmtByte))
+ *why = fmt.Sprintf(":\n\t%v does not implement %v (missing %v method)\n"+"\t\thave %v%01v\n\t\twant %v%01v", src, dst, missing.Sym, have.Sym, have.Type, missing.Sym, missing.Type)
} else {
*why = fmt.Sprintf(":\n\t%v does not implement %v (missing %v method)", src, dst, missing.Sym)
}
// typehash computes a hash value for type t to use in type switch
// statements.
func typehash(t *Type) uint32 {
- // Tconv already contains all the necessary logic to generate
+ // fmt.Sprintf("%- v", t) already contains all the necessary logic to generate
// a representation that completely describes the type, so using
// it here avoids duplicating that code.
- p := Tconv(t, FmtLeft|FmtUnsigned)
+ p := fmt.Sprintf("%- v", t)
// Using MD5 is overkill, but reduces accidental collisions.
h := md5.Sum([]byte(p))
package gc
-import "sort"
+import (
+ "fmt"
+ "sort"
+)
const (
// expression switch
ls[i1] = n1
case !n1.Type.IsInterface() && t.IsInterface() && !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, FmtLong), n1.Type, missing.Sym, have.Sym, Tconv(have.Type, FmtShort), missing.Sym, Tconv(missing.Type, FmtShort))
+ Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (wrong type for %v method)\n\thave %v%1v\n\twant %v%1v", Nconv(n.Left.Right, FmtLong), n1.Type, missing.Sym, have.Sym, have.Type, missing.Sym, missing.Type)
} else if !missing.Broke {
Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (missing %v method)", Nconv(n.Left.Right, FmtLong), n1.Type, missing.Sym)
}
}
n := c.node.Left
tv := typeVal{
- // Tconv here serves to completely describe the type.
+ // fmt.Sprintf("% -v", n.Type) here serves to completely describe the type.
// See the comments in func typehash.
- typ: Tconv(n.Type, FmtLeft|FmtUnsigned),
+ typ: fmt.Sprintf("% -v", n.Type),
val: n.Val().Interface(),
}
prev, dup := seen[tv]
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, FmtShort|FmtByte), missing.Sym, Tconv(missing.Type, FmtShort|FmtByte))
+ Yyerror("impossible type assertion:\n\t%v does not implement %v (wrong type for %v method)\n"+"\t\thave %v%01v\n\t\twant %v%01v", n.Type, t, missing.Sym, have.Sym, have.Type, missing.Sym, missing.Type)
} 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, FmtShort|FmtByte), missing.Sym, Tconv(missing.Type, FmtShort|FmtByte))
+ Yyerror("impossible type assertion:\n\t%v does not implement %v (missing %v method)\n"+"\t\thave %v%01v\n\t\twant %v%01v", n.Type, t, missing.Sym, have.Sym, have.Type, missing.Sym, missing.Type)
} else {
Yyerror("impossible type assertion:\n\t%v does not implement %v (missing %v method)", n.Type, t, missing.Sym)
}
l := args.First()
r := args.Second()
if l.Type != nil && !l.Type.IsMap() {
- Yyerror("first argument to delete must be map; have %v", Tconv(l.Type, FmtLong))
+ Yyerror("first argument to delete must be map; have %2v", l.Type)
n.Type = nil
return n
}
return n
}
- Yyerror("first argument to append must be slice; have %v", Tconv(t, FmtLong))
+ Yyerror("first argument to append must be slice; have %2v", t)
n.Type = nil
return n
}
if Eqtype(n.Left.Type.Elem(), bytetype) {
break OpSwitch
}
- Yyerror("arguments to copy have different element types: %v and string", Tconv(n.Left.Type, FmtLong))
+ Yyerror("arguments to copy have different element types: %2v and string", n.Left.Type)
n.Type = nil
return n
}
if !n.Left.Type.IsSlice() || !n.Right.Type.IsSlice() {
if !n.Left.Type.IsSlice() && !n.Right.Type.IsSlice() {
- Yyerror("arguments to copy must be slices; have %v, %v", Tconv(n.Left.Type, FmtLong), Tconv(n.Right.Type, FmtLong))
+ Yyerror("arguments to copy must be slices; have %2v, %2v", n.Left.Type, n.Right.Type)
} else if !n.Left.Type.IsSlice() {
- Yyerror("first argument to copy should be slice; have %v", Tconv(n.Left.Type, FmtLong))
+ Yyerror("first argument to copy should be slice; have %2v", n.Left.Type)
} else {
- Yyerror("second argument to copy should be slice or string; have %v", Tconv(n.Right.Type, FmtLong))
+ Yyerror("second argument to copy should be slice or string; have %2v", n.Right.Type)
}
n.Type = nil
return n
}
if !Eqtype(n.Left.Type.Elem(), n.Right.Type.Elem()) {
- Yyerror("arguments to copy have different element types: %v and %v", Tconv(n.Left.Type, FmtLong), Tconv(n.Right.Type, FmtLong))
+ Yyerror("arguments to copy have different element types: %2v and %2v", n.Left.Type, n.Right.Type)
n.Type = nil
return n
}
if s != "" {
s += ", "
}
- s += Tconv(r.Type, 0)
+ s += r.Type.String()
}
if s == "" {
s = fmt.Sprintf("[no arguments %s]", what)
return
}
}
- if Tconv(res0.Type, 0) != "reflect.Method" {
+ if res0.Type.String() != "reflect.Method" {
return
}
switch uint32(ft)<<16 | uint32(tt) {
default:
- gc.Fatalf("gmove %v -> %v", gc.Tconv(f.Type, gc.FmtLong), gc.Tconv(t.Type, gc.FmtLong))
+ gc.Fatalf("gmove %2v -> %2v", f.Type, t.Type)
/*
* integer copy and truncate
switch uint32(ft)<<16 | uint32(tt) {
default:
- gc.Fatalf("gmove %v -> %v", gc.Tconv(f.Type, gc.FmtLong), gc.Tconv(t.Type, gc.FmtLong))
+ gc.Fatalf("gmove %2v -> %2v", f.Type, t.Type)
/*
* integer copy and truncate
// otherwise handle and return.
switch uint32(ft)<<16 | uint32(tt) {
default:
- gc.Fatalf("gmove %v -> %v", gc.Tconv(f.Type, gc.FmtLong), gc.Tconv(t.Type, gc.FmtLong))
+ gc.Fatalf("gmove %2v -> %2v", f.Type, t.Type)
// integer copy and truncate
case gc.TINT8<<16 | gc.TINT8,