summary refs log tree commit diff stats
path: root/compiler/vmdef.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-08-30 16:37:27 +0200
committerAraq <rumpf_a@web.de>2014-08-30 16:37:27 +0200
commit1f85b3b5d3f8a9cf84fc5c03604ac3a7ea901d8c (patch)
tree88799a003b88e742d8548a2965e9ef42b6ce2a3b /compiler/vmdef.nim
parentc40f981e647eef2fb558c462f1df10c61d250a97 (diff)
downloadNim-1f85b3b5d3f8a9cf84fc5c03604ac3a7ea901d8c.tar.gz
VM supports math and a few os procs
Diffstat (limited to 'compiler/vmdef.nim')
-rw-r--r--compiler/vmdef.nim13
1 files changed, 11 insertions, 2 deletions
diff --git a/compiler/vmdef.nim b/compiler/vmdef.nim
index e25fd6392..d7cdafb69 100644
--- a/compiler/vmdef.nim
+++ b/compiler/vmdef.nim
@@ -170,7 +170,12 @@ type
     sym*: PSym
     slots*: array[TRegister, tuple[inUse: bool, kind: TSlotKind]]
     maxSlots*: int
-    
+
+  VmArgs* = object
+    ra*, rb*, rc*: Natural
+    slots*: pointer
+  VmCallback* = proc (args: VmArgs) {.closure.}
+  
   PCtx* = ref TCtx
   TCtx* = object of passes.TPassContext # code gen context
     code*: seq[TInstr]
@@ -189,6 +194,7 @@ type
     traceActive*: bool
     loopIterations*: int
     comesFromHeuristic*: TLineInfo # Heuristic for better macro stack traces
+    callbacks*: seq[tuple[key: string, value: VmCallback]]
 
   TPosition* = distinct int
 
@@ -198,12 +204,15 @@ proc newCtx*(module: PSym): PCtx =
   PCtx(code: @[], debug: @[],
     globals: newNode(nkStmtListExpr), constants: newNode(nkStmtList), types: @[],
     prc: PProc(blocks: @[]), module: module, loopIterations: MaxLoopIterations,
-    comesFromHeuristic: unknownLineInfo())
+    comesFromHeuristic: unknownLineInfo(), callbacks: @[])
 
 proc refresh*(c: PCtx, module: PSym) =
   c.module = module
   c.prc = PProc(blocks: @[])
 
+proc registerCallback*(c: PCtx; name: string; callback: VmCallback) =
+  c.callbacks.add((name, callback))
+
 const
   firstABxInstr* = opcTJmp
   largeInstrs* = { # instructions which use 2 int32s instead of 1: