internal/runtime: structStr
This commit is contained in:
@@ -487,7 +487,7 @@ func interfaceStr(ft *abi.InterfaceType) string {
|
|||||||
repr = append(repr, "interface {"...)
|
repr = append(repr, "interface {"...)
|
||||||
for i, t := range ft.Methods {
|
for i, t := range ft.Methods {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
repr = append(repr, "; "...)
|
repr = append(repr, ';')
|
||||||
}
|
}
|
||||||
repr = append(repr, ' ')
|
repr = append(repr, ' ')
|
||||||
repr = append(repr, t.Name_...)
|
repr = append(repr, t.Name_...)
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ func Struct(pkgPath string, size uintptr, fields ...abi.StructField) *Type {
|
|||||||
Size_: size,
|
Size_: size,
|
||||||
Hash: uint32(abi.Struct), // TODO(xsw): hash
|
Hash: uint32(abi.Struct), // TODO(xsw): hash
|
||||||
Kind_: uint8(abi.Struct),
|
Kind_: uint8(abi.Struct),
|
||||||
Str_: "struct {...}",
|
Str_: structStr(fields),
|
||||||
},
|
},
|
||||||
PkgPath_: pkgPath,
|
PkgPath_: pkgPath,
|
||||||
Fields: fields,
|
Fields: fields,
|
||||||
@@ -401,6 +401,27 @@ func ispaddedfield(st *structtype, i int) bool {
|
|||||||
return fd.Offset+fd.Typ.Size_ != end
|
return fd.Offset+fd.Typ.Size_ != end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func structStr(fields []abi.StructField) string {
|
||||||
|
repr := make([]byte, 0, 64)
|
||||||
|
repr = append(repr, "struct {"...)
|
||||||
|
for i, st := range fields {
|
||||||
|
if i > 0 {
|
||||||
|
repr = append(repr, ';')
|
||||||
|
}
|
||||||
|
repr = append(repr, ' ')
|
||||||
|
if !st.Embedded_ {
|
||||||
|
repr = append(repr, st.Name_...)
|
||||||
|
repr = append(repr, ' ')
|
||||||
|
}
|
||||||
|
repr = append(repr, st.Typ.String()...)
|
||||||
|
}
|
||||||
|
if len(fields) > 0 {
|
||||||
|
repr = append(repr, ' ')
|
||||||
|
}
|
||||||
|
repr = append(repr, '}')
|
||||||
|
return string(repr)
|
||||||
|
}
|
||||||
|
|
||||||
type rtypes struct {
|
type rtypes struct {
|
||||||
types []*abi.Type
|
types []*abi.Type
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user