--gc:destructors: next steps; WIP
This commit is contained in:
parent
4389409e26
commit
f485ebe162
8 changed files with 108 additions and 64 deletions
|
|
@ -278,3 +278,21 @@ proc nimBoolToStr(x: bool): string {.compilerRtl.} =
|
|||
proc nimCharToStr(x: char): string {.compilerRtl.} =
|
||||
result = newString(1)
|
||||
result[0] = x
|
||||
|
||||
proc `$`(x: uint64): string =
|
||||
if x == 0:
|
||||
result = "0"
|
||||
else:
|
||||
result = newString(60)
|
||||
var i = 0
|
||||
var n = x
|
||||
while n != 0:
|
||||
let nn = n div 10'u64
|
||||
result[i] = char(n - 10'u64 * nn + ord('0'))
|
||||
inc i
|
||||
n = nn
|
||||
result.setLen i
|
||||
|
||||
let half = i div 2
|
||||
# Reverse
|
||||
for t in 0 .. half-1: swap(result[t], result[i-t-1])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue