diff options
author | Zahary Karadjov <zahary@gmail.com> | 2013-05-05 16:34:00 +0300 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2013-05-05 16:34:00 +0300 |
commit | 961d3de8e5ae24778e0c2882656a3771b8332d38 (patch) | |
tree | 31099bcaccf326a5835a038bf41aa2a7cf9c3b46 | |
parent | f52ea04d229b5cdf70a352efd93e0e01fa8faadf (diff) | |
download | Nim-961d3de8e5ae24778e0c2882656a3771b8332d38.tar.gz |
fix compiling after suggest
-rw-r--r-- | compiler/cgen.nim | 34 | ||||
-rw-r--r-- | compiler/main.nim | 40 | ||||
-rw-r--r-- | compiler/service.nim | 3 |
3 files changed, 36 insertions, 41 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 753576aa0..7837ca160 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -1266,10 +1266,6 @@ proc updateCachedModule(m: BModule) = addFileToLink(cfilenoext) -proc updateCachedModules* = - for m in cgenModules(): - if m.fromCache: m.updateCachedModule - proc myClose(b: PPassContext, n: PNode): PNode = result = n if b == nil or passes.skipCodegen(n): return @@ -1279,24 +1275,28 @@ proc myClose(b: PPassContext, n: PNode): PNode = genStmts(m.initProc, n) # cached modules need to registered too: registerModuleToMain(m.module) - + if sfMainModule in m.module.flags: var disp = generateMethodDispatchers() for i in 0..sonsLen(disp)-1: genProcAux(m, disp.sons[i].sym) - genMainProc(m) - # we need to process the transitive closure because recursive module - # deps are allowed (and the system module is processed in the wrong - # order anyway) - if generatedHeader != nil: finishModule(generatedHeader) - while gForwardedProcsCounter > 0: - for m in cgenModules(): - if not m.fromCache: - finishModule(m) + genMainProc(m) + +proc cgenWriteModules* = + # we need to process the transitive closure because recursive module + # deps are allowed (and the system module is processed in the wrong + # order anyway) + if generatedHeader != nil: finishModule(generatedHeader) + while gForwardedProcsCounter > 0: for m in cgenModules(): if not m.fromCache: - writeModule(m, pending=true) - writeMapping(gMapping) - if generatedHeader != nil: writeHeader(generatedHeader) + finishModule(m) + for m in cgenModules(): + if m.fromCache: + m.updateCachedModule + else: + m.writeModule(pending=true) + writeMapping(gMapping) + if generatedHeader != nil: writeHeader(generatedHeader) const cgenPass* = makePass(myOpen, myOpenCached, myProcess, myClose) diff --git a/compiler/main.nim b/compiler/main.nim index c9b3967e5..2ff7691d8 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -89,24 +89,23 @@ proc addDep(x: Psym, dep: int32) = growCache gMemCacheData, dep gMemCacheData[x.position].deps.safeAdd(dep) -proc ResetModule(fileIdx: int32) = - writeStackTrace() +proc resetModule(fileIdx: int32) = # echo "HARD RESETTING ", fileIdx.toFilename gMemCacheData[fileIdx].needsRecompile = Yes gCompiledModules[fileIdx] = nil cgendata.gModules[fileIdx] = nil resetSourceMap(fileIdx) -proc ResetAllModules = +proc resetAllModules = for i in 0..gCompiledModules.high: if gCompiledModules[i] != nil: - ResetModule(i.int32) + resetModule(i.int32) # for m in cgenModules(): echo "CGEN MODULE FOUND" proc checkDepMem(fileIdx: int32): TNeedRecompile = template markDirty = - ResetModule(fileIdx) + resetModule(fileIdx) return Yes if gMemCacheData[fileIdx].needsRecompile != Maybe: @@ -150,12 +149,7 @@ proc newModule(fileIdx: int32): PSym = initStrTable(result.tab) StrTableAdd(result.tab, result) # a module knows itself -proc compileModule(fileIdxArg: int32, flagsArg: TSymFlags): PSym = - let (fileIdx, flags) = if fileIdxArg == gDirtyOriginalIdx: - (gDirtyBufferIdx, flagsArg + {sfDirty}) - else: - (fileIdxArg, flagsArg) - +proc compileModule(fileIdx: int32, flags: TSymFlags): PSym = result = getModule(fileIdx) if result == nil: growCache gMemCacheData, fileIdx @@ -260,14 +254,11 @@ proc CommandCompileToC = # echo "CHECK DEP COMPLETE" compileProject() - - if compilationCachePresent: - updateCachedModules() - + cgenWriteModules() if gCmd != cmdRun: extccomp.CallCCompiler(changeFileExt(gProjectFull, "")) - if optCaasEnabled in gGlobalOptions: + if isServing: # caas will keep track only of the compilation commands lastCaasCmd = curCaasCmd resetCgenModules() @@ -386,20 +377,23 @@ proc CommandScan = rawMessage(errCannotOpenFile, f) proc CommandSuggest = - msgs.gErrorMax = high(int) # do not stop after first error - semanticPasses() - rodPass() if isServing: # XXX: hacky work-around ahead # Currently, it's possible to issue a idetools command, before # issuing the first compile command. This will leave the compiler # cache in a state where "no recompilation is necessary", but the # cgen pass was never executed at all. - codegenPass() - compileProject() - if isServing: + CommandCompileToC() + if gDirtyBufferIdx != 0: + discard compileModule(gDirtyBufferIdx, {sfDirty}) + resetModule(gDirtyBufferIdx) if optDef in gGlobalOptions: defFromSourceMap(optTrackPos) + else: + msgs.gErrorMax = high(int) # do not stop after first error + semanticPasses() + rodPass() + compileProject() proc wantMainModule = if gProjectFull.len == 0: @@ -423,7 +417,7 @@ proc requireMainModuleOption = proc resetMemory = resetCompilationLists() ccgutils.resetCaches() - ResetAllModules() + resetAllModules() resetRopeCache() resetSysTypes() gOwners = @[] diff --git a/compiler/service.nim b/compiler/service.nim index 6a0cfd292..8e8fe20bf 100644 --- a/compiler/service.nim +++ b/compiler/service.nim @@ -67,7 +67,8 @@ proc serve*(action: proc (){.nimcall.}) = action() gDirtyBufferIdx = 0 gDirtyOriginalIdx = 0 - + gErrorCounter = 0 + let typ = getConfigVar("server.type") case typ of "stdin": |