Skip to content

Commit 633ab74

Browse files
sbinetcrawshaw
authored andcommitted
reflect: implement StructOf
This change exposes a facility to create new struct types from a slice of reflect.StructFields. - reflect: first stab at implementing StructOf - reflect: tests for StructOf StructOf creates new struct types in the form of structTypeWithMethods to accomodate the GC (especially the uncommonType.methods slice field.) Creating struct types with embedded interfaces with unexported methods is not supported yet and will panic. Creating struct types with non-ASCII field names or types is not yet supported (see #15064.) Binaries' sizes for linux_amd64: old=tip (0104a31) old bytes new bytes delta bin/go 9911336 9915456 +0.04% reflect 781704 830048 +6.18% Updates #5748. Updates #15064. Change-Id: I3b8fd4fadd6ce3b1b922e284f0ae72a3a8e3ce44 Reviewed-on: https://go-review.googlesource.com/9251 Reviewed-by: David Crawshaw <[email protected]> Run-TryBot: David Crawshaw <[email protected]>
1 parent 014f3e1 commit 633ab74

File tree

3 files changed

+1043
-7
lines changed

3 files changed

+1043
-7
lines changed

src/cmd/compile/internal/gc/reflect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ ok:
13071307
// we want be able to find.
13081308
if t.Sym == nil {
13091309
switch t.Etype {
1310-
case TPTR32, TPTR64, TARRAY, TCHAN, TFUNC, TMAP:
1310+
case TPTR32, TPTR64, TARRAY, TCHAN, TFUNC, TMAP, TSTRUCT:
13111311
slink := typelinksym(t)
13121312
dsymptr(slink, 0, s, 0)
13131313
ggloblsym(slink, int32(Widthptr), int16(dupok|obj.RODATA))

0 commit comments

Comments
 (0)