This module contains the data structures for the semantic checking phase.
Types
ImportedModule = object m*: PSym case mode*: ImportMode of importAll: nil of importSet: imported*: IntSet of importExcept: exceptSet*: IntSet
- Source Edit
ImportMode = enum importAll, importSet, importExcept
- Source Edit
POptionEntry = ref TOptionEntry
- Source Edit
TBorrowState = enum bsNone, bsReturnNotMatch, bsNoDistinct, bsGeneric, bsNotSupported, bsMatch
- Source Edit
TContext = object of TPassContext enforceVoidContext*: PType voidType*: PType module*: PSym currentScope*: PScope moduleScope*: PScope imports*: seq[ImportedModule] topLevelScope*: PScope p*: PProcCon intTypeCache*: array[-5 .. 32, PType] nilTypeCache*: PType matchedConcept*: ptr TMatchedConcept friendModules*: seq[PSym] instCounter*: int templInstCounter*: ref int inGenericContext*: int inStaticContext*: int inUnrolledContext*: int compilesContextId*: int compilesContextIdGenerator*: int inGenericInst*: int converters*: seq[PSym] patterns*: seq[PSym] optionStack*: seq[POptionEntry] libs*: seq[PLib] semConstExpr*: proc (c: PContext; n: PNode; expectedType: PType = nil): PNode {. nimcall.} semExpr*: proc (c: PContext; n: PNode; flags: TExprFlags = {}; expectedType: PType = nil): PNode {.nimcall.} semExprWithType*: proc (c: PContext; n: PNode; flags: TExprFlags = {}; expectedType: PType = nil): PNode {.nimcall.} semTryExpr*: proc (c: PContext; n: PNode; flags: TExprFlags = {}): PNode {. nimcall.} semTryConstExpr*: proc (c: PContext; n: PNode; expectedType: PType = nil): PNode {. nimcall.} computeRequiresInit*: proc (c: PContext; t: PType): bool {.nimcall.} hasUnresolvedArgs*: proc (c: PContext; n: PNode): bool semOperand*: proc (c: PContext; n: PNode; flags: TExprFlags = {}): PNode {. nimcall.} semConstBoolExpr*: proc (c: PContext; n: PNode): PNode {.nimcall.} semOverloadedCall*: proc (c: PContext; n, nOrig: PNode; filter: TSymKinds; flags: TExprFlags; expectedType: PType = nil): PNode {. nimcall.} semTypeNode*: proc (c: PContext; n: PNode; prev: PType): PType {.nimcall.} semInferredLambda*: proc (c: PContext; pt: LayeredIdTable; n: PNode): PNode semGenerateInstance*: proc (c: PContext; fn: PSym; pt: LayeredIdTable; info: TLineInfo): PSym instantiateOnlyProcType*: proc (c: PContext; pt: LayeredIdTable; prc: PSym; info: TLineInfo): PType fitDefaultNode*: proc (c: PContext; n: var PNode; expectedType: PType) includedFiles*: IntSet pureEnumFields*: TStrTable userPragmas*: TStrTable evalContext*: PEvalContext unknownIdents*: IntSet generics*: seq[TInstantiationPair] topStmts*: int lastGenericIdx*: int hloLoopDetector*: int inParallelStmt*: int instTypeBoundOp*: proc (c: PContext; dc: PSym; t: PType; info: TLineInfo; op: TTypeAttachedOp; col: int): PSym {.nimcall.} cache*: IdentCache graph*: ModuleGraph signatures*: TStrTable recursiveDep*: string suggestionsMade*: bool isAmbiguous*: bool features*: set[Feature] inTypeContext*, inConceptDecl*: int unusedImports*: seq[(PSym, TLineInfo)] exportIndirections*: HashSet[(int, int)] importModuleMap*: Table[int, int] lastTLineInfo*: TLineInfo sideEffects*: Table[int, seq[(TLineInfo, PSym)]] inUncheckedAssignSection*: int importModuleLookup*: Table[int, seq[int]] skipTypes*: seq[PNode] inTypeofContext*: int
- Source Edit
TExprFlag = enum efLValue, efWantIterator, efWantIterable, efInTypeof, efNeedStatic, efPreferStatic, efPreferNilResult, efWantStmt, efAllowStmt, efDetermineType, efExplain, efWantValue, efOperand, efNoSemCheck, efNoEvaluateGeneric, efInCall, efFromHlo, efNoSem2Check, efNoUndeclared, efIsDotCall, efCannotBeDotCall, efTypeAllowed, efWantNoDefaults, efIgnoreDefaults, efAllowSymChoice
- Source Edit
TExprFlags = set[TExprFlag]
- Source Edit
TInstantiationPair = object genericSym*: PSym inst*: PInstantiation
- Source Edit
TMatchedConcept = object candidateType*: PType prev*: ptr TMatchedConcept depth*: int
- Source Edit
TOptionEntry = object options*: TOptions defaultCC*: TCallingConvention dynlib*: PLib notes*: TNoteKinds features*: set[Feature] otherPragmas*: PNode warningAsErrors*: TNoteKinds
- Source Edit
Procs
proc addConverter(c: PContext; conv: LazySym) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc addConverterDef(c: PContext; conv: LazySym) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc addImportFileDep(c: PContext; f: FileIndex) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc addIncludeFileDep(c: PContext; f: FileIndex) {....raises: [IOError], tags: [ReadIOEffect], forbids: [].}
- Source Edit
proc addPattern(c: PContext; p: LazySym) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc addPragmaComputation(c: PContext; n: PNode) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc addPureEnum(c: PContext; e: LazySym) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc addToGenericProcCache(c: PContext; s: PSym; inst: PInstantiation) {. ...raises: [], tags: [], forbids: [].}
- Source Edit
proc checkMinSonsLen(n: PNode; length: int; conf: ConfigRef) {. ...raises: [Exception, ValueError, KeyError, IOError, ERecoverableError], tags: [ RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect], forbids: [].}
- Source Edit
proc checkSonsLen(n: PNode; length: int; conf: ConfigRef) {. ...raises: [Exception, ValueError, KeyError, IOError, ERecoverableError], tags: [ RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect], forbids: [].}
- Source Edit
proc considerGenSyms(c: PContext; n: PNode) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc getCurrOwner(c: PContext): PSym {....raises: [], tags: [], forbids: [].}
- Source Edit
proc illFormedAst(n: PNode; conf: ConfigRef) {. ...raises: [Exception, ValueError, KeyError, IOError, ERecoverableError], tags: [ RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect], forbids: [].}
- Source Edit
proc illFormedAstLocal(n: PNode; conf: ConfigRef) {. ...raises: [Exception, ValueError, KeyError, IOError, ERecoverableError], tags: [ RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect], forbids: [].}
- Source Edit
proc isTopLevel(c: PContext): bool {.inline, ...raises: [], tags: [], forbids: [].}
- Source Edit
proc isTopLevelInsideDeclaration(c: PContext; sym: PSym): bool {.inline, ...raises: [], tags: [], forbids: [].}
- Source Edit
proc lastOptionEntry(c: PContext): POptionEntry {....raises: [], tags: [], forbids: [].}
- Source Edit
proc makeInstPair(s: PSym; inst: PInstantiation): TInstantiationPair {. ...raises: [], tags: [], forbids: [].}
- Source Edit
proc makePtrType(c: PContext; baseType: PType): PType {....raises: [], tags: [], forbids: [].}
- Source Edit
proc makePtrType(owner: PSym; baseType: PType; idgen: IdGenerator): PType {. ...raises: [], tags: [], forbids: [].}
- Source Edit
proc markIndirect(c: PContext; s: PSym) {.inline, ...raises: [], tags: [], forbids: [].}
- Source Edit
proc newContext(graph: ModuleGraph; module: PSym): PContext {....raises: [IOError], tags: [ReadIOEffect], forbids: [].}
- Source Edit
proc newOptionEntry(conf: ConfigRef): POptionEntry {....raises: [], tags: [], forbids: [].}
- Source Edit
proc popCaseContext(c: PContext) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc popOptionEntry(c: PContext) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc popProcCon(c: PContext) {.inline, ...raises: [], tags: [], forbids: [].}
- Source Edit
proc pushCaseContext(c: PContext; caseNode: PNode) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc pushOptionEntry(c: PContext): POptionEntry {....raises: [], tags: [], forbids: [].}
- Source Edit
proc reexportSym(c: PContext; s: PSym) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc rememberExpansion(c: PContext; info: TLineInfo; expandedSym: PSym) {. ...raises: [], tags: [], forbids: [].}
- Templates and macros are very special in Nim; these have inlining semantics so after semantic checking they leave no trace in the sem'checked AST. This is very bad for IDE-like tooling ("find all usages of this template" would not work). We need special logic to remember macro/template expansions. This is done here and delegated to the "rod" file mechanism. Source Edit
proc scopeDepth(c: PContext): int {.inline, ...raises: [], tags: [], forbids: [].}
- Source Edit
proc sealRodFile(c: PContext) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc setCaseContextIdx(c: PContext; idx: int) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc setIntLitType(c: PContext; result: PNode) {. ...raises: [KeyError, Exception, ValueError, IOError, ERecoverableError], tags: [ ReadDirEffect, RootEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect], forbids: [].}
- Source Edit
proc storeRodNode(c: PContext; n: PNode) {....raises: [Exception], tags: [RootEffect], forbids: [].}
- Source Edit