Source file
src/go/types/typelists.go
1
2
3
4
5
6
7
8 package types
9
10
11 type TypeParamList struct{ tparams []*TypeParam }
12
13
14
15 func (l *TypeParamList) Len() int { return len(l.list()) }
16
17
18 func (l *TypeParamList) At(i int) *TypeParam { return l.tparams[i] }
19
20
21
22
23 func (l *TypeParamList) list() []*TypeParam {
24 if l == nil {
25 return nil
26 }
27 return l.tparams
28 }
29
30
31 type TypeList struct{ types []Type }
32
33
34 func newTypeList(list []Type) *TypeList {
35 if len(list) == 0 {
36 return nil
37 }
38 return &TypeList{list}
39 }
40
41
42
43 func (l *TypeList) Len() int { return len(l.list()) }
44
45
46 func (l *TypeList) At(i int) Type { return l.types[i] }
47
48
49
50
51 func (l *TypeList) list() []Type {
52 if l == nil {
53 return nil
54 }
55 return l.types
56 }
57
58
59
60
61 func bindTParams(list []*TypeParam) *TypeParamList {
62 if len(list) == 0 {
63 return nil
64 }
65 for i, typ := range list {
66 if typ.index >= 0 {
67 panic("type parameter bound more than once")
68 }
69 typ.index = i
70 }
71 return &TypeParamList{tparams: list}
72 }
73
View as plain text