modulegraphs

Search:
Group by:
Source   Edit  

This module implements the module graph data structure. The module graph represents a complete Nim project. Single modules can either be kept in RAM or stored in a rod-file.

Types

FullId = object
  module*: int
  packed*: PackedItemId
Source   Edit  
Iface = object
  module*: PSym              ## module this "Iface" belongs to
  converters*: seq[LazySym]
  patterns*: seq[LazySym]
  pureEnums*: seq[LazySym]
  uniqueName*: Rope
data we don't want to store directly in the ast.PSym type for s.kind == skModule Source   Edit  
LazyInstantiation = object
  module*: int
  sym*: FullId
  concreteTypes*: seq[FullId]
  inst*: PInstantiation
Source   Edit  
LazySym = object
  id*: FullId
  sym*: PSym
Source   Edit  
LazyType = object
  id*: FullId
  typ*: PType
Source   Edit  
ModuleGraph {.acyclic.} = ref object
  ifaces*: seq[Iface]        ## indexed by int32 fileIdx
  packed*: PackedModuleGraph
  encoders*: seq[PackedEncoder]
  typeInstCache*: Table[ItemId, seq[LazyType]]
  procInstCache*: Table[ItemId, seq[LazyInstantiation]]
  attachedOps*: array[TTypeAttachedOp, Table[ItemId, LazySym]]
  methodsPerType*: Table[ItemId, seq[(int, LazySym)]]
  memberProcsPerType*: Table[ItemId, seq[PSym]]
  enumToStringProcs*: Table[ItemId, LazySym]
  emittedTypeInfo*: Table[string, FileIndex]
  startupPackedConfig*: PackedConfig
  packageSyms*: TStrTable
  deps*: IntSet
  importDeps*: Table[FileIndex, seq[FileIndex]]
  suggestMode*: bool
  inclToMod*: Table[FileIndex, FileIndex]
  importStack*: seq[FileIndex]
  backend*: RootRef
  config*: ConfigRef
  cache*: IdentCache
  vm*: RootRef
  doStopCompile*: proc (): bool {.closure.}
  usageSym*: PSym
  owners*: seq[PSym]
  suggestSymbols*: Table[FileIndex, seq[SymInfoPair]]
  suggestErrors*: Table[FileIndex, seq[Suggest]]
  methods*: seq[tuple[methods: seq[PSym], dispatcher: PSym]]
  systemModule*: PSym
  sysTypes*: array[TTypeKind, PType]
  compilerprocs*: TStrTable
  exposed*: TStrTable
  packageTypes*: TStrTable
  emptyNode*: PNode
  canonTypes*: Table[SigHash, PType]
  symBodyHashes*: Table[int, SigHash]
  importModuleCallback*: proc (graph: ModuleGraph; m: PSym; fileIdx: FileIndex): PSym {.
      nimcall.}
  includeFileCallback*: proc (graph: ModuleGraph; m: PSym; fileIdx: FileIndex): PNode {.
      nimcall.}
  cacheSeqs*: Table[string, PNode]
  cacheCounters*: Table[string, BiggestInt]
  cacheTables*: Table[string, BTree[string, PNode]]
  passes*: seq[TPass]
  pipelinePass*: PipelinePass
  onDefinition*: proc (graph: ModuleGraph; s: PSym; info: TLineInfo) {.nimcall.}
  onDefinitionResolveForward*: proc (graph: ModuleGraph; s: PSym;
                                     info: TLineInfo) {.nimcall.}
  onUsage*: proc (graph: ModuleGraph; s: PSym; info: TLineInfo) {.nimcall.}
  globalDestructors*: seq[PNode]
  strongSemCheck*: proc (graph: ModuleGraph; owner: PSym; body: PNode) {.nimcall.}
  compatibleProps*: proc (graph: ModuleGraph; formal, actual: PType): bool {.
      nimcall.}
  idgen*: IdGenerator
  operators*: Operators
Source   Edit  
ModuleIter = object
  
Source   Edit  
Operators = object
  opNot*, opContains*, opLe*, opLt*, opAnd*, opOr*, opIsNil*, opEq*: PSym
  opAdd*, opSub*, opMul*, opDiv*, opLen*: PSym
Source   Edit  
PipelinePass = enum
  NonePass, SemPass, JSgenPass, CgenPass, EvalPass, InterpreterPass,
  GenDependPass, Docgen2TexPass, Docgen2JsonPass, Docgen2Pass
Source   Edit  
SigHash = distinct MD5Digest
Source   Edit  
SymInfoPair = object
  sym*: PSym
  info*: TLineInfo
Source   Edit  
TPass = tuple[open: TPassOpen, process: TPassProcess, close: TPassClose,
              isFrontend: bool]
Source   Edit  
TPassClose = proc (graph: ModuleGraph; p: PPassContext; n: PNode): PNode {.
    nimcall.}
Source   Edit  
TPassContext = object of RootObj
  idgen*: IdGenerator
Source   Edit  
TPassOpen = proc (graph: ModuleGraph; module: PSym; idgen: IdGenerator): PPassContext {.
    nimcall.}
Source   Edit  
TPassProcess = proc (p: PPassContext; topLevelStmt: PNode): PNode {.nimcall.}
Source   Edit  

Procs

proc `$`(u: SigHash): string {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc `==`(a, b: SigHash): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc `==`(a, b: SymInfoPair): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc addDep(g: ModuleGraph; m: PSym; dep: FileIndex) {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc addIncludeDep(g: ModuleGraph; module, includeFile: FileIndex) {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc addMethodToGeneric(g: ModuleGraph; module: int; t: PType; col: int; m: PSym) {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
func belongsToStdlib(graph: ModuleGraph; sym: PSym): bool {....raises: [],
    tags: [], forbids: [].}
Check if symbol belongs to the 'stdlib' package. Source   Edit  
proc closeRodFile(g: ModuleGraph; m: PSym) {.
    ...raises: [Exception, IOError, OSError, KeyError], tags: [RootEffect,
    WriteIOEffect, WriteDirEffect, ReadEnvEffect, ReadIOEffect, ReadDirEffect],
    forbids: [].}
Source   Edit  
proc completePartialOp(g: ModuleGraph; module: int; t: PType;
                       op: TTypeAttachedOp; value: PSym) {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc configComplete(g: ModuleGraph) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc copyTypeProps(g: ModuleGraph; module: int; dest, src: PType) {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect],
    forbids: [].}
Source   Edit  
proc createMagic(g: ModuleGraph; idgen: IdGenerator; name: string; m: TMagic): PSym {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc fileSymbols(graph: ModuleGraph; fileIdx: FileIndex): seq[SymInfoPair] {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc getAttachedOp(g: ModuleGraph; t: PType; op: TTypeAttachedOp): PSym {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect],
    forbids: [].}
returns the requested attached operation for type t. Can return nil if no such operation exists. Source   Edit  
proc getBody(g: ModuleGraph; s: PSym): PNode {.inline,
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect],
    forbids: [].}
Source   Edit  
proc getModule(g: ModuleGraph; fileIdx: FileIndex): PSym {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc getPackage(graph: ModuleGraph; fileIdx: FileIndex): PSym {.
    ...raises: [KeyError, OSError], tags: [ReadDirEffect], forbids: [].}
Returns a package symbol for yet to be defined module for fileIdx. The package symbol is added to the graph if it doesn't exist. Source   Edit  
proc getToStringProc(g: ModuleGraph; t: PType): PSym {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect],
    forbids: [].}
Source   Edit  
proc hasDisabledAsgn(g: ModuleGraph; t: PType): bool {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect],
    forbids: [].}
Source   Edit  
proc hash(u: SigHash): Hash {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc hash(x: FileIndex): Hash {.borrow, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc initEncoder(g: ModuleGraph; module: PSym) {....raises: [IOError],
    tags: [ReadIOEffect], forbids: [].}
Source   Edit  
proc initModuleIter(mi: var ModuleIter; g: ModuleGraph; m: PSym; name: PIdent): PSym {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect],
    forbids: [].}
Source   Edit  
proc initOperators(g: ModuleGraph): Operators {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc initStrTables(g: ModuleGraph; m: PSym) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc isDirty(g: ModuleGraph; m: PSym): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc loadCompilerProc(g: ModuleGraph; name: string): PSym {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect],
    forbids: [].}
Source   Edit  
proc loadPackedSym(g: ModuleGraph; s: var LazySym) {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect],
    forbids: [].}
Source   Edit  
proc markClientsDirty(g: ModuleGraph; fileIdx: FileIndex) {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc markDirty(g: ModuleGraph; fileIdx: FileIndex) {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc moduleFromRodFile(g: ModuleGraph; fileIdx: FileIndex;
                       cachedModules: var seq[FileIndex]): PSym {....raises: [
    OSError, IOError, Exception, KeyError, ValueError, ERecoverableError], tags: [
    ReadEnvEffect, ReadIOEffect, WriteDirEffect, ReadDirEffect, RootEffect,
    WriteIOEffect], forbids: [].}
Returns 'nil' if the module needs to be recompiled. Source   Edit  
proc moduleOpenForCodegen(g: ModuleGraph; m: FileIndex): bool {.inline,
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc needsCompilation(g: ModuleGraph): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc needsCompilation(g: ModuleGraph; fileIdx: FileIndex): bool {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc newModuleGraph(cache: IdentCache; config: ConfigRef): ModuleGraph {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc nextModuleIter(mi: var ModuleIter; g: ModuleGraph): PSym {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect],
    forbids: [].}
Source   Edit  
proc onProcessing(graph: ModuleGraph; fileIdx: FileIndex; moduleStatus: string;
                  fromModule: PSym) {....raises: [Exception, KeyError, OSError,
    ValueError, IOError, ERecoverableError], tags: [RootEffect, ReadDirEffect,
    WriteIOEffect, ReadIOEffect, ReadEnvEffect], forbids: [].}
Source   Edit  
proc parentModule(g: ModuleGraph; fileIdx: FileIndex): FileIndex {....raises: [],
    tags: [], forbids: [].}
returns 'fileIdx' if the file belonging to this index is directly used as a module or else the module that first references this include file. Source   Edit  
proc registerModule(g: ModuleGraph; m: PSym) {....raises: [Exception],
    tags: [RootEffect], forbids: [].}
Source   Edit  
proc registerModuleById(g: ModuleGraph; m: FileIndex) {....raises: [Exception],
    tags: [RootEffect], forbids: [].}
Source   Edit  
proc rememberEmittedTypeInfo(g: ModuleGraph; m: FileIndex; ti: string) {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc rememberFlag(g: ModuleGraph; m: PSym; flag: ModuleBackendFlag) {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc resetAllModules(g: ModuleGraph) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc resetForBackend(g: ModuleGraph) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc setAttachedOp(g: ModuleGraph; module: int; t: PType; op: TTypeAttachedOp;
                   value: PSym) {....raises: [], tags: [], forbids: [].}
we also need to record this to the packed module. Source   Edit  
proc setAttachedOpPartial(g: ModuleGraph; module: int; t: PType;
                          op: TTypeAttachedOp; value: PSym) {....raises: [],
    tags: [], forbids: [].}
we also need to record this to the packed module. Source   Edit  
proc setToStringProc(g: ModuleGraph; t: PType; value: PSym) {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc simulateCachedModule(g: ModuleGraph; moduleSym: PSym; m: PackedModule) {.
    ...raises: [KeyError, OSError, Exception], tags: [ReadDirEffect, RootEffect],
    forbids: [].}
Source   Edit  
proc someSym(g: ModuleGraph; m: PSym; name: PIdent): PSym {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect],
    forbids: [].}
Source   Edit  
proc stopCompile(g: ModuleGraph): bool {.inline, ...raises: [Exception],
    tags: [RootEffect], forbids: [].}
Source   Edit  
proc strTableAdds(g: ModuleGraph; m: PSym; s: PSym) {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc systemModuleSym(g: ModuleGraph; name: PIdent): PSym {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect],
    forbids: [].}
Source   Edit  
proc unmarkAllDirty(g: ModuleGraph) {....raises: [], tags: [], forbids: [].}
Source   Edit  

Iterators

iterator allSyms(g: ModuleGraph; m: PSym): PSym {....raises: [KeyError, Exception],
    tags: [ReadDirEffect, RootEffect], forbids: [].}
Source   Edit  
iterator methodsForGeneric(g: ModuleGraph; t: PType): (int, PSym) {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect],
    forbids: [].}
Source   Edit  
iterator procInstCacheItems(g: ModuleGraph; s: PSym): PInstantiation {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect],
    forbids: [].}
Source   Edit  
iterator suggestErrorsIter(g: ModuleGraph): Suggest {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
iterator suggestSymbolsIter(g: ModuleGraph): SymInfoPair {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
iterator systemModuleSyms(g: ModuleGraph; name: PIdent): PSym {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect],
    forbids: [].}
Source   Edit  
iterator typeInstCacheItems(g: ModuleGraph; s: PSym): PType {.
    ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect],
    forbids: [].}
Source   Edit  

Templates

template onDef(info: TLineInfo; s: PSym)
Source   Edit  
template onDefResolveForward(info: TLineInfo; s: PSym)
Source   Edit  
template onUse(info: TLineInfo; s: PSym)
Source   Edit  
template semtabAll(g: ModuleGraph; m: PSym): TStrTable
Source   Edit