refactoring: explict config state instead of globals
This commit is contained in:
parent
5565b9ef10
commit
f04d21f279
12 changed files with 110 additions and 79 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue