mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-23 13:59:02 +00:00
reflect: add (u)int -> string conversions
This commit is contained in:
committed by
Damian Gryski
parent
f31b39775f
commit
e111b489ec
@@ -1686,12 +1686,25 @@ func makeComplex(flags valueFlags, f complex128, t *RawType) Value {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func cvtIntString(src Value, t *RawType) Value {
|
//go:linkname stringFromUnicode runtime.stringFromUnicode
|
||||||
panic("cvtUintString: unimplemented")
|
func stringFromUnicode(x rune) string
|
||||||
|
|
||||||
|
func cvtIntString(v Value, t *RawType) Value {
|
||||||
|
b := stringFromUnicode(rune(v.Int()))
|
||||||
|
return Value{
|
||||||
|
typecode: t,
|
||||||
|
value: unsafe.Pointer(&b),
|
||||||
|
flags: v.flags,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func cvtUintString(src Value, t *RawType) Value {
|
func cvtUintString(v Value, t *RawType) Value {
|
||||||
panic("cvtUintString: unimplemented")
|
b := stringFromUnicode(rune(v.Uint()))
|
||||||
|
return Value{
|
||||||
|
typecode: t,
|
||||||
|
value: unsafe.Pointer(&b),
|
||||||
|
flags: v.flags,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:linkname stringToRunes runtime.stringToRunes
|
//go:linkname stringToRunes runtime.stringToRunes
|
||||||
|
|||||||
Reference in New Issue
Block a user