This module implements semantic checking for calls.this module does the semantic checking of statementsThis module does the semantic transformation of the fields* iterators.This module implements Nim's object construction rules.
Imports
-
ast, options, astalgo, trees, wordrecg, ropes, msgs, idents, renderer, types, platform, magicsys, nversion, nimsets, semfold, modulepaths, importer, procfind, lookups, pragmas, semdata, semtypinst, sigmatch, transf, vmdef, vm, aliases, cgmeth, lambdalifting, evaltempl, patterns, parampatterns, sempass2, linter, semmacrosanity, lowerings, lineinfos, int128, isolation_check, typeallowed, modulegraphs, enumtostr, concepts, astmsgs, extccomp, layeredtable, vtables, icprof, spawn
Consts
tyGenericLike = {tyGenericInvocation, tyGenericInst, tyArray, tySet, tySequence, tyOpenArray, tyUserTypeClassInst..tyCompositeTypeClass}
- Source Edit
tyMagicGenerics = {tySet, tySequence, tyArray, tyOpenArray}
- Source Edit
tyUserDefinedGenerics = {tyGenericInst, tyGenericInvocation, tyUserTypeClassInst}
- Source Edit
Procs
proc closePContext(graph: ModuleGraph; c: PContext; n: PNode): PNode {....raises: [ Exception, ValueError, OSError, KeyError, IOError, ERecoverableError], tags: [ RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect, TimeEffect], forbids: [].}
- Source Edit
proc drainBeforeModulePass(c: PContext) {....raises: [Exception, ValueError, OSError, KeyError, IOError, ERecoverableError], tags: [RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect, TimeEffect], forbids: [].}
-
About to compile another module from inside this one's header pass.
That module may reference anything declared here so far โ system imports std/syncio from its own last statements, and syncio's routines call system's โ and it will be compiled to completion before this statement returns. So this module's units have to be complete first, or the importee sees them as "not yet processed" and infers RootEffect for every call into them. Draining here keeps the invariant an importer already relies on today: everything declared above an import is fully semmed when it runs.
Imports sit at the top of a module, so in practice this drains nothing.
Source Edit proc drainBodyTasks(c: PContext) {....raises: [Exception, ValueError, OSError, KeyError, IOError, ERecoverableError], tags: [RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect, TimeEffect], forbids: [].}
- The body pass. In key order, which for stage 1 is simply front to back: the header pass appended in source order and the on-demand path only ever marks entries done early, never reorders them. Source Edit
proc flushBodiesBeforeTopLevelStmt(c: PContext; stmt: PNode) {....raises: [ Exception, ValueError, OSError, KeyError, IOError, ERecoverableError], tags: [ RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect, TimeEffect], forbids: [].}
-
Units live only until the next top-level statement that could OBSERVE one.
Deferring a body all the way to the end of the module is what ยง2.1 asks for, but it puts a pending unit in reach of the VM: a top-level const x = f() makes vmgen compile f, vmgen goes through transformBody, and answering the demand there means running sem โ and a nested VM session โ while one is already executing on the graph's single PCtx. That is ยง4.6 step 2, "the hardest single item in this plan", and the doc allows it to be deferred behind a restriction until it is done. This is that restriction, and it is a cheap one: modules are long runs of routine definitions, so a run defers as a batch and only a const, static:, var initialiser or plain expression ends one.
Flushing HERE and not at the VM's own entry matters: this is a statement boundary at module scope, where the only live state is the module's, and running a unit is safe. vm.setupGlobalCtx is reached from inside generic instantiations and template expansions, where it is not.
Source Edit proc instGenericConvertersArg(c: PContext; a: PNode; x: TCandidate) {....raises: [ KeyError, OSError, Exception, ValueError, IOError, ERecoverableError, EOFError], tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect, RootEffect, WriteIOEffect, WriteDirEffect, TimeEffect], forbids: [].}
- Source Edit
proc instGenericConvertersSons(c: PContext; n: PNode; x: TCandidate) {....raises: [ KeyError, OSError, Exception, ValueError, IOError, ERecoverableError, EOFError], tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect, RootEffect, WriteIOEffect, WriteDirEffect, TimeEffect], forbids: [].}
- Source Edit
proc isRecursiveType(t: PType): bool {....raises: [KeyError, OSError, Exception], tags: [ ReadEnvEffect, ReadIOEffect, ReadDirEffect, RootEffect], forbids: [].}
- Source Edit
proc markConvertersUsed(c: PContext; n: PNode) {....raises: [KeyError, OSError, Exception, ValueError, IOError, ERecoverableError], tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect, RootEffect, WriteIOEffect], forbids: [].}
- Source Edit
proc notFoundError(c: PContext; n: PNode; errors: CandidateErrors) {....raises: [ Exception, ValueError, OSError, KeyError, IOError, ERecoverableError], tags: [ RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect], forbids: [].}
- Source Edit
proc preparePContext(graph: ModuleGraph; module: PSym; idgen: IdGenerator): PContext {....raises: [ KeyError, Exception, ValueError, OSError, IOError, ERecoverableError], tags: [ RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect], forbids: [].}
- Source Edit
proc pushProcCon(c: PContext; owner: PSym) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc semWithPContext(c: PContext; n: PNode): PNode {....raises: [OSError, Exception, ValueError, KeyError, IOError, ERecoverableError, EOFError, ESuggestDone, OSError, Exception, ValueError, KeyError, IOError, EOFError, ERecoverableError], tags: [ReadEnvEffect, ReadIOEffect, RootEffect, ReadDirEffect, WriteIOEffect, WriteDirEffect, TimeEffect, ExecIOEffect], forbids: [].}
- Source Edit
Templates
template commonTypeBegin(): PType
- Source Edit