macros: added bool literal support
This commit is contained in:
parent
2b4e233510
commit
43eae0c113
1 changed files with 6 additions and 0 deletions
|
|
@ -164,6 +164,7 @@ proc kind*(n: NimNode): NimNodeKind {.magic: "NKind", noSideEffect.}
|
||||||
## returns the `kind` of the node `n`.
|
## returns the `kind` of the node `n`.
|
||||||
|
|
||||||
proc intVal*(n: NimNode): BiggestInt {.magic: "NIntVal", noSideEffect.}
|
proc intVal*(n: NimNode): BiggestInt {.magic: "NIntVal", noSideEffect.}
|
||||||
|
proc boolVal*(n: NimNode): bool {.compileTime, noSideEffect.} = n.intVal != 0
|
||||||
proc floatVal*(n: NimNode): BiggestFloat {.magic: "NFloatVal", noSideEffect.}
|
proc floatVal*(n: NimNode): BiggestFloat {.magic: "NFloatVal", noSideEffect.}
|
||||||
proc symbol*(n: NimNode): NimSym {.magic: "NSymbol", noSideEffect.}
|
proc symbol*(n: NimNode): NimSym {.magic: "NSymbol", noSideEffect.}
|
||||||
proc ident*(n: NimNode): NimIdent {.magic: "NIdent", noSideEffect.}
|
proc ident*(n: NimNode): NimIdent {.magic: "NIdent", noSideEffect.}
|
||||||
|
|
@ -397,6 +398,11 @@ proc newLit*(i: BiggestInt): NimNode {.compileTime.} =
|
||||||
result = newNimNode(nnkIntLit)
|
result = newNimNode(nnkIntLit)
|
||||||
result.intVal = i
|
result.intVal = i
|
||||||
|
|
||||||
|
proc newLit*(b: bool): NimNode {.compileTime.} =
|
||||||
|
## produces a new boolean literal node.
|
||||||
|
result = newNimNode(nnkIntLit)
|
||||||
|
result.intVal = ord(b)
|
||||||
|
|
||||||
proc newLit*(f: BiggestFloat): NimNode {.compileTime.} =
|
proc newLit*(f: BiggestFloat): NimNode {.compileTime.} =
|
||||||
## produces a new float literal node.
|
## produces a new float literal node.
|
||||||
result = newNimNode(nnkFloatLit)
|
result = newNimNode(nnkFloatLit)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue