compiler refactoring: TSymSeq is gone for good

This commit is contained in:
Araq 2018-12-11 12:31:32 +01:00
commit 366b6be4fb
5 changed files with 11 additions and 12 deletions

View file

@ -723,10 +723,9 @@ type
sons*: TNodeSeq sons*: TNodeSeq
comment*: string comment*: string
TSymSeq* = seq[PSym]
TStrTable* = object # a table[PIdent] of PSym TStrTable* = object # a table[PIdent] of PSym
counter*: int counter*: int
data*: TSymSeq data*: seq[PSym]
# -------------- backend information ------------------------------- # -------------- backend information -------------------------------
TLocKind* = enum TLocKind* = enum

View file

@ -507,7 +507,7 @@ proc strTableContains*(t: TStrTable, n: PSym): bool =
h = nextTry(h, high(t.data)) h = nextTry(h, high(t.data))
result = false result = false
proc strTableRawInsert(data: var TSymSeq, n: PSym) = proc strTableRawInsert(data: var seq[PSym], n: PSym) =
var h: Hash = n.name.h and high(data) var h: Hash = n.name.h and high(data)
if sfImmediate notin n.flags: if sfImmediate notin n.flags:
# fast path: # fast path:
@ -535,7 +535,7 @@ proc strTableRawInsert(data: var TSymSeq, n: PSym) =
data[h] = n data[h] = n
if favPos >= 0: swap data[h], data[favPos] if favPos >= 0: swap data[h], data[favPos]
proc symTabReplaceRaw(data: var TSymSeq, prevSym: PSym, newSym: PSym) = proc symTabReplaceRaw(data: var seq[PSym], prevSym: PSym, newSym: PSym) =
assert prevSym.name.h == newSym.name.h assert prevSym.name.h == newSym.name.h
var h: Hash = prevSym.name.h and high(data) var h: Hash = prevSym.name.h and high(data)
while data[h] != nil: while data[h] != nil:
@ -549,7 +549,7 @@ proc symTabReplace*(t: var TStrTable, prevSym: PSym, newSym: PSym) =
symTabReplaceRaw(t.data, prevSym, newSym) symTabReplaceRaw(t.data, prevSym, newSym)
proc strTableEnlarge(t: var TStrTable) = proc strTableEnlarge(t: var TStrTable) =
var n: TSymSeq var n: seq[PSym]
newSeq(n, len(t.data) * GrowthFactor) newSeq(n, len(t.data) * GrowthFactor)
for i in countup(0, high(t.data)): for i in countup(0, high(t.data)):
if t.data[i] != nil: strTableRawInsert(n, t.data[i]) if t.data[i] != nil: strTableRawInsert(n, t.data[i])

View file

@ -188,7 +188,7 @@ proc methodDef*(g: ModuleGraph; s: PSym, fromCache: bool) =
elif sfBase notin s.flags: elif sfBase notin s.flags:
message(g.config, s.info, warnUseBase) message(g.config, s.info, warnUseBase)
proc relevantCol(methods: TSymSeq, col: int): bool = proc relevantCol(methods: seq[PSym], col: int): bool =
# returns true iff the position is relevant # returns true iff the position is relevant
var t = methods[0].typ.sons[col].skipTypes(skipPtrs) var t = methods[0].typ.sons[col].skipTypes(skipPtrs)
if t.kind == tyObject: if t.kind == tyObject:
@ -206,7 +206,7 @@ proc cmpSignatures(a, b: PSym, relevantCols: IntSet): int =
if (d != high(int)) and d != 0: if (d != high(int)) and d != 0:
return d return d
proc sortBucket(a: var TSymSeq, relevantCols: IntSet) = proc sortBucket(a: var seq[PSym], relevantCols: IntSet) =
# we use shellsort here; fast and simple # we use shellsort here; fast and simple
var n = len(a) var n = len(a)
var h = 1 var h = 1
@ -225,7 +225,7 @@ proc sortBucket(a: var TSymSeq, relevantCols: IntSet) =
a[j] = v a[j] = v
if h == 1: break if h == 1: break
proc genDispatcher(g: ModuleGraph; methods: TSymSeq, relevantCols: IntSet): PSym = proc genDispatcher(g: ModuleGraph; methods: seq[PSym], relevantCols: IntSet): PSym =
var base = lastSon(methods[0].ast).sym var base = lastSon(methods[0].ast).sym
result = base result = base
var paramLen = sonsLen(base.typ) var paramLen = sonsLen(base.typ)

View file

@ -47,7 +47,7 @@ type
doStopCompile*: proc(): bool {.closure.} doStopCompile*: proc(): bool {.closure.}
usageSym*: PSym # for nimsuggest usageSym*: PSym # for nimsuggest
owners*: seq[PSym] owners*: seq[PSym]
methods*: seq[tuple[methods: TSymSeq, dispatcher: PSym]] # needs serialization! methods*: seq[tuple[methods: seq[PSym], dispatcher: PSym]] # needs serialization!
systemModule*: PSym systemModule*: PSym
sysTypes*: array[TTypeKind, PType] sysTypes*: array[TTypeKind, PType]
compilerprocs*: TStrTable compilerprocs*: TStrTable

View file

@ -100,8 +100,8 @@ type
compilesContextId*: int # > 0 if we are in a ``compiles`` magic compilesContextId*: int # > 0 if we are in a ``compiles`` magic
compilesContextIdGenerator*: int compilesContextIdGenerator*: int
inGenericInst*: int # > 0 if we are instantiating a generic inGenericInst*: int # > 0 if we are instantiating a generic
converters*: TSymSeq # sequence of converters converters*: seq[PSym]
patterns*: TSymSeq # sequence of pattern matchers patterns*: seq[PSym] # sequence of pattern matchers
optionStack*: seq[POptionEntry] optionStack*: seq[POptionEntry]
symMapping*: TIdTable # every gensym'ed symbol needs to be mapped symMapping*: TIdTable # every gensym'ed symbol needs to be mapped
# to some new symbol in a generic instantiation # to some new symbol in a generic instantiation
@ -239,7 +239,7 @@ proc newContext*(graph: ModuleGraph; module: PSym): PContext =
result.typesWithOps = @[] result.typesWithOps = @[]
result.features = graph.config.features result.features = graph.config.features
proc inclSym(sq: var TSymSeq, s: PSym) = proc inclSym(sq: var seq[PSym], s: PSym) =
var L = len(sq) var L = len(sq)
for i in countup(0, L - 1): for i in countup(0, L - 1):
if sq[i].id == s.id: return if sq[i].id == s.id: return