OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [runtime/] [type.go] - Blame information for rev 747

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// 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
/*
6
 * Runtime type representation.
7
 *
8
 * The following files know the exact layout of these
9
 * data structures and must be kept in sync with this file:
10
 *
11
 *      ../../cmd/gc/reflect.c
12
 *      ../../cmd/ld/dwarf.c decodetype_*
13
 *      ../reflect/type.go
14
 *      type.h
15
 */
16
 
17
package runtime
18
 
19
import "unsafe"
20
 
21
// All types begin with a few common fields needed for
22
// the interface runtime.
23
type commonType struct {
24
        Kind       uint8   // type kind
25
        align      uint8   // alignment of variable with this type
26
        fieldAlign uint8   // alignment of struct field with this type
27
        size       uintptr // size in bytes
28
        hash       uint32  // hash of type; avoids computation in hash tables
29
 
30
        hashfn  func(unsafe.Pointer, uintptr) uintptr              // hash function
31
        equalfn func(unsafe.Pointer, unsafe.Pointer, uintptr) bool // equality function
32
 
33
        string        *string // string form; unnecessary  but undeniably useful
34
        *uncommonType         // (relatively) uncommon fields
35
        ptrToThis     *Type   // pointer to this type, if used in binary or has methods
36
}
37
 
38
// Values for commonType.kind.
39
const (
40
        kindBool = 1 + iota
41
        kindInt
42
        kindInt8
43
        kindInt16
44
        kindInt32
45
        kindInt64
46
        kindUint
47
        kindUint8
48
        kindUint16
49
        kindUint32
50
        kindUint64
51
        kindUintptr
52
        kindFloat32
53
        kindFloat64
54
        kindComplex64
55
        kindComplex128
56
        kindArray
57
        kindChan
58
        kindFunc
59
        kindInterface
60
        kindMap
61
        kindPtr
62
        kindSlice
63
        kindString
64
        kindStruct
65
        kindUnsafePointer
66
 
67
        // Not currently generated by gccgo.
68
        // kindNoPointers = 1 << 7 // OR'ed into kind
69
)
70
 
71
// Externally visible name.
72
type Type commonType
73
 
74
// Method on non-interface type
75
type _method struct { // underscore is to avoid collision with C
76
        name    *string        // name of method
77
        pkgPath *string        // nil for exported Names; otherwise import path
78
        mtyp    *Type          // method type (without receiver)
79
        typ     *Type          // .(*FuncType) underneath (with receiver)
80
        tfn     unsafe.Pointer // fn used for normal method call
81
}
82
 
83
// uncommonType is present only for types with names or methods
84
// (if T is a named type, the uncommonTypes for T and *T have methods).
85
// Using a pointer to this struct reduces the overall size required
86
// to describe an unnamed type with no methods.
87
type uncommonType struct {
88
        name    *string   // name of type
89
        pkgPath *string   // import path; nil for built-in types like int, string
90
        methods []_method // methods associated with type
91
}
92
 
93
// BoolType represents a boolean type.
94
type BoolType commonType
95
 
96
// FloatType represents a float type.
97
type FloatType commonType
98
 
99
// ComplexType represents a complex type.
100
type ComplexType commonType
101
 
102
// IntType represents an int type.
103
type IntType commonType
104
 
105
// UintType represents a uint type.
106
type UintType commonType
107
 
108
// StringType represents a string type.
109
type StringType commonType
110
 
111
// UintptrType represents a uintptr type.
112
type UintptrType commonType
113
 
114
// UnsafePointerType represents an unsafe.Pointer type.
115
type UnsafePointerType commonType
116
 
117
// ArrayType represents a fixed array type.
118
type ArrayType struct {
119
        commonType
120
        elem  *Type // array element type
121
        slice *Type // slice type
122
        len   uintptr
123
}
124
 
125
// SliceType represents a slice type.
126
type SliceType struct {
127
        commonType
128
        elem *Type // slice element type
129
}
130
 
131
// ChanDir represents a channel type's direction.
132
type ChanDir int
133
 
134
const (
135
        RecvDir ChanDir             = 1 << iota // <-chan
136
        SendDir                                 // chan<-
137
        BothDir = RecvDir | SendDir             // chan
138
)
139
 
140
// ChanType represents a channel type.
141
type ChanType struct {
142
        commonType
143
        elem *Type   // channel element type
144
        dir  uintptr // channel direction (ChanDir)
145
}
146
 
147
// FuncType represents a function type.
148
type FuncType struct {
149
        commonType
150
        dotdotdot bool    // last input parameter is ...
151
        in        []*Type // input parameter types
152
        out       []*Type // output parameter types
153
}
154
 
155
// Method on interface type
156
type _imethod struct { // underscore is to avoid collision with C
157
        name    *string // name of method
158
        pkgPath *string // nil for exported Names; otherwise import path
159
        typ     *Type   // .(*FuncType) underneath
160
}
161
 
162
// InterfaceType represents an interface type.
163
type InterfaceType struct {
164
        commonType
165
        methods []_imethod // sorted by hash
166
}
167
 
168
// MapType represents a map type.
169
type MapType struct {
170
        commonType
171
        key  *Type // map key type
172
        elem *Type // map element (value) type
173
}
174
 
175
// PtrType represents a pointer type.
176
type PtrType struct {
177
        commonType
178
        elem *Type // pointer element (pointed at) type
179
}
180
 
181
// Struct field
182
type structField struct {
183
        name    *string // nil for embedded fields
184
        pkgPath *string // nil for exported Names; otherwise import path
185
        typ     *Type   // type of field
186
        tag     *string // nil if no tag
187
        offset  uintptr // byte offset of field within struct
188
}
189
 
190
// StructType represents a struct type.
191
type StructType struct {
192
        commonType
193
        fields []structField // sorted by offset
194
}
195
 
196
/*
197
 * Must match iface.c:/Itab and compilers.
198
 * NOTE: this is the version used by the reflection code, there is another
199
 * one in iface_defs.go that is closer to the original C version.
200
 */
201
type Itable struct {
202
        Itype  *Type // (*tab.inter).(*InterfaceType) is the interface type
203
        Type   *Type
204
        link   *Itable
205
        bad    int32
206
        unused int32
207
        Fn     [100000]uintptr // bigger than we'll ever see
208
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.