summary refs log tree commit diff stats
path: root/compiler/vmdef.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-10-15 08:06:54 +0200
committerAraq <rumpf_a@web.de>2013-10-15 08:06:54 +0200
commit6a9baf3fd7842027a30ee4856d40841610dccc13 (patch)
tree66489b9bbf27673beabc0b2219bf0036b315b289 /compiler/vmdef.nim
parent5659a1662e755baac1de555e33f2e8c13e30f2e2 (diff)
downloadNim-6a9baf3fd7842027a30ee4856d40841610dccc13.tar.gz
compiler bootstraps with new VM
Diffstat (limited to 'compiler/vmdef.nim')
-rw-r--r--compiler/vmdef.nim18
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler/vmdef.nim b/compiler/vmdef.nim
index d4b3d891d..bc6824d3b 100644
--- a/compiler/vmdef.nim
+++ b/compiler/vmdef.nim
@@ -165,12 +165,30 @@ type
 
   PEvalContext* = PCtx
 
+  TEvalMode* = enum           ## reason for evaluation
+    emRepl,                   ## evaluate because in REPL mode
+    emConst,                  ## evaluate for 'const' according to spec
+    emOptimize,               ## evaluate for optimization purposes (same as
+                              ## emConst?)
+    emStatic                  ## evaluate for enforced compile time eval
+                              ## ('static' context)
+
+  TSandboxFlag* = enum        ## what the evaluation engine should allow
+    allowCast,                ## allow unsafe language feature: 'cast'
+    allowFFI,                 ## allow the FFI
+    allowInfiniteLoops        ## allow endless loops
+  TSandboxFlags* = set[TSandboxFlag]
+
   
 proc newCtx*(module: PSym): PCtx =
   PCtx(code: @[], debug: @[],
     globals: newNode(nkStmtList), constants: newNode(nkStmtList), types: @[],
     prc: PProc(blocks: @[]), module: module)
 
+proc refresh*(c: PCtx, module: PSym) =
+  c.module = module
+  c.prc = PProc(blocks: @[])
+
 const
   firstABxInstr* = opcTJmp
   largeInstrs* = { # instructions which use 2 int32s instead of 1: