mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 05:53:39 +00:00
reflect: add SetLen()
This commit is contained in:
committed by
Damian Gryski
parent
e4ef6f85ac
commit
960a0b79bf
@@ -952,7 +952,15 @@ func (v Value) SetCap(n int) {
|
||||
}
|
||||
|
||||
func (v Value) SetLen(n int) {
|
||||
panic("unimplemented: (reflect.Value).SetLen()")
|
||||
if v.typecode.Kind() != Slice {
|
||||
panic(&ValueError{"reflect.Value.SetLen", v.Kind()})
|
||||
}
|
||||
|
||||
hdr := (*sliceHeader)(v.value)
|
||||
if int(uintptr(n)) != n || uintptr(n) > hdr.cap {
|
||||
panic("reflect.Value.SetLen: slice length out of range")
|
||||
}
|
||||
hdr.len = uintptr(n)
|
||||
}
|
||||
|
||||
func (v Value) checkAddressable() {
|
||||
|
||||
Reference in New Issue
Block a user