mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
include std/private/digitsutils
This commit is contained in:
@@ -21,7 +21,9 @@ proc addCstringN(result: var string, buf: cstring; buflen: int) =
|
||||
result.setLen newLen
|
||||
c_memcpy(result[oldLen].addr, buf, buflen.csize_t)
|
||||
|
||||
import std/private/digitsutils
|
||||
|
||||
when not declared(ThisIsSystem):
|
||||
include std/private/digitsutils
|
||||
|
||||
include private/dragonbox
|
||||
include private/schubfach
|
||||
|
||||
@@ -34,12 +34,12 @@ const
|
||||
when not defined(nimHasEnforceNoRaises):
|
||||
{.pragma: enforceNoRaises.}
|
||||
|
||||
proc utoa2Digits*(buf: var openArray[char]; pos: int; digits: uint32) {.inline, enforceNoRaises.} =
|
||||
proc utoa2Digits(buf: var openArray[char]; pos: int; digits: uint32) {.inline, enforceNoRaises.} =
|
||||
buf[pos] = digits100[2 * digits]
|
||||
buf[pos+1] = digits100[2 * digits + 1]
|
||||
#copyMem(buf, unsafeAddr(digits100[2 * digits]), 2 * sizeof((char)))
|
||||
|
||||
proc trailingZeros2Digits*(digits: uint32): int {.inline, enforceNoRaises.} =
|
||||
proc trailingZeros2Digits(digits: uint32): int {.inline, enforceNoRaises.} =
|
||||
trailingZeros100[digits]
|
||||
|
||||
when defined(js):
|
||||
@@ -85,14 +85,14 @@ func addIntImpl(result: var string, x: uint64) {.inline, enforceNoRaises.} =
|
||||
addChars(result, tmp, next, tmp.len - next)
|
||||
|
||||
|
||||
func addInt*(result: var string, x: uint64) {.enforceNoRaises.} =
|
||||
func addInt(result: var string, x: uint64) {.enforceNoRaises.} =
|
||||
when nimvm: addIntImpl(result, x)
|
||||
else:
|
||||
when not defined(js): addIntImpl(result, x)
|
||||
else:
|
||||
addChars(result, numToString(x))
|
||||
|
||||
proc addInt*(result: var string; x: int64) {.enforceNoRaises.} =
|
||||
proc addInt(result: var string; x: int64) {.enforceNoRaises.} =
|
||||
## Converts integer to its string representation and appends it to `result`.
|
||||
runnableExamples:
|
||||
var s = "foo"
|
||||
@@ -115,7 +115,10 @@ proc addInt*(result: var string; x: int64) {.enforceNoRaises.} =
|
||||
addChars(result, numToString(x))
|
||||
else: impl()
|
||||
|
||||
proc addInt*(result: var string; x: int) {.inline, enforceNoRaises.} =
|
||||
proc addInt(result: var string; x: int) {.inline, enforceNoRaises.} =
|
||||
addInt(result, int64(x))
|
||||
|
||||
proc addIntSysimpl*(result: var string; x: int) {.inline, enforceNoRaises.} =
|
||||
addInt(result, x)
|
||||
|
||||
{.pop.}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from std/private/digitsutils import addInt
|
||||
from digitsutils import addIntSysimpl
|
||||
|
||||
template toLocation*(result: var string, file: string | cstring, line: int, col: int) =
|
||||
## avoids spurious allocations
|
||||
@@ -13,10 +13,10 @@ template toLocation*(result: var string, file: string | cstring, line: int, col:
|
||||
result.add file
|
||||
if line > 0:
|
||||
result.add "("
|
||||
addInt(result, line)
|
||||
addIntSysimpl(result, line)
|
||||
if col > 0:
|
||||
result.add ", "
|
||||
addInt(result, col)
|
||||
addIntSysimpl(result, col)
|
||||
result.add ")"
|
||||
|
||||
proc isNamedTuple(T: typedesc): bool {.magic: "TypeTrait".}
|
||||
|
||||
@@ -2127,6 +2127,9 @@ template unlikely*(val: bool): bool =
|
||||
else:
|
||||
unlikelyProc(val)
|
||||
|
||||
include std/private/digitsutils
|
||||
export addInt
|
||||
|
||||
import system/dollars
|
||||
export dollars
|
||||
|
||||
@@ -2457,9 +2460,6 @@ proc finished*[T: iterator {.closure.}](x: T): bool {.noSideEffect, inline, magi
|
||||
`result` = ((NI*) `x`.ClE_0)[1] < 0;
|
||||
""".}
|
||||
|
||||
from std/private/digitsutils import addInt
|
||||
export addInt
|
||||
|
||||
when defined(js) and not defined(nimscript):
|
||||
# nimscript can be defined if config file for js compilation
|
||||
include "system/jssys"
|
||||
|
||||
@@ -3,7 +3,7 @@ runnableExamples:
|
||||
assert $0.1 == "0.1"
|
||||
assert $(-2*3) == "-6"
|
||||
|
||||
import std/private/[digitsutils, miscdollars]
|
||||
import std/private/miscdollars
|
||||
|
||||
when not defined(nimPreviewSlimSystem):
|
||||
import std/formatfloat
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#
|
||||
|
||||
# Compilerprocs for strings that do not depend on the string implementation.
|
||||
import std/private/digitsutils as digitsutils2
|
||||
|
||||
proc cmpStrings(a, b: string): int {.inline, compilerproc.} =
|
||||
let alen = a.len
|
||||
|
||||
Reference in New Issue
Block a user