added 'newLit'
This commit is contained in:
parent
ff1273a312
commit
094d7fd4b1
1 changed files with 21 additions and 1 deletions
|
|
@ -336,6 +336,26 @@ proc newCall*(theProc: string,
|
||||||
result.add(newIdentNode(theProc))
|
result.add(newIdentNode(theProc))
|
||||||
result.add(args)
|
result.add(args)
|
||||||
|
|
||||||
|
proc newLit*(c: char): PNimrodNode {.compileTime.} =
|
||||||
|
## produces a new character literal node.
|
||||||
|
result = newNimNode(nnkCharLit)
|
||||||
|
result.intVal = ord(c)
|
||||||
|
|
||||||
|
proc newLit*(i: biggestInt): PNimrodNode {.compileTime.} =
|
||||||
|
## produces a new integer literal node.
|
||||||
|
result = newNimNode(nnkIntLit)
|
||||||
|
result.intVal = i
|
||||||
|
|
||||||
|
proc newLit*(f: biggestFloat): PNimrodNode {.compileTime.} =
|
||||||
|
## produces a new float literal node.
|
||||||
|
result = newNimNode(nnkFloatLit)
|
||||||
|
result.floatVal = f
|
||||||
|
|
||||||
|
proc newLit*(s: string): PNimrodNode {.compileTime.} =
|
||||||
|
## produces a new string literal node.
|
||||||
|
result = newNimNode(nnkStrLit)
|
||||||
|
result.strVal = s
|
||||||
|
|
||||||
proc nestList*(theProc: TNimrodIdent,
|
proc nestList*(theProc: TNimrodIdent,
|
||||||
x: PNimrodNode): PNimrodNode {.compileTime.} =
|
x: PNimrodNode): PNimrodNode {.compileTime.} =
|
||||||
## nests the list `x` into a tree of call expressions:
|
## nests the list `x` into a tree of call expressions:
|
||||||
|
|
@ -677,7 +697,7 @@ proc addIdentIfAbsent*(dest: PNimrodNode, ident: string) {.compiletime.} =
|
||||||
of nnkIdent:
|
of nnkIdent:
|
||||||
if ident.eqIdent($node): return
|
if ident.eqIdent($node): return
|
||||||
of nnkExprColonExpr:
|
of nnkExprColonExpr:
|
||||||
if ident.eqIdent($ node[0]): return
|
if ident.eqIdent($node[0]): return
|
||||||
else: nil
|
else: nil
|
||||||
dest.add(ident(ident))
|
dest.add(ident(ident))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue