mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 13:03:39 +00:00
reflect,reflectlite: make IsRO/MakeRO package methods
Having them as methods on reflectlite.Value makes them visible to the user. Also move new functions out of all_test.go so it can stay closer to upstream (except for comments).
This commit is contained in:
committed by
Damian Gryski
parent
33ddee76db
commit
10224a4bf8
@@ -47,11 +47,18 @@ func (v Value) isExported() bool {
|
||||
return v.flags&valueFlagExported != 0
|
||||
}
|
||||
|
||||
func (v Value) IsRO() bool {
|
||||
func (v Value) isRO() bool {
|
||||
return v.flags&(valueFlagRO) != 0
|
||||
}
|
||||
|
||||
func (v Value) MakeRO(ro bool) Value {
|
||||
// These are package methods, not methods on Value, since the reflect.Value embeds a reflectlite.Value, so any
|
||||
// methods added to reflectlite.Value are visible to the user.
|
||||
|
||||
func IsRO(v Value) bool {
|
||||
return v.isRO()
|
||||
}
|
||||
|
||||
func MakeRO(v Value, ro bool) Value {
|
||||
if ro {
|
||||
v.flags |= valueFlagRO
|
||||
} else {
|
||||
@@ -61,7 +68,7 @@ func (v Value) MakeRO(ro bool) Value {
|
||||
}
|
||||
|
||||
func (v Value) checkRO() {
|
||||
if v.IsRO() {
|
||||
if v.isRO() {
|
||||
panic("reflect: value is not settable")
|
||||
}
|
||||
}
|
||||
@@ -306,7 +313,7 @@ func (v Value) IsValid() bool {
|
||||
}
|
||||
|
||||
func (v Value) CanInterface() bool {
|
||||
return v.isExported() && !v.IsRO()
|
||||
return v.isExported() && !v.isRO()
|
||||
}
|
||||
|
||||
func (v Value) CanAddr() bool {
|
||||
|
||||
Reference in New Issue
Block a user