2017-03-02 Richard Biener <rguenther@suse.de>
[official-gcc.git] / libgo / go / runtime / type.go
blobcfee35a6fe719b6e3f12332a982f6319d11e8d01
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.
5 // Runtime type representation.
7 package runtime
9 import "unsafe"
11 type _type struct {
12 kind uint8
13 align int8
14 fieldAlign uint8
15 _ uint8
16 size uintptr
17 hash uint32
19 hashfn func(unsafe.Pointer, uintptr) uintptr
20 equalfn func(unsafe.Pointer, unsafe.Pointer) bool
22 gc unsafe.Pointer
23 string *string
24 *uncommontype
25 ptrToThis *_type
28 // Return whether two type descriptors are equal.
29 // This is gccgo-specific, as gccgo, unlike gc, permits multiple
30 // independent descriptors for a single type.
31 func eqtype(t1, t2 *_type) bool {
32 switch {
33 case t1 == t2:
34 return true
35 case t1 == nil || t2 == nil:
36 return false
37 case t1.kind != t2.kind || t1.hash != t2.hash:
38 return false
39 default:
40 return *t1.string == *t2.string
44 type method struct {
45 name *string
46 pkgPath *string
47 mtyp *_type
48 typ *_type
49 tfn unsafe.Pointer
52 type uncommontype struct {
53 name *string
54 pkgPath *string
55 methods []method
58 type imethod struct {
59 name *string
60 pkgPath *string
61 typ *_type
64 type interfacetype struct {
65 typ _type
66 methods []imethod
69 type maptype struct {
70 typ _type
71 key *_type
72 elem *_type
73 bucket *_type // internal type representing a hash bucket
74 hmap *_type // internal type representing a hmap
75 keysize uint8 // size of key slot
76 indirectkey bool // store ptr to key instead of key itself
77 valuesize uint8 // size of value slot
78 indirectvalue bool // store ptr to value instead of value itself
79 bucketsize uint16 // size of bucket
80 reflexivekey bool // true if k==k for all keys
81 needkeyupdate bool // true if we need to update key on an overwrite
84 type arraytype struct {
85 typ _type
86 elem *_type
87 slice *_type
88 len uintptr
91 type chantype struct {
92 typ _type
93 elem *_type
94 dir uintptr
97 type slicetype struct {
98 typ _type
99 elem *_type
102 type functype struct {
103 typ _type
104 dotdotdot bool
105 in []*_type
106 out []*_type
109 type ptrtype struct {
110 typ _type
111 elem *_type
114 type structfield struct {
115 name *string // nil for embedded fields
116 pkgPath *string // nil for exported Names; otherwise import path
117 typ *_type // type of field
118 tag *string // nil if no tag
119 offset uintptr // byte offset of field within struct
122 type structtype struct {
123 typ _type
124 fields []structfield