replaced asArray with a much more powerful mapLiterals macro

This commit is contained in:
Andreas Rumpf
2017-11-18 14:14:08 +01:00
parent 5b57abe354
commit 908a25a2ca
3 changed files with 49 additions and 19 deletions

View File

@@ -237,7 +237,7 @@ proc `ident=`*(n: NimNode, val: NimIdent) {.magic: "NSetIdent", noSideEffect.}
proc `strVal=`*(n: NimNode, val: string) {.magic: "NSetStrVal", noSideEffect.}
proc newNimNode*(kind: NimNodeKind,
lineInfoFrom: NimNode=nil): NimNode
lineInfoFrom: NimNode = nil): NimNode
{.magic: "NNewNimNode", noSideEffect.}
## Creates a new AST node of the specified kind.
##
@@ -470,7 +470,6 @@ proc newLit*(c: char): NimNode {.compileTime.} =
result = newNimNode(nnkCharLit)
result.intVal = ord(c)
proc newLit*(i: int): NimNode {.compileTime.} =
## produces a new integer literal node.
result = newNimNode(nnkIntLit)
@@ -581,6 +580,11 @@ proc newLit*(s: string): NimNode {.compileTime.} =
result = newNimNode(nnkStrLit)
result.strVal = s
proc isAtomicLit*(n: NimNode): bool =
## returns true if ``n`` is some kind literal like ``0.3`` (a ``float``
## literal) or ``"abc"`` (a ``string`` literal).
result = n.kind in {nnkCharLit..nnkNilLit}
proc nestList*(theProc: NimIdent,
x: NimNode): NimNode {.compileTime.} =
## nests the list `x` into a tree of call expressions: