nim-chronos/chronos/srcloc.nim
cheatfate cd745a20ed
Add SourceLocation.
All the Future[T] operations using SourceLocation now.
2019-04-08 03:59:49 +03:00

17 lines
425 B
Nim

type
SrcLoc* = object
file*: cstring
line*: int
proc `$`*(loc: ptr SrcLoc): string =
result.add loc.file
result.add ":"
result.add $loc.line
proc srcLocImpl(file: static string, line: static int): ptr SrcLoc =
var loc {.global.} = SrcLoc(file: cstring(file), line: line)
return addr(loc)
template getSrcLocation*(): ptr SrcLoc =
srcLocImpl(instantiationInfo(-2).filename, instantiationInfo(-2).line)