summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-04-26 02:16:33 -0700
committerAraq <rumpf_a@web.de>2013-04-26 02:16:33 -0700
commita31c81e31c47d3b1aeb5ff30c166cc72985cfe84 (patch)
tree994bb129caacdb122dad45abc25154fe12dca8a2
parent171155a12dcb08d9557b7099efae54bebd1d19f1 (diff)
parent0169d671b3727c239d3808877b94b6e0ebc505d4 (diff)
downloadNim-a31c81e31c47d3b1aeb5ff30c166cc72985cfe84.tar.gz
Merge pull request #403 from fowlmouth/patch-4
update macros.add()
-rw-r--r--compiler/evals.nim4
-rw-r--r--lib/core/macros.nim14
2 files changed, 10 insertions, 8 deletions
diff --git a/compiler/evals.nim b/compiler/evals.nim
index 2a9fae5f0..3f5b7887a 100644
--- a/compiler/evals.nim
+++ b/compiler/evals.nim
@@ -1099,7 +1099,7 @@ proc evalMagicOrCall(c: PEvalContext, n: PNode): PNode =
     result = evalAux(c, n.sons[2], {efLValue})
     if isSpecial(result): return 
     addSon(a, result)
-    result = emptyNode
+    result = a
   of mNAddMultiple: 
     result = evalAux(c, n.sons[1], {efLValue})
     if isSpecial(result): return 
@@ -1107,7 +1107,7 @@ proc evalMagicOrCall(c: PEvalContext, n: PNode): PNode =
     result = evalAux(c, n.sons[2], {efLValue})
     if isSpecial(result): return 
     for i in countup(0, sonsLen(result) - 1): addSon(a, result.sons[i])
-    result = emptyNode
+    result = a
   of mNDel: 
     result = evalAux(c, n.sons[1], {efLValue})
     if isSpecial(result): return 
diff --git a/lib/core/macros.nim b/lib/core/macros.nim
index 4598fa9ea..949719316 100644
--- a/lib/core/macros.nim
+++ b/lib/core/macros.nim
@@ -130,12 +130,14 @@ proc `==`*(a, b: PNimrodNode): bool {.magic: "EqNimrodNode", noSideEffect.}
 proc len*(n: PNimrodNode): int {.magic: "NLen".}
   ## returns the number of children of `n`.
 
-proc add*(father, child: PNimrodNode) {.magic: "NAdd".}
-  ## adds the `child` to the `father` node
-
-proc add*(father: PNimrodNode, children: varargs[PNimrodNode]) {.
-  magic: "NAddMultiple".}
-  ## adds each child of `children` to the `father` node
+proc add*(father, child: PNimrodNode): PNimrodNode {.magic: "NAdd", discardable.}
+  ## Adds the `child` to the `father` node. Returns the
+  ## father node so that calls can be nested.
+
+proc add*(father: PNimrodNode, children: varargs[PNimrodNode]): PNimrodNode {.
+  magic: "NAddMultiple", discardable.}
+  ## Adds each child of `children` to the `father` node.
+  ## Returns the `father` node so that calls can be nested.
 
 proc del*(father: PNimrodNode, idx = 0, n = 1) {.magic: "NDel".}
   ## deletes `n` children of `father` starting at index `idx`.