mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-06 04:57:49 +00:00
nimsuggest improvements
This commit is contained in:
@@ -186,14 +186,11 @@ proc compileModule*(fileIdx: int32, flags: TSymFlags): PSym =
|
||||
return
|
||||
else:
|
||||
result.id = getID()
|
||||
if sfMainModule in flags and gProjectIsStdin:
|
||||
processModule(result, llStreamOpen(stdin), rd)
|
||||
else:
|
||||
processModule(result, nil, rd)
|
||||
let validFile = processModule(result, if sfMainModule in flags and gProjectIsStdin: llStreamOpen(stdin) else: nil, rd)
|
||||
if optCaasEnabled in gGlobalOptions:
|
||||
gMemCacheData[fileIdx].compiledAt = gLastCmdTime
|
||||
gMemCacheData[fileIdx].needsRecompile = Recompiled
|
||||
doHash fileIdx
|
||||
if validFile: doHash fileIdx
|
||||
else:
|
||||
if checkDepMem(fileIdx) == Yes:
|
||||
result = compileModule(fileIdx, flags)
|
||||
|
||||
@@ -46,12 +46,6 @@ proc makePass*(open: TPassOpen = nil,
|
||||
result.close = close
|
||||
result.process = process
|
||||
|
||||
# This implements a memory preserving scheme: Top level statements are
|
||||
# processed in a pipeline. The compiler never looks at a whole module
|
||||
# any longer. However, this is simple to change, as new passes may perform
|
||||
# whole program optimizations. For now, we avoid it to save a lot of memory.
|
||||
proc processModule*(module: PSym, stream: PLLStream, rd: PRodReader)
|
||||
|
||||
# the semantic checker needs these:
|
||||
var
|
||||
gImportModule*: proc (m: PSym, fileIdx: int32): PSym {.nimcall.}
|
||||
@@ -160,7 +154,8 @@ proc processImplicits(implicits: seq[string], nodeKind: TNodeKind,
|
||||
importStmt.addSon str
|
||||
if not processTopLevelStmt(importStmt, a): break
|
||||
|
||||
proc processModule(module: PSym, stream: PLLStream, rd: PRodReader) =
|
||||
proc processModule*(module: PSym, stream: PLLStream,
|
||||
rd: PRodReader): bool {.discardable.} =
|
||||
var
|
||||
p: TParsers
|
||||
a: TPassContextArray
|
||||
@@ -173,7 +168,7 @@ proc processModule(module: PSym, stream: PLLStream, rd: PRodReader) =
|
||||
s = llStreamOpen(filename, fmRead)
|
||||
if s == nil:
|
||||
rawMessage(errCannotOpenFile, filename)
|
||||
return
|
||||
return false
|
||||
else:
|
||||
s = stream
|
||||
while true:
|
||||
@@ -211,4 +206,4 @@ proc processModule(module: PSym, stream: PLLStream, rd: PRodReader) =
|
||||
var n = loadInitSection(rd)
|
||||
for i in countup(0, sonsLen(n) - 1): processTopLevelStmtCached(n.sons[i], a)
|
||||
closePassesCached(a)
|
||||
|
||||
result = true
|
||||
|
||||
@@ -150,7 +150,7 @@ proc runNimScript*(scriptName: string; freshDefines=true) =
|
||||
vm.globalCtx = setupVM(m, scriptName)
|
||||
|
||||
compileSystemModule()
|
||||
processModule(m, llStreamOpen(scriptName, fmRead), nil)
|
||||
discard processModule(m, llStreamOpen(scriptName, fmRead), nil)
|
||||
|
||||
# ensure we load 'system.nim' again for the real non-config stuff!
|
||||
resetAllModulesHard()
|
||||
|
||||
Reference in New Issue
Block a user