$ now works for unsigned intergers with nim js (#14122)

* $(unsigned) now works for js
* move NimMajor+friends closer to NimVersion according as per reviewer feedback
This commit is contained in:
Timothee Cour 2020-04-27 10:15:17 -07:00 • committed by GitHub
commit a3a317b76d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 96 additions and 4 deletions

View file

@ -1,8 +1,25 @@
include system/inclrtl
proc `$`*(x: int): string {.magic: "IntToStr", noSideEffect.}
## The stringify operator for an integer argument. Returns `x`
## converted to a decimal string. ``$`` is Nim's general way of
## spelling `toString`:idx:.
when defined(js):
since (1, 3):
proc `$`*(x: uint): string =
## Caveat: currently implemented as $(cast[int](x)), tied to current
## semantics of js' Number type.
# for c, see strmantle.`$`
$(cast[int](x))
proc `$`*(x: uint64): string =
## Compatibility note:
## the results may change in future releases if/when js target implements
## 64bit ints.
# pending https://github.com/nim-lang/RFCs/issues/187
$(cast[int](x))
proc `$`*(x: int64): string {.magic: "Int64ToStr", noSideEffect.}
## The stringify operator for an integer argument. Returns `x`
## converted to a decimal string.