nimsuggest improvements
This commit is contained in:
parent
12cd8fe9e2
commit
e92a7fd508
3 changed files with 7 additions and 15 deletions
|
|
@ -186,14 +186,11 @@ proc compileModule*(fileIdx: int32, flags: TSymFlags): PSym =
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
result.id = getID()
|
result.id = getID()
|
||||||
if sfMainModule in flags and gProjectIsStdin:
|
let validFile = processModule(result, if sfMainModule in flags and gProjectIsStdin: llStreamOpen(stdin) else: nil, rd)
|
||||||
processModule(result, llStreamOpen(stdin), rd)
|
|
||||||
else:
|
|
||||||
processModule(result, nil, rd)
|
|
||||||
if optCaasEnabled in gGlobalOptions:
|
if optCaasEnabled in gGlobalOptions:
|
||||||
gMemCacheData[fileIdx].compiledAt = gLastCmdTime
|
gMemCacheData[fileIdx].compiledAt = gLastCmdTime
|
||||||
gMemCacheData[fileIdx].needsRecompile = Recompiled
|
gMemCacheData[fileIdx].needsRecompile = Recompiled
|
||||||
doHash fileIdx
|
if validFile: doHash fileIdx
|
||||||
else:
|
else:
|
||||||
if checkDepMem(fileIdx) == Yes:
|
if checkDepMem(fileIdx) == Yes:
|
||||||
result = compileModule(fileIdx, flags)
|
result = compileModule(fileIdx, flags)
|
||||||
|
|
|
||||||
|
|
@ -46,12 +46,6 @@ proc makePass*(open: TPassOpen = nil,
|
||||||
result.close = close
|
result.close = close
|
||||||
result.process = process
|
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:
|
# the semantic checker needs these:
|
||||||
var
|
var
|
||||||
gImportModule*: proc (m: PSym, fileIdx: int32): PSym {.nimcall.}
|
gImportModule*: proc (m: PSym, fileIdx: int32): PSym {.nimcall.}
|
||||||
|
|
@ -160,7 +154,8 @@ proc processImplicits(implicits: seq[string], nodeKind: TNodeKind,
|
||||||
importStmt.addSon str
|
importStmt.addSon str
|
||||||
if not processTopLevelStmt(importStmt, a): break
|
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
|
var
|
||||||
p: TParsers
|
p: TParsers
|
||||||
a: TPassContextArray
|
a: TPassContextArray
|
||||||
|
|
@ -173,7 +168,7 @@ proc processModule(module: PSym, stream: PLLStream, rd: PRodReader) =
|
||||||
s = llStreamOpen(filename, fmRead)
|
s = llStreamOpen(filename, fmRead)
|
||||||
if s == nil:
|
if s == nil:
|
||||||
rawMessage(errCannotOpenFile, filename)
|
rawMessage(errCannotOpenFile, filename)
|
||||||
return
|
return false
|
||||||
else:
|
else:
|
||||||
s = stream
|
s = stream
|
||||||
while true:
|
while true:
|
||||||
|
|
@ -211,4 +206,4 @@ proc processModule(module: PSym, stream: PLLStream, rd: PRodReader) =
|
||||||
var n = loadInitSection(rd)
|
var n = loadInitSection(rd)
|
||||||
for i in countup(0, sonsLen(n) - 1): processTopLevelStmtCached(n.sons[i], a)
|
for i in countup(0, sonsLen(n) - 1): processTopLevelStmtCached(n.sons[i], a)
|
||||||
closePassesCached(a)
|
closePassesCached(a)
|
||||||
|
result = true
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ proc runNimScript*(scriptName: string; freshDefines=true) =
|
||||||
vm.globalCtx = setupVM(m, scriptName)
|
vm.globalCtx = setupVM(m, scriptName)
|
||||||
|
|
||||||
compileSystemModule()
|
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!
|
# ensure we load 'system.nim' again for the real non-config stuff!
|
||||||
resetAllModulesHard()
|
resetAllModulesHard()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue