various bugfixes for generics; added generic sort proc

This commit is contained in:
Araq 2011-03-03 02:01:22 +01:00
commit e424e13bd9
18 changed files with 392 additions and 113 deletions

View file

@ -750,6 +750,12 @@ proc newSymNode(sym: PSym): PNode =
result.typ = sym.typ
result.info = sym.info
proc newSymNode*(sym: PSym, info: TLineInfo): PNode =
result = newNode(nkSym)
result.sym = sym
result.typ = sym.typ
result.info = info
proc newNodeI(kind: TNodeKind, info: TLineInfo): PNode =
result = newNode(kind)
result.info = info
@ -869,6 +875,11 @@ proc len*(n: PNode): int {.inline.} =
if isNil(n.sons): result = 0
else: result = len(n.sons)
proc safeLen*(n: PNode): int {.inline.} =
## works even for leaves.
if n.kind in {nkNone..nkNilLit} or isNil(n.sons): result = 0
else: result = len(n.sons)
proc add*(father, son: PNode) =
assert son != nil
if isNil(father.sons): father.sons = @[]