WIP: an API for VM replay global state support

This commit is contained in:
Andreas Rumpf 2018-06-03 20:18:43 +02:00
commit b5194f592c
8 changed files with 288 additions and 35 deletions

View file

@ -10,7 +10,8 @@
## 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, options, modulegraphs, lineinfos
import ast, passes, msgs, idents, intsets, options, modulegraphs, lineinfos,
tables, btrees
const
byteExcess* = 128 # we use excess-K for immediates
@ -91,6 +92,9 @@ type
opcNSetFloatVal, opcNSetSymbol, opcNSetIdent, opcNSetType, opcNSetStrVal,
opcNNewNimNode, opcNCopyNimNode, opcNCopyNimTree, opcNDel, opcGenSym,
opcNccValue, opcNccInc, opcNcsAdd, opcNcsIncl, opcNcsLen, opcNcsAt,
opcNctPut, opcNctLen, opcNctGet, opcNctHasNext, opcNctNext,
opcSlurp,
opcGorge,
opcParseExprToAst,
@ -209,6 +213,9 @@ type
config*: ConfigRef
graph*: ModuleGraph
oldErrorCount*: int
cacheSeqs*: Table[string, PNode]
cacheCounters*: Table[string, BiggestInt]
cacheTables*: Table[string, BTree[string, PNode]]
TPosition* = distinct int
@ -219,7 +226,10 @@ proc newCtx*(module: PSym; cache: IdentCache; g: ModuleGraph): PCtx =
globals: newNode(nkStmtListExpr), constants: newNode(nkStmtList), types: @[],
prc: PProc(blocks: @[]), module: module, loopIterations: MaxLoopIterations,
comesFromHeuristic: unknownLineInfo(), callbacks: @[], errorFlag: "",
cache: cache, config: g.config, graph: g)
cache: cache, config: g.config, graph: g,
cacheSeqs: initTable[string, PNode]()
cacheCounters: initTable[string, BiggestInt]()
cacheTables: initTable[string, BTree[string, PNode]]())
proc refresh*(c: PCtx, module: PSym) =
c.module = module