rsc.io/go@v0.0.0-20150416155037-e040fd465409/src/runtime/type.go (about) 1 // Copyright 2009 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Runtime type representation. 6 7 package runtime 8 9 import "unsafe" 10 11 // Needs to be in sync with ../../cmd/internal/ld/decodesym.go:/^commonsize and pkg/reflect/type.go:/type. 12 type _type struct { 13 size uintptr 14 hash uint32 15 _unused uint8 16 align uint8 17 fieldalign uint8 18 kind uint8 19 alg *typeAlg 20 // gc stores type info required for garbage collector. 21 // If (kind&KindGCProg)==0, then gc[0] points at sparse GC bitmap 22 // (no indirection), 4 bits per word. 23 // If (kind&KindGCProg)!=0, then gc[1] points to a compiler-generated 24 // read-only GC program; and gc[0] points to BSS space for sparse GC bitmap. 25 // For huge types (>maxGCMask), runtime unrolls the program directly into 26 // GC bitmap and gc[0] is not used. For moderately-sized types, runtime 27 // unrolls the program into gc[0] space on first use. The first byte of gc[0] 28 // (gc[0][0]) contains 'unroll' flag saying whether the program is already 29 // unrolled into gc[0] or not. 30 gc [2]uintptr 31 _string *string 32 x *uncommontype 33 ptrto *_type 34 zero *byte // ptr to the zero value for this type 35 } 36 37 type method struct { 38 name *string 39 pkgpath *string 40 mtyp *_type 41 typ *_type 42 ifn unsafe.Pointer 43 tfn unsafe.Pointer 44 } 45 46 type uncommontype struct { 47 name *string 48 pkgpath *string 49 mhdr []method 50 } 51 52 type imethod struct { 53 name *string 54 pkgpath *string 55 _type *_type 56 } 57 58 type interfacetype struct { 59 typ _type 60 mhdr []imethod 61 } 62 63 type maptype struct { 64 typ _type 65 key *_type 66 elem *_type 67 bucket *_type // internal type representing a hash bucket 68 hmap *_type // internal type representing a hmap 69 keysize uint8 // size of key slot 70 indirectkey bool // store ptr to key instead of key itself 71 valuesize uint8 // size of value slot 72 indirectvalue bool // store ptr to value instead of value itself 73 bucketsize uint16 // size of bucket 74 reflexivekey bool // true if k==k for all keys 75 } 76 77 type chantype struct { 78 typ _type 79 elem *_type 80 dir uintptr 81 } 82 83 type slicetype struct { 84 typ _type 85 elem *_type 86 } 87 88 type functype struct { 89 typ _type 90 dotdotdot bool 91 in slice 92 out slice 93 } 94 95 type ptrtype struct { 96 typ _type 97 elem *_type 98 }