Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions lib/system/strmantle.nim → lib/std/private/strmantle.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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" &
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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" &
13 changes: 12 additions & 1 deletion lib/system.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/dll/nimhcr_0.nim
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/dll/nimhcr_0_1.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/dll/nimhcr_0_2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
2 changes: 1 addition & 1 deletion tests/dll/nimhcr_0_3.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/dll/nimhcr_0_4.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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.} =
Expand Down
2 changes: 1 addition & 1 deletion tests/dll/nimhcr_0_5.nim
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

proc getInt*(): int = return 42 # back to the answer...
proc tgetInt*(): int = return 42 # back to the answer...
2 changes: 1 addition & 1 deletion tests/dll/nimhcr_0_6.nim
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions tests/dll/nimhcr_integration.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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]
Expand Down
File renamed without changes.