Skip to content

Commit c613514

Browse files
Working through reflectlite and got to tests requiring reflect
1 parent aa74f45 commit c613514

File tree

6 files changed

+359
-518
lines changed

6 files changed

+359
-518
lines changed

compiler/natives/src/internal/abi/type.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ type UncommonType struct {
3232
Methods_ []Method
3333
}
3434

35+
//gopherjs:purge Used for pointer arthmatic
36+
func addChecked(p unsafe.Pointer, x uintptr, whySafe string) unsafe.Pointer
37+
3538
//gopherjs:replace
3639
func (t *UncommonType) Methods() []Method {
3740
return t.Methods_

compiler/natives/src/internal/reflectlite/export_test.go

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,30 @@
22

33
package reflectlite
44

5-
import "unsafe"
5+
import "internal/abi"
66

77
// Field returns the i'th field of the struct v.
88
// It panics if v's Kind is not Struct or i is out of range.
9+
//
10+
//gopherjs:replace
911
func Field(v Value, i int) Value {
10-
if v.kind() != Struct {
11-
panic(&ValueError{"reflect.Value.Field", v.kind()})
12+
if v.kind() != abi.Struct {
13+
panic(&ValueError{Method: "reflect.Value.Field", Kind: v.kind()})
1214
}
1315
return v.Field(i)
1416
}
1517

16-
func TField(typ Type, i int) Type {
17-
t := typ.(*rtype)
18-
if t.Kind() != Struct {
19-
panic("reflect: Field of non-struct type")
20-
}
21-
tt := (*structType)(unsafe.Pointer(t))
22-
return StructFieldType(tt, i)
23-
}
18+
//gopherjs:purge Used in FirstMethodNameBytes
19+
type EmbedWithUnexpMeth struct{}
2420

25-
// Field returns the i'th struct field.
26-
func StructFieldType(t *structType, i int) Type {
27-
if i < 0 || i >= len(t.fields) {
28-
panic("reflect: Field index out of bounds")
29-
}
30-
p := &t.fields[i]
31-
return toType(p.typ)
32-
}
21+
//gopherjs:purge Used in FirstMethodNameBytes
22+
type pinUnexpMeth interface{}
23+
24+
//gopherjs:purge Used in FirstMethodNameBytes
25+
var pinUnexpMethI pinUnexpMeth
26+
27+
//gopherjs:purge Uses pointer arithmetic for names
28+
func FirstMethodNameBytes(t Type) *byte
29+
30+
//gopherjs:purge Was unused
31+
type Buffer struct{}

0 commit comments

Comments
 (0)