1 // Code generated by "go test -run=Generate -write=all"; DO NOT EDIT.
2 // Source: ../../cmd/compile/internal/types2/typelists.go
3 4 // Copyright 2021 The Go Authors. All rights reserved.
5 // Use of this source code is governed by a BSD-style
6 // license that can be found in the LICENSE file.
7 8 package types
9 10 // TypeParamList holds a list of type parameters.
11 type TypeParamList struct{ tparams []*TypeParam }
12 13 // Len returns the number of type parameters in the list.
14 // It is safe to call on a nil receiver.
15 func (l *TypeParamList) Len() int { return len(l.list()) }
16 17 // At returns the i'th type parameter in the list.
18 func (l *TypeParamList) At(i int) *TypeParam { return l.tparams[i] }
19 20 // list is for internal use where we expect a []*TypeParam.
21 // TODO(rfindley): list should probably be eliminated: we can pass around a
22 // TypeParamList instead.
23 func (l *TypeParamList) list() []*TypeParam {
24 if l == nil {
25 return nil
26 }
27 return l.tparams
28 }
29 30 // TypeList holds a list of types.
31 type TypeList struct{ types []Type }
32 33 // newTypeList returns a new TypeList with the types in list.
34 func newTypeList(list []Type) *TypeList {
35 if len(list) == 0 {
36 return nil
37 }
38 return &TypeList{list}
39 }
40 41 // Len returns the number of types in the list.
42 // It is safe to call on a nil receiver.
43 func (l *TypeList) Len() int { return len(l.list()) }
44 45 // At returns the i'th type in the list.
46 func (l *TypeList) At(i int) Type { return l.types[i] }
47 48 // list is for internal use where we expect a []Type.
49 // TODO(rfindley): list should probably be eliminated: we can pass around a
50 // TypeList instead.
51 func (l *TypeList) list() []Type {
52 if l == nil {
53 return nil
54 }
55 return l.types
56 }
57 58 // ----------------------------------------------------------------------------
59 // Implementation
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