summary refs log tree commit diff stats
path: root/compiler/ast.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2015-06-10 10:55:31 +0200
committerAndreas Rumpf <rumpf_a@web.de>2015-06-10 10:55:31 +0200
commitcb439d70bc85a1315b7dc44e82cf4aabd02ae7e4 (patch)
tree39900ed9e66d903382a32eb1bcdb6534b8032d77 /compiler/ast.nim
parentc237473e7184c3ccb6708b50d8d44e0f65cb43bc (diff)
parent867b38496b234df22ab34ef15344f848278b096d (diff)
downloadNim-cb439d70bc85a1315b7dc44e82cf4aabd02ae7e4.tar.gz
Merge pull request #2892 from apense/patch-6
Fixes #2886 (moves compiler function into the compiler)
Diffstat (limited to 'compiler/ast.nim')
-rw-r--r--compiler/ast.nim3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index 36d29e06a..668f20bcd 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -948,6 +948,9 @@ proc add*(father, son: PNode) =
 proc `[]`*(n: PNode, i: int): PNode {.inline.} =
   result = n.sons[i]
 
+template `-|`*(b, s: expr): expr =
+  (if b >= 0: b else: s.len + b)
+
 # son access operators with support for negative indices
 template `{}`*(n: PNode, i: int): expr = n[i -| n]
 template `{}=`*(n: PNode, i: int, s: PNode): stmt =