mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 20:17:42 +00:00
IC: further progress (#17150)
* IC: respect the -f switch * IC: better rod file inspection * progress
This commit is contained in:
@@ -33,7 +33,7 @@ proc isExportedToC(c: var AliveContext; g: PackedModuleGraph; symId: int32): boo
|
||||
# are not transformed correctly; issue (#411). However, the whole purpose here
|
||||
# is to eliminate unused procs. So there is no special logic required for this case.
|
||||
if sfCompileTime notin flags:
|
||||
if ({sfExportc, sfCompilerProc} * flags == {sfExportc}) or
|
||||
if ({sfExportc, sfCompilerProc} * flags != {}) or
|
||||
(symPtr.kind == skMethod):
|
||||
result = true
|
||||
# XXX: This used to be a condition to:
|
||||
@@ -52,6 +52,10 @@ proc followLater(c: var AliveContext; g: PackedModuleGraph; module: int; item: i
|
||||
let opt = g[module].fromDisk.sh.syms[item].options
|
||||
c.stack.add((module, opt, NodePos(body)))
|
||||
|
||||
when false:
|
||||
let name = g[module].fromDisk.sh.strings[g[module].fromDisk.sh.syms[item].name]
|
||||
echo "I was called! ", name, " body exists: ", body != emptyNodeId
|
||||
|
||||
proc requestCompilerProc(c: var AliveContext; g: PackedModuleGraph; name: string) =
|
||||
let (module, item) = c.compilerProcs[name]
|
||||
followLater(c, g, module, item)
|
||||
@@ -107,7 +111,9 @@ proc aliveCode(c: var AliveContext; g: PackedModuleGraph; tree: PackedTree; n: N
|
||||
nkFromStmt, nkStaticStmt:
|
||||
discard
|
||||
of nkVarSection, nkLetSection, nkConstSection:
|
||||
discard
|
||||
# XXX ignore the defining local variable name?
|
||||
for son in sonsReadonly(tree, n):
|
||||
aliveCode(c, g, tree, son)
|
||||
of nkChckRangeF, nkChckRange64, nkChckRange:
|
||||
rangeCheckAnalysis(c, g, tree, n)
|
||||
of nkProcDef, nkConverterDef, nkMethodDef, nkLambda, nkDo, nkFuncDef:
|
||||
|
||||
@@ -453,7 +453,8 @@ proc toPackedNodeTopLevel*(n: PNode, encoder: var PackedEncoder; m: var PackedMo
|
||||
proc loadError(err: RodFileError; filename: AbsoluteFile) =
|
||||
echo "Error: ", $err, " loading file: ", filename.string
|
||||
|
||||
proc loadRodFile*(filename: AbsoluteFile; m: var PackedModule; config: ConfigRef): RodFileError =
|
||||
proc loadRodFile*(filename: AbsoluteFile; m: var PackedModule; config: ConfigRef;
|
||||
ignoreConfig = false): RodFileError =
|
||||
m.sh = Shared()
|
||||
var f = rodfiles.open(filename.string)
|
||||
f.loadHeader()
|
||||
@@ -462,7 +463,7 @@ proc loadRodFile*(filename: AbsoluteFile; m: var PackedModule; config: ConfigRef
|
||||
f.loadPrim m.definedSymbols
|
||||
f.loadPrim m.cfg
|
||||
|
||||
if f.err == ok and not configIdentical(m, config):
|
||||
if f.err == ok and not configIdentical(m, config) and not ignoreConfig:
|
||||
f.err = configMismatch
|
||||
|
||||
template loadSeqSection(section, data) {.dirty.} =
|
||||
@@ -875,7 +876,7 @@ proc needsRecompile(g: var PackedModuleGraph; conf: ConfigRef; cache: IdentCache
|
||||
let rod = toRodFile(conf, AbsoluteFile fullpath)
|
||||
let err = loadRodFile(rod, g[m].fromDisk, conf)
|
||||
if err == ok:
|
||||
result = false
|
||||
result = optForceFullMake in conf.globalOptions
|
||||
# check its dependencies:
|
||||
for dep in g[m].fromDisk.imports:
|
||||
let fid = toFileIndex(dep, g[m].fromDisk, conf)
|
||||
@@ -887,7 +888,9 @@ proc needsRecompile(g: var PackedModuleGraph; conf: ConfigRef; cache: IdentCache
|
||||
if not result:
|
||||
setupLookupTables(g, conf, cache, fileIdx, g[m])
|
||||
cachedModules.add fileIdx
|
||||
g[m].status = if result: outdated else: loaded
|
||||
g[m].status = loaded
|
||||
else:
|
||||
g[m] = LoadedModule(status: outdated, module: g[m].module)
|
||||
else:
|
||||
loadError(err, rod)
|
||||
g[m].status = outdated
|
||||
@@ -1062,14 +1065,15 @@ proc idgenFromLoadedModule*(m: LoadedModule): IdGenerator =
|
||||
|
||||
proc rodViewer*(rodfile: AbsoluteFile; config: ConfigRef, cache: IdentCache) =
|
||||
var m: PackedModule
|
||||
if loadRodFile(rodfile, m, config) != ok:
|
||||
echo "Error: could not load: ", rodfile.string
|
||||
let err = loadRodFile(rodfile, m, config, ignoreConfig=true)
|
||||
if err != ok:
|
||||
echo "Error: could not load: ", rodfile.string, " reason: ", err
|
||||
quit 1
|
||||
|
||||
when true:
|
||||
echo "exports:"
|
||||
for ex in m.exports:
|
||||
echo " ", m.sh.strings[ex[0]]
|
||||
echo " ", m.sh.strings[ex[0]], " local ID: ", ex[1]
|
||||
assert ex[0] == m.sh.syms[ex[1]].name
|
||||
# ex[1] int32
|
||||
|
||||
|
||||
@@ -378,7 +378,6 @@ proc reportUnhandledErrorAux(e: ref Exception) {.nodestroy.} =
|
||||
# ugly, but avoids heap allocations :-)
|
||||
template xadd(buf, s, slen) =
|
||||
if L + slen < high(buf):
|
||||
|
||||
copyMem(addr(buf[L]), (when s is cstring: s else: cstring(s)), slen)
|
||||
inc L, slen
|
||||
template add(buf, s) =
|
||||
@@ -404,8 +403,6 @@ proc reportUnhandledError(e: ref Exception) {.nodestroy.} =
|
||||
unhandledExceptionHook(e)
|
||||
when hostOS != "any":
|
||||
reportUnhandledErrorAux(e)
|
||||
else:
|
||||
discard ()
|
||||
|
||||
proc nimLeaveFinally() {.compilerRtl.} =
|
||||
when defined(cpp) and not defined(noCppExceptions) and not gotoBasedExceptions:
|
||||
|
||||
Reference in New Issue
Block a user