kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/go/indexer/testdata/types.go (about) 1 package types 2 3 import "fmt" 4 5 //- Array4Builtin=vname("array4#builtin", "golang.org", "", "", "go").node/kind tbuiltin 6 //- BoolBuiltin=vname("bool#builtin", "golang.org", "", "", "go").node/kind tbuiltin 7 //- ByteBuiltin=vname("byte#builtin", "golang.org", "", "", "go").node/kind tbuiltin 8 //- ChanBuiltin=vname("chan#builtin", "golang.org", "", "", "go").node/kind tbuiltin 9 //- ChanRecvBuiltin=vname("<-chan#builtin", "golang.org", "", "", "go").node/kind tbuiltin 10 //- ChanSendBuiltin=vname("chan<-#builtin", "golang.org", "", "", "go").node/kind tbuiltin 11 //- Float64Builtin=vname("float64#builtin", "golang.org", "", "", "go").node/kind tbuiltin 12 //- FnBuiltin=vname("fn#builtin", "golang.org", "", "", "go").node/kind tbuiltin 13 //- IntBuiltin=vname("int#builtin", "golang.org", "", "", "go").node/kind tbuiltin 14 //- MapBuiltin=vname("map#builtin", "golang.org", "", "", "go").node/kind tbuiltin 15 //- PointerBuiltin=vname("pointer#builtin", "golang.org", "", "", "go").node/kind tbuiltin 16 //- SliceBuiltin=vname("slice#builtin", "golang.org", "", "", "go").node/kind tbuiltin 17 //- StringBuiltin=vname("string#builtin", "golang.org", "", "", "go").node/kind tbuiltin 18 //- TupleBuiltin=vname("tuple#builtin", "golang.org", "", "", "go").node/kind tbuiltin 19 //- Uint8Builtin=vname("uint8#builtin", "golang.org", "", "", "go").node/kind tbuiltin 20 //- VariadicBuiltin=vname("variadic#builtin", "golang.org", "", "", "go").node/kind tbuiltin 21 22 // float32 is not used in this package; it shouldn't be emitted 23 //- !{ _Float32Builtin=vname("float32#builtin", "golang.org", "", "", "go").node/kind tbuiltin } 24 25 //- FnBuiltin code FnCode 26 //- FnCode.kind "TYPE" 27 //- FnCode.pre_text "fn" 28 //- BoolBuiltin code BoolCode 29 //- BoolCode.kind "TYPE" 30 //- BoolCode.pre_text "bool" 31 32 //- SliceTAppCode.kind "TYPE" 33 //- SliceTAppCode.pre_text "[]" 34 //- SliceTAppCode child.0 SliceTAppCodeParam 35 //- SliceTAppCodeParam.kind "LOOKUP_BY_PARAM" 36 //- SliceTAppCodeParam.lookup_index 1 37 38 //- PointerTAppCode.kind "TYPE" 39 //- PointerTAppCode.pre_text "*" 40 //- PointerTAppCode child.0 PointerTAppCodeParam 41 //- PointerTAppCodeParam.kind "LOOKUP_BY_PARAM" 42 //- PointerTAppCodeParam.lookup_index 1 43 44 //- TupleTAppCode.kind "TYPE" 45 //- TupleTAppCode.pre_text "(" 46 //- TupleTAppCode.post_text ")" 47 //- TupleTAppCode child.0 TupleTAppCodeParam 48 //- TupleTAppCodeParam.kind "PARAMETER_LOOKUP_BY_PARAM" 49 //- TupleTAppCodeParam.post_child_text ", " 50 //- TupleTAppCodeParam.lookup_index 1 51 52 //- VariadicTAppCode.kind "TYPE" 53 //- VariadicTAppCode.pre_text "..." 54 //- VariadicTAppCode child.0 VariadicTAppCodeParam 55 //- VariadicTAppCodeParam.kind "LOOKUP_BY_PARAM" 56 //- VariadicTAppCodeParam.lookup_index 1 57 58 //- Array4TAppCode.kind "TYPE" 59 //- Array4TAppCode.pre_text "[4]" 60 //- Array4TAppCode child.0 Array4TAppCodeParam 61 //- Array4TAppCodeParam.kind "LOOKUP_BY_PARAM" 62 //- Array4TAppCodeParam.lookup_index 1 63 64 //- ChanTAppCode.kind "TYPE" 65 //- ChanTAppCode.pre_text "chan " 66 //- ChanTAppCode child.0 ChanTAppCodeParam 67 //- ChanTAppCodeParam.kind "LOOKUP_BY_PARAM" 68 //- ChanTAppCodeParam.lookup_index 1 69 70 //- SendChanTAppCode.kind "TYPE" 71 //- SendChanTAppCode.pre_text "chan<- " 72 //- SendChanTAppCode child.0 SendChanTAppCodeParam 73 //- SendChanTAppCodeParam.kind "LOOKUP_BY_PARAM" 74 //- SendChanTAppCodeParam.lookup_index 1 75 76 //- RecvChanTAppCode.kind "TYPE" 77 //- RecvChanTAppCode.pre_text "<-chan " 78 //- RecvChanTAppCode child.0 RecvChanTAppCodeParam 79 //- RecvChanTAppCodeParam.kind "LOOKUP_BY_PARAM" 80 //- RecvChanTAppCodeParam.lookup_index 1 81 82 //- MapTAppCode.kind "TYPE" 83 //- MapTAppCode.pre_text "map" 84 //- MapTAppCode child.0 MapTAppCodeKeyBox 85 //- MapTAppCodeKeyBox.kind "BOX" 86 //- MapTAppCodeKeyBox.pre_text "[" 87 //- MapTAppCodeKeyBox.post_text "]" 88 //- MapTAppCodeKeyBox child.0 MapTAppCodeKey 89 //- MapTAppCodeKey.kind "LOOKUP_BY_PARAM" 90 //- MapTAppCodeKey.lookup_index 1 91 //- MapTAppCode child.1 MapTAppCodeValue 92 //- MapTAppCodeValue.kind "LOOKUP_BY_PARAM" 93 //- MapTAppCodeValue.lookup_index 2 94 95 //- FnTAppCode.kind "TYPE" 96 //- FnTAppCode child.0 FnTAppCodeParam 97 //- FnTAppCodeParam.kind "PARAMETER_LOOKUP_BY_PARAM" 98 //- FnTAppCodeParam.lookup_index 3 99 //- FnTAppCodeParam.pre_text "func(" 100 //- FnTAppCodeParam.post_child_text ", " 101 //- FnTAppCodeParam.post_text ")" 102 //- FnTAppCode child.1 FnTAppCodeReturnBox 103 //- FnTAppCodeReturnBox.kind "BOX" 104 //- FnTAppCodeReturnBox.pre_text " " 105 //- FnTAppCodeReturnBox child.0 FnTAppCodeReturn 106 //- FnTAppCodeReturn.kind "LOOKUP_BY_PARAM" 107 //- FnTAppCodeReturn.lookup_index 1 108 109 //- VoidFnTAppCode.kind "TYPE" 110 //- VoidFnTAppCode child.0 VoidFnTAppCodeParam 111 //- VoidFnTAppCodeParam.kind "PARAMETER_LOOKUP_BY_PARAM" 112 //- VoidFnTAppCodeParam.lookup_index 3 113 //- VoidFnTAppCodeParam.pre_text "func(" 114 //- VoidFnTAppCodeParam.post_child_text ", " 115 //- VoidFnTAppCodeParam.post_text ")" 116 117 //- MethodTAppCode.kind "TYPE" 118 //- MethodTAppCode child.0 MethodTAppCodeRecvBox 119 //- MethodTAppCodeRecvBox.kind "BOX" 120 //- MethodTAppCodeRecvBox.pre_text "(" 121 //- MethodTAppCodeRecvBox.post_text ") " 122 //- MethodTAppCodeRecvBox child.0 MethodTAppCodeRecv 123 //- MethodTAppCodeRecv.kind "LOOKUP_BY_PARAM" 124 //- MethodTAppCodeRecv.lookup_index 2 125 //- MethodTAppCode child.1 MethodTAppCodeParam 126 //- MethodTAppCodeParam.kind "PARAMETER_LOOKUP_BY_PARAM" 127 //- MethodTAppCodeParam.lookup_index 3 128 //- MethodTAppCodeParam.pre_text "func(" 129 //- MethodTAppCodeParam.post_child_text ", " 130 //- MethodTAppCodeParam.post_text ")" 131 //- MethodTAppCode child.2 MethodTAppCodeReturnBox 132 //- MethodTAppCodeReturnBox.kind "BOX" 133 //- MethodTAppCodeReturnBox.pre_text " " 134 //- MethodTAppCodeReturnBox child.0 MethodTAppCodeReturn 135 //- MethodTAppCodeReturn.kind "LOOKUP_BY_PARAM" 136 //- MethodTAppCodeReturn.lookup_index 1 137 138 //- VoidMethodTAppCode.kind "TYPE" 139 //- VoidMethodTAppCode child.0 VoidMethodTAppCodeRecvBox 140 //- VoidMethodTAppCodeRecvBox.kind "BOX" 141 //- VoidMethodTAppCodeRecvBox.pre_text "(" 142 //- VoidMethodTAppCodeRecvBox.post_text ") " 143 //- VoidMethodTAppCodeRecvBox child.0 VoidMethodTAppCodeRecv 144 //- VoidMethodTAppCodeRecv.kind "LOOKUP_BY_PARAM" 145 //- VoidMethodTAppCodeRecv.lookup_index 2 146 //- VoidMethodTAppCode child.1 VoidMethodTAppCodeParam 147 //- VoidMethodTAppCodeParam.kind "PARAMETER_LOOKUP_BY_PARAM" 148 //- VoidMethodTAppCodeParam.lookup_index 3 149 //- VoidMethodTAppCodeParam.pre_text "func(" 150 //- VoidMethodTAppCodeParam.post_child_text ", " 151 //- VoidMethodTAppCodeParam.post_text ")" 152 153 //- EmptyTuple.node/kind tapp 154 //- EmptyTuple param.0 TupleBuiltin 155 //- EmptyTuple code TupleTAppCode 156 157 // - @f0 defines/binding F0 158 // - F0 typed NullFuncType 159 // - NullFuncType.node/kind tapp 160 // - NullFuncType param.0 FnBuiltin 161 // - NullFuncType param.1 EmptyTuple 162 // - NullFuncType param.2 EmptyTuple 163 // - !{ NullFuncType param.3 _ } 164 // - NullFuncType code VoidFnTAppCode 165 func f0() {} 166 167 // - @f1 defines/binding F1 168 // - F1 typed F1FuncType 169 // - F1FuncType.node/kind tapp 170 // - F1FuncType param.0 FnBuiltin 171 // - F1FuncType param.1 EmptyTuple 172 // - F1FuncType param.2 EmptyTuple 173 // - F1FuncType param.3 IntBuiltin 174 // - F1FuncType param.4 BoolBuiltin 175 // - F1FuncType param.5 StringBuiltin 176 func f1(a int, b bool, c string) {} 177 178 // - @f2 defines/binding F2 179 // - F2 typed F2FuncType 180 // - F2FuncType.node/kind tapp 181 // - F2FuncType param.0 FnBuiltin 182 // - F2FuncType param.1 IntBuiltin 183 // - F2FuncType param.2 EmptyTuple 184 // - !{ NullFuncType param.3 _ } 185 // - F2FuncType code FnTAppCode 186 func f2() int { return 0 } 187 188 // - @f3 defines/binding F3 189 // - F3 typed F3FuncType 190 // - F3FuncType.node/kind tapp 191 // - F3FuncType param.0 FnBuiltin 192 // - F3FuncType param.1 F3Return 193 // - F3FuncType param.2 EmptyTuple 194 // - F3Return.node/kind tapp 195 // - F3Return param.0 TupleBuiltin 196 // - F3Return param.1 IntBuiltin 197 // - F3Return param.2 BoolBuiltin 198 // - !{ NullFuncType param.3 _ } 199 func f3() (int, bool) { return 0, false } 200 201 // - @f4 defines/binding F4 202 // - F4 typed F4FuncType 203 // - F4FuncType.node/kind tapp 204 // - F4FuncType param.0 FnBuiltin 205 // - F4FuncType param.1 EmptyTuple 206 // - F4FuncType param.2 EmptyTuple 207 // - F4FuncType param.3 IntBuiltin 208 // - F4FuncType param.4 VariadicInt 209 // - VariadicInt.node/kind tapp 210 // - VariadicInt param.0 VariadicBuiltin 211 // - VariadicInt param.1 IntBuiltin 212 // - VariadicInt code VariadicTAppCode 213 func f4(a int, b ...int) {} 214 215 func paramTypes( 216 //- @intParam defines/binding IntParam 217 //- IntParam typed IntBuiltin 218 intParam int, 219 //- @fParam defines/binding FParam 220 //- FParam typed NullFuncType 221 fParam func()) { 222 } 223 224 func retTypes() ( 225 //- @intRet defines/binding IntRet 226 //- IntRet typed IntBuiltin 227 intRet int, 228 //- @fRet defines/binding FRet 229 //- FRet typed NullFuncType 230 fRet func()) { 231 return 0, nil 232 } 233 234 // - @EmptyStruct defines/binding EmptyStruct 235 // - EmptyStruct typed EmptyStruct 236 type EmptyStruct struct{} 237 238 // - @S defines/binding S 239 // - S.node/kind record 240 type S struct { 241 //- @Float64Field defines/binding Float64Field 242 //- Float64Field.node/kind variable 243 //- Float64Field typed Float64Builtin 244 Float64Field float64 245 246 //- @IntPointerField defines/binding IntPointerField 247 //- IntPointerField.node/kind variable 248 //- IntPointerField typed IntPointer 249 //- IntPointer.node/kind tapp 250 //- IntPointer param.0 PointerBuiltin 251 //- IntPointer param.1 IntBuiltin 252 //- IntPointer code PointerTAppCode 253 IntPointerField *int 254 255 //- @IntArray4Field defines/binding IA4F 256 //- IA4F typed IA4 257 //- IA4.node/kind tapp 258 //- IA4 param.0 Array4Builtin 259 //- IA4 param.1 IntBuiltin 260 //- IA4 code Array4TAppCode 261 IntArray4Field [4]int 262 263 //- @IntSliceField defines/binding IntSliceField 264 //- IntSliceField typed IntSlice 265 //- IntSlice.node/kind tapp 266 //- IntSlice param.0 SliceBuiltin 267 //- IntSlice param.1 IntBuiltin 268 //- IntSlice code SliceTAppCode 269 IntSliceField []int 270 271 //- @StrSetField defines/binding StrSetField 272 //- StrSetField typed StrSet 273 //- StrSet param.0 MapBuiltin 274 //- StrSet param.1 StringBuiltin 275 //- StrSet param.2 EmptyStruct 276 //- StrSet code MapTAppCode 277 StrSetField map[string]EmptyStruct 278 279 //- @ByteField defines/binding ByteField 280 //- ByteField typed ByteBuiltin 281 ByteField byte 282 283 //- @Uint8Field defines/binding Uint8Field 284 //- Uint8Field typed Uint8Builtin 285 Uint8Field uint8 286 287 //- @"整数型Chan" defines/binding IntChanField 288 //- IntChanField.node/kind variable 289 //- IntChanField typed IntChan 290 //- IntChan.node/kind tapp 291 //- IntChan param.0 ChanBuiltin 292 //- IntChan param.1 IntBuiltin 293 //- IntChan code ChanTAppCode 294 整数型Chan chan int 295 296 //- @RecvIntChan defines/binding RecvIntChanField 297 //- RecvIntChanField typed RecvIntChan 298 //- RecvIntChan.node/kind tapp 299 //- RecvIntChan param.0 ChanRecvBuiltin 300 //- RecvIntChan param.1 IntBuiltin 301 //- RecvIntChan code RecvChanTAppCode 302 RecvIntChan <-chan int 303 304 //- @SendIntChan defines/binding SendIntChanField 305 //- SendIntChanField typed SendIntChan 306 //- SendIntChan.node/kind tapp 307 //- SendIntChan param.0 ChanSendBuiltin 308 //- SendIntChan param.1 IntBuiltin 309 //- SendIntChan code SendChanTAppCode 310 SendIntChan chan<- int 311 } 312 313 // - @sv defines/binding SVar 314 // - SVar.node/kind variable 315 // - SVar typed S 316 var sv = S{} 317 318 // - @Method defines/binding Method 319 // - Method typed MethodType 320 // - MethodType.node/kind tapp 321 // - MethodType param.0 FnBuiltin 322 // - MethodType param.1 IntBuiltin 323 // - MethodType param.2 S 324 // - MethodType code MethodTAppCode 325 func (s S) Method() int { return 0 } 326 327 // - @PMethod defines/binding PMethod 328 // - PMethod typed PMethodType 329 // - PMethodType.node/kind tapp 330 // - PMethodType param.0 FnBuiltin 331 // - PMethodType param.1 EmptyTuple 332 // - PMethodType param.2 SPointer 333 // - SPointer.node/kind tapp 334 // - SPointer param.0 PointerBuiltin 335 // - SPointer param.1 S 336 // - MethodType code VoidMethodTAppCode 337 func (s *S) PMethod() {} 338 339 // - @Iter defines/binding Iter 340 // - Iter.node/kind interface 341 type Iter interface { 342 //- @Method defines/binding IMethod 343 //- IMethod typed IMethodType 344 //- IMethodType.node/kind tapp 345 //- IMethodType param.0 FnBuiltin 346 //- IMethodType param.1 IntBuiltin 347 //- IMethodType param.2 Iter 348 Method() int 349 } 350 351 // - @iv defines/binding IVar 352 // - IVar.node/kind variable 353 // - IVar typed Iter 354 var iv Iter 355 356 // - @main defines/binding Main 357 // - Main typed NullFuncType 358 func main() { 359 //- @i defines/binding LocalAssign 360 //- LocalAssign.node/kind variable 361 //- LocalAssign typed IntBuiltin 362 i := 0 363 364 //- @localF defines/binding LocalF 365 //- LocalF.node/kind variable 366 //- LocalF typed LocalFType 367 //- LocalFType.node/kind tapp 368 //- LocalFType param.0 FnBuiltin 369 localF := func(a int) { print(a) } 370 371 localF(i) 372 } 373 374 // Test the that the String method remains identical across these different embeddings. 375 type StringerI fmt.Stringer 376 type StringerE interface{ fmt.Stringer } 377 type StringerE2 interface{ StringerI } 378 type StringerA = fmt.Stringer 379 380 func f( 381 i StringerI, 382 s fmt.Stringer, 383 e StringerE, 384 e2 StringerE2, 385 a StringerA, 386 ) { 387 //- @String ref String 388 i.String() 389 //- @String ref String 390 s.String() 391 //- @String ref String 392 e.String() 393 //- @String ref String 394 e2.String() 395 //- @String ref String 396 a.String() 397 } 398 399 // TODO(schroederc): taliases 400 // - @StringAlias defines/binding StringAlias 401 // - StringAlias.node/kind record 402 // - StringAlias typed StringBuiltin 403 type StringAlias = string