mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-29 01:51:43 +00:00
system.nim: refactoring that removes cyclic dependencies in prep for IC
This commit is contained in:
@@ -19,12 +19,16 @@ import std/private/miscdollars
|
||||
|
||||
type InstantiationInfo = tuple[filename: string, line: int, column: int]
|
||||
|
||||
{.push overflowChecks: off, rangeChecks: off.}
|
||||
|
||||
proc `$`(info: InstantiationInfo): string =
|
||||
# The +1 is needed here
|
||||
# instead of overriding `$` (and changing its meaning), consider explicit name.
|
||||
result = ""
|
||||
result.toLocation(info.filename, info.line, info.column + 1)
|
||||
|
||||
{.pop.}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,13 @@ template toLocation*(result: var string, file: string | cstring, line: int, col:
|
||||
## avoids spurious allocations
|
||||
# Hopefully this can be re-used everywhere so that if a user needs to customize,
|
||||
# it can be done in a single place.
|
||||
result.add file
|
||||
when file is cstring:
|
||||
var i = 0
|
||||
while file[i] != '\0':
|
||||
add(result, file[i])
|
||||
inc i
|
||||
else:
|
||||
result.add file
|
||||
if line > 0:
|
||||
result.add "("
|
||||
addInt(result, line)
|
||||
|
||||
Reference in New Issue
Block a user