diff options
Diffstat (limited to 'compiler/ast.nim')
-rw-r--r-- | compiler/ast.nim | 37 |
1 files changed, 5 insertions, 32 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index 31d47a6fd..63db11d54 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -1127,11 +1127,7 @@ proc discardSons*(father: PNode) type Indexable = PNode | PType proc len*(n: Indexable): int {.inline.} = - when defined(nimNoNilSeqs): - result = n.sons.len - else: - if isNil(n.sons): result = 0 - else: result = n.sons.len + result = n.sons.len proc safeLen*(n: PNode): int {.inline.} = ## works even for leaves. @@ -1146,8 +1142,6 @@ proc safeArrLen*(n: PNode): int {.inline.} = proc add*(father, son: Indexable) = assert son != nil - when not defined(nimNoNilSeqs): - if isNil(father.sons): father.sons = @[] father.sons.add(son) proc addAllowNil*(father, son: Indexable) {.inline.} = @@ -1308,10 +1302,7 @@ proc copyObjectSet*(dest: var TObjectSet, src: TObjectSet) = for i in 0..high(src.data): dest.data[i] = src.data[i] proc discardSons*(father: PNode) = - when defined(nimNoNilSeqs): - father.sons = @[] - else: - father.sons = nil + father.sons = @[] proc withInfo*(n: PNode, info: TLineInfo): PNode = n.info = info @@ -1436,13 +1427,7 @@ proc mergeLoc(a: var TLoc, b: TLoc) = if a.r == nil: a.r = b.r proc newSons*(father: Indexable, length: int) = - when defined(nimNoNilSeqs): - setLen(father.sons, length) - else: - if isNil(father.sons): - newSeq(father.sons, length) - else: - setLen(father.sons, length) + setLen(father.sons, length) proc assignType*(dest, src: PType) = dest.kind = src.kind @@ -1576,26 +1561,17 @@ proc propagateToOwner*(owner, elem: PType; propagateHasAsgn = true) = owner.flags.incl tfHasGCedMem proc rawAddSon*(father, son: PType; propagateHasAsgn = true) = - when not defined(nimNoNilSeqs): - if isNil(father.sons): father.sons = @[] father.sons.add(son) if not son.isNil: propagateToOwner(father, son, propagateHasAsgn) proc rawAddSonNoPropagationOfTypeFlags*(father, son: PType) = - when not defined(nimNoNilSeqs): - if isNil(father.sons): father.sons = @[] father.sons.add(son) proc addSonNilAllowed*(father, son: PNode) = - when not defined(nimNoNilSeqs): - if isNil(father.sons): father.sons = @[] father.sons.add(son) proc delSon*(father: PNode, idx: int) = - when defined(nimNoNilSeqs): - if father.len == 0: return - else: - if isNil(father.sons): return + if father.len == 0: return for i in idx..<father.len - 1: father[i] = father[i + 1] father.sons.setLen(father.len - 1) @@ -1766,10 +1742,7 @@ proc getStr*(a: PNode): string = of nkStrLit..nkTripleStrLit: result = a.strVal of nkNilLit: # let's hope this fixes more problems than it creates: - when defined(nimNoNilSeqs): - result = "" - else: - result = nil + result = "" else: raiseRecoverableError("cannot extract string from invalid AST node") #doAssert false, "getStr" |