This module implements the code generator for the VM.
Imports
-
../ast/renderer, ../ast/types, ../ast/ast, ../ast/lineinfos, ../ast/trees, ../backend/cgir, ../modules/magicsys, ../modules/modulegraphs, ../mir/mirenv, ../mir/mirtrees, ../mir/mirtypes, ../front/msgs, ../front/options, ../utils/containers, ../utils/idioms, identpatterns, vmaux, vmdef, vmobjects, vmtypegen, vmtypes, ../backend/compat
Types
CodeGenCtx = object prc: BProc env*: MirEnv graph*: ModuleGraph config*: ConfigRef features*: TSandboxFlags module*: PSym callbackKeys*: Patterns code*: seq[TInstr] debug*: seq[TLineInfo] ehTable*: seq[HandlerTableEntry] ehCode*: seq[EhInstr] constants*: seq[VmConstant] typeInfoCache*: TypeInfoCache rtti*: seq[VmTypeInfo]
- Bundles all input, output, and other contextual data needed for the code generator Source Edit
VmGenResult = Result[CodeInfo, VmGenDiag]
- Result of a vmgen invocation Source Edit
Consts
MagicsToKeep = {mIsolate, mNHint, mNWarning, mNError, mMinI, mMaxI, mAbsI, mDotDot, mNGetType, mNSizeOf, mNLineInfo, mEvalToAst}
- the set of magics that are kept as normal procedure calls and thus need an entry in the function table. Source Edit
slotSomeTemp = slotTempUnknown
- Source Edit
Procs
func gABC(ctx: var TCtx; i: TLineInfo; opc: TOpcode; a, b, c: TRegister = 0) {. ...raises: [], tags: [].}
- Takes the registers b and c, applies the operation opc to them, and stores the result into register a The node is needed for debug information Source Edit
proc gABx(c: var TCtx; i: TLineInfo; opc: TOpcode; a: TRegister = 0; bx: int) {. ...raises: [Exception, ERecoverableError], tags: [RootEffect].}
- Source Edit
proc genProc(c: var TCtx; s: PSym; body: sink Body): VmGenResult {....raises: [ Exception, ERecoverableError, KeyError, Exception, ERecoverableError, ValueError], tags: [RootEffect].}
- Source Edit
proc genStmt(c: var TCtx; body: sink Body): Result[int, VmGenDiag] {. ...raises: [Exception], tags: [RootEffect].}
- Source Edit
proc getOrCreate(c: var TCtx; typ: PType; noClosure = false): PVmType {.inline, ...raises: [KeyError, Exception], tags: [RootEffect].}
- Source Edit
proc importcCond(c: TCtx; s: PSym): bool {.inline, ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
- return true to importc s, false to execute its body instead (refs #8405) Source Edit
proc importcCondVar(s: PSym): bool {.inline, ...raises: [], tags: [].}
- Source Edit
proc initCodeGen(g: ModuleGraph): CodeGenCtx {. ...raises: [KeyError, Exception, ERecoverableError], tags: [ReadDirEffect, RootEffect].}
- Source Edit
func vmGenDiagToAstDiagVmGenError(diag: VmGenDiag): AstDiagVmGenError {.inline, ...raises: [], tags: [].}
- Source Edit