diff --git a/lib/system/strmantle.nim b/lib/std/private/strmantle.nim similarity index 96% rename from lib/system/strmantle.nim rename to lib/std/private/strmantle.nim index 42ea9d22609c8..fd7d8f2aba694 100644 --- a/lib/system/strmantle.nim +++ b/lib/std/private/strmantle.nim @@ -9,6 +9,9 @@ # Compilerprocs for strings that do not depend on the string implementation. +import system/ansi_c +include system/inclrtl + const digitsTable = "0001020304050607080910111213141516171819" & "2021222324252627282930313233343536373839" & "4041424344454647484950515253545556575859" & @@ -143,7 +146,7 @@ proc addCstringN(result: var string, buf: cstring; buflen: int) = result.setLen newLen copyMem(result[oldLen].addr, buf, buflen) -import formatfloat +import system/formatfloat proc addFloat*(result: var string; x: float) = ## Converts float to its string representation and appends it to `result`. @@ -344,12 +347,3 @@ proc nimBoolToStr(x: bool): string {.compilerRtl.} = proc nimCharToStr(x: char): string {.compilerRtl.} = result = newString(1) result[0] = x - -when defined(gcDestructors): - proc GC_getStatistics*(): string = - result = "[GC] total memory: " - result.addInt getTotalMem() - result.add "\n[GC] occupied memory: " - result.addInt getOccupiedMem() - result.add '\n' - #"[GC] cycle collections: " & $gch.stat.cycleCollections & "\n" & diff --git a/lib/system.nim b/lib/system.nim index 4c31f20a21fa2..d8b5221762f0b 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2379,7 +2379,18 @@ when notJSnotNims and hasAlloc: include "system/sysstr" {.pop.} - include "system/strmantle" + from std/private/strmantle import addInt, addFloat + export addInt, addFloat + + when defined(gcDestructors): + proc GC_getStatistics*(): string = + result = "[GC] total memory: " + result.addInt getTotalMem() + result.add "\n[GC] occupied memory: " + result.addInt getOccupiedMem() + result.add '\n' + #"[GC] cycle collections: " & $gch.stat.cycleCollections & "\n" & + include "system/assign" when not defined(nimV2): diff --git a/tests/dll/nimhcr_0.nim b/tests/dll/nimhcr_0.nim index fe0b29a36f610..98cae5815eace 100644 --- a/tests/dll/nimhcr_0.nim +++ b/tests/dll/nimhcr_0.nim @@ -1,4 +1,4 @@ let g_0 = 1000 # new value! but also a "new" global :) -proc getInt*(): int = return g_0 +proc tgetInt*(): int = return g_0 diff --git a/tests/dll/nimhcr_0_1.nim b/tests/dll/nimhcr_0_1.nim index 620050be3ed17..d3df5ca6dfceb 100644 --- a/tests/dll/nimhcr_0_1.nim +++ b/tests/dll/nimhcr_0_1.nim @@ -3,7 +3,7 @@ import hotcodereloading let g_0 = 42 # lets start with the ultimate answer -proc getInt*(): int = return g_0 +proc tgetInt*(): int = return g_0 programResult = 0 # should be accessible diff --git a/tests/dll/nimhcr_0_2.nim b/tests/dll/nimhcr_0_2.nim index 9ce228dc16648..e55fe584decb5 100644 --- a/tests/dll/nimhcr_0_2.nim +++ b/tests/dll/nimhcr_0_2.nim @@ -9,7 +9,7 @@ echo " 0: I SHOULDN'T BE PRINTED!" var g_0 = 0 # changed value but won't take effect -proc getInt*(): int = return g_0 + g_1 + f_1() +proc tgetInt*(): int = return g_0 + g_1 + f_1() beforeCodeReload: echo " 0: before - improved!" # changed handlers! diff --git a/tests/dll/nimhcr_0_3.nim b/tests/dll/nimhcr_0_3.nim index 183424e11f5e9..d8b10f3eb10e5 100644 --- a/tests/dll/nimhcr_0_3.nim +++ b/tests/dll/nimhcr_0_3.nim @@ -16,4 +16,4 @@ afterCodeReload: echo " 0: after - closure iterator: ", c() echo " 0: after - c_2 = ", c_2 -proc getInt*(): int = return g_1 + g_2.len +proc tgetInt*(): int = return g_1 + g_2.len diff --git a/tests/dll/nimhcr_0_4.nim b/tests/dll/nimhcr_0_4.nim index 4471782a7eaa5..748b3c02fe00a 100644 --- a/tests/dll/nimhcr_0_4.nim +++ b/tests/dll/nimhcr_0_4.nim @@ -5,7 +5,7 @@ import nimhcr_1 # only importing 1 let g_0 = 1000 # new value! but also a "new" global :) -proc getInt*(): int = return g_0 +proc tgetInt*(): int = return g_0 proc makeCounter*(): auto = return iterator: int {.closure.} = diff --git a/tests/dll/nimhcr_0_5.nim b/tests/dll/nimhcr_0_5.nim index aff4014ca02f9..253bc72435c12 100644 --- a/tests/dll/nimhcr_0_5.nim +++ b/tests/dll/nimhcr_0_5.nim @@ -1,2 +1,2 @@ -proc getInt*(): int = return 42 # back to the answer... +proc tgetInt*(): int = return 42 # back to the answer... diff --git a/tests/dll/nimhcr_0_6.nim b/tests/dll/nimhcr_0_6.nim index fe0b29a36f610..98cae5815eace 100644 --- a/tests/dll/nimhcr_0_6.nim +++ b/tests/dll/nimhcr_0_6.nim @@ -1,4 +1,4 @@ let g_0 = 1000 # new value! but also a "new" global :) -proc getInt*(): int = return g_0 +proc tgetInt*(): int = return g_0 diff --git a/tests/dll/nimhcr_integration.nim b/tests/dll/nimhcr_integration.nim index ac34f1f85e649..6e1563810fab0 100644 --- a/tests/dll/nimhcr_integration.nim +++ b/tests/dll/nimhcr_integration.nim @@ -79,7 +79,7 @@ After instrumenting code, the stacktrace actually points to the call to `check m ## A few files can be updated by calling `update` for each of their indexes ## and after that with a single call to `compileReloadExecute` the new version ## of the program will be compiled, reloaded, and the only thing the main module -## calls from `nimhcr_0.nim` (the procedure `getInt` proc) is called for a result. +## calls from `nimhcr_0.nim` (the procedure `tgetInt` proc) is called for a result. ## ## This test is expected to be executed with arguments - the full nim compiler ## command used for building it - so it can rebuild iself the same way - example: @@ -91,7 +91,7 @@ After instrumenting code, the stacktrace actually points to the call to `check m import os, osproc, strutils, hotcodereloading -import nimhcr_0 # getInt() - the only thing we continually call from the main module +import nimhcr_0 # tgetInt() - the only thing we continually call from the main module proc compileReloadExecute() = # Remove the `--forceBuild` option - is there in the first place because: @@ -121,7 +121,7 @@ proc compileReloadExecute() = quit 1 echo "main: hasAnyModuleChanged? ", hasAnyModuleChanged() performCodeReload() - echo " The answer is: ", getInt() + echo " The answer is: ", tgetInt() # there are 3 files and all of them start from their 1st version var vers = [1, 1, 1] diff --git a/tests/system/tstrmantle.nim b/tests/stdlib/tstrmantle.nim similarity index 100% rename from tests/system/tstrmantle.nim rename to tests/stdlib/tstrmantle.nim