more compiler API cleanups
This commit is contained in:
parent
83834be938
commit
b92fcacb99
3 changed files with 25 additions and 28 deletions
|
|
@ -22,14 +22,14 @@ from magicsys import resetSysTypes
|
||||||
|
|
||||||
proc rodPass(g: ModuleGraph) =
|
proc rodPass(g: ModuleGraph) =
|
||||||
if g.config.symbolFiles in {enabledSf, writeOnlySf}:
|
if g.config.symbolFiles in {enabledSf, writeOnlySf}:
|
||||||
registerPass(rodwritePass)
|
registerPass(g, rodwritePass)
|
||||||
|
|
||||||
proc codegenPass =
|
proc codegenPass(g: ModuleGraph) =
|
||||||
registerPass cgenPass
|
registerPass g, cgenPass
|
||||||
|
|
||||||
proc semanticPasses =
|
proc semanticPasses(g: ModuleGraph) =
|
||||||
registerPass verbosePass
|
registerPass g, verbosePass
|
||||||
registerPass semPass
|
registerPass g, semPass
|
||||||
|
|
||||||
proc writeDepsFile(g: ModuleGraph; project: string) =
|
proc writeDepsFile(g: ModuleGraph; project: string) =
|
||||||
let f = open(changeFileExt(project, "deps"), fmWrite)
|
let f = open(changeFileExt(project, "deps"), fmWrite)
|
||||||
|
|
@ -42,8 +42,8 @@ proc writeDepsFile(g: ModuleGraph; project: string) =
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
proc commandGenDepend(graph: ModuleGraph; cache: IdentCache) =
|
proc commandGenDepend(graph: ModuleGraph; cache: IdentCache) =
|
||||||
semanticPasses()
|
semanticPasses(graph)
|
||||||
registerPass(gendependPass)
|
registerPass(graph, gendependPass)
|
||||||
#registerPass(cleanupPass)
|
#registerPass(cleanupPass)
|
||||||
compileProject(graph, cache)
|
compileProject(graph, cache)
|
||||||
let project = graph.config.projectFull
|
let project = graph.config.projectFull
|
||||||
|
|
@ -55,15 +55,15 @@ proc commandGenDepend(graph: ModuleGraph; cache: IdentCache) =
|
||||||
proc commandCheck(graph: ModuleGraph; cache: IdentCache) =
|
proc commandCheck(graph: ModuleGraph; cache: IdentCache) =
|
||||||
graph.config.errorMax = high(int) # do not stop after first error
|
graph.config.errorMax = high(int) # do not stop after first error
|
||||||
defineSymbol(graph.config.symbols, "nimcheck")
|
defineSymbol(graph.config.symbols, "nimcheck")
|
||||||
semanticPasses() # use an empty backend for semantic checking only
|
semanticPasses(graph) # use an empty backend for semantic checking only
|
||||||
rodPass(graph)
|
rodPass(graph)
|
||||||
compileProject(graph, cache)
|
compileProject(graph, cache)
|
||||||
|
|
||||||
proc commandDoc2(graph: ModuleGraph; cache: IdentCache; json: bool) =
|
proc commandDoc2(graph: ModuleGraph; cache: IdentCache; json: bool) =
|
||||||
graph.config.errorMax = high(int) # do not stop after first error
|
graph.config.errorMax = high(int) # do not stop after first error
|
||||||
semanticPasses()
|
semanticPasses(graph)
|
||||||
if json: registerPass(docgen2JsonPass)
|
if json: registerPass(graph, docgen2JsonPass)
|
||||||
else: registerPass(docgen2Pass)
|
else: registerPass(graph, docgen2Pass)
|
||||||
#registerPass(cleanupPass())
|
#registerPass(cleanupPass())
|
||||||
compileProject(graph, cache)
|
compileProject(graph, cache)
|
||||||
finishDoc2Pass(graph.config.projectName)
|
finishDoc2Pass(graph.config.projectName)
|
||||||
|
|
@ -71,8 +71,8 @@ proc commandDoc2(graph: ModuleGraph; cache: IdentCache; json: bool) =
|
||||||
proc commandCompileToC(graph: ModuleGraph; cache: IdentCache) =
|
proc commandCompileToC(graph: ModuleGraph; cache: IdentCache) =
|
||||||
let conf = graph.config
|
let conf = graph.config
|
||||||
extccomp.initVars(conf)
|
extccomp.initVars(conf)
|
||||||
semanticPasses()
|
semanticPasses(graph)
|
||||||
registerPass(cgenPass)
|
registerPass(graph, cgenPass)
|
||||||
rodPass(graph)
|
rodPass(graph)
|
||||||
#registerPass(cleanupPass())
|
#registerPass(cleanupPass())
|
||||||
|
|
||||||
|
|
@ -95,17 +95,17 @@ proc commandCompileToJS(graph: ModuleGraph; cache: IdentCache) =
|
||||||
#initDefines()
|
#initDefines()
|
||||||
defineSymbol(graph.config.symbols, "ecmascript") # For backward compatibility
|
defineSymbol(graph.config.symbols, "ecmascript") # For backward compatibility
|
||||||
defineSymbol(graph.config.symbols, "js")
|
defineSymbol(graph.config.symbols, "js")
|
||||||
semanticPasses()
|
semanticPasses(graph)
|
||||||
registerPass(JSgenPass)
|
registerPass(graph, JSgenPass)
|
||||||
compileProject(graph, cache)
|
compileProject(graph, cache)
|
||||||
|
|
||||||
proc interactivePasses(graph: ModuleGraph; cache: IdentCache) =
|
proc interactivePasses(graph: ModuleGraph; cache: IdentCache) =
|
||||||
initDefines(graph.config.symbols)
|
initDefines(graph.config.symbols)
|
||||||
defineSymbol(graph.config.symbols, "nimscript")
|
defineSymbol(graph.config.symbols, "nimscript")
|
||||||
when hasFFI: defineSymbol(graph.config.symbols, "nimffi")
|
when hasFFI: defineSymbol(graph.config.symbols, "nimffi")
|
||||||
registerPass(verbosePass)
|
registerPass(graph, verbosePass)
|
||||||
registerPass(semPass)
|
registerPass(graph, semPass)
|
||||||
registerPass(evalPass)
|
registerPass(graph, evalPass)
|
||||||
|
|
||||||
proc commandInteractive(graph: ModuleGraph; cache: IdentCache) =
|
proc commandInteractive(graph: ModuleGraph; cache: IdentCache) =
|
||||||
graph.config.errorMax = high(int) # do not stop after first error
|
graph.config.errorMax = high(int) # do not stop after first error
|
||||||
|
|
@ -156,7 +156,7 @@ proc mainCommand*(graph: ModuleGraph; cache: IdentCache) =
|
||||||
|
|
||||||
setupModuleCache()
|
setupModuleCache()
|
||||||
# In "nim serve" scenario, each command must reset the registered passes
|
# In "nim serve" scenario, each command must reset the registered passes
|
||||||
clearPasses()
|
clearPasses(graph)
|
||||||
conf.lastCmdTime = epochTime()
|
conf.lastCmdTime = epochTime()
|
||||||
conf.searchPaths.add(conf.libpath)
|
conf.searchPaths.add(conf.libpath)
|
||||||
setId(100)
|
setId(100)
|
||||||
|
|
@ -300,5 +300,3 @@ proc mainCommand*(graph: ModuleGraph; cache: IdentCache) =
|
||||||
ffDecimal, 3)
|
ffDecimal, 3)
|
||||||
|
|
||||||
resetAttributes(conf)
|
resetAttributes(conf)
|
||||||
|
|
||||||
#proc mainCommand*() = mainCommand(newModuleGraph(newConfigRef()), newIdentCache())
|
|
||||||
|
|
|
||||||
|
|
@ -74,10 +74,10 @@ var
|
||||||
gPasses: array[0..maxPasses - 1, TPass]
|
gPasses: array[0..maxPasses - 1, TPass]
|
||||||
gPassesLen*: int
|
gPassesLen*: int
|
||||||
|
|
||||||
proc clearPasses* =
|
proc clearPasses*(g: ModuleGraph) =
|
||||||
gPassesLen = 0
|
gPassesLen = 0
|
||||||
|
|
||||||
proc registerPass*(p: TPass) =
|
proc registerPass*(g: ModuleGraph; p: TPass) =
|
||||||
gPasses[gPassesLen] = p
|
gPasses[gPassesLen] = p
|
||||||
inc(gPassesLen)
|
inc(gPassesLen)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,15 +152,14 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
|
||||||
proc runNimScript*(cache: IdentCache; scriptName: string;
|
proc runNimScript*(cache: IdentCache; scriptName: string;
|
||||||
freshDefines=true; conf: ConfigRef) =
|
freshDefines=true; conf: ConfigRef) =
|
||||||
rawMessage(conf, hintConf, scriptName)
|
rawMessage(conf, hintConf, scriptName)
|
||||||
passes.gIncludeFile = includeModule
|
|
||||||
passes.gImportModule = importModule
|
|
||||||
let graph = newModuleGraph(cache, conf)
|
let graph = newModuleGraph(cache, conf)
|
||||||
if freshDefines: initDefines(conf.symbols)
|
if freshDefines: initDefines(conf.symbols)
|
||||||
|
|
||||||
defineSymbol(conf.symbols, "nimscript")
|
defineSymbol(conf.symbols, "nimscript")
|
||||||
defineSymbol(conf.symbols, "nimconfig")
|
defineSymbol(conf.symbols, "nimconfig")
|
||||||
registerPass(semPass)
|
registerPass(graph, semPass)
|
||||||
registerPass(evalPass)
|
registerPass(graph, evalPass)
|
||||||
|
|
||||||
conf.searchPaths.add(conf.libpath)
|
conf.searchPaths.add(conf.libpath)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue