vmgen

Source   Edit  

This module implements the code generator for the VM.

The VM works on packed data (see vmdef): registers are 8 byte slots of the stack frame. Scalars held in registers are widened to 64 bits, aggregates occupy consecutive slots and use the memory layout.

Every expression that denotes a location (a local, a global, a field, an array element, a dereferenced pointer) is translated to a Loc. Values are loaded from and stored to locations with typed loads and stores.

The code that is fed to the code generator went through transf and, for the new runtime, through injectdestructors: assignments are bit copies, all non-trivial copies, moves and destructions are explicit calls to hooks.

Consts

debugEchoCode = false
Source   Edit  

Procs

proc callShapeOf(c: PCtx; s: PSym): CallShape {....raises: [KeyError, OSError,
    Exception, ValueError, IOError, ERecoverableError], tags: [ReadEnvEffect,
    ReadIOEffect, ReadDirEffect, RootEffect, WriteIOEffect], forbids: [].}
where the arguments and the result of a call of s are, relative to the call area; used for callbacks and templates. Source   Edit  
proc echoCode(c: PCtx; start = 0; last = -1) {....deprecated,
    raises: [ValueError, OSError, KeyError], tags: [RootEffect, ReadDirEffect],
    forbids: [].}
Deprecated
Source   Edit  
proc genExpr(c: PCtx; n: PNode; requiresValue = true): int {....raises: [KeyError,
    OSError, Exception, ValueError, IOError, ERecoverableError], tags: [
    ReadEnvEffect, ReadIOEffect, ReadDirEffect, RootEffect, WriteIOEffect],
    forbids: [].}
Source   Edit  
proc genProc(c: PCtx; s: PSym): VmProcInfo {....raises: [KeyError, OSError,
    Exception, ValueError, IOError, ERecoverableError], tags: [ReadEnvEffect,
    ReadIOEffect, ReadDirEffect, RootEffect, WriteIOEffect, TimeEffect],
    forbids: [].}
Source   Edit  
proc genStmt(c: PCtx; n: PNode): int {....raises: [KeyError, OSError, Exception,
    ValueError, IOError, ERecoverableError], tags: [ReadEnvEffect, ReadIOEffect,
    ReadDirEffect, RootEffect, WriteIOEffect], forbids: [].}
Source   Edit  
proc importcCond(c: PCtx; s: PSym): bool {.
    ...raises: [KeyError, OSError, Exception, ValueError],
    tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect, RootEffect], forbids: [].}
Source   Edit  
proc importcCondVar(s: PSym): bool {.inline, ...raises: [KeyError, OSError,
    Exception, ValueError], tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect,
                                   RootEffect], forbids: [].}
Source   Edit  
proc valueConv(c: PCtx): ValueConv {....raises: [KeyError, OSError, Exception,
    ValueError, IOError, ERecoverableError], tags: [ReadEnvEffect, ReadIOEffect,
    ReadDirEffect, RootEffect, WriteIOEffect], forbids: [].}
Source   Edit