This module implements semantic checking for pragmas
Imports
-
../ast/ast, ../ast/astalgo, ../ast/idents, ../ast/renderer, ../ast/wordrecg, ../ast/trees, ../ast/linter, ../ast/errorhandling, ../ast/lineinfos, ../modules/magicsys, ../modules/modulegraphs, ../front/msgs, ../front/options, ../utils/pathutils, ../utils/debugutils, ../utils/idioms, semdata, semfold, lookups, ../backend/extccomp, ../ast/reports_sem, ../ast/reports_debug, ../ast/report_enums, ../ic/ic
Consts
allRoutinePragmas = {wMagic..wThread, wEffectsOf, wImportCompilerProc..wExportNims, wNodecl, wSideEffect..wNosinks, wDynlib..wUsed, wError, wStackTrace..wLineTrace, wDeprecated..wVarargs, wNimcall..wNoconv, wRaises, wTags, wNoDestroy, wCompileTime..wNoInit, wBorrow..wDiscardable, wGensym..wInject, wAsmNoStackFrame, wCodegenDecl, wLocks, wExtern}
- Source Edit
constPragmas = {wMagic, wIntDefine..wBoolDefine, wImportc..wExportNims, wNodecl, wHeader, wCompilerProc..wCore, wUsed, wError, wDeprecated, wGensym..wInject, wExtern}
- Source Edit
converterPragmas = {wMagic..wThread, wEffectsOf, wImportCompilerProc..wExportNims, wNodecl, wSideEffect..wNosinks, wDynlib..wProcVar, wUsed, wError, wStackTrace..wLineTrace, wDeprecated..wVarargs, wNimcall..wNoconv, wRaises, wTags, wNoDestroy, wCompileTime..wNoInit, wBorrow..wDiscardable, wGensym..wInject, wAsmNoStackFrame, wCodegenDecl, wLocks, wExtern}
- Source Edit
enumFieldPragmas = {wDeprecated}
- Source Edit
exprPragmas = {wLine, wLocks, wNoRewrite, wGcSafe, wNoSideEffect}
- Source Edit
fieldPragmas = {wCursor..wNoalias, wImportc..wExportc, wRequiresInit..wAlign, wUsed, wError, wDeprecated, wGuard, wExtern, wBitsize}
- Source Edit
FirstCallConv = wNimcall
- Source Edit
forVarPragmas = {wInject, wGensym}
- Source Edit
iteratorPragmas = {wMagic, wEffectsOf, wImportc..wExportNims, wNodecl, wSideEffect, wNoSideEffect..wGcSafe, wUsed, wError, wStackTrace..wLineTrace, wDeprecated, wNimcall..wNoconv, wRaises, wTags, wBorrow..wDiscardable, wGensym..wInject, wLocks, wExtern}
- Source Edit
lambdaPragmas = {wNimcall..wNoconv, wNoSideEffect, wSideEffect, wNoreturn, wNosinks, wDynlib, wHeader, wThread, wAsmNoStackFrame, wRaises, wLocks, wTags, wEffectsOf, wGcSafe, wCodegenDecl, wNoInit, wCompileTime}
- Source Edit
LastCallConv = wNoconv
- Source Edit
letPragmas = {wMagic, wCursor..wNoalias, wImportc..wExportNims, wAlign..wNodecl, wHeader, wDynlib..wCore, wUsed, wError, wDeprecated, wCompileTime..wNoInit, wGensym..wInject, wThreadVar, wGlobal, wGuard, wExtern, wRegister, wVolatile}
- Source Edit
macroPragmas = {wMagic, wImportc..wExportNims, wNodecl, wNoSideEffect, wCompilerProc..wCore, wUsed, wError, wDeprecated, wNimcall..wNoconv, wDiscardable, wGensym..wInject, wExtern}
- Source Edit
methodPragmas = {wMagic..wThread, wEffectsOf, wImportCompilerProc..wExportNims, wNodecl, wSideEffect..wNosinks, wDynlib..wUsed, wError, wStackTrace..wLineTrace, wDeprecated..wVarargs, wNimcall..wNoconv, wRaises, wTags, wNoDestroy, wCompileTime..wNoInit, wBorrow..wDiscardable, wGensym..wInject, wAsmNoStackFrame, wCodegenDecl, wLocks, wExtern}
- Source Edit
paramPragmas = {wNoalias, wInject, wGensym}
- Source Edit
procPragmas = {wMagic..wThread, wEffectsOf, wImportCompilerProc..wExportNims, wNodecl, wSideEffect..wNosinks, wDynlib..wProcVar, wUsed, wError, wStackTrace..wLineTrace, wDeprecated..wVarargs, wNimcall..wNoconv, wRaises, wTags, wNoDestroy, wCompileTime..wNoInit, wBorrow..wDiscardable, wGensym..wInject, wAsmNoStackFrame, wCodegenDecl, wLocks, wExtern}
- Source Edit
procTypePragmas = {wNimcall..wNoconv, wVarargs, wNoSideEffect, wThread, wRaises, wEffectsOf, wLocks, wTags, wGcSafe}
- Source Edit
stmtPragmas = {wChecks, wObjChecks, wFieldChecks, wRangeChecks, wBoundChecks, wOverflowChecks, wNilChecks, wStaticBoundchecks, wStyleChecks, wAssertions, wWarnings, wHints, wLineDir, wStackTrace, wLineTrace, wOptimization, wHint, wWarning, wError, wFatal, wDefine, wUndef, wCompile, wLink, wPush, wPop, wPassl, wPassc, wLocalPassc, wDebugger, wProfiler, wDeprecated, wFloatChecks, wInfChecks, wNanChecks, wPragma, wEmit, wTrMacros, wEffects, wComputedGoto, wExperimental, wUsed, wByRef, wCallconv}
- Source Edit
templatePragmas = {wDeprecated, wError, wGensym, wInject, wDirty, wExportNims, wUsed, wPragma}
- Source Edit
typePragmas = {wMagic, wFinal, wImportc..wRequiresInit, wNodecl..wPure, wHeader, wGcSafe, wCompilerProc..wCore, wUsed, wError, wDeprecated, wSize, wPackage, wBorrow, wAcyclic, wGensym..wInject, wInheritable, wExplain, wExtern, wUnion..wPacked, wByCopy..wByRef}
- Source Edit
varPragmas = {wMagic, wCursor..wNoalias, wImportc..wExportNims, wAlign..wNodecl, wHeader, wDynlib..wCore, wUsed, wError, wDeprecated, wCompileTime..wNoInit, wGensym..wInject, wThreadVar, wGlobal, wGuard, wExtern, wRegister, wVolatile}
- Source Edit
Procs
proc getPragmaVal(procAst: PNode; name: TSpecialWord): PNode {....raises: [], tags: [].}
- Source Edit
proc hasPragma(n: PNode; pragma: TSpecialWord): bool {....raises: [], tags: [].}
- true if any of n's children are of pragma special words Source Edit
proc illegalCustomPragma(c: PContext; n: PNode; s: PSym): PNode {....raises: [], tags: [].}
- create an error node (nkError) for an illegal custom pragma error Source Edit
proc implicitPragmas(c: PContext; sym: PSym; n: PNode; validPragmas: TSpecialWords): PNode {. ...raises: [Exception, ERecoverableError, KeyError, ValueError], tags: [RootEffect, ReadIOEffect, ReadDirEffect, ReadEnvEffect, TimeEffect].}
- Adds implicit pragmas to the list n and applies them to sym afterwards. Implicit pragmas that don't apply (because they're, for example, built-in pragmas not present in validPragmas) are ignored. Source Edit
proc inheritDynlib(c: PContext; sym: PSym) {....raises: [], tags: [].}
- Apply the dynlib pragma from the top of the option stack to sym, if applicable. The dynlib pragma can be applied if the symbol is marked as imported, but no header nor dynlib are specified. Source Edit
proc invalidPragma(c: PContext; n: PNode): PNode {....raises: [], tags: [].}
- create an error node (nkError) for an invalid pragma error Source Edit
proc pragmaAsm(c: PContext; n: PNode): tuple[marker: char, err: PNode] {. ...raises: [], tags: [].}
- Gets the marker out of an asm stmts pragma list Returns ` as the default marker if no other markers are found Source Edit
proc pragmaDecl(c: PContext; sym: PSym; n: PNode; validPragmas: TSpecialWords): PNode {. ...raises: [KeyError, Exception, ERecoverableError, ValueError], tags: [RootEffect, ReadIOEffect, ReadDirEffect, ReadEnvEffect, TimeEffect].}
- Similar to pragmaDeclNoImplicit, but adds the implicit pragmas to the resulting list and applies. Source Edit
proc pragmaDeclNoImplicit(c: PContext; sym: PSym; n: PNode; validPragmas: TSpecialWords): PNode {. ...raises: [KeyError, Exception, ERecoverableError, ValueError], tags: [RootEffect, ReadIOEffect, ReadDirEffect, ReadEnvEffect, TimeEffect].}
-
Analyses the pragma list n, making sure each pragma is semantically valid and applying the symbol operators to sym. validPragmas is the list of built-in pragmas that are allowed -- usage of one not present in the set is an error.
No implicit pragmas (i.e. pushed ones) are added to the list nor applied.
Source Edit proc pragmaExpr(c: PContext; n: PNode): PNode {. ...raises: [KeyError, Exception, ERecoverableError], tags: [RootEffect, ReadIOEffect, ReadDirEffect].}
- Pre-processes the pragma list n for the purpose of further processing by sem in the context of applying pragmas to an expression. Source Edit
proc pragmaStmt(c: PContext; n: PNode; owner: PSym): PNode {....raises: [KeyError, Exception, ERecoverableError, OSError, IOError, ValueError, EOFError], tags: [ RootEffect, ReadIOEffect, ReadDirEffect, WriteDirEffect, WriteIOEffect, ReadEnvEffect, TimeEffect].}
- Analyses and evaluates for their side-effects the pragmas in list n. owner is provided for addition context and is sometimes mutated. Source Edit