dumpexporttype(t)
if t != nil && !t.IsUntyped() {
- exportf("\tconst %v %v = %v\n", Sconv(s, FmtSharp), Tconv(t, FmtSharp), Vconv(n.Val(), 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, FmtSharp), Vconv(n.Val(), FmtSharp))
+ exportf("\tconst %v = %v\n", sconv(s, FmtSharp), vconv(n.Val(), FmtSharp))
}
}
}
// NOTE: The space after %#S here is necessary for ld's export data parser.
- exportf("\tfunc %v %v { %v }\n", Sconv(s, FmtSharp), Tconv(t, FmtShort|FmtSharp), Hconv(n.Func.Inl, FmtSharp|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, FmtSharp), Tconv(t, FmtShort|FmtSharp))
+ exportf("\tfunc %v %v\n", sconv(s, FmtSharp), Tconv(t, FmtShort|FmtSharp))
}
} else {
- exportf("\tvar %v %v\n", Sconv(s, FmtSharp), Tconv(t, FmtSharp))
+ exportf("\tvar %v %v\n", sconv(s, FmtSharp), Tconv(t, FmtSharp))
}
}
}
sort.Sort(methodbyname(m))
- exportf("\ttype %v %v\n", Sconv(t.Sym, FmtSharp), Tconv(t, FmtSharp|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")
if Debug['l'] < 2 {
typecheckinl(f.Type.Nname())
}
- 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|FmtBody))
+ 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|FmtBody))
reexportdeplist(f.Type.Nname().Func.Inl)
} else {
- exportf("\tfunc %v %v %v\n", Tconv(f.Type.Recvs(), FmtSharp), Sconv(f.Sym, FmtShort|FmtByte|FmtSharp), Tconv(f.Type, FmtShort|FmtSharp))
+ exportf("\tfunc %v %v %v\n", Tconv(f.Type.Recvs(), FmtSharp), sconv(f.Sym, FmtShort|FmtByte|FmtSharp), Tconv(f.Type, FmtShort|FmtSharp))
}
}
}
}
switch n.Op {
case OLITERAL:
- fmt.Fprintf(b, "#define const_%s %v\n", n.Sym.Name, Vconv(n.Val(), FmtSharp))
+ fmt.Fprintf(b, "#define const_%s %v\n", n.Sym.Name, vconv(n.Val(), FmtSharp))
case OTYPE:
t := n.Type
}
// Fmt "%J": Node details.
-func Jconv(n *Node, flag FmtFlag) string {
+func jconv(n *Node, flag FmtFlag) string {
var buf bytes.Buffer
c := flag & FmtShort
}
// Fmt "%V": Values
-func Vconv(v Val, flag FmtFlag) string {
+func vconv(v Val, flag FmtFlag) string {
switch u := v.U.(type) {
case *Mpint:
if !u.Rune {
if (flag&FmtSharp != 0) || fmtmode == FExp {
- return Bconv(u, FmtSharp)
+ return bconv(u, FmtSharp)
}
- return Bconv(u, 0)
+ return bconv(u, 0)
}
x := u.Int64()
case *Mpflt:
if (flag&FmtSharp != 0) || fmtmode == FExp {
- return Fconv(u, 0)
+ return fconv(u, 0)
}
- return Fconv(u, FmtSharp)
+ return fconv(u, FmtSharp)
case *Mpcplx:
if (flag&FmtSharp != 0) || fmtmode == FExp {
return fmt.Sprintf("(%v+%vi)", &u.Real, &u.Imag)
}
if v.U.(*Mpcplx).Real.CmpFloat64(0) == 0 {
- return fmt.Sprintf("%vi", Fconv(&u.Imag, FmtSharp))
+ return fmt.Sprintf("%vi", fconv(&u.Imag, FmtSharp))
}
if v.U.(*Mpcplx).Imag.CmpFloat64(0) == 0 {
- return Fconv(&u.Real, FmtSharp)
+ return fconv(&u.Real, FmtSharp)
}
if v.U.(*Mpcplx).Imag.CmpFloat64(0) < 0 {
- return fmt.Sprintf("(%v%vi)", Fconv(&u.Real, FmtSharp), Fconv(&u.Imag, FmtSharp))
+ return fmt.Sprintf("(%v%vi)", fconv(&u.Real, FmtSharp), fconv(&u.Imag, FmtSharp))
}
- return fmt.Sprintf("(%v+%vi)", Fconv(&u.Real, FmtSharp), Fconv(&u.Imag, FmtSharp))
+ return fmt.Sprintf("(%v+%vi)", fconv(&u.Real, FmtSharp), fconv(&u.Imag, FmtSharp))
case string:
return strconv.Quote(u)
TDDDFIELD: "TDDDFIELD",
}
-// Fmt "%E": etype
-func Econv(et EType) string {
+func (et EType) String() string {
if int(et) < len(etnames) && etnames[et] != "" {
return etnames[et]
}
return fmt.Sprintf("E-%d", et)
}
-func (e EType) String() string {
- return Econv(e)
-}
-
// Fmt "%S": syms
func symfmt(s *Sym, flag FmtFlag) string {
if s.Pkg != nil && flag&FmtShort == 0 {
if t == bytetype || t == runetype {
// in %-T mode collapse rune and byte with their originals.
if fmtmode != FTypeId {
- return Sconv(t.Sym, FmtShort)
+ return sconv(t.Sym, FmtShort)
}
t = Types[t.Etype]
}
case FTypeId:
if flag&FmtShort != 0 {
if t.Vargen != 0 {
- return fmt.Sprintf("%v·%d", Sconv(t.Sym, FmtShort), t.Vargen)
+ return fmt.Sprintf("%v·%d", sconv(t.Sym, FmtShort), t.Vargen)
}
- return Sconv(t.Sym, FmtShort)
+ return sconv(t.Sym, FmtShort)
}
if flag&FmtUnsigned != 0 {
- return Sconv(t.Sym, FmtUnsigned)
+ return sconv(t.Sym, FmtUnsigned)
}
fallthrough
}
}
- return Sconv(t.Sym, 0)
+ return sconv(t.Sym, 0)
}
if int(t.Etype) < len(basicnames) && basicnames[t.Etype] != "" {
// Wrong interface definitions may have types lacking a symbol.
break
case exportname(f.Sym.Name):
- buf.WriteString(Sconv(f.Sym, FmtShort))
+ buf.WriteString(sconv(f.Sym, FmtShort))
default:
- buf.WriteString(Sconv(f.Sym, FmtUnsigned))
+ buf.WriteString(sconv(f.Sym, FmtUnsigned))
}
buf.WriteString(Tconv(f.Type, FmtShort))
}
case OAS2:
if n.Colas && !complexinit {
- f += fmt.Sprintf("%v := %v", Hconv(n.List, FmtComma), Hconv(n.Rlist, FmtComma))
+ f += fmt.Sprintf("%v := %v", hconv(n.List, FmtComma), hconv(n.Rlist, FmtComma))
break
}
fallthrough
case OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV:
- f += fmt.Sprintf("%v = %v", Hconv(n.List, FmtComma), Hconv(n.Rlist, FmtComma))
+ f += fmt.Sprintf("%v = %v", hconv(n.List, FmtComma), hconv(n.Rlist, FmtComma))
case ORETURN:
- f += fmt.Sprintf("return %v", Hconv(n.List, FmtComma))
+ f += fmt.Sprintf("return %v", hconv(n.List, FmtComma))
case ORETJMP:
f += fmt.Sprintf("retjmp %v", n.Sym)
break
}
- f += fmt.Sprintf("for %v = range %v { %v }", Hconv(n.List, FmtComma), n.Right, n.Nbody)
+ f += fmt.Sprintf("for %v = range %v { %v }", hconv(n.List, FmtComma), n.Right, n.Nbody)
case OSELECT, OSWITCH:
if fmtmode == FErr {
case OCASE, OXCASE:
if n.List.Len() != 0 {
- f += fmt.Sprintf("case %v: %v", Hconv(n.List, FmtComma), n.Nbody)
+ f += fmt.Sprintf("case %v: %v", hconv(n.List, FmtComma), n.Nbody)
} else {
f += fmt.Sprintf("default: %v", n.Nbody)
}
return exprfmt(n.Orig, prec)
}
if n.Sym != nil {
- return Sconv(n.Sym, 0)
+ return sconv(n.Sym, 0)
}
}
if n.Val().Ctype() == CTNIL && n.Orig != nil && n.Orig != n {
// Need parens when type begins with what might
// be misinterpreted as a unary operator: * or <-.
if n.Type.IsPtr() || (n.Type.IsChan() && n.Type.ChanDir() == Crecv) {
- return fmt.Sprintf("(%v)(%v)", n.Type, Vconv(n.Val(), 0))
+ return fmt.Sprintf("(%v)(%v)", n.Type, vconv(n.Val(), 0))
} else {
- return fmt.Sprintf("%v(%v)", n.Type, Vconv(n.Val(), 0))
+ return fmt.Sprintf("%v(%v)", n.Type, vconv(n.Val(), 0))
}
}
- return Vconv(n.Val(), 0)
+ return vconv(n.Val(), 0)
// Special case: name used as local variable in export.
// _ becomes ~b%d internally; print as _ for export
// These nodes have the special property that they are names with a left OTYPE and a right ONAME.
if fmtmode == FExp && n.Left != nil && n.Left.Op == OTYPE && n.Right != nil && n.Right.Op == ONAME {
if n.Left.Type.IsPtr() {
- return fmt.Sprintf("(%v).%v", n.Left.Type, Sconv(n.Right.Sym, FmtShort|FmtByte))
+ return fmt.Sprintf("(%v).%v", n.Left.Type, sconv(n.Right.Sym, FmtShort|FmtByte))
} else {
- return fmt.Sprintf("%v.%v", n.Left.Type, Sconv(n.Right.Sym, FmtShort|FmtByte))
+ return fmt.Sprintf("%v.%v", n.Left.Type, sconv(n.Right.Sym, FmtShort|FmtByte))
}
}
fallthrough
case OPACK, ONONAME:
- return Sconv(n.Sym, 0)
+ return sconv(n.Sym, 0)
case OTYPE:
if n.Type == nil && n.Sym != nil {
- return Sconv(n.Sym, 0)
+ return sconv(n.Sym, 0)
}
return Tconv(n.Type, 0)
if fmtmode == FExp && ptrlit {
// typecheck has overwritten OIND by OTYPE with pointer type.
- return fmt.Sprintf("(&%v{ %v })", n.Right.Type.Elem(), Hconv(n.List, FmtComma))
+ return fmt.Sprintf("(&%v{ %v })", n.Right.Type.Elem(), hconv(n.List, FmtComma))
}
- return fmt.Sprintf("(%v{ %v })", n.Right, Hconv(n.List, FmtComma))
+ return fmt.Sprintf("(%v{ %v })", n.Right, hconv(n.List, FmtComma))
case OPTRLIT:
if fmtmode == FExp && n.Left.Implicit {
f += fmt.Sprintf("(%v{", n.Type)
}
for i1, n1 := range n.List.Slice() {
- f += fmt.Sprintf(" %v:%v", Sconv(n1.Left.Sym, FmtShort|FmtByte), n1.Right)
+ f += fmt.Sprintf(" %v:%v", sconv(n1.Left.Sym, FmtShort|FmtByte), n1.Right)
if i1+1 < n.List.Len() {
f += ","
return fmt.Sprintf("%v literal", n.Type)
}
if fmtmode == FExp && n.Implicit {
- return fmt.Sprintf("{ %v }", Hconv(n.List, FmtComma))
+ return fmt.Sprintf("{ %v }", hconv(n.List, FmtComma))
}
- return fmt.Sprintf("(%v{ %v })", n.Type, Hconv(n.List, FmtComma))
+ return fmt.Sprintf("(%v{ %v })", n.Type, hconv(n.List, FmtComma))
case OKEY:
if n.Left != nil && n.Right != nil {
if fmtmode == FExp && n.Left.Type == structkey {
// requires special handling of field names
- return fmt.Sprintf("%v:%v", Sconv(n.Left.Sym, FmtShort|FmtByte), n.Right)
+ return fmt.Sprintf("%v:%v", sconv(n.Left.Sym, FmtShort|FmtByte), n.Right)
} else {
return fmt.Sprintf("%v:%v", n.Left, n.Right)
}
f += ".<nil>"
return f
}
- f += fmt.Sprintf(".%v", Sconv(n.Right.Sym, FmtShort|FmtByte))
+ f += fmt.Sprintf(".%v", sconv(n.Right.Sym, FmtShort|FmtByte))
return f
case OXDOT, ODOT, ODOTPTR, ODOTINTER, ODOTMETH:
f += ".<nil>"
return f
}
- f += fmt.Sprintf(".%v", Sconv(n.Sym, FmtShort|FmtByte))
+ f += fmt.Sprintf(".%v", sconv(n.Sym, FmtShort|FmtByte))
return f
case ODOTTYPE, ODOTTYPE2:
if n.Left != nil {
return fmt.Sprintf("%v(%v)", n.Type, n.Left)
}
- return fmt.Sprintf("%v(%v)", n.Type, Hconv(n.List, FmtComma))
+ return fmt.Sprintf("%v(%v)", n.Type, hconv(n.List, FmtComma))
case OREAL,
OIMAG,
return fmt.Sprintf("%#v(%v)", n.Op, n.Left)
}
if n.Isddd {
- return fmt.Sprintf("%#v(%v...)", n.Op, Hconv(n.List, FmtComma))
+ return fmt.Sprintf("%#v(%v...)", n.Op, hconv(n.List, FmtComma))
}
- return fmt.Sprintf("%#v(%v)", n.Op, Hconv(n.List, FmtComma))
+ return fmt.Sprintf("%#v(%v)", n.Op, hconv(n.List, FmtComma))
case OCALL, OCALLFUNC, OCALLINTER, OCALLMETH, OGETG:
var f string
f += exprfmt(n.Left, nprec)
if n.Isddd {
- f += fmt.Sprintf("(%v...)", Hconv(n.List, FmtComma))
+ f += fmt.Sprintf("(%v...)", hconv(n.List, FmtComma))
return f
}
- f += fmt.Sprintf("(%v)", Hconv(n.List, FmtComma))
+ f += fmt.Sprintf("(%v)", hconv(n.List, FmtComma))
return f
case OMAKEMAP, OMAKECHAN, OMAKESLICE:
if n.List.Len() != 0 { // pre-typecheck
- return fmt.Sprintf("make(%v, %v)", n.Type, Hconv(n.List, FmtComma))
+ return fmt.Sprintf("make(%v, %v)", n.Type, hconv(n.List, FmtComma))
}
if n.Right != nil {
return fmt.Sprintf("make(%v, %v, %v)", n.Type, n.Left, n.Right)
switch n.Op {
default:
- fmt.Fprintf(&buf, "%v%v", n.Op, Jconv(n, 0))
+ fmt.Fprintf(&buf, "%v%v", n.Op, jconv(n, 0))
case OREGISTER, OINDREG:
- fmt.Fprintf(&buf, "%v-%v%v", n.Op, obj.Rconv(int(n.Reg)), Jconv(n, 0))
+ fmt.Fprintf(&buf, "%v-%v%v", n.Op, obj.Rconv(int(n.Reg)), jconv(n, 0))
case OLITERAL:
- fmt.Fprintf(&buf, "%v-%v%v", n.Op, Vconv(n.Val(), 0), Jconv(n, 0))
+ fmt.Fprintf(&buf, "%v-%v%v", n.Op, vconv(n.Val(), 0), jconv(n, 0))
case ONAME, ONONAME:
if n.Sym != nil {
- fmt.Fprintf(&buf, "%v-%v%v", n.Op, n.Sym, Jconv(n, 0))
+ fmt.Fprintf(&buf, "%v-%v%v", n.Op, n.Sym, jconv(n, 0))
} else {
- fmt.Fprintf(&buf, "%v%v", n.Op, Jconv(n, 0))
+ fmt.Fprintf(&buf, "%v%v", n.Op, jconv(n, 0))
}
if recur && n.Type == nil && n.Name != nil && n.Name.Param != nil && n.Name.Param.Ntype != nil {
indent(&buf)
}
case OASOP:
- fmt.Fprintf(&buf, "%v-%v%v", n.Op, Op(n.Etype), Jconv(n, 0))
+ fmt.Fprintf(&buf, "%v-%v%v", n.Op, Op(n.Etype), jconv(n, 0))
case OTYPE:
- fmt.Fprintf(&buf, "%v %v%v type=%v", n.Op, n.Sym, Jconv(n, 0), n.Type)
+ fmt.Fprintf(&buf, "%v %v%v type=%v", n.Op, n.Sym, jconv(n, 0), n.Type)
if recur && n.Type == nil && n.Name.Param.Ntype != nil {
indent(&buf)
fmt.Fprintf(&buf, "%v-ntype%v", n.Op, n.Name.Param.Ntype)
}
func (s *Sym) String() string {
- return Sconv(s, 0)
+ return sconv(s, 0)
}
// Fmt "%S": syms
// Flags: "%hS" suppresses qualifying with package
-func Sconv(s *Sym, flag FmtFlag) string {
+func sconv(s *Sym, flag FmtFlag) string {
if flag&FmtLong != 0 {
panic("linksymfmt")
}
if f.Funarg {
name = Nconv(f.Nname, 0)
} else if flag&FmtLong != 0 {
- name = Sconv(s, FmtShort|FmtByte) // qualify non-exported names (used on structs, not on funarg)
+ name = sconv(s, FmtShort|FmtByte) // qualify non-exported names (used on structs, not on funarg)
} else {
- name = Sconv(s, 0)
+ name = sconv(s, 0)
}
} else if fmtmode == FExp {
if f.Embedded != 0 && s.Pkg != nil && len(s.Pkg.Path) > 0 {
}
func (n Nodes) String() string {
- return Hconv(n, 0)
+ return hconv(n, 0)
}
// Fmt '%H': Nodes.
// Flags: all those of %N plus ',': separate with comma's instead of semicolons.
-func Hconv(l Nodes, flag FmtFlag) string {
+func hconv(l Nodes, flag FmtFlag) string {
if l.Len() == 0 && fmtmode == FDbg {
return "<nil>"
}
}
func dumplist(s string, l Nodes) {
- fmt.Printf("%s%v\n", s, Hconv(l, FmtSign))
+ fmt.Printf("%s%v\n", s, hconv(l, FmtSign))
}
func Dump(s string, n *Node) {