VM supports math and a few os procs
This commit is contained in:
parent
c40f981e64
commit
1f85b3b5d3
8 changed files with 157 additions and 10 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue