compiler/ic/ic

    Dark Mode
Search:
  Source   Edit

Types

LoadedModule = object
  status*: ModuleStatus
  symsInit, typesInit, loadedButAliveSetChanged*: bool
  fromDisk*: PackedModule
  syms: seq[PSym]
  types: seq[PType]
  module*: PSym
  iface, ifaceHidden: Table[PIdent, seq[PackedItemId]]
  Source   Edit
ModuleBackendFlag = enum
  HasDatInitProc, HasModuleInitProc
  Source   Edit
ModuleStatus = enum
  undefined, storing, loading, loaded, outdated, stored
  Source   Edit
PackedConfig = object
  backend: TBackend
  selectedGC: TGCMode
  cCompiler: TSystemCC
  options: TOptions
  globalOptions: TGlobalOptions
  Source   Edit
PackedDecoder = object
  lastModule: int
  lastLit: LitId
  lastFile: FileIndex
  config*: ConfigRef
  cache*: IdentCache
  Source   Edit
PackedEncoder = object
  thisModule*: int32
  lastFile*: FileIndex       ## remember the last lookup entry.
  lastLit*: LitId
  filenames*: Table[FileIndex, LitId]
  pendingTypes*: seq[PType]
  pendingSyms*: seq[PSym]
  typeMarker*: IntSet
  symMarker*: IntSet
  config*: ConfigRef
  Source   Edit
PackedModule = object
  definedSymbols: string
  moduleFlags: TSymFlags
  includes*: seq[(LitId, string)] ## first entry is the module filename itself
  imports: seq[LitId]        ## the modules this module depends on
  toReplay*: PackedTree      ## pragmas and VM specific state to replay.
  topLevel*: PackedTree      ## top level statements
  bodies*: PackedTree        ## other trees. Referenced from typ.n and sym.ast by their position.
  exports*: seq[(LitId, int32)]
  hidden*: seq[(LitId, int32)]
  reexports*: seq[(LitId, PackedItemId)]
  compilerProcs*: seq[(LitId, int32)]
  converters*, methods*, trmacros*, pureEnums*: seq[int32]
  macroUsages*: seq[(PackedItemId, PackedLineInfo)]
  typeInstCache*: seq[(PackedItemId, PackedItemId)]
  procInstCache*: seq[PackedInstantiation]
  attachedOps*: seq[(TTypeAttachedOp, PackedItemId, PackedItemId)]
  methodsPerType*: seq[(PackedItemId, int, PackedItemId)]
  enumToStringProcs*: seq[(PackedItemId, PackedItemId)]
  libs*: seq[PackedLib]
  emittedTypeInfo*: seq[string]
  backendFlags*: set[ModuleBackendFlag]
  syms*: seq[PackedSym]
  types*: seq[PackedType]
  strings*: BiTable[string]  ## we could share these between modules.
  numbers*: BiTable[BiggestInt] ## we also store floats in here so
                                ## that we can assure that every bit is kept
  cfg: PackedConfig
the parts of a PackedEncoder that are part of the .rod file   Source   Edit
RodIter = object
  decoder: PackedDecoder
  values: seq[PackedItemId]
  i, module: int
  Source   Edit

Procs

proc addCompilerProc(c: var PackedEncoder; m: var PackedModule; s: PSym) {.
    ...raises: [], tags: [].}
  Source   Edit
proc addConverter(c: var PackedEncoder; m: var PackedModule; s: PSym) {.
    ...raises: [], tags: [].}
  Source   Edit
proc addExported(c: var PackedEncoder; m: var PackedModule; s: PSym) {.
    ...raises: [], tags: [].}
  Source   Edit
proc addHidden(c: var PackedEncoder; m: var PackedModule; s: PSym) {....raises: [],
    tags: [].}
  Source   Edit
proc addImportFileDep(c: var PackedEncoder; m: var PackedModule; f: FileIndex) {.
    ...raises: [], tags: [].}
  Source   Edit
proc addIncludeFileDep(c: var PackedEncoder; m: var PackedModule; f: FileIndex) {.
    ...raises: [IOError], tags: [ReadIOEffect].}
  Source   Edit
proc addMethod(c: var PackedEncoder; m: var PackedModule; s: PSym) {....raises: [],
    tags: [].}
  Source   Edit
proc addPragmaComputation(c: var PackedEncoder; m: var PackedModule; n: PNode) {.
    ...raises: [], tags: [].}
  Source   Edit
proc addPureEnum(c: var PackedEncoder; m: var PackedModule; s: PSym) {.
    ...raises: [], tags: [].}
  Source   Edit
proc addReexport(c: var PackedEncoder; m: var PackedModule; s: PSym) {.
    ...raises: [], tags: [].}
  Source   Edit
proc addTrmacro(c: var PackedEncoder; m: var PackedModule; s: PSym) {.
    ...raises: [], tags: [].}
  Source   Edit
proc checkForHoles(m: PackedModule; config: ConfigRef; moduleId: int) {.
    ...deprecated: "for debugging", raises: [], tags: [].}
Deprecated: for debugging
  Source   Edit
proc debug(tree: PackedTree; m: PackedModule) {....raises: [IOError],
    tags: [WriteIOEffect].}
  Source   Edit
proc idgenFromLoadedModule(m: LoadedModule): IdGenerator {....raises: [], tags: [].}
  Source   Edit
proc initEncoder(c: var PackedEncoder; m: var PackedModule; moduleSym: PSym;
                 config: ConfigRef; pc: PackedConfig) {....raises: [IOError],
    tags: [ReadIOEffect].}
setup a context for serializing to packed ast   Source   Edit
proc initPackedDecoder(config: ConfigRef; cache: IdentCache): PackedDecoder {.
    ...raises: [], tags: [].}
  Source   Edit
proc initRodIter(it: var RodIter; config: ConfigRef; cache: IdentCache;
                 g: var PackedModuleGraph; module: FileIndex; name: PIdent;
                 importHidden: bool): PSym {....raises: [KeyError, Exception],
    tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc initRodIterAllSyms(it: var RodIter; config: ConfigRef; cache: IdentCache;
                        g: var PackedModuleGraph; module: FileIndex;
                        importHidden: bool): PSym {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc interfaceSymbol(config: ConfigRef; cache: IdentCache;
                     g: var PackedModuleGraph; module: FileIndex; name: PIdent;
                     importHidden: bool): PSym {....raises: [KeyError, Exception],
    tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc isActive(e: PackedEncoder): bool {....raises: [], tags: [].}
  Source   Edit
proc loadLibs(config: ConfigRef; cache: IdentCache; g: var PackedModuleGraph;
              module: int): seq[TLib] {....raises: [Exception, KeyError],
                                        tags: [RootEffect, ReadDirEffect].}
  Source   Edit
proc loadNodes(c: var PackedDecoder; g: var PackedModuleGraph; thisModule: int;
               tree: PackedTree; n: NodePos): PNode {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc loadProcBody(config: ConfigRef; cache: IdentCache;
                  g: var PackedModuleGraph; s: PSym): PNode {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc loadRodFile(filename: AbsoluteFile; m: var PackedModule; config: ConfigRef;
                 ignoreConfig = false): RodFileError {.
    ...raises: [IOError, KeyError, Exception],
    tags: [ReadIOEffect, ReadDirEffect, RootEffect].}
  Source   Edit
proc loadSymFromId(config: ConfigRef; cache: IdentCache;
                   g: var PackedModuleGraph; module: int; id: PackedItemId): PSym {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
Loads the symbol with id from the context of the module module. The resulting symbol is cached if it wasn't already.   Source   Edit
proc loadTypeFromId(config: ConfigRef; cache: IdentCache;
                    g: var PackedModuleGraph; module: int; id: PackedItemId): PType {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc moduleFromRodFile(g: var PackedModuleGraph; conf: ConfigRef;
                       cache: IdentCache; fileIdx: FileIndex;
                       cachedModules: var seq[FileIndex]): PSym {.
    ...raises: [OSError, IOError, KeyError, Exception, ERecoverableError], tags: [
    ReadEnvEffect, ReadIOEffect, WriteDirEffect, ReadDirEffect, RootEffect].}
Returns 'nil' if the module needs to be recompiled.   Source   Edit
proc moduleIndex(c: var PackedDecoder; g: PackedModuleGraph; thisModule: int;
                 s: PackedItemId): int32 {.inline,
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc nextRodIter(it: var RodIter; g: var PackedModuleGraph): PSym {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc rememberStartupConfig(dest: var PackedConfig; config: ConfigRef) {.
    ...raises: [], tags: [].}
  Source   Edit
proc rodViewer(rodfile: AbsoluteFile; config: ConfigRef; cache: IdentCache) {.
    ...raises: [IOError, KeyError, Exception],
    tags: [ReadIOEffect, ReadDirEffect, RootEffect].}
  Source   Edit
proc saveRodFile(filename: AbsoluteFile; encoder: var PackedEncoder;
                 m: var PackedModule) {....raises: [Exception, IOError, OSError], tags: [
    RootEffect, WriteIOEffect, WriteDirEffect].}
  Source   Edit
proc searchForCompilerproc(m: LoadedModule; name: string): int32 {....raises: [],
    tags: [].}
  Source   Edit
proc simulateLoadedModule(g: var PackedModuleGraph; conf: ConfigRef;
                          cache: IdentCache; moduleSym: PSym; m: PackedModule) {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc storeAttachedOp(c: var PackedEncoder; m: var PackedModule;
                     kind: TTypeAttachedOp; t: PType; s: PSym) {....raises: [],
    tags: [].}
Records a type-bound operator attachment action to module m.   Source   Edit
proc storeExpansion(c: var PackedEncoder; m: var PackedModule; info: TLineInfo;
                    s: PSym) {....raises: [], tags: [].}
  Source   Edit
proc storeInstantiation(c: var PackedEncoder; m: var PackedModule; s: PSym;
                        i: PInstantiation) {....raises: [], tags: [].}
  Source   Edit
proc storeLib(c: var PackedEncoder; m: var PackedModule; lib: TLib) {.
    ...raises: [Exception], tags: [RootEffect].}
  Source   Edit
proc storeSym(s: PSym; c: var PackedEncoder; m: var PackedModule): PackedItemId {.
    ...raises: [Exception], tags: [RootEffect].}
serialize a psym   Source   Edit
proc storeTypeInst(c: var PackedEncoder; m: var PackedModule; s: PSym;
                   inst: PType) {....raises: [], tags: [].}
  Source   Edit
proc toFileIndex(x: LitId; m: PackedModule; config: ConfigRef): FileIndex {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc toFileIndexCached(c: var PackedDecoder; g: PackedModuleGraph;
                       thisModule: int; f: LitId): FileIndex {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc toPackedGeneratedProcDef(s: PSym; encoder: var PackedEncoder;
                              m: var PackedModule) {....raises: [], tags: [].}
Generic procs and generated =hook's need explicit top-level entries so that the code generator can work without having to special case these. These entries will also be useful for other tools and are the cleanest design I can come up with.   Source   Edit
proc toPackedNode(n: PNode; ir: var PackedTree; c: var PackedEncoder;
                  m: var PackedModule) {....raises: [], tags: [].}
serialize a node into the tree   Source   Edit
proc toPackedNodeTopLevel(n: PNode; encoder: var PackedEncoder;
                          m: var PackedModule) {....raises: [Exception],
    tags: [RootEffect].}
  Source   Edit
proc toString(tree: PackedTree; n: NodePos; m: PackedModule): string {.
    ...raises: [], tags: [].}
  Source   Edit
proc toString(tree: PackedTree; n: NodePos; m: PackedModule; nesting: int;
              result: var string) {....raises: [], tags: [].}
  Source   Edit
proc translateId(id: PackedItemId; g: PackedModuleGraph; thisModule: int;
                 config: ConfigRef): ItemId {....raises: [KeyError, Exception],
    tags: [ReadDirEffect, RootEffect].}
  Source   Edit

Iterators

iterator interfaceSymbols(config: ConfigRef; cache: IdentCache;
                          g: var PackedModuleGraph; module: FileIndex;
                          name: PIdent; importHidden: bool): PSym {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit