github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/compile/internal/reflectdata/reflect.go (about) 1 // 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 package reflectdata 6 7 import ( 8 "github.com/shogo82148/std/cmd/compile/internal/ir" 9 "github.com/shogo82148/std/cmd/compile/internal/types" 10 "github.com/shogo82148/std/cmd/internal/obj" 11 "github.com/shogo82148/std/cmd/internal/src" 12 ) 13 14 // MapBucketType makes the map bucket type given the type of the map. 15 func MapBucketType(t *types.Type) *types.Type 16 17 // MapType returns a type interchangeable with runtime.hmap. 18 // Make sure this stays in sync with runtime/map.go. 19 func MapType() *types.Type 20 21 // MapIterType returns a type interchangeable with runtime.hiter. 22 // Make sure this stays in sync with runtime/map.go. 23 func MapIterType() *types.Type 24 25 // TrackSym returns the symbol for tracking use of field/method f, assumed 26 // to be a member of struct/interface type t. 27 func TrackSym(t *types.Type, f *types.Field) *obj.LSym 28 29 func TypeSymPrefix(prefix string, t *types.Type) *types.Sym 30 31 func TypeSym(t *types.Type) *types.Sym 32 33 func TypeLinksymPrefix(prefix string, t *types.Type) *obj.LSym 34 35 func TypeLinksymLookup(name string) *obj.LSym 36 37 func TypeLinksym(t *types.Type) *obj.LSym 38 39 // TypePtrAt returns an expression that evaluates to the 40 // *runtime._type value for t. 41 func TypePtrAt(pos src.XPos, t *types.Type) *ir.AddrExpr 42 43 // ITabLsym returns the LSym representing the itab for concrete type typ implementing 44 // interface iface. A dummy tab will be created in the unusual case where typ doesn't 45 // implement iface. Normally, this wouldn't happen, because the typechecker would 46 // have reported a compile-time error. This situation can only happen when the 47 // destination type of a type assert or a type in a type switch is parameterized, so 48 // it may sometimes, but not always, be a type that can't implement the specified 49 // interface. 50 func ITabLsym(typ, iface *types.Type) *obj.LSym 51 52 // ITabAddrAt returns an expression that evaluates to the 53 // *runtime.itab value for concrete type typ implementing interface 54 // iface. 55 func ITabAddrAt(pos src.XPos, typ, iface *types.Type) *ir.AddrExpr 56 57 // InterfaceMethodOffset returns the offset of the i-th method in the interface 58 // type descriptor, ityp. 59 func InterfaceMethodOffset(ityp *types.Type, i int64) int64 60 61 // NeedRuntimeType ensures that a runtime type descriptor is emitted for t. 62 func NeedRuntimeType(t *types.Type) 63 64 func WriteRuntimeTypes() 65 66 func WriteGCSymbols() 67 68 func WritePluginTable() 69 70 func WriteBasicTypes() 71 72 // GCSym returns a data symbol containing GC information for type t, along 73 // with a boolean reporting whether the UseGCProg bit should be set in the 74 // type kind, and the ptrdata field to record in the reflect type information. 75 // GCSym may be called in concurrent backend, so it does not emit the symbol 76 // content. 77 func GCSym(t *types.Type) (lsym *obj.LSym, useGCProg bool, ptrdata int64) 78 79 // ZeroAddr returns the address of a symbol with at least 80 // size bytes of zeros. 81 func ZeroAddr(size int64) ir.Node 82 83 // NeedEmit reports whether typ is a type that we need to emit code 84 // for (e.g., runtime type descriptors, method wrappers). 85 func NeedEmit(typ *types.Type) bool 86 87 var ZeroSize int64 88 89 // MarkTypeUsedInInterface marks that type t is converted to an interface. 90 // This information is used in the linker in dead method elimination. 91 func MarkTypeUsedInInterface(t *types.Type, from *obj.LSym) 92 93 func MarkTypeSymUsedInInterface(tsym *obj.LSym, from *obj.LSym) 94 95 // MarkUsedIfaceMethod marks that an interface method is used in the current 96 // function. n is OCALLINTER node. 97 func MarkUsedIfaceMethod(n *ir.CallExpr)