small steps for making --symbolFiles:on work again

This commit is contained in:
Araq 2015-07-20 13:43:59 +02:00
commit d3255f708c
3 changed files with 108 additions and 106 deletions

View file

@ -276,7 +276,8 @@ proc processNote(c: PContext, n: PNode) =
if (n.kind == nkExprColonExpr) and (sonsLen(n) == 2) and if (n.kind == nkExprColonExpr) and (sonsLen(n) == 2) and
(n.sons[0].kind == nkBracketExpr) and (n.sons[0].kind == nkBracketExpr) and
(n.sons[0].sons[1].kind == nkIdent) and (n.sons[0].sons[1].kind == nkIdent) and
(n.sons[0].sons[0].kind == nkIdent) and (n.sons[1].kind == nkIdent): (n.sons[0].sons[0].kind == nkIdent):
#and (n.sons[1].kind == nkIdent):
var nk: TNoteKind var nk: TNoteKind
case whichKeyword(n.sons[0].sons[0].ident) case whichKeyword(n.sons[0].sons[0].ident)
of wHint: of wHint:

View file

@ -90,7 +90,7 @@
import import
os, options, strutils, nversion, ast, astalgo, msgs, platform, condsyms, os, options, strutils, nversion, ast, astalgo, msgs, platform, condsyms,
ropes, idents, securehash, idgen, types, rodutils, memfiles ropes, idents, securehash, idgen, types, rodutils, memfiles, tables
type type
TReasonForRecompile* = enum ## all the reasons that can trigger recompilation TReasonForRecompile* = enum ## all the reasons that can trigger recompilation
@ -136,7 +136,7 @@ type
readerIndex: int readerIndex: int
line: int # only used for debugging, but is always in the code line: int # only used for debugging, but is always in the code
moduleID: int moduleID: int
syms: TIdTable # already processed symbols syms: Table[int, PSym] # already processed symbols
memfile: MemFile # unfortunately there is no point in time where we memfile: MemFile # unfortunately there is no point in time where we
# can close this! XXX # can close this! XXX
methods*: TSymSeq methods*: TSymSeq
@ -372,11 +372,11 @@ proc decodeSym(r: PRodReader, info: TLineInfo): PSym =
else: else:
internalError(info, "decodeSym: no ident") internalError(info, "decodeSym: no ident")
#echo "decoding: {", ident.s #echo "decoding: {", ident.s
result = PSym(idTableGet(r.syms, id)) result = r.syms[id]
if result == nil: if result == nil:
new(result) new(result)
result.id = id result.id = id
idTablePut(r.syms, result, result) r.syms[result.id] = result
if debugIds: registerID(result) if debugIds: registerID(result)
elif result.id != id: elif result.id != id:
internalError(info, "decodeSym: wrong id") internalError(info, "decodeSym: wrong id")
@ -481,7 +481,7 @@ proc processInterf(r: PRodReader, module: PSym) =
var s = newStub(r, w, key) var s = newStub(r, w, key)
s.owner = module s.owner = module
strTableAdd(module.tab, s) strTableAdd(module.tab, s)
idTablePut(r.syms, s, s) r.syms[s.id] = s
proc processCompilerProcs(r: PRodReader, module: PSym) = proc processCompilerProcs(r: PRodReader, module: PSym) =
if r.compilerProcsIdx == 0: internalError("processCompilerProcs") if r.compilerProcsIdx == 0: internalError("processCompilerProcs")
@ -491,11 +491,11 @@ proc processCompilerProcs(r: PRodReader, module: PSym) =
inc(r.pos) inc(r.pos)
var key = decodeVInt(r.s, r.pos) var key = decodeVInt(r.s, r.pos)
inc(r.pos) # #10 inc(r.pos) # #10
var s = PSym(idTableGet(r.syms, key)) var s = r.syms[key]
if s == nil: if s == nil:
s = newStub(r, w, key) s = newStub(r, w, key)
s.owner = module s.owner = module
idTablePut(r.syms, s, s) r.syms[s.id] = s
strTableAdd(rodCompilerprocs, s) strTableAdd(rodCompilerprocs, s)
proc processIndex(r: PRodReader; idx: var TIndex; outf: File = nil) = proc processIndex(r: PRodReader; idx: var TIndex; outf: File = nil) =
@ -667,7 +667,7 @@ proc newRodReader(modfilename: string, hash: SecureHash,
r.line = 1 r.line = 1
r.readerIndex = readerIndex r.readerIndex = readerIndex
r.filename = modfilename r.filename = modfilename
initIdTable(r.syms) r.syms = initTable[int, PSym]()
# we terminate the file explicitly with ``\0``, so the cast to `cstring` # we terminate the file explicitly with ``\0``, so the cast to `cstring`
# is safe: # is safe:
r.s = cast[cstring](r.memfile.mem) r.s = cast[cstring](r.memfile.mem)
@ -737,7 +737,7 @@ proc getReader(moduleId: int): PRodReader =
return nil return nil
proc rrGetSym(r: PRodReader, id: int, info: TLineInfo): PSym = proc rrGetSym(r: PRodReader, id: int, info: TLineInfo): PSym =
result = PSym(idTableGet(r.syms, id)) result = r.syms[id]
if result == nil: if result == nil:
# load the symbol: # load the symbol:
var d = iiTableGet(r.index.tab, id) var d = iiTableGet(r.index.tab, id)
@ -802,7 +802,7 @@ proc getHash*(fileIdx: int32): SecureHash =
if gMods[fileIdx].hashDone: if gMods[fileIdx].hashDone:
return gMods[fileIdx].hash return gMods[fileIdx].hash
result = secureHashFile(fileIdx.toFilename) result = secureHashFile(fileIdx.toFullPath)
gMods[fileIdx].hash = result gMods[fileIdx].hash = result
template growCache*(cache, pos) = template growCache*(cache, pos) =
@ -859,7 +859,7 @@ proc handleSymbolFile(module: PSym): PRodReader =
result = gMods[fileIdx].rd result = gMods[fileIdx].rd
if result != nil: if result != nil:
module.id = result.moduleID module.id = result.moduleID
idTablePut(result.syms, module, module) result.syms[module.id] = module
processInterf(result, module) processInterf(result, module)
processCompilerProcs(result, module) processCompilerProcs(result, module)
loadConverters(result) loadConverters(result)

View file

@ -336,8 +336,9 @@ proc symStack(w: PRodWriter): int =
inc result inc result
elif iiTableGet(w.index.tab, s.id) == InvalidKey: elif iiTableGet(w.index.tab, s.id) == InvalidKey:
var m = getModule(s) var m = getModule(s)
if m == nil: internalError("symStack: module nil: " & s.name.s) if m == nil and s.kind != skPackage:
if (m.id == w.module.id) or (sfFromGeneric in s.flags): internalError("symStack: module nil: " & s.name.s)
if s.kind == skPackage or m.id == w.module.id or sfFromGeneric in s.flags:
# put definition in here # put definition in here
var L = w.data.len var L = w.data.len
addToIndex(w.index, s.id, L) addToIndex(w.index, s.id, L)
@ -365,12 +366,12 @@ proc symStack(w: PRodWriter): int =
elif iiTableGet(w.imports.tab, s.id) == InvalidKey: elif iiTableGet(w.imports.tab, s.id) == InvalidKey:
addToIndex(w.imports, s.id, m.id) addToIndex(w.imports, s.id, m.id)
when debugWrittenIds: when debugWrittenIds:
if not Contains(debugWritten, s.id): if not contains(debugWritten, s.id):
echo(w.filename) echo(w.filename)
debug(s) debug(s)
debug(s.owner) debug(s.owner)
debug(m) debug(m)
InternalError("Symbol referred to but never written") internalError("Symbol referred to but never written")
inc(i) inc(i)
setLen(w.sstack, result) setLen(w.sstack, result)