mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 12:03:41 +00:00
reflect: add support for DeepEqual
The implementation has been mostly copied from the Go reference implementation with some small changes to fit TinyGo. Source: https://github.com/golang/go/blob/77a11c05d6a6f766c75f804ea9b8796f9a9f85a3/src/reflect/deepequal.go In addition, this commit also contains the following: - A set of tests copied from the Go reflect package. - An increased stack size for the riscv-qemu and hifive1-qemu targets (because they otherwise fail to run the tests). Because these targets are only used for testing, this seems fine to me.
This commit is contained in:
committed by
Ron Evans
parent
5866a47e77
commit
335fb71d2f
+10
-4
@@ -140,10 +140,7 @@ func (v Value) IsNil() bool {
|
||||
func (v Value) Pointer() uintptr {
|
||||
switch v.Kind() {
|
||||
case Chan, Map, Ptr, UnsafePointer:
|
||||
if v.isIndirect() {
|
||||
return *(*uintptr)(v.value)
|
||||
}
|
||||
return uintptr(v.value)
|
||||
return uintptr(v.pointer())
|
||||
case Slice:
|
||||
slice := (*sliceHeader)(v.value)
|
||||
return uintptr(slice.data)
|
||||
@@ -154,6 +151,15 @@ func (v Value) Pointer() uintptr {
|
||||
}
|
||||
}
|
||||
|
||||
// pointer returns the underlying pointer represented by v.
|
||||
// v.Kind() must be Ptr, Map, Chan, or UnsafePointer
|
||||
func (v Value) pointer() unsafe.Pointer {
|
||||
if v.isIndirect() {
|
||||
return *(*unsafe.Pointer)(v.value)
|
||||
}
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v Value) IsValid() bool {
|
||||
return v.typecode != 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user