diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system/embedded.nim | 10 | ||||
-rw-r--r-- | lib/system/strmantle.nim | 20 |
2 files changed, 20 insertions, 10 deletions
diff --git a/lib/system/embedded.nim b/lib/system/embedded.nim index c4f15a336..258558c3f 100644 --- a/lib/system/embedded.nim +++ b/lib/system/embedded.nim @@ -44,3 +44,13 @@ proc setControlCHook(hook: proc () {.noconv.}) = discard proc closureIterSetupExc(e: ref Exception) {.compilerproc, inline.} = sysFatal(ReraiseDefect, "exception handling is not available") + +when gotoBasedExceptions: + var nimInErrorMode {.threadvar.}: bool + + proc nimErrorFlag(): ptr bool {.compilerRtl, inl.} = + result = addr(nimInErrorMode) + + proc nimTestErrorFlag() {.compilerRtl.} = + if nimInErrorMode: + sysFatal(ReraiseDefect, "exception handling is not available") diff --git a/lib/system/strmantle.nim b/lib/system/strmantle.nim index b5d275e25..7553f921b 100644 --- a/lib/system/strmantle.nim +++ b/lib/system/strmantle.nim @@ -24,26 +24,26 @@ const digitsTable = "0001020304050607080910111213141516171819" & # else: # res.add $i # doAssert res == digitsTable - + func digits10(num: uint64): int {.noinline.} = - if num < 10: + if num < 10'u64: result = 1 - elif num < 100: + elif num < 100'u64: result = 2 - elif num < 1_000: + elif num < 1_000'u64: result = 3 - elif num < 10_000: + elif num < 10_000'u64: result = 4 - elif num < 100_000: + elif num < 100_000'u64: result = 5 - elif num < 1_000_000: + elif num < 1_000_000'u64: result = 6 - elif num < 10_000_000: + elif num < 10_000_000'u64: result = 7 - elif num < 100_000_000: + elif num < 100_000_000'u64: result = 8 - elif num < 1_000_000_000: + elif num < 1_000_000_000'u64: result = 9 elif num < 10_000_000_000'u64: result = 10 |