@@ -63,7 +63,7 @@ func reflectType(typ *js.Object) *rtype {
63
63
rt := & rtype {
64
64
size : uintptr (typ .Get ("size" ).Int ()),
65
65
kind : uint8 (typ .Get ("kind" ).Int ()),
66
- str : newNameOff (newName (internalStr (typ .Get ("string" )), "" , typ .Get ("exported" ).Bool ())),
66
+ str : resolveReflectName (newName (internalStr (typ .Get ("string" )), "" , typ .Get ("exported" ).Bool ())),
67
67
}
68
68
js .InternalObject (rt ).Set ("jsType" , typ )
69
69
typ .Set ("reflectType" , js .InternalObject (rt ))
@@ -82,7 +82,7 @@ func reflectType(typ *js.Object) *rtype {
82
82
continue
83
83
}
84
84
reflectMethods = append (reflectMethods , method {
85
- name : newNameOff (newMethodName (m )),
85
+ name : resolveReflectName (newMethodName (m )),
86
86
mtyp : newTypeOff (reflectType (m .Get ("typ" ))),
87
87
})
88
88
}
@@ -94,18 +94,18 @@ func reflectType(typ *js.Object) *rtype {
94
94
continue
95
95
}
96
96
reflectMethods = append (reflectMethods , method {
97
- name : newNameOff (newMethodName (m )),
97
+ name : resolveReflectName (newMethodName (m )),
98
98
mtyp : newTypeOff (reflectType (m .Get ("typ" ))),
99
99
})
100
100
}
101
101
ut := & uncommonType {
102
- pkgPath : newNameOff (newName (internalStr (typ .Get ("pkg" )), "" , false )),
102
+ pkgPath : resolveReflectName (newName (internalStr (typ .Get ("pkg" )), "" , false )),
103
103
mcount : uint16 (methodSet .Length ()),
104
104
xcount : xcount ,
105
105
_methods : reflectMethods ,
106
106
}
107
- uncommonTypeMap [rt ] = ut
108
107
js .InternalObject (ut ).Set ("jsType" , typ )
108
+ js .InternalObject (rt ).Set ("uncommonType" , js .InternalObject (ut ))
109
109
}
110
110
111
111
switch rt .Kind () {
@@ -154,7 +154,7 @@ func reflectType(typ *js.Object) *rtype {
154
154
for i := range imethods {
155
155
m := methods .Index (i )
156
156
imethods [i ] = imethod {
157
- name : newNameOff (newMethodName (m )),
157
+ name : resolveReflectName (newMethodName (m )),
158
158
typ : newTypeOff (reflectType (m .Get ("typ" ))),
159
159
}
160
160
}
@@ -224,10 +224,12 @@ func (t *uncommonType) exportedMethods() []method {
224
224
return t ._methods [:t .xcount :t .xcount ]
225
225
}
226
226
227
- var uncommonTypeMap = make (map [* rtype ]* uncommonType )
228
-
229
227
func (t * rtype ) uncommon () * uncommonType {
230
- return uncommonTypeMap [t ]
228
+ obj := js .InternalObject (t ).Get ("uncommonType" )
229
+ if obj == js .Undefined {
230
+ return nil
231
+ }
232
+ return (* uncommonType )(unsafe .Pointer (obj .Unsafe ()))
231
233
}
232
234
233
235
type funcType struct {
@@ -298,7 +300,7 @@ func (t *rtype) nameOff(off nameOff) name {
298
300
return nameOffList [int (off )]
299
301
}
300
302
301
- func newNameOff (n name ) nameOff {
303
+ func resolveReflectName (n name ) nameOff {
302
304
i := len (nameOffList )
303
305
nameOffList = append (nameOffList , n )
304
306
return nameOff (i )
0 commit comments