removed macros.high as it never worked outside of macros.nim
This commit is contained in:
parent
f3a0d702ae
commit
8913e82f45
2 changed files with 10 additions and 10 deletions
|
|
@ -592,10 +592,8 @@ proc newNilLit*(): NimNode {.compileTime.} =
|
||||||
## New nil literal shortcut
|
## New nil literal shortcut
|
||||||
result = newNimNode(nnkNilLit)
|
result = newNimNode(nnkNilLit)
|
||||||
|
|
||||||
proc high*(node: NimNode): int {.compileTime.} = len(node) - 1
|
proc last*(node: NimNode): NimNode {.compileTime.} = node[<node.len]
|
||||||
## Return the highest index available for a node
|
## Return the last item in nodes children. Same as `node[^1]`
|
||||||
proc last*(node: NimNode): NimNode {.compileTime.} = node[node.high]
|
|
||||||
## Return the last item in nodes children. Same as `node[node.high()]`
|
|
||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
@ -695,7 +693,7 @@ proc `body=`*(someProc: NimNode, val: NimNode) {.compileTime.} =
|
||||||
of nnkBlockStmt, nnkWhileStmt:
|
of nnkBlockStmt, nnkWhileStmt:
|
||||||
someProc[1] = val
|
someProc[1] = val
|
||||||
of nnkForStmt:
|
of nnkForStmt:
|
||||||
someProc[high(someProc)] = val
|
someProc[len(someProc)-1] = val
|
||||||
else:
|
else:
|
||||||
badNodeKind someProc.kind, "body="
|
badNodeKind someProc.kind, "body="
|
||||||
|
|
||||||
|
|
@ -722,7 +720,7 @@ proc ident*(name: string): NimNode {.compileTime,inline.} = newIdentNode(name)
|
||||||
## Create a new ident node from a string
|
## Create a new ident node from a string
|
||||||
|
|
||||||
iterator children*(n: NimNode): NimNode {.inline.}=
|
iterator children*(n: NimNode): NimNode {.inline.}=
|
||||||
for i in 0 .. high(n):
|
for i in 0 ..< n.len:
|
||||||
yield n[i]
|
yield n[i]
|
||||||
|
|
||||||
template findChild*(n: NimNode; cond: expr): NimNode {.
|
template findChild*(n: NimNode; cond: expr): NimNode {.
|
||||||
|
|
@ -742,16 +740,16 @@ template findChild*(n: NimNode; cond: expr): NimNode {.
|
||||||
|
|
||||||
proc insert*(a: NimNode; pos: int; b: NimNode) {.compileTime.} =
|
proc insert*(a: NimNode; pos: int; b: NimNode) {.compileTime.} =
|
||||||
## Insert node B into A at pos
|
## Insert node B into A at pos
|
||||||
if high(a) < pos:
|
if len(a)-1 < pos:
|
||||||
## add some empty nodes first
|
## add some empty nodes first
|
||||||
for i in high(a)..pos-2:
|
for i in len(a)-1..pos-2:
|
||||||
a.add newEmptyNode()
|
a.add newEmptyNode()
|
||||||
a.add b
|
a.add b
|
||||||
else:
|
else:
|
||||||
## push the last item onto the list again
|
## push the last item onto the list again
|
||||||
## and shift each item down to pos up one
|
## and shift each item down to pos up one
|
||||||
a.add(a[a.high])
|
a.add(a[a.len-1])
|
||||||
for i in countdown(high(a) - 2, pos):
|
for i in countdown(len(a) - 3, pos):
|
||||||
a[i + 1] = a[i]
|
a[i + 1] = a[i]
|
||||||
a[pos] = b
|
a[pos] = b
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,8 @@ News
|
||||||
- ``sequtils.delete`` doesn't take confusing default arguments anymore.
|
- ``sequtils.delete`` doesn't take confusing default arguments anymore.
|
||||||
- ``system.free`` was an error-prone alias to ``system.dealloc`` and has
|
- ``system.free`` was an error-prone alias to ``system.dealloc`` and has
|
||||||
been removed.
|
been removed.
|
||||||
|
- ``macros.high`` never worked and the manual says ``high`` cannot be
|
||||||
|
overloaded, so we removed it with no deprecation cycle.
|
||||||
|
|
||||||
|
|
||||||
Library additions
|
Library additions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue