mirror of
https://github.com/golang/go
synced 2024-11-18 16:54:43 -07:00
cmd/internal/gc: add String methods to *Mpint, *Mpflt, *Node, *NodeList, *Sym, *Type
The next CL will remove unnecessary conv calls. Change-Id: I0e8dbd1756cdec1ef6095ae67629cd3fae0fb4a4 Reviewed-on: https://go-review.googlesource.com/9031 Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
8e5346571c
commit
96c91fa9db
@ -1591,6 +1591,10 @@ func nodedump(n *Node, flag int) string {
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func (s *Sym) String() string {
|
||||
return Sconv(s, 0)
|
||||
}
|
||||
|
||||
// Fmt "%S": syms
|
||||
// Flags: "%hS" suppresses qualifying with package
|
||||
func Sconv(s *Sym, flag int) string {
|
||||
@ -1616,6 +1620,10 @@ func Sconv(s *Sym, flag int) string {
|
||||
return str
|
||||
}
|
||||
|
||||
func (t *Type) String() string {
|
||||
return Tconv(t, 0)
|
||||
}
|
||||
|
||||
// Fmt "%T": types.
|
||||
// Flags: 'l' print definition, not name
|
||||
// 'h' omit 'func' and receiver from function types, short type names
|
||||
@ -1654,6 +1662,10 @@ func Tconv(t *Type, flag int) string {
|
||||
return str
|
||||
}
|
||||
|
||||
func (n *Node) String() string {
|
||||
return Nconv(n, 0)
|
||||
}
|
||||
|
||||
// Fmt '%N': Nodes.
|
||||
// Flags: 'l' suffix with "(type %T)" where possible
|
||||
// '+h' in debug mode, don't recurse, no multiline output
|
||||
@ -1685,6 +1697,10 @@ func Nconv(n *Node, flag int) string {
|
||||
return str
|
||||
}
|
||||
|
||||
func (l *NodeList) String() string {
|
||||
return Hconv(l, 0)
|
||||
}
|
||||
|
||||
// Fmt '%H': NodeList.
|
||||
// Flags: all those of %N plus ',': separate with comma's instead of semicolons.
|
||||
func Hconv(l *NodeList, flag int) string {
|
||||
|
@ -288,6 +288,10 @@ func mpatofix(a *Mpint, as string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Mpint) String() string {
|
||||
return Bconv(x, 0)
|
||||
}
|
||||
|
||||
func Bconv(xval *Mpint, flag int) string {
|
||||
if flag&obj.FmtSharp != 0 {
|
||||
return fmt.Sprintf("%#x", &xval.Val)
|
||||
|
@ -184,6 +184,10 @@ func mpatoflt(a *Mpflt, as string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (f *Mpflt) String() string {
|
||||
return Fconv(f, 0)
|
||||
}
|
||||
|
||||
func Fconv(fvp *Mpflt, flag int) string {
|
||||
if flag&obj.FmtSharp == 0 {
|
||||
return fvp.Val.Format('b', 0)
|
||||
|
Loading…
Reference in New Issue
Block a user