diff options
author | Arne Döring <arne.doering@gmx.net> | 2017-07-17 08:12:15 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-07-17 08:12:15 +0200 |
commit | 52f092d02b5a4afa8cbd591bab9160e671f71700 (patch) | |
tree | 014875d219163f285d9e00137dcd19de0e106e79 /lib/core/macros.nim | |
parent | 9427724a718ece9396d85fe8fa6a604b59f6bfd7 (diff) | |
download | Nim-52f092d02b5a4afa8cbd591bab9160e671f71700.tar.gz |
Lineinfo change (#6084)
Diffstat (limited to 'lib/core/macros.nim')
-rw-r--r-- | lib/core/macros.nim | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index cdc91ce2b..3473c5d7e 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -317,10 +317,30 @@ proc toStrLit*(n: NimNode): NimNode {.compileTime.} = ## in a string literal node return newStrLitNode(repr(n)) -proc lineinfo*(n: NimNode): string {.magic: "NLineInfo", noSideEffect.} +type + LineInfo* = object + filename*: string + line*,column*: int + +proc `$`*(arg: Lineinfo): string = + result = arg.filename & "(" & $arg.line & ", " & $arg.column & ")" + +#proc lineinfo*(n: NimNode): LineInfo {.magic: "NLineInfo", noSideEffect.} ## returns the position the node appears in the original source file ## in the form filename(line, col) +proc getLine(arg: NimNode): int {.magic: "NLineInfo", noSideEffect.} +proc getColumn(arg: NimNode): int {.magic: "NLineInfo", noSideEffect.} +proc getFile(arg: NimNode): string {.magic: "NLineInfo", noSideEffect.} + +proc lineInfoObj*(n: NimNode): LineInfo {.compileTime.} = + result.filename = n.getFile + result.line = n.getLine + result.column = n.getColumn + +proc lineInfo*(arg: NimNode): string {.compileTime.} = + $arg.lineInfoObj + proc internalParseExpr(s: string): NimNode {. magic: "ParseExprToAst", noSideEffect.} |