cgen

Source   Edit  

This module implements the C code generator.This include file contains the logic to produce constant string and seq literals. The code here is responsible that const x = ["a", "b"] works without hidden runtime creation code. The price is that seqs and strings are not purely a library implementation.Generates traversal procs for the C backend.Code specialization instead of the old, incredibly slow 'genericReset' implementation.Thread var support for architectures that lack native support for thread local storage.

Procs

proc cgenWriteModules(backend: RootRef; config: ConfigRef) {....raises: [KeyError,
    ValueError, Exception, OSError, IOError, ERecoverableError], tags: [
    RootEffect, ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect,
    TimeEffect, WriteDirEffect], forbids: [].}
Source   Edit  
proc fillObjectFields(m: BModule; typ: PType) {....raises: [Exception, ValueError,
    OSError, KeyError, IOError, ERecoverableError], tags: [RootEffect,
    ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect], forbids: [].}
Source   Edit  
proc finalCodegenActions(graph: ModuleGraph; m: BModule; n: PNode) {....raises: [
    KeyError, ValueError, Exception, OSError, IOError, ERecoverableError], tags: [
    RootEffect, ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect,
    TimeEffect], forbids: [].}
Also called from IC. Source   Edit  
proc genProcLvl3(m: BModule; prc: PSym) {....raises: [KeyError, ValueError,
    Exception, OSError, IOError, ERecoverableError], tags: [RootEffect,
    ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect, TimeEffect],
    forbids: [].}
Source   Edit  
proc genTopLevelStmt(m: BModule; n: PNode) {....raises: [KeyError, ValueError,
    Exception, OSError, IOError, ERecoverableError], tags: [RootEffect,
    ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect, TimeEffect],
    forbids: [].}
Also called from ic/cbackend.nim. Source   Edit  
proc genTypeInfo(config: ConfigRef; m: BModule; t: PType; info: TLineInfo): Rope {....raises: [
    KeyError, ValueError, Exception, OSError, IOError, ERecoverableError], tags: [
    RootEffect, ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect],
    forbids: [].}
Source   Edit  
proc getCFile(m: BModule): AbsoluteFile {.
    ...raises: [KeyError, ValueError, Exception, OSError, IOError], tags: [
    RootEffect, ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteDirEffect],
    forbids: [].}
Source   Edit  
proc getSomeNameForModule(m: BModule): Rope {.
    ...raises: [KeyError, ValueError, Exception, OSError],
    tags: [RootEffect, ReadEnvEffect, ReadIOEffect, ReadDirEffect], forbids: [].}
Returns a mangled module name. Source   Edit  
proc multiFormat(frmt: var string; chars: static openArray[char];
                 args: openArray[seq[string]])
Source   Edit  
proc newModule(g: BModuleList; module: PSym; conf: ConfigRef; idgen: IdGenerator): BModule {.
    ...raises: [KeyError, ValueError, Exception, OSError],
    tags: [RootEffect, ReadEnvEffect, ReadIOEffect, ReadDirEffect], forbids: [].}
Source   Edit  
proc registerReusedModuleToMain(g: BModuleList; m: BModule;
                                initRequired, datInitRequired: bool) {....raises: [
    KeyError, ValueError, Exception, OSError, IOError, ERecoverableError], tags: [
    RootEffect, ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect],
    forbids: [].}
registerModuleToMain for a module whose cached translation unit is reused: the init/datInit presence comes from the artifact's meta head instead of the (never generated) sections. Mirrors the non-hcr path of registerModuleToMain — reuse is disabled when hcr is on. Source   Edit  
proc requestProcDef(m: BModule; prc: PSym) {....raises: [KeyError, ValueError,
    Exception, OSError, IOError, ERecoverableError], tags: [RootEffect,
    ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect, TimeEffect],
    forbids: [].}
Public demand entry: request prc's definition; it is routed to the module that owns it and generated once, exactly as if some generated code had referenced it. Source   Edit  
proc setupCgen(graph: ModuleGraph; module: PSym; idgen: IdGenerator): PPassContext {.
    ...raises: [KeyError, ValueError, Exception, OSError, IOError], tags: [
    RootEffect, ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteDirEffect],
    forbids: [].}
Source   Edit  

Templates

template cgDeclFrmt(s: PSym): string
Source   Edit