Merge branch 'devel' into araq

This commit is contained in:
Andreas Rumpf 2017-09-15 21:12:59 +02:00
commit ecf1424456
18 changed files with 229 additions and 73 deletions

View file

@ -1009,6 +1009,12 @@ proc safeLen*(n: PNode): int {.inline.} =
if n.kind in {nkNone..nkNilLit} or isNil(n.sons): result = 0
else: result = len(n.sons)
proc safeArrLen*(n: PNode): int {.inline.} =
## works for array-like objects (strings passed as openArray in VM).
if n.kind in {nkStrLit..nkTripleStrLit}:result = len(n.strVal)
elif n.kind in {nkNone..nkFloat128Lit}: result = 0
else: result = len(n)
proc add*(father, son: PNode) =
assert son != nil
if isNil(father.sons): father.sons = @[]