@@ -50,7 +50,7 @@ func reflectType(typ *js.Object) *rtype {
50
50
rt := & rtype {
51
51
size : uintptr (typ .Get ("size" ).Int ()),
52
52
kind : uint8 (typ .Get ("kind" ).Int ()),
53
- str : newNameOff (newName (internalStr (typ .Get ("string" )), "" , typ .Get ("exported" ).Bool ())),
53
+ str : newNameOff (newName (internalStr (typ .Get ("string" )), "" , typ .Get ("exported" ).Bool (), false )),
54
54
}
55
55
js .InternalObject (rt ).Set (idJsType , typ )
56
56
typ .Set (idReflectType , js .InternalObject (rt ))
@@ -69,7 +69,7 @@ func reflectType(typ *js.Object) *rtype {
69
69
continue
70
70
}
71
71
reflectMethods = append (reflectMethods , method {
72
- name : newNameOff (newName (internalStr (m .Get ("name" )), "" , exported )),
72
+ name : newNameOff (newName (internalStr (m .Get ("name" )), "" , exported , false )),
73
73
mtyp : newTypeOff (reflectType (m .Get ("typ" ))),
74
74
})
75
75
}
@@ -81,12 +81,12 @@ func reflectType(typ *js.Object) *rtype {
81
81
continue
82
82
}
83
83
reflectMethods = append (reflectMethods , method {
84
- name : newNameOff (newName (internalStr (m .Get ("name" )), "" , exported )),
84
+ name : newNameOff (newName (internalStr (m .Get ("name" )), "" , exported , false )),
85
85
mtyp : newTypeOff (reflectType (m .Get ("typ" ))),
86
86
})
87
87
}
88
88
ut := & uncommonType {
89
- pkgPath : newNameOff (newName (internalStr (typ .Get ("pkg" )), "" , false )),
89
+ pkgPath : newNameOff (newName (internalStr (typ .Get ("pkg" )), "" , false , false )),
90
90
mcount : uint16 (methodSet .Length ()),
91
91
xcount : xcount ,
92
92
_methods : reflectMethods ,
@@ -141,13 +141,13 @@ func reflectType(typ *js.Object) *rtype {
141
141
for i := range imethods {
142
142
m := methods .Index (i )
143
143
imethods [i ] = imethod {
144
- name : newNameOff (newName (internalStr (m .Get ("name" )), "" , internalStr (m .Get ("pkg" )) == "" )),
144
+ name : newNameOff (newName (internalStr (m .Get ("name" )), "" , internalStr (m .Get ("pkg" )) == "" , false )),
145
145
typ : newTypeOff (reflectType (m .Get ("typ" ))),
146
146
}
147
147
}
148
148
setKindType (rt , & interfaceType {
149
149
rtype : * rt ,
150
- pkgPath : newName (internalStr (typ .Get ("pkg" )), "" , false ),
150
+ pkgPath : newName (internalStr (typ .Get ("pkg" )), "" , false , false ),
151
151
methods : imethods ,
152
152
})
153
153
case Map :
@@ -168,19 +168,15 @@ func reflectType(typ *js.Object) *rtype {
168
168
reflectFields := make ([]structField , fields .Length ())
169
169
for i := range reflectFields {
170
170
f := fields .Index (i )
171
- offsetEmbed := uintptr (i ) << 1
172
- if f .Get ("embedded" ).Bool () {
173
- offsetEmbed |= 1
174
- }
175
171
reflectFields [i ] = structField {
176
- name : newName (internalStr (f .Get ("name" )), internalStr (f .Get ("tag" )), f .Get ("exported" ).Bool ()),
177
- typ : reflectType (f .Get ("typ" )),
178
- offsetEmbed : offsetEmbed ,
172
+ name : newName (internalStr (f .Get ("name" )), internalStr (f .Get ("tag" )), f .Get ("exported" ). Bool (), f . Get ( "embedded " ).Bool ()),
173
+ typ : reflectType (f .Get ("typ" )),
174
+ offset : uintptr ( i ) ,
179
175
}
180
176
}
181
177
setKindType (rt , & structType {
182
178
rtype : * rt ,
183
- pkgPath : newName (internalStr (typ .Get ("pkgPath" )), "" , false ),
179
+ pkgPath : newName (internalStr (typ .Get ("pkgPath" )), "" , false , false ),
184
180
fields : reflectFields ,
185
181
})
186
182
}
@@ -242,6 +238,7 @@ type nameData struct {
242
238
name string
243
239
tag string
244
240
exported bool
241
+ embedded bool
245
242
}
246
243
247
244
var nameMap = make (map [* byte ]* nameData )
@@ -250,13 +247,15 @@ func (n name) name() (s string) { return nameMap[n.bytes].name }
250
247
func (n name ) tag () (s string ) { return nameMap [n .bytes ].tag }
251
248
func (n name ) pkgPath () string { return "" }
252
249
func (n name ) isExported () bool { return nameMap [n .bytes ].exported }
250
+ func (n name ) embedded () bool { return nameMap [n .bytes ].embedded }
253
251
254
- func newName (n , tag string , exported bool ) name {
252
+ func newName (n , tag string , exported , embedded bool ) name {
255
253
b := new (byte )
256
254
nameMap [b ] = & nameData {
257
255
name : n ,
258
256
tag : tag ,
259
257
exported : exported ,
258
+ embedded : embedded ,
260
259
}
261
260
return name {
262
261
bytes : b ,
0 commit comments