diff --git a/internal/runtime/z_face.go b/internal/runtime/z_face.go index 333738d7..6b007402 100644 --- a/internal/runtime/z_face.go +++ b/internal/runtime/z_face.go @@ -487,7 +487,7 @@ func interfaceStr(ft *abi.InterfaceType) string { repr = append(repr, "interface {"...) for i, t := range ft.Methods { if i > 0 { - repr = append(repr, "; "...) + repr = append(repr, ';') } repr = append(repr, ' ') repr = append(repr, t.Name_...) diff --git a/internal/runtime/z_type.go b/internal/runtime/z_type.go index f46fbe29..24fc4222 100644 --- a/internal/runtime/z_type.go +++ b/internal/runtime/z_type.go @@ -153,7 +153,7 @@ func Struct(pkgPath string, size uintptr, fields ...abi.StructField) *Type { Size_: size, Hash: uint32(abi.Struct), // TODO(xsw): hash Kind_: uint8(abi.Struct), - Str_: "struct {...}", + Str_: structStr(fields), }, PkgPath_: pkgPath, Fields: fields, @@ -401,6 +401,27 @@ func ispaddedfield(st *structtype, i int) bool { 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 { types []*abi.Type }