return
}
fmt.Fprint(s, "*"+t.Elem().String())
- return
case TARRAY:
if t.isDDDArray() {
return
}
fmt.Fprintf(s, "[%d]%v", t.NumElem(), t.Elem())
- return
case TSLICE:
fmt.Fprint(s, "[]"+t.Elem().String())
- return
case TCHAN:
switch t.ChanDir() {
return
}
fmt.Fprint(s, "chan "+t.Elem().String())
- return
case TMAP:
fmt.Fprint(s, "map["+t.Key().String()+"]"+t.Val().String())
- return
case TINTER:
fmt.Fprint(s, "interface {")
fmt.Fprint(s, " ")
}
fmt.Fprint(s, "}")
- return
case TFUNC:
if flag&FmtShort != 0 {
default:
fmt.Fprintf(s, " %v", t.Results())
}
- return
case TSTRUCT:
if m := t.StructType().Map; m != nil {
}
fmt.Fprint(s, "}")
}
- return
case TFORW:
if t.Sym != nil {
return
}
fmt.Fprint(s, "undefined")
- return
case TUNSAFEPTR:
fmt.Fprint(s, "unsafe.Pointer")
- return
case TDDDFIELD:
fmt.Fprintf(s, "%v <%v> %v", t.Etype, t.Sym, t.DDDField())
- return
case Txxx:
fmt.Fprint(s, "Txxx")
- return
- }
- // Don't know how to handle - fall back to detailed prints.
- fmt.Fprintf(s, "%v <%v> %v", t.Etype, t.Sym, t.Elem())
+ default:
+ // Don't know how to handle - fall back to detailed prints.
+ fmt.Fprintf(s, "%v <%v> %v", t.Etype, t.Sym, t.Elem())
+ }
}
// Statements which may be rendered with a simplestmt as init.
switch n.Op {
case OPAREN:
fmt.Fprintf(s, "(%v)", n.Left)
- return
case ODDDARG:
fmt.Fprint(s, "... argument")
- return
case OREGISTER:
fmt.Fprint(s, obj.Rconv(int(n.Reg)))
- return
case OLITERAL: // this is a bit of a mess
if fmtmode == FErr {
}
fmt.Fprintf(s, "%s", n.Val())
- return
// Special case: name used as local variable in export.
// _ becomes ~b%d internally; print as _ for export
return
}
fallthrough
-
case OPACK, ONONAME:
fmt.Fprint(s, n.Sym.String())
- return
case OTYPE:
if n.Type == nil && n.Sym != nil {
return
}
fmt.Fprintf(s, "%v", n.Type)
- return
case OTARRAY:
if n.Left != nil {
return
}
fmt.Fprintf(s, "[]%v", n.Right) // happens before typecheck
- return
case OTMAP:
fmt.Fprintf(s, "map[%v]%v", n.Left, n.Right)
- return
case OTCHAN:
switch ChanDir(n.Etype) {
case Crecv:
fmt.Fprintf(s, "<-chan %v", n.Left)
- return
case Csend:
fmt.Fprintf(s, "chan<- %v", n.Left)
- return
default:
if n.Left != nil && n.Left.Op == OTCHAN && n.Left.Sym == nil && ChanDir(n.Left.Etype) == Crecv {
fmt.Fprintf(s, "chan (%v)", n.Left)
- return
} else {
fmt.Fprintf(s, "chan %v", n.Left)
- return
}
}
case OTSTRUCT:
fmt.Fprint(s, "<struct>")
- return
case OTINTER:
fmt.Fprint(s, "<inter>")
- return
case OTFUNC:
fmt.Fprint(s, "<func>")
- return
case OCLOSURE:
if fmtmode == FErr {
return
}
fmt.Fprintf(s, "%v { %v }", n.Type, n.Func.Closure.Nbody)
- return
case OCOMPLIT:
ptrlit := n.Right != nil && n.Right.Implicit && n.Right.Type != nil && n.Right.Type.IsPtr()
fmt.Fprint(s, "composite literal")
return
}
-
fmt.Fprintf(s, "(%v{ %.v })", n.Right, n.List)
- return
case OPTRLIT:
fmt.Fprintf(s, "&%v", n.Left)
- return
case OSTRUCTLIT, OARRAYLIT, OSLICELIT, OMAPLIT:
if fmtmode == FErr {
return
}
fmt.Fprintf(s, "(%v{ %.v })", n.Type, n.List)
- return
case OKEY:
if n.Left != nil && n.Right != nil {
return
}
fmt.Fprint(s, ":")
- return
case OCALLPART:
n.Left.exprfmt(s, nprec)
return
}
fmt.Fprintf(s, ".%01v", n.Right.Sym)
- return
case OXDOT, ODOT, ODOTPTR, ODOTINTER, ODOTMETH:
n.Left.exprfmt(s, nprec)
return
}
fmt.Fprintf(s, ".%01v", n.Sym)
- return
case ODOTTYPE, ODOTTYPE2:
n.Left.exprfmt(s, nprec)
return
}
fmt.Fprintf(s, ".(%v)", n.Type)
- return
case OINDEX, OINDEXMAP:
n.Left.exprfmt(s, nprec)
fmt.Fprintf(s, "[%v]", n.Right)
- return
case OSLICE, OSLICESTR, OSLICEARR, OSLICE3, OSLICE3ARR:
n.Left.exprfmt(s, nprec)
}
}
fmt.Fprint(s, "]")
- return
case OCOPY, OCOMPLEX:
fmt.Fprintf(s, "%#v(%v, %v)", n.Op, n.Left, n.Right)
- return
case OCONV,
OCONVIFACE,
return
}
fmt.Fprintf(s, "%v(%.v)", n.Type, n.List)
- return
case OREAL,
OIMAG,
return
}
fmt.Fprintf(s, "%#v(%.v)", n.Op, n.List)
- return
case OCALL, OCALLFUNC, OCALLINTER, OCALLMETH, OGETG:
n.Left.exprfmt(s, nprec)
return
}
fmt.Fprintf(s, "(%.v)", n.List)
- return
case OMAKEMAP, OMAKECHAN, OMAKESLICE:
if n.List.Len() != 0 { // pre-typecheck
return
}
fmt.Fprintf(s, "make(%v)", n.Type)
- return
// Unary
case OPLUS,
fmt.Fprint(s, " ")
}
n.Left.exprfmt(s, nprec+1)
- return
// Binary
case OADD,
n.Left.exprfmt(s, nprec)
fmt.Fprintf(s, " %#v ", n.Op)
n.Right.exprfmt(s, nprec+1)
- return
case OADDSTR:
i := 0
n1.exprfmt(s, nprec)
i++
}
- return
case OCMPSTR, OCMPIFACE:
n.Left.exprfmt(s, nprec)
// TODO(marvin): Fix Node.EType type union.
fmt.Fprintf(s, " %#v ", Op(n.Etype))
n.Right.exprfmt(s, nprec+1)
- return
- }
- fmt.Fprintf(s, "<node %v>", n.Op)
+ default:
+ fmt.Fprintf(s, "<node %v>", n.Op)
+ }
}
func (n *Node) nodefmt(s fmt.State, flag FmtFlag) {