refactoring: explict config state instead of globals

This commit is contained in:
Andreas Rumpf 2017-02-01 15:39:56 +01:00
commit f04d21f279
12 changed files with 110 additions and 79 deletions

View file

@ -25,7 +25,7 @@
## - Its dependent module stays the same.
##
import ast, intsets, tables
import ast, intsets, tables, options
type
ModuleGraph* = ref object
@ -39,16 +39,18 @@ type
importStack*: seq[int32] # The current import stack. Used for detecting recursive
# module dependencies.
backend*: RootRef # minor hack so that a backend can extend this easily
config*: ConfigRef
{.this: g.}
proc newModuleGraph*(): ModuleGraph =
proc newModuleGraph*(config: ConfigRef = nil): ModuleGraph =
result = ModuleGraph()
initStrTable(result.packageSyms)
result.deps = initIntSet()
result.modules = @[]
result.importStack = @[]
result.inclToMod = initTable[int32, int32]()
result.config = config
proc resetAllModules*(g: ModuleGraph) =
initStrTable(packageSyms)