2021-08-01 14:08:49 +03:00
|
|
|
module builtin
|
|
|
|
|
2022-04-15 20:50:51 +03:00
|
|
|
type byte = u8
|
|
|
|
|
2021-10-03 10:08:21 +03:00
|
|
|
pub fn (i i8) str() string {
|
|
|
|
mut res := ''
|
|
|
|
#res.str = i.val.toString()
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (i i16) str() string {
|
|
|
|
mut res := ''
|
|
|
|
#res.str = i.val.toString()
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (i u16) str() string {
|
|
|
|
mut res := ''
|
|
|
|
#res.str = i.val.toString()
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
2021-08-01 14:08:49 +03:00
|
|
|
pub fn (i int) str() string {
|
|
|
|
mut res := ''
|
2021-10-07 15:55:47 +03:00
|
|
|
#res = new string( i+'' )
|
2021-09-08 20:30:46 +03:00
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (i i64) str() string {
|
|
|
|
mut res := ''
|
2021-10-07 15:55:47 +03:00
|
|
|
#res = new string( i + '')
|
2021-09-08 20:30:46 +03:00
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (i u32) str() string {
|
|
|
|
mut res := ''
|
2021-10-07 15:55:47 +03:00
|
|
|
#res = new string( i + '')
|
2021-09-08 20:30:46 +03:00
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (i u64) str() string {
|
|
|
|
mut res := ''
|
2021-10-07 15:55:47 +03:00
|
|
|
#res = new string( i + '')
|
2021-09-08 20:30:46 +03:00
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (i bool) str() string {
|
|
|
|
mut res := ''
|
2021-10-07 15:55:47 +03:00
|
|
|
#res = new string( i + '')
|
2021-09-08 20:30:46 +03:00
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (i any) str() string {
|
|
|
|
mut res := ''
|
|
|
|
#res = new string( i.toString() )
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (i int_literal) str() string {
|
|
|
|
res := ''
|
|
|
|
#res.str = i.val.toString()
|
2021-08-01 14:08:49 +03:00
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
2021-10-03 10:08:21 +03:00
|
|
|
|
|
|
|
pub fn (x u64) hex() string {
|
|
|
|
res := ''
|
|
|
|
#res.str = x.val.toString(16)
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
2021-10-19 12:11:54 +03:00
|
|
|
pub fn (x u64) hex_full() string {
|
|
|
|
res := ''
|
|
|
|
#res.str = x.val.toString(16)
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
2021-10-03 10:08:21 +03:00
|
|
|
pub fn (x i64) hex() string {
|
|
|
|
res := ''
|
|
|
|
#res.str = x.val.toString(16)
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (x u32) hex() string {
|
|
|
|
res := ''
|
|
|
|
#res.str = x.val.toString(16)
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (x u16) hex() string {
|
|
|
|
res := ''
|
|
|
|
#res.str = x.val.toString(16)
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (x i8) hex() string {
|
|
|
|
res := ''
|
|
|
|
#res.str = x.val.toString(16)
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (x i16) hex() string {
|
|
|
|
res := ''
|
|
|
|
#res.str = x.val.toString(16)
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (x int) hex() string {
|
|
|
|
res := ''
|
|
|
|
#res.str = x.val.toString(16)
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (x int_literal) hex() string {
|
|
|
|
res := ''
|
|
|
|
#res.str = x.val.toString(16)
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
2022-04-15 20:31:10 +03:00
|
|
|
pub fn (x u8) hex() string {
|
2021-10-03 10:08:21 +03:00
|
|
|
res := ''
|
|
|
|
#res.str = x.val.toString(16)
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
// hex returns a string with the hexadecimal representation
|
|
|
|
// of the byte elements of the array.
|
2022-04-15 15:35:35 +03:00
|
|
|
pub fn (b []u8) hex() string {
|
2021-10-03 10:08:21 +03:00
|
|
|
mut hex := ''
|
|
|
|
for i in b {
|
|
|
|
mut z := i
|
|
|
|
z = z
|
|
|
|
#let n0 = i.val >> 4
|
|
|
|
#hex.str += n0 < 10 ? String.fromCharCode(n0) : String.fromCharCode(n0 + 87)
|
|
|
|
|
|
|
|
#let n1 = i.val & 0xF
|
|
|
|
#hex.str += n1 < 10 ? String.fromCharCode(n1) : String.fromCharCode(n1 + 87)
|
|
|
|
}
|
|
|
|
return hex
|
|
|
|
}
|
2021-10-20 16:02:21 +03:00
|
|
|
|
|
|
|
pub fn (i int) hex2() string {
|
|
|
|
return '0x' + i.hex()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (i i8) hex2() string {
|
|
|
|
return '0x' + i.hex()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (i i16) hex2() string {
|
|
|
|
return '0x' + i.hex()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (i i64) hex2() string {
|
|
|
|
return '0x' + i.hex()
|
|
|
|
}
|
|
|
|
|
2022-04-15 20:31:10 +03:00
|
|
|
pub fn (i u8) hex2() string {
|
2021-10-20 16:02:21 +03:00
|
|
|
return '0x' + i.hex()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (i u16) hex2() string {
|
|
|
|
return '0x' + i.hex()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (i u32) hex2() string {
|
|
|
|
return '0x' + i.hex()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (i u64) hex2() string {
|
|
|
|
return '0x' + i.hex()
|
|
|
|
}
|