github.com/goccy/go-reflect@v1.2.1-0.20220925055700-4646ad15ec8a/type.go (about) 1 package reflect 2 3 import ( 4 "reflect" 5 _ "unsafe" 6 ) 7 8 //go:linkname ifaceIndir reflect.ifaceIndir 9 //go:noescape 10 func ifaceIndir(Type) bool 11 12 func arrayOf(i int, typ Type) Type { 13 return toT(reflect.ArrayOf(i, toRT(typ))) 14 } 15 16 func chanOf(dir ChanDir, typ Type) Type { 17 return toT(reflect.ChanOf(dir, toRT(typ))) 18 } 19 20 func funcOf(in []Type, out []Type, variadic bool) Type { 21 return toT(reflect.FuncOf(toRTs(in), toRTs(out), variadic)) 22 } 23 24 func mapOf(key Type, elem Type) Type { 25 return toT(reflect.MapOf(toRT(key), toRT(elem))) 26 } 27 28 func ptrTo(typ Type) Type { 29 return toT(reflect.PtrTo(toRT(typ))) 30 } 31 32 func sliceOf(t Type) Type { 33 return toT(reflect.SliceOf(toRT(t))) 34 } 35 36 func structOf(fields []StructField) Type { 37 return ToType(reflect.StructOf(toRSFs(fields))) 38 } 39 40 //go:linkname type_Align reflect.(*rtype).Align 41 //go:noescape 42 func type_Align(Type) int 43 44 //go:linkname type_FieldAlign reflect.(*rtype).FieldAlign 45 //go:noescape 46 func type_FieldAlign(Type) int 47 48 //go:linkname type_Method reflect.(*rtype).Method 49 //go:noescape 50 func type_Method(Type, int) reflect.Method 51 52 //go:linkname type_MethodByName reflect.(*rtype).MethodByName 53 //go:noescape 54 func type_MethodByName(Type, string) (reflect.Method, bool) 55 56 //go:linkname type_NumMethod reflect.(*rtype).NumMethod 57 //go:noescape 58 func type_NumMethod(Type) int 59 60 //go:linkname type_Name reflect.(*rtype).Name 61 //go:noescape 62 func type_Name(Type) string 63 64 //go:linkname type_PkgPath reflect.(*rtype).PkgPath 65 //go:noescape 66 func type_PkgPath(Type) string 67 68 //go:linkname type_Size reflect.(*rtype).Size 69 //go:noescape 70 func type_Size(Type) uintptr 71 72 //go:linkname type_String reflect.(*rtype).String 73 //go:noescape 74 func type_String(Type) string 75 76 //go:linkname type_Kind reflect.(*rtype).Kind 77 //go:noescape 78 func type_Kind(Type) reflect.Kind 79 80 //go:linkname type_Implements reflect.(*rtype).Implements 81 //go:noescape 82 func type_Implements(Type, reflect.Type) bool 83 84 //go:linkname type_AssignableTo reflect.(*rtype).AssignableTo 85 //go:noescape 86 func type_AssignableTo(Type, reflect.Type) bool 87 88 //go:linkname type_ConvertibleTo reflect.(*rtype).ConvertibleTo 89 //go:noescape 90 func type_ConvertibleTo(Type, reflect.Type) bool 91 92 //go:linkname type_Comparable reflect.(*rtype).Comparable 93 //go:noescape 94 func type_Comparable(Type) bool 95 96 //go:linkname type_Bits reflect.(*rtype).Bits 97 //go:noescape 98 func type_Bits(Type) int 99 100 //go:linkname type_ChanDir reflect.(*rtype).ChanDir 101 //go:noescape 102 func type_ChanDir(Type) ChanDir 103 104 //go:linkname type_IsVariadic reflect.(*rtype).IsVariadic 105 //go:noescape 106 func type_IsVariadic(Type) bool 107 108 //go:linkname type_Elem reflect.(*rtype).Elem 109 //go:noescape 110 func type_Elem(t Type) reflect.Type 111 112 //go:linkname type_Field reflect.(*rtype).Field 113 //go:noescape 114 func type_Field(typ Type, i int) reflect.StructField 115 116 //go:linkname type_FieldByIndex reflect.(*rtype).FieldByIndex 117 //go:noescape 118 func type_FieldByIndex(Type, []int) reflect.StructField 119 120 //go:linkname type_FieldByName reflect.(*rtype).FieldByName 121 //go:noescape 122 func type_FieldByName(Type, string) (reflect.StructField, bool) 123 124 //go:linkname type_FieldByNameFunc reflect.(*rtype).FieldByNameFunc 125 //go:noescape 126 func type_FieldByNameFunc(Type, func(string) bool) (reflect.StructField, bool) 127 128 //go:linkname type_In reflect.(*rtype).In 129 //go:noescape 130 func type_In(Type, int) reflect.Type 131 132 //go:linkname type_Key reflect.(*rtype).Key 133 //go:noescape 134 func type_Key(Type) reflect.Type 135 136 //go:linkname type_Len reflect.(*rtype).Len 137 //go:noescape 138 func type_Len(Type) int 139 140 //go:linkname type_NumField reflect.(*rtype).NumField 141 //go:noescape 142 func type_NumField(Type) int 143 144 //go:linkname type_NumIn reflect.(*rtype).NumIn 145 //go:noescape 146 func type_NumIn(Type) int 147 148 //go:linkname type_NumOut reflect.(*rtype).NumOut 149 //go:noescape 150 func type_NumOut(Type) int 151 152 //go:linkname type_Out reflect.(*rtype).Out 153 //go:noescape 154 func type_Out(Type, int) reflect.Type 155 156 //go:linkname type_toType reflect.toType 157 //go:noescape 158 func type_toType(t Type) reflect.Type 159 160 var dummy struct { 161 b bool 162 x interface{} 163 } 164 165 func escape(x interface{}) { 166 if dummy.b { 167 dummy.x = x 168 } 169 }