condsyms.nim 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #
  2. #
  3. # The Nim Compiler
  4. # (c) Copyright 2015 Andreas Rumpf
  5. #
  6. # See the file "copying.txt", included in this
  7. # distribution, for details about the copyright.
  8. #
  9. # This module handles the conditional symbols.
  10. import
  11. std/strtabs
  12. from options import Feature
  13. from lineinfos import hintMin, hintMax, warnMin, warnMax
  14. proc defineSymbol*(symbols: StringTableRef; symbol: string, value: string = "true") =
  15. symbols[symbol] = value
  16. proc undefSymbol*(symbols: StringTableRef; symbol: string) =
  17. symbols.del(symbol)
  18. #proc lookupSymbol*(symbols: StringTableRef; symbol: string): string =
  19. # result = if isDefined(symbol): gSymbols[symbol] else: nil
  20. iterator definedSymbolNames*(symbols: StringTableRef): string =
  21. for key in keys(symbols):
  22. yield key
  23. proc countDefinedSymbols*(symbols: StringTableRef): int =
  24. symbols.len
  25. proc initDefines*(symbols: StringTableRef) =
  26. # for bootstrapping purposes and old code:
  27. template defineSymbol(s) = symbols.defineSymbol(s)
  28. defineSymbol("nimhygiene") # deadcode
  29. defineSymbol("niminheritable") # deadcode
  30. defineSymbol("nimmixin") # deadcode
  31. defineSymbol("nimeffects") # deadcode
  32. defineSymbol("nimbabel") # deadcode
  33. defineSymbol("nimcomputedgoto") # deadcode
  34. defineSymbol("nimunion") # deadcode
  35. defineSymbol("nimnewshared") # deadcode
  36. defineSymbol("nimNewTypedesc") # deadcode
  37. defineSymbol("nimrequiresnimframe") # deadcode
  38. defineSymbol("nimparsebiggestfloatmagic") # deadcode
  39. defineSymbol("nimlocks") # deadcode
  40. defineSymbol("nimnode") # deadcode
  41. defineSymbol("nimvarargstyped") # deadcode
  42. defineSymbol("nimtypedescfixed") # deadcode
  43. defineSymbol("nimKnowsNimvm") # deadcode
  44. defineSymbol("nimArrIdx") # deadcode
  45. defineSymbol("nimHasalignOf") # deadcode
  46. defineSymbol("nimDistros") # deadcode
  47. defineSymbol("nimHasCppDefine") # deadcode
  48. defineSymbol("nimGenericInOutFlags") # deadcode
  49. when false: defineSymbol("nimHasOpt") # deadcode
  50. defineSymbol("nimNoArrayToCstringConversion") # deadcode
  51. defineSymbol("nimHasRunnableExamples") # deadcode
  52. defineSymbol("nimNewDot") # deadcode
  53. defineSymbol("nimHasNilChecks") # deadcode
  54. defineSymbol("nimSymKind") # deadcode
  55. defineSymbol("nimVmEqIdent") # deadcode
  56. defineSymbol("nimNoNil") # deadcode
  57. defineSymbol("nimNoZeroTerminator") # deadcode
  58. defineSymbol("nimNotNil") # deadcode
  59. defineSymbol("nimVmExportFixed") # deadcode
  60. defineSymbol("nimHasSymOwnerInMacro") # deadcode
  61. defineSymbol("nimNewRuntime") # deadcode
  62. defineSymbol("nimIncrSeqV3") # deadcode
  63. defineSymbol("nimAshr") # deadcode
  64. defineSymbol("nimNoNilSeqs") # deadcode
  65. defineSymbol("nimNoNilSeqs2") # deadcode
  66. defineSymbol("nimHasUserErrors") # deadcode
  67. defineSymbol("nimUncheckedArrayTyp") # deadcode
  68. defineSymbol("nimHasTypeof") # deadcode
  69. defineSymbol("nimErrorProcCanHaveBody") # deadcode
  70. defineSymbol("nimHasInstantiationOfInMacro") # deadcode
  71. defineSymbol("nimHasHotCodeReloading") # deadcode
  72. defineSymbol("nimHasNilSeqs") # deadcode
  73. defineSymbol("nimHasSignatureHashInMacro") # deadcode
  74. defineSymbol("nimHasDefault") # deadcode
  75. defineSymbol("nimMacrosSizealignof") # deadcode
  76. defineSymbol("nimNoZeroExtendMagic") # deadcode
  77. defineSymbol("nimMacrosGetNodeId") # deadcode
  78. defineSymbol("nimFixedForwardGeneric") # deadcode
  79. defineSymbol("nimToOpenArrayCString") # deadcode
  80. defineSymbol("nimHasUsed") # deadcode
  81. defineSymbol("nimnomagic64") # deadcode
  82. defineSymbol("nimNewShiftOps") # deadcode
  83. defineSymbol("nimHasCursor") # deadcode
  84. defineSymbol("nimAlignPragma") # deadcode
  85. defineSymbol("nimHasExceptionsQuery") # deadcode
  86. defineSymbol("nimHasIsNamedTuple") # deadcode
  87. defineSymbol("nimHashOrdinalFixed") # deadcode
  88. defineSymbol("nimHasSinkInference") # deadcode
  89. defineSymbol("nimNewIntegerOps") # deadcode
  90. defineSymbol("nimHasInvariant") # deadcode
  91. for f in Feature:
  92. defineSymbol("nimHas" & $f)
  93. for s in warnMin..warnMax:
  94. defineSymbol("nimHasWarning" & $s)
  95. for s in hintMin..hintMax:
  96. defineSymbol("nimHasHint" & $s)
  97. defineSymbol("nimFixedOwned")
  98. defineSymbol("nimHasStyleChecks")
  99. when defined(nimHasLibFFI):
  100. # Renaming as we can't conflate input vs output define flags; e.g. this
  101. # will report the right thing regardless of whether user adds
  102. # `-d:nimHasLibFFI` in his user config.
  103. defineSymbol("nimHasLibFFIEnabled") # deadcode
  104. defineSymbol("nimHasStacktraceMsgs") # deadcode
  105. defineSymbol("nimDoesntTrackDefects")
  106. defineSymbol("nimHasLentIterators") # deadcode
  107. defineSymbol("nimHasDeclaredMagic") # deadcode
  108. defineSymbol("nimHasStacktracesModule") # deadcode
  109. defineSymbol("nimHasEffectTraitsModule")
  110. defineSymbol("nimHasCastPragmaBlocks")
  111. defineSymbol("nimHasDeclaredLocs")
  112. defineSymbol("nimHasJsBigIntBackend")
  113. defineSymbol("nimHasWarningAsError")
  114. defineSymbol("nimHasHintAsError")
  115. defineSymbol("nimHasSpellSuggest")
  116. defineSymbol("nimHasCustomLiterals")
  117. defineSymbol("nimHasUnifiedTuple")
  118. defineSymbol("nimHasIterable")
  119. defineSymbol("nimHasTypeofVoid") # deadcode
  120. defineSymbol("nimHasDragonBox") # deadcode
  121. defineSymbol("nimHasHintAll")
  122. defineSymbol("nimHasTrace")
  123. defineSymbol("nimHasEffectsOf")
  124. defineSymbol("nimHasEnforceNoRaises")
  125. defineSymbol("nimHasTopDownInference")
  126. defineSymbol("nimHasTemplateRedefinitionPragma")
  127. defineSymbol("nimHasCstringCase")
  128. defineSymbol("nimHasCallsitePragma")
  129. defineSymbol("nimHasWarnCastSizes") # deadcode
  130. defineSymbol("nimHasOutParams")
  131. defineSymbol("nimHasSystemRaisesDefect")
  132. defineSymbol("nimHasWarnUnnamedBreak")
  133. defineSymbol("nimHasGenericDefine")
  134. defineSymbol("nimHasDefineAliases")
  135. defineSymbol("nimHasWarnBareExcept")
  136. defineSymbol("nimHasDup")
  137. defineSymbol("nimHasChecksums")
  138. defineSymbol("nimHasSendable")
  139. defineSymbol("nimAllowNonVarDestructor")
  140. defineSymbol("nimHasQuirky")
  141. defineSymbol("nimHasEnsureMove")
  142. defineSymbol("nimHasNoReturnError")
  143. defineSymbol("nimUseStrictDefs")
  144. defineSymbol("nimHasNolineTooLong")
  145. defineSymbol("nimHasCastExtendedVm")
  146. defineSymbol("nimHasWarnStdPrefix")
  147. defineSymbol("nimHasVtables")
  148. defineSymbol("nimHasGenericsOpenSym2")
  149. defineSymbol("nimHasJsNoLambdaLifting")