Skip to content

Commit 2d9b486

Browse files
committed
cmd/compile: update doc at top of iexport.go on the changes for typeparams
Add in the documentation of the new declarations and type descriptors to support parameterized functions and types. Change-Id: Ia21c544caa704309cc8fd639f104c192e1786b72 Reviewed-on: https://go-review.googlesource.com/c/go/+/350951 Trust: Dan Scales <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent a81b0dc commit 2d9b486

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

src/cmd/compile/internal/typecheck/iexport.go

+34-4
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@
6363
// }
6464
//
6565
// type Func struct {
66-
// Tag byte // 'F'
66+
// Tag byte // 'F' or 'G'
6767
// Pos Pos
68+
// TypeParams []typeOff // only present if Tag == 'G'
6869
// Signature Signature
6970
// }
7071
//
@@ -75,8 +76,9 @@
7576
// }
7677
//
7778
// type Type struct {
78-
// Tag byte // 'T'
79+
// Tag byte // 'T' or 'U'
7980
// Pos Pos
81+
// TypeParams []typeOff // only present if Tag == 'U'
8082
// Underlying typeOff
8183
//
8284
// Methods []struct{ // omitted if Underlying is an interface type
@@ -93,6 +95,12 @@
9395
// Type typeOff
9496
// }
9597
//
98+
// // "Automatic" declaration of each typeparam
99+
// type TypeParam struct {
100+
// Tag byte // 'P'
101+
// Pos Pos
102+
// Bound typeOff
103+
// }
96104
//
97105
// typeOff means a uvarint that either indicates a predeclared type,
98106
// or an offset into the Data section. If the uvarint is less than
@@ -104,7 +112,7 @@
104112
// (*exportWriter).value for details.
105113
//
106114
//
107-
// There are nine kinds of type descriptors, distinguished by an itag:
115+
// There are twelve kinds of type descriptors, distinguished by an itag:
108116
//
109117
// type DefinedType struct {
110118
// Tag itag // definedType
@@ -172,8 +180,30 @@
172180
// }
173181
// }
174182
//
183+
// // Reference to a type param declaration
184+
// type TypeParamType struct {
185+
// Tag itag // typeParamType
186+
// Name stringOff
187+
// PkgPath stringOff
188+
// }
189+
//
190+
// // Instantiation of a generic type (like List[T2] or List[int])
191+
// type InstanceType struct {
192+
// Tag itag // instanceType
193+
// Pos pos
194+
// TypeArgs []typeOff
195+
// BaseType typeOff
196+
// }
197+
//
198+
// type UnionType struct {
199+
// Tag itag // interfaceType
200+
// Terms []struct {
201+
// tilde bool
202+
// Type typeOff
203+
// }
204+
// }
205+
//
175206
//
176-
// TODO(danscales): fill in doc for 'type TypeParamType' and 'type InstType'
177207
//
178208
// type Signature struct {
179209
// Params []Param

0 commit comments

Comments
 (0)