mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: allow spaces in types.(*Type).LinkString()
Go back to allowing spaces in types.(*Type).LinkSring(). Delve folks prefer that there are spaces in type names, if needed, since DWARF expects type names to be "a string representing the name as it appears in the source program". At this point, it doesn't necessarily seem worth having a separate function that removes spaces, only for use when printing the type names in a function/method instantiation. Most names of function/method instantiations will still not have spaces, since they most type args are named or builtin types. I confirmed that we are back to the original definition of LinkString(), except for some comment changes. Change-Id: Iab7143f659ddea4f099c6230cb134edf8aaef868 Reviewed-on: https://go-review.googlesource.com/c/go/+/355354 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
78d01be00b
commit
4fb2e1cb86
1 changed files with 9 additions and 36 deletions
|
|
@ -461,25 +461,15 @@ func tconv2(b *bytes.Buffer, t *Type, verb rune, mode fmtMode, visited map[*Type
|
|||
|
||||
case TINTER:
|
||||
if t.IsEmptyInterface() {
|
||||
if mode == fmtTypeID {
|
||||
b.WriteString("interface {}")
|
||||
} else {
|
||||
b.WriteString("interface {}")
|
||||
}
|
||||
break
|
||||
}
|
||||
if mode == fmtTypeID {
|
||||
b.WriteString("interface {")
|
||||
} else {
|
||||
b.WriteString("interface {")
|
||||
}
|
||||
for i, f := range t.AllMethods().Slice() {
|
||||
if i != 0 {
|
||||
b.WriteByte(';')
|
||||
}
|
||||
if mode != fmtTypeID {
|
||||
b.WriteByte(' ')
|
||||
}
|
||||
switch {
|
||||
case f.Sym == nil:
|
||||
// Check first that a symbol is defined for this type.
|
||||
|
|
@ -495,7 +485,7 @@ func tconv2(b *bytes.Buffer, t *Type, verb rune, mode fmtMode, visited map[*Type
|
|||
}
|
||||
tconv2(b, f.Type, 'S', mode, visited)
|
||||
}
|
||||
if t.AllMethods().Len() != 0 && mode != fmtTypeID {
|
||||
if t.AllMethods().Len() != 0 {
|
||||
b.WriteByte(' ')
|
||||
}
|
||||
b.WriteByte('}')
|
||||
|
|
@ -570,21 +560,15 @@ func tconv2(b *bytes.Buffer, t *Type, verb rune, mode fmtMode, visited map[*Type
|
|||
}
|
||||
b.WriteByte(byte(close))
|
||||
} else {
|
||||
if mode == fmtTypeID {
|
||||
b.WriteString("struct {")
|
||||
} else {
|
||||
b.WriteString("struct {")
|
||||
}
|
||||
for i, f := range t.Fields().Slice() {
|
||||
if i != 0 {
|
||||
b.WriteByte(';')
|
||||
}
|
||||
if mode != fmtTypeID {
|
||||
b.WriteByte(' ')
|
||||
}
|
||||
fldconv(b, f, 'L', mode, visited, funarg)
|
||||
}
|
||||
if t.NumFields() != 0 && mode != fmtTypeID {
|
||||
if t.NumFields() != 0 {
|
||||
b.WriteByte(' ')
|
||||
}
|
||||
b.WriteByte('}')
|
||||
|
|
@ -668,15 +652,8 @@ func fldconv(b *bytes.Buffer, f *Field, verb rune, mode fmtMode, visited map[*Ty
|
|||
|
||||
if name != "" {
|
||||
b.WriteString(name)
|
||||
if mode == fmtTypeID {
|
||||
// This is the one case where we can't omit the space, since
|
||||
// we need a separate between field name and type, so we use
|
||||
// "#" instead.
|
||||
b.WriteString("#")
|
||||
} else {
|
||||
b.WriteString(" ")
|
||||
}
|
||||
}
|
||||
|
||||
if f.IsDDD() {
|
||||
var et *Type
|
||||
|
|
@ -690,11 +667,7 @@ func fldconv(b *bytes.Buffer, f *Field, verb rune, mode fmtMode, visited map[*Ty
|
|||
}
|
||||
|
||||
if verb != 'S' && funarg == FunargNone && f.Note != "" {
|
||||
if mode != fmtTypeID {
|
||||
b.WriteString(" ")
|
||||
}
|
||||
// TODO: for fmtTypeID, we should possibly using %-quoting, so
|
||||
// space is %20, etc.
|
||||
b.WriteString(strconv.Quote(f.Note))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue