diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ast.nim | 37 | ||||
-rw-r--r-- | compiler/condsyms.nim | 6 | ||||
-rw-r--r-- | compiler/docgen.nim | 3 | ||||
-rw-r--r-- | compiler/magicsys.nim | 2 | ||||
-rw-r--r-- | compiler/parser.nim | 2 | ||||
-rw-r--r-- | compiler/patterns.nim | 7 | ||||
-rw-r--r-- | compiler/semstmts.nim | 5 | ||||
-rw-r--r-- | compiler/types.nim | 2 | ||||
-rw-r--r-- | compiler/vm.nim | 4 |
9 files changed, 12 insertions, 56 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" diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim index a6ad45436..df216fb45 100644 --- a/compiler/condsyms.nim +++ b/compiler/condsyms.nim @@ -71,9 +71,9 @@ proc initDefines*(symbols: StringTableRef) = defineSymbol("nimNewRuntime") defineSymbol("nimIncrSeqV3") defineSymbol("nimAshr") - defineSymbol("nimNoNilSeqs") - defineSymbol("nimNoNilSeqs2") - defineSymbol("nimHasUserErrors") + defineSymbol("nimNoNilSeqs") # deadcode + defineSymbol("nimNoNilSeqs2") # deadcode + defineSymbol("nimHasUserErrors") # deadcode defineSymbol("nimUncheckedArrayTyp") defineSymbol("nimHasTypeof") defineSymbol("nimErrorProcCanHaveBody") diff --git a/compiler/docgen.nim b/compiler/docgen.nim index 6352ef583..ff9e8b8f4 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -329,8 +329,7 @@ proc genRecCommentAux(d: PDoc, n: PNode): Rope = result = genRecCommentAux(d, n[i]) if result != nil: return else: - when defined(nimNoNilSeqs): n.comment = "" - else: n.comment = nil + n.comment = "" proc genRecComment(d: PDoc, n: PNode): Rope = if n == nil: return nil diff --git a/compiler/magicsys.nim b/compiler/magicsys.nim index 74cc07df5..91dc0d49f 100644 --- a/compiler/magicsys.nim +++ b/compiler/magicsys.nim @@ -98,8 +98,6 @@ proc skipIntLit*(t: PType; id: IdGenerator): PType {.inline.} = result = t proc addSonSkipIntLit*(father, son: PType; id: IdGenerator) = - when not defined(nimNoNilSeqs): - if isNil(father.sons): father.sons = @[] let s = son.skipIntLit(id) father.sons.add(s) propagateToOwner(father, s) diff --git a/compiler/parser.nim b/compiler/parser.nim index 01ec6fe95..be39a6bc1 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -164,8 +164,6 @@ proc validInd(p: var Parser): bool {.inline.} = proc rawSkipComment(p: var Parser, node: PNode) = if p.tok.tokType == tkComment: if node != nil: - when not defined(nimNoNilSeqs): - if node.comment == nil: node.comment = "" when defined(nimpretty): if p.tok.commentOffsetB > p.tok.commentOffsetA: node.comment.add fileSection(p.lex.config, p.lex.fileIdx, p.tok.commentOffsetA, p.tok.commentOffsetB) diff --git a/compiler/patterns.nim b/compiler/patterns.nim index f24d25c5c..1ef903161 100644 --- a/compiler/patterns.nim +++ b/compiler/patterns.nim @@ -210,11 +210,8 @@ proc matchStmtList(c: PPatternContext, p, n: PNode): PNode = for j in 0..<p.len: if not matches(c, p[j], n[i+j]): # we need to undo any bindings: - when defined(nimNoNilSeqs): - c.mapping = @[] - c.mappingIsFull = false - else: - if not isNil(c.mapping): c.mapping = nil + c.mapping = @[] + c.mappingIsFull = false return false result = true diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index d14830249..ce780ab51 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -1237,10 +1237,7 @@ proc typeSectionRightSidePass(c: PContext, n: PNode) = var body = s.typ.lastSon if body.kind == tyObject: # erases all declared fields - when defined(nimNoNilSeqs): - body.n.sons = @[] - else: - body.n.sons = nil + body.n.sons = @[] popOwner(c) closeScope(c) diff --git a/compiler/types.nim b/compiler/types.nim index 09aee628a..bcd472d06 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -895,8 +895,6 @@ proc initSameTypeClosure: TSameTypeClosure = proc containsOrIncl(c: var TSameTypeClosure, a, b: PType): bool = result = c.s.len > 0 and c.s.contains((a.id, b.id)) if not result: - when not defined(nimNoNilSeqs): - if isNil(c.s): c.s = @[] c.s.add((a.id, b.id)) proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool diff --git a/compiler/vm.nim b/compiler/vm.nim index 00f0aca7c..0c9c0ec33 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -271,8 +271,6 @@ template getstr(a: untyped): untyped = (if a.kind == rkNode: a.node.strVal else: $chr(int(a.intVal))) proc pushSafePoint(f: PStackFrame; pc: int) = - when not defined(nimNoNilSeqs): - if f.safePoints.isNil: f.safePoints = @[] f.safePoints.add(pc) proc popSafePoint(f: PStackFrame) = @@ -2092,8 +2090,6 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = inc pc let typ = c.types[c.code[pc].regBx - wordExcess] createStrKeepNode(regs[ra]) - when not defined(nimNoNilSeqs): - if regs[ra].node.strVal.isNil: regs[ra].node.strVal = newStringOfCap(1000) storeAny(regs[ra].node.strVal, typ, regs[rb].regToNode, c.config) c.profiler.leave(c) |