mirror of
https://github.com/nim-lang/Nim.git
synced 2026-05-04 13:04:44 +00:00
Lineinfo change (#6084)
This commit is contained in:
committed by
Andreas Rumpf
parent
9427724a71
commit
52f092d02b
@@ -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.}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user