new dependency tracking for nimsuggest

This commit is contained in:
Araq 2016-11-05 01:19:23 +01:00
commit 9e6fb3f696
21 changed files with 284 additions and 393 deletions

View file

@ -13,7 +13,7 @@
import
ast, modules, idents, passes, passaux, condsyms,
options, nimconf, lists, sem, semdata, llstream, vm, vmdef, commands, msgs,
os, times, osproc, wordrecg, strtabs
os, times, osproc, wordrecg, strtabs, modulegraphs
# we support 'cmpIgnoreStyle' natively for efficiency:
from strutils import cmpIgnoreStyle, contains
@ -134,9 +134,11 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string): PEvalContext
cbconf selfExe:
setResult(a, os.getAppFilename())
proc runNimScript*(cache: IdentCache; scriptName: string; freshDefines=true) =
proc runNimScript*(cache: IdentCache; scriptName: string;
freshDefines=true) =
passes.gIncludeFile = includeModule
passes.gImportModule = importModule
let graph = newModuleGraph()
if freshDefines: initDefines()
defineSymbol("nimscript")
@ -146,15 +148,15 @@ proc runNimScript*(cache: IdentCache; scriptName: string; freshDefines=true) =
appendStr(searchPaths, options.libpath)
var m = makeModule(scriptName)
var m = graph.makeModule(scriptName)
incl(m.flags, sfMainModule)
vm.globalCtx = setupVM(m, cache, scriptName)
compileSystemModule(cache)
discard processModule(m, llStreamOpen(scriptName, fmRead), nil, cache)
graph.compileSystemModule(cache)
discard graph.processModule(m, llStreamOpen(scriptName, fmRead), nil, cache)
# ensure we load 'system.nim' again for the real non-config stuff!
resetAllModulesHard()
#resetAllModulesHard()
vm.globalCtx = nil
# do not remove the defined symbols
#initDefines()