Skip to content

Commit

Permalink
reflect: allow creation of recursive types
Browse files Browse the repository at this point in the history
Introduce two new functions, Named and Bind, to the reflect API to
create possibly recursive, named types.

Fixes golang#39528.
  • Loading branch information
TheCount committed Jun 14, 2020
1 parent bc85ee6 commit 5b6a938
Show file tree
Hide file tree
Showing 6 changed files with 806 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/cmd/compile/internal/gc/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,7 @@ const (
tflagExtraStar = 1 << 1
tflagNamed = 1 << 2
tflagRegularMemory = 1 << 3
tflagIncomplete = 1 << 4
)

var (
Expand Down
5 changes: 3 additions & 2 deletions src/cmd/link/internal/ld/decodesym.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import (
// reflect/type.go
// runtime/type.go
const (
tflagUncommon = 1 << 0
tflagExtraStar = 1 << 1
tflagUncommon = 1 << 0
tflagExtraStar = 1 << 1
tflagIncomplete = 1 << 4
)

func decodeInuxi(arch *sys.Arch, p []byte, sz int) uint64 {
Expand Down
4 changes: 4 additions & 0 deletions src/internal/reflectlite/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ const (
// tflagRegularMemory means that equal and hash functions can treat
// this type as a single region of t.size bytes.
tflagRegularMemory tflag = 1 << 3

// tflagIncomplete means this type was created by Named and Bind has not
// been called on it yet.
tflagIncomplete tflag = 1 << 4
)

// rtype is the common implementation of most values.
Expand Down
Loading

0 comments on commit 5b6a938

Please sign in to comment.