const (
tflagUncommon = 1 << 0
tflagExtraStar = 1 << 1
+ tflagNamed = 1 << 2
)
var dcommontype_algarray *Sym
if uncommonSize(t) != 0 {
tflag |= tflagUncommon
}
+ if t.Sym != nil && t.Sym.Name != "" {
+ tflag |= tflagNamed
+ }
exported := false
p := Tconv(t, FmtLeft|FmtUnsigned)
// a program, the type *T also exists and reusing the str data
// saves binary size.
tflagExtraStar tflag = 1 << 1
+
+ // tflagNamed means the type has a name.
+ tflagNamed tflag = 1 << 2
)
// rtype is the common implementation of most values.
}
func (t *rtype) Name() string {
- s := t.String()
- switch s[0] {
- case 'm':
- if hasPrefix(s, "map[") {
- return ""
- }
- case 's':
- if hasPrefix(s, "struct {") {
- return ""
- }
- case 'c':
- if hasPrefix(s, "chan ") {
- return ""
- }
- if hasPrefix(s, "chan<-") {
- return ""
- }
- case 'f':
- if hasPrefix(s, "func(") {
- return ""
- }
- case 'i':
- if hasPrefix(s, "interface {") {
- return ""
- }
- case '[', '*', '<':
+ if t.tflag&tflagNamed == 0 {
return ""
}
+ s := t.String()
i := len(s) - 1
for i >= 0 {
if s[i] == '.' {
const (
tflagUncommon tflag = 1 << 0
tflagExtraStar tflag = 1 << 1
+ tflagNamed tflag = 1 << 2
)
// Needs to be in sync with ../cmd/compile/internal/ld/decodesym.go:/^func.commonsize,
}
func (t *_type) name() string {
- s := t.string()
- if hasPrefix(s, "map[") {
- return ""
- }
- if hasPrefix(s, "struct {") {
- return ""
- }
- if hasPrefix(s, "chan ") {
- return ""
- }
- if hasPrefix(s, "chan<-") {
- return ""
- }
- if hasPrefix(s, "func(") {
- return ""
- }
- if hasPrefix(s, "interface {") {
- return ""
- }
- switch s[0] {
- case '[', '*', '<':
+ if t.tflag&tflagNamed == 0 {
return ""
}
+ s := t.string()
i := len(s) - 1
for i >= 0 {
if s[i] == '.' {