Source file
src/reflect/export_test.go
1
2
3
4
5 package reflect
6
7 import (
8 "internal/abi"
9 "internal/goarch"
10 "sync"
11 "unsafe"
12 )
13
14
15 func MakeRO(v Value) Value {
16 v.flag |= flagStickyRO
17 return v
18 }
19
20
21 func IsRO(v Value) bool {
22 return v.flag&flagStickyRO != 0
23 }
24
25 var CallGC = &callGC
26
27
28
29
30
31
32 func FuncLayout(t Type, rcvr Type) (frametype Type, argSize, retOffset uintptr, stack, gc, inReg, outReg []byte, ptrs bool) {
33 var ft *abi.Type
34 var abid abiDesc
35 if rcvr != nil {
36 ft, _, abid = funcLayout((*funcType)(unsafe.Pointer(t.common())), rcvr.common())
37 } else {
38 ft, _, abid = funcLayout((*funcType)(unsafe.Pointer(t.(*rtype))), nil)
39 }
40
41 argSize = abid.stackCallArgsSize
42 retOffset = abid.retOffset
43 frametype = toType(ft)
44
45
46 for i := uint32(0); i < abid.stackPtrs.n; i++ {
47 stack = append(stack, abid.stackPtrs.data[i/8]>>(i%8)&1)
48 }
49
50
51 bool2byte := func(b bool) byte {
52 if b {
53 return 1
54 }
55 return 0
56 }
57 for i := 0; i < intArgRegs; i++ {
58 inReg = append(inReg, bool2byte(abid.inRegPtrs.Get(i)))
59 outReg = append(outReg, bool2byte(abid.outRegPtrs.Get(i)))
60 }
61
62
63 ptrs = ft.Pointers()
64 if ptrs {
65 nptrs := ft.PtrBytes / goarch.PtrSize
66 gcdata := ft.GcSlice(0, (nptrs+7)/8)
67 for i := uintptr(0); i < nptrs; i++ {
68 gc = append(gc, gcdata[i/8]>>(i%8)&1)
69 }
70 }
71 return
72 }
73
74 func TypeLinks() []string {
75 var r []string
76 sections, offset := typelinks()
77 for i, offs := range offset {
78 rodata := sections[i]
79 for _, off := range offs {
80 typ := (*rtype)(resolveTypeOff(rodata, off))
81 r = append(r, typ.String())
82 }
83 }
84 return r
85 }
86
87 var GCBits = gcbits
88
89 func gcbits(any) []byte
90
91 type EmbedWithUnexpMeth struct{}
92
93 func (EmbedWithUnexpMeth) f() {}
94
95 type pinUnexpMeth interface {
96 f()
97 }
98
99 var pinUnexpMethI = pinUnexpMeth(EmbedWithUnexpMeth{})
100
101 func FirstMethodNameBytes(t Type) *byte {
102 _ = pinUnexpMethI
103
104 ut := t.uncommon()
105 if ut == nil {
106 panic("type has no methods")
107 }
108 m := ut.Methods()[0]
109 mname := t.(*rtype).nameOff(m.Name)
110 if *mname.DataChecked(0, "name flag field")&(1<<2) == 0 {
111 panic("method name does not have pkgPath *string")
112 }
113 return mname.Bytes
114 }
115
116 type OtherPkgFields struct {
117 OtherExported int
118 otherUnexported int
119 }
120
121 func IsExported(t Type) bool {
122 typ := t.(*rtype)
123 n := typ.nameOff(typ.t.Str)
124 return n.IsExported()
125 }
126
127 func ResolveReflectName(s string) {
128 resolveReflectName(newName(s, "", false, false))
129 }
130
131 type Buffer struct {
132 buf []byte
133 }
134
135 func clearLayoutCache() {
136 layoutCache = sync.Map{}
137 }
138
139 func SetArgRegs(ints, floats int, floatSize uintptr) (oldInts, oldFloats int, oldFloatSize uintptr) {
140 oldInts = intArgRegs
141 oldFloats = floatArgRegs
142 oldFloatSize = floatRegSize
143 intArgRegs = ints
144 floatArgRegs = floats
145 floatRegSize = floatSize
146 clearLayoutCache()
147 return
148 }
149
150 var MethodValueCallCodePtr = methodValueCallCodePtr
151
152 var InternalIsZero = isZero
153
154 var IsRegularMemory = isRegularMemory
155
View as plain text