Types
CompilesId = int
- id that is used for the caching logic within system.compiles. See the seminst module. Source Edit
LogEntry = object kind*: LogEntryKind op*: TTypeAttachedOp isGeneric*: bool module*: int key*: string sym*: PSym
- Source Edit
LogEntryKind = enum HookEntry, ConverterEntry, MethodEntry, EnumToStrEntry, GenericInstEntry, PureEnumEntry, CppMemberEntry
- Source Edit
TCallingConvention = enum ccNimCall = "nimcall", ccStdCall = "stdcall", ccCDecl = "cdecl", ccSafeCall = "safecall", ccSysCall = "syscall", ccInline = "inline", ccNoInline = "noinline", ccFastCall = "fastcall", ccThisCall = "thiscall", ccClosure = "closure", ccNoConvention = "noconv", ccMember = "member"
- Source Edit
TIdPairSeq[T] = seq[TIdPair[T]]
- Source Edit
TIdTable[T] = object counter*: int data*: TIdPairSeq[T]
- Source Edit
TImplication = enum impUnknown, impNo, impYes
- Source Edit
TInstantiation = object sym*: PSym concreteTypes*: seq[PType] bindings*: seq[tuple[key: ItemId, value: PType]] ## An optional exact snapshot of the matcher bindings. In-process ## instances use it for a fast cache probe; serialized instances fall ## back to comparing the fully instantiated signature. genericParamsCount*: int compilesId*: CompilesId
- Source Edit
TLib = object kind*: TLibKind generated*: bool isOverridden*: bool name*: Rope path*: PNode
- Source Edit
TLoc = object k*: TLocKind storage*: TStorageLoc flags*: TLocFlags lode*: PNode snippet*: Rope
- Source Edit
TLocFlag = enum lfIndirect, lfNoDeepCopy, lfNoDecl, lfDynamicLib, lfExportLib, lfHeader, lfImportCompilerProc, lfSingleUse, lfEnforceDeref, lfPrepareForMutation
- Source Edit
TLocKind = enum locNone, locTemp, locLocalVar, locGlobalVar, locParam, locField, locExpr, locProc, locData, locCall, locOther
- Source Edit
TMagic = enum mNone, mDefined, mDeclared, mDeclaredInScope, mCompiles, mArrGet, mArrPut, mAsgn, mLow, mHigh, mSizeOf, mAlignOf, mOffsetOf, mTypeTrait, mIs, mOf, mAddr, mType, mTypeOf, mPlugin, mEcho, mShallowCopy, mSlurp, mStaticExec, mStatic, mParseExprToAst, mParseStmtToAst, mExpandToAst, mQuoteAst, mInc, mDec, mOrd, mNew, mNewFinalize, mNewSeq, mNewSeqOfCap, mLengthOpenArray, mLengthStr, mLengthArray, mLengthSeq, mIncl, mExcl, mCard, mChr, mGCref, mGCunref, mAddI, mSubI, mMulI, mDivI, mModI, mSucc, mPred, mAddF64, mSubF64, mMulF64, mDivF64, mShrI, mShlI, mAshrI, mBitandI, mBitorI, mBitxorI, mMinI, mMaxI, mAddU, mSubU, mMulU, mDivU, mModU, mEqI, mLeI, mLtI, mEqF64, mLeF64, mLtF64, mLeU, mLtU, mEqEnum, mLeEnum, mLtEnum, mEqCh, mLeCh, mLtCh, mEqB, mLeB, mLtB, mEqRef, mLePtr, mLtPtr, mXor, mEqCString, mEqProc, mUnaryMinusI, mUnaryMinusI64, mAbsI, mNot, mUnaryPlusI, mBitnotI, mUnaryPlusF64, mUnaryMinusF64, mCharToStr, mBoolToStr, mCStrToStr, mStrToStr, mEnumToStr, mAnd, mOr, mImplies, mIff, mExists, mForall, mOld, mEqStr, mLeStr, mLtStr, mEqSet, mLeSet, mLtSet, mMulSet, mPlusSet, mMinusSet, mXorSet, mConStrStr, mSlice, mDotDot, mFields, mFieldPairs, mOmpParFor, mAppendStrCh, mAppendStrStr, mAppendSeqElem, mInSet, mRepr, mExit, mSetLengthStr, mSetLengthSeq, mSetLengthSeqUninit, mIsPartOf, mAstToStr, mParallel, mSwap, mIsNil, mArrToSeq, mOpenArrayToSeq, mNewString, mNewStringOfCap, mParseBiggestFloat, mMove, mEnsureMove, mWasMoved, mDup, mDestroy, mTrace, mDefault, mUnown, mFinished, mIsolate, mAccessEnv, mAccessTypeField, mArray, mOpenArray, mRange, mSet, mSeq, mVarargs, mRef, mPtr, mVar, mDistinct, mVoid, mTuple, mOrdinal, mIterableType, mInt, mInt8, mInt16, mInt32, mInt64, mUInt, mUInt8, mUInt16, mUInt32, mUInt64, mFloat, mFloat32, mFloat64, mFloat128, mBool, mChar, mString, mCstring, mPointer, mNil, mExpr, mStmt, mTypeDesc, mVoidType, mPNimrodNode, mSpawn, mDeepCopy, mIsMainModule, mCompileDate, mCompileTime, mProcCall, mCpuEndian, mHostOS, mHostCPU, mBuildOS, mBuildCPU, mAppType, mCompileOption, mCompileOptionArg, mNLen, mNChild, mNSetChild, mNAdd, mNAddMultiple, mNDel, mNKind, mNSymKind, mNccValue, mNccInc, mNcsAdd, mNcsIncl, mNcsLen, mNcsAt, mNctPut, mNctLen, mNctGet, mNctHasNext, mNctNext, mNIntVal, mNFloatVal, mNSymbol, mNIdent, mNGetType, mNStrVal, mNSetIntVal, mNSetFloatVal, mNSetSymbol, mNSetIdent, mNSetStrVal, mNLineInfo, mNNewNimNode, mNCopyNimNode, mNCopyNimTree, mStrToIdent, mNSigHash, mNSizeOf, mNBindSym, mNCallSite, mEqIdent, mEqNimrodNode, mSameNodeType, mGetImpl, mNGenSym, mNHint, mNWarning, mNError, mInstantiationInfo, mGetTypeInfo, mGetTypeInfoV2, mNimvm, mIntDefine, mStrDefine, mBoolDefine, mGenericDefine, mRunnableExamples, mException, mBuiltinType, mSymOwner, mUncheckedArray, mGetImplTransf, mSymIsInstantiationOf, mNodeId, mPrivateAccess, mZeroDefault
- Source Edit
TNode {.final, acyclic.} = object when defined(useNodeIds): id*: int typField*: PType info*: TLineInfo flags*: TNodeFlags case kind*: TNodeKind of nkCharLit .. nkUInt64Lit: intVal*: BiggestInt of nkFloatLit .. nkFloat128Lit: floatVal*: BiggestFloat of nkStrLit .. nkTripleStrLit: strVal*: string of nkSym: sym*: PSym of nkIdent: ident*: PIdent else: sons*: TNodeSeq when defined(nimsuggest): endInfo*: TLineInfo
- Source Edit
TNodeFlag = enum nfNone, nfBase2, nfBase8, nfBase16, nfAllConst, nfTransf, nfNoRewrite, nfSem, nfLL, nfDotField, nfDotSetter, nfExplicitCall, nfExprCall, nfIsRef, nfIsPtr, nfPreventCg, nfBlockArg, nfFromTemplate, nfDefaultParam, nfDefaultRefsParam, nfExecuteOnReload, nfLastRead, nfFirstWrite, nfHasComment, nfSkipFieldChecking, nfDisabledOpenSym, nfLazyType, nfLazyBody, nfBroadcast
- Source Edit
TNodeFlags = set[TNodeFlag]
- Source Edit
TNodeKinds = set[TNodeKind]
- Source Edit
TNodePairSeq = seq[TNodePair]
- Source Edit
TNodeTable = object counter*: int data*: TNodePairSeq ignoreTypes*: bool
- Source Edit
TObjectSeq = seq[RootRef]
- Source Edit
TObjectSet = object counter*: int data*: TObjectSeq
- Source Edit
TScope {.acyclic.} = object depthLevel*: int symbols*: TStrTable parent*: PScope allowPrivateAccess*: seq[PSym] optionStackLen*: int
- Source Edit
TStorageLoc = enum OnUnknown, OnStatic, OnStack, OnHeap
- Source Edit
TStrTable = object counter*: int data*: seq[PSym] next*: seq[int32]
- Insertion ordered: data is the symbols in the order they were added and the symbols that share a name form a chain through next that is in insertion order too. Iteration is therefore independent of the hash values and of the table's growth history -- overload resolution and error messages must not depend on either. Source Edit
TSym {.acyclic.} = object itemId*: ItemId state*: ItemState case kindImpl*: TSymKind of routineKinds: gcUnsafetyReasonImpl*: PSym transformedBodyImpl*: PNode nifBodyLoadedImpl*: bool of skLet, skVar, skField, skForVar: guardImpl*: PSym bitsizeImpl*: int alignmentImpl*: int else: nil magicImpl*: TMagic typImpl*: PType name*: PIdent infoImpl*: TLineInfo when defined(nimsuggest): endInfoImpl*: TLineInfo hasUserSpecifiedTypeImpl*: bool ownerFieldImpl*: PSym flagsImpl*: TSymFlags astImpl*: PNode optionsImpl*: TOptions positionImpl*: int offsetImpl*: int32 disamb*: int32 locImpl*: TLoc annexImpl*: PLib when hasFFI: cnameImpl*: string constraintImpl*: PNode instantiatedFromImpl*: PSym when defined(nimsuggest): allUsagesImpl*: seq[TLineInfo]
- Source Edit
TSymFlag = enum sfUsed, sfExported, sfFromGeneric, sfGlobal, sfForward, sfWasForwarded, sfImportc, sfExportc, sfMangleCpp, sfVolatile, sfRegister, sfPure, sfNoSideEffect, sfSideEffect, sfMainModule, sfSystemModule, sfNoReturn, sfAddrTaken, sfCompilerProc, sfEscapes, sfDiscriminant, sfRequiresInit, sfDeprecated, sfExplain, sfError, sfShadowed, sfThread, sfCppNonPod, sfCompileTime, sfConstructor, sfDispatcher, sfBorrow, sfInfixCall, sfNamedParamCall, sfDiscardable, sfOverridden, sfCallsite, sfGenSym, sfNonReloadable, sfGeneratedOp, sfTemplateParam, sfCursor, sfInjectDestructors, sfNeverRaises, sfSystemRaisesDefect, sfUsedInFinallyOrExcept, sfSingleUsedTemp, sfNoalias, sfEffectsDelayed, sfGeneratedType, sfVirtual, sfByCopy, sfMember, sfCodegenDecl, sfWasGenSym, sfForceLift, sfDirty, sfCustomPragma, sfBase, sfGoto, sfAnon, sfAllUntyped, sfTemplateRedefinition
- Source Edit
TSymKind = enum skUnknown, skConditional, skDynLib, skParam, skGenericParam, skTemp, skModule, skType, skVar, skLet, skConst, skResult, skProc, skFunc, skMethod, skIterator, skConverter, skMacro, skTemplate, skField, skEnumField, skForVar, skLabel, skStub, skPackage
- Source Edit
TType {.acyclic.} = object itemId*: ItemId kind*: TTypeKind state*: ItemState bindingId*: ItemId callConvImpl*: TCallingConvention flagsImpl*: TTypeFlags sonsImpl*: TTypeSeq nImpl*: PNode ownerFieldImpl*: PSym symImpl*: PSym sizeImpl*: BiggestInt alignImpl*: int16 paddingAtEndImpl*: int16 locImpl*: TLoc typeInstImpl*: PType
- Source Edit
TTypeAttachedOp = enum attachedWasMoved, attachedDestructor, attachedAsgn, attachedDup, attachedSink, attachedTrace, attachedDeepCopy
- as usual, order is important here Source Edit
TTypeFlag = enum tfVarargs, tfNoSideEffect, tfFinal, tfInheritable, tfHasOwned, tfEnumHasHoles, tfShallow, tfThread, tfFromGeneric, tfUnresolved, tfResolved, tfRetType, tfCapturesEnv, tfByCopy, tfByRef, tfIterator, tfPartial, tfNotNil, tfRequiresInit, tfNeedsFullInit, tfVarIsPtr, tfHasMeta, tfHasGCedMem, tfPacked, tfHasStatic, tfGenericTypeParam, tfImplicitTypeParam, tfInferrableStatic, tfConceptMatchedTypeSym, tfExplicit, tfWildcard, tfHasAsgn, tfBorrowDot, tfTriggersCompileTime, tfRefsAnonObj, tfCovariant, tfWeakCovariant, tfContravariant, tfCheckedForDestructor, tfAcyclic, tfIncompleteStruct, tfCompleteStruct, tfExplicitCallConv, tfIsConstructor, tfEffectSystemWorkaround, tfIsOutParam, tfSendable, tfImplicitStatic
- Source Edit
TTypeFlags = set[TTypeFlag]
- Source Edit
TTypeKind = enum tyNone, tyBool, tyChar, tyEmpty, tyAlias, tyNil, tyUntyped, tyTyped, tyTypeDesc, tyGenericInvocation, tyGenericBody, tyGenericInst, tyGenericParam, tyDistinct, tyEnum, tyOrdinal, tyArray, tyObject, tyTuple, tySet, tyRange, tyPtr, tyRef, tyVar, tySequence, tyProc, tyPointer, tyOpenArray, tyString, tyCstring, tyForward, tyInt, tyInt8, tyInt16, tyInt32, tyInt64, tyFloat, tyFloat32, tyFloat64, tyFloat128, tyUInt, tyUInt8, tyUInt16, tyUInt32, tyUInt64, tyOwned, tySink, tyLent, tyVarargs, tyUncheckedArray, tyError, tyBuiltInTypeClass, tyUserTypeClass, tyUserTypeClassInst, tyCompositeTypeClass, tyInferred, tyAnd, tyOr, tyNot, tyAnything, tyStatic, tyFromExpr, tyConcept, tyVoid, tyIterable
- Source Edit
TTypeKinds = set[TTypeKind]
- Source Edit
Vars
eqTypeFlags = {tfIterator, tfNotNil, tfVarIsPtr, tfGcSafe, tfNoSideEffect, tfIsOutParam}
- type flags that are essential for type equality. This is now a variable because for emulation of version:1.0 we might exclude {tfGcSafe, tfNoSideEffect}. Source Edit
forceLazyBodyHook: proc (n: PNode) {.nimcall, ...raises: [], tags: [], gcsafe.}
-
Set by the IC loader (ast2nif). When a node carries nfLazyBody, any access to its children through len materializes the deferred routine body in place. safeLen delegates to len, so it is covered transitively; a lazy body is never a leaf kind, so the {nkNone..nkNilLit} short-circuit never hides it.
The type MUST be effect-free (raises: []/tags: []): len is a fundamental PNode accessor that the whole compiler — and every compiler-as-library consumer (nimble, nimsuggest, ...) — assumes cannot raise. An unannotated proc var defaults to raises: [Exception], so the indirect call tainted len/safeLen/items with Exception, breaking any iterator/{.raises.} over a PNode (e.g. nimble's extract {.raises: [CatchableError].}). Materialization is a pure in-memory buffer transform; a corrupt buffer is a Defect (raiseAssert), which is outside exception tracking.
Source Edit nifcBackendActive = false
- Set only while the per-module NIF backend codegen stage runs (nifbackend.generateCgStage, cmd == cmdNifC). It gates newSymNode's lazy-type marking so it applies ONLY in the backend — where syms are loaded from NIF and a cg-stage transform can build a sym node from a not-yet-typed stub — and never during frontend sem, where the same marking would perturb effect/exception inference (it diverges from a non-IC build, e.g. times.toDateTimeByWeek gaining a spurious unlisted Exception). Source Edit
nodeCommentReader: proc (n: PNode): string {.nimcall.}
- Source Edit
nodeCommentWriter: proc (n: PNode; s: string) {.nimcall.}
- Source Edit
Consts
abstractInst = {tyGenericInst, tyDistinct, tyOrdinal, tyTypeDesc, tyAlias, tyInferred, tySink, tyOwned}
- Source Edit
abstractVarRange = {tyGenericInst, tyRange, tyVar, tyDistinct, tyOrdinal, tyTypeDesc, tyAlias, tyInferred, tySink, tyOwned}
- Source Edit
callableDefs = {nkLambda..nkDo, nkProcDef..nkIteratorDef, nkFuncDef}
- Source Edit
ConcreteTypes: TTypeKinds = {tyBool, tyChar, tyEnum, tyArray, tyObject, tySet, tyTuple, tyRange, tyPtr, tyRef, tyVar, tyLent, tySequence, tyProc, tyPointer, tyOpenArray, tyString, tyCstring, tyInt..tyInt64, tyFloat..tyFloat128, tyUInt..tyUInt64}
- Source Edit
ConstantDataTypes: TTypeKinds = {tyArray, tySet, tyTuple, tySequence}
- Source Edit
ctfeWhitelist = {mNone, mSucc, mPred, mInc, mDec, mOrd, mLengthOpenArray, mLengthStr, mLengthArray, mLengthSeq, mArrGet, mArrPut, mAsgn, mDestroy, mIncl, mExcl, mCard, mChr, mAddI, mSubI, mMulI, mDivI, mModI, mAddF64, mSubF64, mMulF64, mDivF64, mShrI, mShlI, mBitandI, mBitorI, mBitxorI, mMinI, mMaxI, mAddU, mSubU, mMulU, mDivU, mModU, mEqI, mLeI, mLtI, mEqF64, mLeF64, mLtF64, mLeU, mLtU, mEqEnum, mLeEnum, mLtEnum, mEqCh, mLeCh, mLtCh, mEqB, mLeB, mLtB, mEqRef, mEqProc, mLePtr, mLtPtr, mEqCString, mXor, mUnaryMinusI, mUnaryMinusI64, mAbsI, mNot, mUnaryPlusI, mBitnotI, mUnaryPlusF64, mUnaryMinusF64, mCharToStr, mBoolToStr, mCStrToStr, mStrToStr, mEnumToStr, mAnd, mOr, mEqStr, mLeStr, mLtStr, mEqSet, mLeSet, mLtSet, mMulSet, mPlusSet, mMinusSet, mXorSet, mConStrStr, mAppendStrCh, mAppendStrStr, mAppendSeqElem, mInSet, mRepr, mOpenArrayToSeq}
- Source Edit
declarativeDefs = {nkProcDef, nkFuncDef, nkMethodDef, nkIteratorDef, nkConverterDef}
- Source Edit
defaultAlignment = -1
- Source Edit
defaultOffset = -1
- Source Edit
defaultSize = -1
- Source Edit
derivedTypeFlags = {tfHasAsgn, tfHasOwned, tfHasGCedMem, tfCheckedForDestructor}
-
Codegen/lifting BOOKKEEPING bits, as opposed to the flags that make a type what it is. They are derived: a fixpoint over the type's own kind, the memory management config, its elements and the attached-op table -- never something the source said. They are in none of eqTypeFlags, the typekeys content key or the NIF name, so changing one cannot rename a type, move it in the cache, or alter sameType.
Because they are derived rather than declared, a consumer module can legitimately discover one after the defining module sealed the type (the classic case: an alias carries tfHasAsgn into the NIF but the object behind it only gets it at the first generic instantiation, which happens in another module -- and, under IC, another process). Writing one is therefore exempt from the Sealed assert: see ast.inclDerived.
NOT in this set even though it looks like it belongs: tfGenericHasDestructor, which is an ALIAS for tfExplicitCallConv. Exempting it would exempt a real proc-type property from the seal.
Source Edit dispatcherPos = 8
- Source Edit
effectListLen = 6
- Source Edit
ensuresEffects = 2
- Source Edit
ExportableSymKinds = {skType..skConst, skProc..skTemplate, skEnumField, skStub}
- Source Edit
GcTypeKinds = {tyRef, tySequence, tyString}
- Source Edit
generatedMagics = {mNone, mIsolate, mFinished, mOpenArrayToSeq}
- magics that are generated as normal procs in the backend Source Edit
GenericTypes: TTypeKinds = {tyGenericInvocation, tyGenericBody, tyGenericParam}
- Source Edit
GrowthFactor = 2
- Source Edit
HookDisambBit = 0x20000000'i32
-
Set in the disamb of synthesized type-bound operators and $enum procs whose value is content-derived (see modulegraphs.setHookDisamb); disjoint from both the small counter range and InstanceDisambBit.
Both live here rather than in modulegraphs because ast2nif — which cannot import that module — names symbols by them.
Source Edit InstanceDisambBit = 0x40000000'i32
- Set in the disamb of routine instances whose value is content-derived (see modulegraphs.setInstanceDisamb); keeps them disjoint from the small counter range ordinary symbols draw from, so the NIF name name.disamb.module stays collision-free within a module. Source Edit
IntegralTypes = {tyBool, tyChar, tyEnum, tyInt..tyInt64, tyFloat..tyFloat128, tyUInt..tyUInt64}
- Source Edit
nfAllFieldsSet = nfBase2
- Source Edit
NilableTypes: TTypeKinds = {tyPointer, tyCstring, tyRef, tyPtr, tyProc, tyError}
- Source Edit
nkEffectList = nkArgList
- Source Edit
nkFloatLiterals = {nkFloatLit..nkFloat128Lit}
- Source Edit
nkIdentKinds = {nkIdent, nkSym, nkAccQuoted, nkOpenSymChoice, nkClosedSymChoice, nkOpenSym}
- Source Edit
nkLambdaKinds = {nkLambda, nkDo}
- Source Edit
nkLastBlockStmts = {nkRaiseStmt, nkReturnStmt, nkBreakStmt, nkContinueStmt}
- Source Edit
nkLiterals = {nkCharLit..nkTripleStrLit}
- Source Edit
nkPragmaCallKinds = {nkExprColonExpr, nkCall, nkCallStrLit}
- Source Edit
nkStrKinds = {nkStrLit..nkTripleStrLit}
- Source Edit
nkSymChoices = {nkClosedSymChoice, nkOpenSymChoice}
- Source Edit
nkWhenExpr = nkWhenStmt
- Source Edit
OverloadableSyms = {skProc, skFunc, skMethod, skIterator, skConverter, skModule, skTemplate, skMacro, skEnumField}
- Source Edit
patternPos = 1
- Source Edit
PersistentNodeFlags: TNodeFlags = {nfBase2, nfBase8, nfBase16, nfDotSetter, nfDotField, nfIsRef, nfIsPtr, nfPreventCg, nfLL, nfFromTemplate, nfDefaultRefsParam, nfExecuteOnReload, nfLastRead, nfFirstWrite, nfSkipFieldChecking, nfDisabledOpenSym, nfLazyType, nfBroadcast}
- Source Edit
pragmasEffects = 4
- Source Edit
pragmasPos = 4
- Source Edit
PtrLikeKinds: TTypeKinds = {tyPointer, tyPtr}
- Source Edit
routineDefs = {nkProcDef..nkIteratorDef, nkFuncDef}
- Source Edit
routineKinds = {skProc, skFunc, skMethod, skIterator, skConverter, skMacro, skTemplate}
- Source Edit
sfCompileToCpp = sfInfixCall
- Source Edit
sfCompileToObjc = sfNamedParamCall
- Source Edit
sfCppMember = {sfVirtual, sfMember, sfConstructor}
- Source Edit
sfExperimental = sfOverridden
- Source Edit
sfNoForward = sfRegister
- Source Edit
sfWrittenTo = sfBorrow
- Source Edit
skLocalVars = {skVar, skLet, skForVar, skParam, skResult}
- Source Edit
skProcKinds = {skProc, skFunc, skTemplate, skMacro, skIterator, skMethod, skConverter}
- Source Edit
StructuralEquivTypes: TTypeKinds = {tyNil, tyTuple, tyArray, tySet, tyRange, tyPtr, tyRef, tyVar, tyLent, tySequence, tyProc, tyOpenArray, tyVarargs}
- Source Edit
tagEffects = 3
- Source Edit
tfGenericHasDestructor = tfExplicitCallConv
- tyGenericBody where an instance has a generated destructor Source Edit
tfNonConstExpr = tfExplicitCallConv
- tyFromExpr where the expression shouldn't be evaluated as a static value Source Edit
tfObjHasKids = tfEnumHasHoles
- Source Edit
tfReturnsNew = tfInheritable
- Source Edit
tyMetaTypes = {tyUntyped, tyTypeDesc, tyGenericParam, tyBuiltInTypeClass..tyCompositeTypeClass, tyAnd..tyAnything, tyConcept}
- Source Edit
tyPureObject = tyTuple
- Source Edit
tyTypeClasses = {tyBuiltInTypeClass, tyCompositeTypeClass, tyUserTypeClass, tyUserTypeClassInst, tyConcept, tyAnd, tyOr, tyNot, tyAnything}
- Source Edit
tyUserTypeClasses = {tyUserTypeClass, tyUserTypeClassInst}
- Source Edit
Procs
proc backendMintedDisamb(s: PSym): int32 {.inline, ...raises: [], tags: [], forbids: [].}
-
The integer that identifies a BACKEND-MINTED symbol (isBackendMinted) in every name derived from it: its NIF name (ast2nif.toNifSymName) and its C name (mangleutils.mangleProcNameExt, ccgutils.makeUnique).
Two cases, and the whole point of having ONE function is that all three sites take the same one:
- A lifted HOOK's disamb is CONTENT-derived (modulegraphs.setHookDisamb), so it is identical in every process. Such a hook really does cross process boundaries — lower mints the env hooks of nested routines while cg mints those of the module's top level, and both land in the same translation unit — and its C name is also baked into emit-everywhere RTTI tables. itemId.item would differ per process, so two unrelated hooks collided on one _c<item> and the merge stage kept a single body for both (C accepted the mistyped call, C++ rejected it).
- Otherwise itemId.item — the writer's dedup identity, unique per @bk sym. disamb cannot serve here: a module's :env syms are minted from TWO id spaces (the backend lower stage's idgen and sem's vmTransfIdgen) whose disambTables each start :env at the same low count, so a macro-lowered and a backend-lowered :env collide on :env.2.<mod>@bk.
The loader copies the name's numeric component back into disamb, so after a round trip disamb equals this value and ast2nif.globalName — which always reads disamb — agrees with the name the writer produced.
This rule used to be written out at each of the three sites. They drifted: toNifSymName lacked the hook exception, so a content-derived value was overwritten by the loader and two backend hooks merged into one C function.
Source Edit proc forcePartial(s: PSym) {....raises: [], tags: [], forbids: [].}
- Resets all impl-fields to their default values and sets state to Partial. This is useful for creating a stub symbol that can be lazily loaded later. The fields itemId, name, and disamb are preserved. Source Edit
proc forcePartial(t: PType) {....raises: [], tags: [], forbids: [].}
- Resets all impl-fields to their default values and sets state to Partial. This is useful for creating a stub type that can be lazily loaded later. The fields itemId, kind, bindingId are preserved. Source Edit
proc mustRehash(length, counter: int): bool {....raises: [], tags: [], forbids: [].}
- Source Edit
proc newStrNode(kind: TNodeKind; strVal: string): PNode {....raises: [], tags: [], forbids: [].}
- Source Edit
proc newStrNode(strVal: string; info: TLineInfo): PNode {....raises: [], tags: [], forbids: [].}
- Source Edit
proc strTableAdd(t: var TStrTable; n: PSym) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc strTableContains(t: TStrTable; n: PSym): bool {....raises: [], tags: [], forbids: [].}
- Source Edit
proc strTableFirstOfName(t: TStrTable; name: PIdent): int32 {....raises: [], tags: [], forbids: [].}
-
1 + the index of the FIRST symbol named name, 0 if there is none. The rest of them follow through t.next, still in insertion order. Every index in a TStrTable is stored biased by one so that a zeroed newSeq means "empty" and no fill-with-minus-one pass is needed.
The probe reads heads and nothing else: a slot carries the name it stands for, so a wrong slot is rejected without following its index into data and from there into a PSym and a PIdent. Only the slot that matches is ever dereferenced, by the caller, for the symbol it wanted.
Source Edit proc strTableIncl(t: var TStrTable; n: PSym; onConflictKeepOld = false): bool {. discardable, ...raises: [], tags: [], forbids: [].}
- Source Edit
Iterators
iterator isons(n: PNode; start = 0): tuple[i: int, n: PNode] {....raises: [], tags: [], forbids: [].}
-
Like sons but also yields the child index, and optionally skips the first start children. Replaces for i in start..<n.len: ... n[i] ... when i itself is still needed — for a parameter position, a needTmp[i-1] lookup, a parallel index into the routine's PType, and so on. start is almost always 1, to step over a call's callee or a case statement's selector.
Use sonsFrom instead when the index is only ever used to subscript n.
Source Edit iterator isonsButLast(n: PNode; count = 1): tuple[i: int, n: PNode] {. ...raises: [], tags: [], forbids: [].}
- Like sonsButLast but also yields the child index — for a tuple field position, a parallel index into the tuple's PType, and so on. Source Edit
iterator sons(n: PNode): PNode {....raises: [], tags: [], forbids: [].}
- Iterates over the children of n. Preferred over for i in 0..<n.len: n[i] as it does not rely on random indexed access, and over for x in n.sons, which reads the raw FIELD and so skips the len hook that materialises a deferred nfLazyBody body — over such a body that loop silently visits nothing. Source Edit
iterator sonsButLast(n: PNode; count = 1): PNode {....raises: [], tags: [], forbids: [].}
-
sons without the last count children. Replaces for i in 0..<n.len-1: ... n[i] ..., which is what an nkOfBranch/nkExceptBranch walk looks like: the last child is the branch BODY, the ones before it are the labels it matches. count = 2 is the nkVarTuple/nkIdentDefs shape, whose last two children are the type and the value. A Cursor can serve this with a single pass and count nodes of lookahead; the indexed form has to re-walk the children for every label.
Use isonsButLast instead when the index is still needed.
Source Edit iterator sonsFrom(n: PNode; start: int): PNode {....raises: [], tags: [], forbids: [].}
- sons skipping the first start children. Replaces for i in start..<n.len: ... n[i] ..., which is by far the commonest indexed shape in the code generator — start is almost always 1, to step over a case/try statement's selector or a call's callee. Source Edit
Exports
-
$, *, *, *=, +, +, +, +=, -, -, -, -, -=, <, <, <, <=, <=, <=, ==, ==, ==, Int128, NegOne, One, Ten, Zero, abs, addInt128, addToHex, bitand, bitnot, bitor, bitxor, castToInt64, castToUInt64, cmp, div, divMod, fastLog2, high, inc, low, maskBytes, maskUInt16, maskUInt32, maskUInt64, maskUInt8, mod, parseDecimalInt128, shl, shr, toFloat64, toHex, toInt, toInt128, toInt128, toInt16, toInt32, toInt64, toInt64Checked, toInt8, toUInt, toUInt16, toUInt32, toUInt64, toUInt8, TNodeKind, nkCallKinds, $, ==, ItemId, PackageModuleId, backendItemId, derivedFieldId, hash, isBackendMinted, item, itemId, matchesDerivedFieldId, module, toId