mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 11:37:46 +00:00
reflect: implement support for array types
This commit is contained in:
committed by
Ron Evans
parent
bbc3046687
commit
c19c738f52
Vendored
+6
-2
@@ -91,7 +91,8 @@ func main() {
|
||||
[]complex128{1, 1.128 + 0.4i},
|
||||
myslice{5, 3, 11},
|
||||
// array
|
||||
[4]int{1, 2, 3, 4},
|
||||
[3]int64{5, 8, 2},
|
||||
[2]uint8{3, 5},
|
||||
// functions
|
||||
zeroFunc,
|
||||
emptyFunc,
|
||||
@@ -287,7 +288,10 @@ func showValue(rv reflect.Value, indent string) {
|
||||
case reflect.UnsafePointer:
|
||||
println(indent+" pointer:", rv.Pointer() != 0)
|
||||
case reflect.Array:
|
||||
println(indent + " array")
|
||||
println(indent+" array:", rt.Len(), rt.Elem().Kind().String(), int(rt.Size()))
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
showValue(rv.Index(i), indent+" ")
|
||||
}
|
||||
case reflect.Chan:
|
||||
println(indent+" chan:", rt.Elem().Kind().String())
|
||||
println(indent+" nil:", rv.IsNil())
|
||||
|
||||
Vendored
+13
-1
@@ -203,7 +203,19 @@ reflect type: slice
|
||||
reflect type: uint8 settable=true
|
||||
uint: 11
|
||||
reflect type: array
|
||||
array
|
||||
array: 3 int64 24
|
||||
reflect type: int64
|
||||
int: 5
|
||||
reflect type: int64
|
||||
int: 8
|
||||
reflect type: int64
|
||||
int: 2
|
||||
reflect type: array
|
||||
array: 2 uint8 2
|
||||
reflect type: uint8
|
||||
uint: 3
|
||||
reflect type: uint8
|
||||
uint: 5
|
||||
reflect type: func
|
||||
func
|
||||
nil: true
|
||||
|
||||
Reference in New Issue
Block a user