]> Cypherpunks repositories - gostls13.git/commit
reflect: implement StructOf
authorSebastien Binet <seb.binet@gmail.com>
Sat, 5 Mar 2016 12:37:38 +0000 (13:37 +0100)
committerDavid Crawshaw <crawshaw@golang.org>
Fri, 1 Apr 2016 14:56:21 +0000 (14:56 +0000)
commit633ab7426a906b72dcf6f1d54e87f4ae926dc4e1
tree25b330f85e1039b85f37d60a8250fa13b58ef789
parent014f3e1e094c4a173ce503e5dfe1bc0619f2f4a8
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 <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
src/cmd/compile/internal/gc/reflect.go
src/reflect/all_test.go
src/reflect/type.go