Merge branch 'master' of github.com:Araq/Nimrod
This commit is contained in:
commit
05108cf81c
1 changed files with 23 additions and 1 deletions
|
|
@ -429,10 +429,16 @@ proc newStmtList*(stmts: varargs[PNimrodNode]): PNimrodNode {.compileTime.}=
|
||||||
proc newBlockStmt*(label, body: PNimrodNode): PNimrodNode {.compileTime.} =
|
proc newBlockStmt*(label, body: PNimrodNode): PNimrodNode {.compileTime.} =
|
||||||
## Create a new block statement with label
|
## Create a new block statement with label
|
||||||
return newNimNode(nnkBlockStmt).add(label, body)
|
return newNimNode(nnkBlockStmt).add(label, body)
|
||||||
|
|
||||||
proc newBlockStmt*(body: PNimrodNode): PNimrodNode {.compiletime.} =
|
proc newBlockStmt*(body: PNimrodNode): PNimrodNode {.compiletime.} =
|
||||||
## Create a new block: stmt
|
## Create a new block: stmt
|
||||||
return newNimNode(nnkBlockStmt).add(newEmptyNode(), body)
|
return newNimNode(nnkBlockStmt).add(newEmptyNode(), body)
|
||||||
|
|
||||||
|
proc newVarStmt*(name, value: PNimrodNode): PNimrodNode {.compiletime.} =
|
||||||
|
## Create a new var stmt
|
||||||
|
return newNimNode(nnkVarSection).add(
|
||||||
|
newNimNode(nnkIdentDefs).add(name, newNimNode(nnkEmpty), value))
|
||||||
|
|
||||||
proc newLetStmt*(name, value: PNimrodNode): PNimrodNode {.compiletime.} =
|
proc newLetStmt*(name, value: PNimrodNode): PNimrodNode {.compiletime.} =
|
||||||
## Create a new let stmt
|
## Create a new let stmt
|
||||||
return newNimNode(nnkLetSection).add(
|
return newNimNode(nnkLetSection).add(
|
||||||
|
|
@ -484,6 +490,22 @@ proc newProc*(name = newEmptyNode(); params: openarray[PNimrodNode] = [];
|
||||||
newEmptyNode(),
|
newEmptyNode(),
|
||||||
body)
|
body)
|
||||||
|
|
||||||
|
proc newIfStmt*(branches: varargs[tuple[cond, body: PNimrodNode]]):
|
||||||
|
PNimrodNode {.compiletime.} =
|
||||||
|
## Constructor for ``if`` statements.
|
||||||
|
##
|
||||||
|
## .. code-block:: nimrod
|
||||||
|
##
|
||||||
|
## newIfStmt(
|
||||||
|
## (Ident, StmtList),
|
||||||
|
## ...
|
||||||
|
## )
|
||||||
|
##
|
||||||
|
result = newNimNode(nnkIfStmt)
|
||||||
|
for i in branches:
|
||||||
|
result.add(newNimNode(nnkElifBranch).add(i.cond, i.body))
|
||||||
|
|
||||||
|
|
||||||
proc copyChildrenTo*(src, dest: PNimrodNode) {.compileTime.}=
|
proc copyChildrenTo*(src, dest: PNimrodNode) {.compileTime.}=
|
||||||
## Copy all children from `src` to `dest`
|
## Copy all children from `src` to `dest`
|
||||||
for i in 0 .. < src.len:
|
for i in 0 .. < src.len:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue