case OAS2:
if n.Colas && !complexinit {
- fmt.Fprintf(s, "%v := %v", hconv(n.List, FmtComma), hconv(n.Rlist, FmtComma))
+ fmt.Fprintf(s, "%.v := %.v", n.List, n.Rlist)
break
}
fallthrough
case OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV:
- fmt.Fprintf(s, "%v = %v", hconv(n.List, FmtComma), hconv(n.Rlist, FmtComma))
+ fmt.Fprintf(s, "%.v = %.v", n.List, n.Rlist)
case ORETURN:
- fmt.Fprintf(s, "return %v", hconv(n.List, FmtComma))
+ fmt.Fprintf(s, "return %.v", n.List)
case ORETJMP:
fmt.Fprintf(s, "retjmp %v", n.Sym)
break
}
- fmt.Fprintf(s, "for %v = range %v { %v }", hconv(n.List, FmtComma), n.Right, n.Nbody)
+ fmt.Fprintf(s, "for %.v = range %v { %v }", n.List, n.Right, n.Nbody)
case OSELECT, OSWITCH:
if fmtmode == FErr {
case OXCASE:
if n.List.Len() != 0 {
- fmt.Fprintf(s, "case %v", hconv(n.List, FmtComma))
+ fmt.Fprintf(s, "case %.v", n.List)
} else {
fmt.Fprint(s, "default")
}
return
}
- fmt.Fprintf(s, "(%v{ %v })", n.Right, hconv(n.List, FmtComma))
+ fmt.Fprintf(s, "(%v{ %.v })", n.Right, n.List)
return
case OPTRLIT:
fmt.Fprintf(s, "%v literal", n.Type)
return
}
- fmt.Fprintf(s, "(%v{ %v })", n.Type, hconv(n.List, FmtComma))
+ fmt.Fprintf(s, "(%v{ %.v })", n.Type, n.List)
return
case OKEY:
fmt.Fprintf(s, "%v(%v)", n.Type, n.Left)
return
}
- fmt.Fprintf(s, "%v(%v)", n.Type, hconv(n.List, FmtComma))
+ fmt.Fprintf(s, "%v(%.v)", n.Type, n.List)
return
case OREAL,
return
}
if n.Isddd {
- fmt.Fprintf(s, "%#v(%v...)", n.Op, hconv(n.List, FmtComma))
+ fmt.Fprintf(s, "%#v(%.v...)", n.Op, n.List)
return
}
- fmt.Fprintf(s, "%#v(%v)", n.Op, hconv(n.List, FmtComma))
+ fmt.Fprintf(s, "%#v(%.v)", n.Op, n.List)
return
case OCALL, OCALLFUNC, OCALLINTER, OCALLMETH, OGETG:
n.Left.exprfmt(s, nprec)
if n.Isddd {
- fmt.Fprintf(s, "(%v...)", hconv(n.List, FmtComma))
+ fmt.Fprintf(s, "(%.v...)", n.List)
return
}
- fmt.Fprintf(s, "(%v)", hconv(n.List, FmtComma))
+ fmt.Fprintf(s, "(%.v)", n.List)
return
case OMAKEMAP, OMAKECHAN, OMAKESLICE:
if n.List.Len() != 0 { // pre-typecheck
- fmt.Fprintf(s, "make(%v, %v)", n.Type, hconv(n.List, FmtComma))
+ fmt.Fprintf(s, "make(%v, %.v)", n.Type, n.List)
return
}
if n.Right != nil {
fmtmode = sm
}
-func (n Nodes) Print(p *printer) {
- p.hconv(n, 0)
-}
+func (l Nodes) Format(s fmt.State, format rune) {
+ switch format {
+ case 's', 'v':
+ l.hconv(s)
-var _ Printable = Nodes{} // verify that Nodes implements Printable
+ default:
+ fmt.Fprintf(s, "%%!%c(Nodes)", format)
+ }
+}
func (n Nodes) String() string {
- return hconv(n, 0)
+ return fmt.Sprint(n)
}
// Fmt '%H': Nodes.
// Flags: all those of %N plus ',': separate with comma's instead of semicolons.
-func hconv(l Nodes, flag FmtFlag) string {
- return new(printer).hconv(l, flag).String()
-}
+func (l Nodes) hconv(s fmt.State) {
+ flag := fmtFlag(s)
-func (p *printer) hconv(l Nodes, flag FmtFlag) *printer {
if l.Len() == 0 && fmtmode == FDbg {
- return p.s("<nil>")
+ fmt.Fprint(s, "<nil>")
+ return
}
sf := flag
}
for i, n := range l.Slice() {
- p.f("%v", n)
+ fmt.Fprint(s, n)
if i+1 < l.Len() {
- p.s(sep)
+ fmt.Fprint(s, sep)
}
}
flag = sf
fmtmode = sm
-
- return p
}
func dumplist(s string, l Nodes) {
- fmt.Printf("%s%v\n", s, hconv(l, FmtSign))
+ fmt.Printf("%s%+v\n", s, l)
}
func Dump(s string, n *Node) {
}
if Debug['m'] > 2 || Debug_export != 0 {
- fmt.Printf("typecheck import [%v] %2v { %v }\n", fn.Sym, fn, hconv(fn.Func.Inl, FmtSharp))
+ fmt.Printf("typecheck import [%v] %2v { %#v }\n", fn.Sym, fn, fn.Func.Inl)
}
save_safemode := safemode
fn.Type.SetNname(n)
if Debug['m'] > 1 {
- fmt.Printf("%v: can inline %#v as: %#v { %v }\n", fn.Line(), n, fn.Type, hconv(n.Func.Inl, FmtSharp))
+ fmt.Printf("%v: can inline %#v as: %#v { %#v }\n", fn.Line(), n, fn.Type, n.Func.Inl)
} else if Debug['m'] != 0 {
fmt.Printf("%v: can inline %v\n", fn.Line(), n)
}
// 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, fn.Type, hconv(fn.Func.Inl, FmtSharp))
+ fmt.Printf("%v: inlining call to %v %#v { %#v }\n", n.Line(), fn.Sym, fn.Type, fn.Func.Inl)
} 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", fn.Type.Params(), hconv(n.List, FmtComma))
+ Fatalf("arg count mismatch: %#v vs %.v\n", fn.Type.Params(), n.List)
}
}