summary refs log tree commit diff stats
path: root/compiler/vmdef.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-05-05 18:47:29 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-05-05 18:47:29 +0200
commitb7116a28eea13f4fd82b8b22323f2f75c813794f (patch)
tree9dff3b1d346a54aaed204118b8cf3692986867e7 /compiler/vmdef.nim
parenteef12654bd896df9b1219ea4bbd6381ccb920e58 (diff)
downloadNim-b7116a28eea13f4fd82b8b22323f2f75c813794f.tar.gz
compiler refactoring, pass config around explicitly
Diffstat (limited to 'compiler/vmdef.nim')
-rw-r--r--compiler/vmdef.nim8
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/vmdef.nim b/compiler/vmdef.nim
index 66bc8dfd2..b0a559d2c 100644
--- a/compiler/vmdef.nim
+++ b/compiler/vmdef.nim
@@ -10,7 +10,7 @@
 ## This module contains the type definitions for the new evaluation engine.
 ## An instruction is 1-3 int32s in memory, it is a register based VM.
 
-import ast, passes, msgs, idents, intsets
+import ast, passes, msgs, idents, intsets, options
 
 const
   byteExcess* = 128 # we use excess-K for immediates
@@ -206,17 +206,19 @@ type
     callbacks*: seq[tuple[key: string, value: VmCallback]]
     errorFlag*: string
     cache*: IdentCache
+    config*: ConfigRef
 
   TPosition* = distinct int
 
   PEvalContext* = PCtx
 
-proc newCtx*(module: PSym; cache: IdentCache): PCtx =
+proc newCtx*(module: PSym; cache: IdentCache; config: ConfigRef = nil): PCtx =
+  let conf = if config != nil: config else: newConfigRef()
   PCtx(code: @[], debug: @[],
     globals: newNode(nkStmtListExpr), constants: newNode(nkStmtList), types: @[],
     prc: PProc(blocks: @[]), module: module, loopIterations: MaxLoopIterations,
     comesFromHeuristic: unknownLineInfo(), callbacks: @[], errorFlag: "",
-    cache: cache)
+    cache: cache, config: conf)
 
 proc refresh*(c: PCtx, module: PSym) =
   c.module = module