condsyms.nim 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. 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, val in pairs(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("nimalias") # deadcode
  40. defineSymbol("nimlocks") # deadcode
  41. defineSymbol("nimnode") # deadcode pending `nimnode` reference in opengl package
  42. # refs https://github.com/nim-lang/opengl/pull/79
  43. defineSymbol("nimvarargstyped") # deadcode
  44. defineSymbol("nimtypedescfixed") # deadcode
  45. defineSymbol("nimKnowsNimvm") # deadcode
  46. defineSymbol("nimArrIdx") # deadcode
  47. defineSymbol("nimHasalignOf") # deadcode
  48. defineSymbol("nimDistros") # deadcode
  49. defineSymbol("nimHasCppDefine") # deadcode
  50. defineSymbol("nimGenericInOutFlags") # deadcode
  51. when false: defineSymbol("nimHasOpt") # deadcode
  52. defineSymbol("nimNoArrayToCstringConversion") # deadcode
  53. defineSymbol("nimHasRunnableExamples") # deadcode
  54. defineSymbol("nimNewDot") # deadcode
  55. defineSymbol("nimHasNilChecks") # deadcode
  56. defineSymbol("nimSymKind") # deadcode
  57. defineSymbol("nimVmEqIdent") # deadcode
  58. defineSymbol("nimNoNil") # deadcode
  59. defineSymbol("nimNoZeroTerminator") # deadcode
  60. defineSymbol("nimNotNil") # deadcode
  61. defineSymbol("nimVmExportFixed") # deadcode
  62. defineSymbol("nimHasSymOwnerInMacro") # deadcode
  63. defineSymbol("nimNewRuntime") # deadcode
  64. defineSymbol("nimIncrSeqV3") # deadcode
  65. defineSymbol("nimAshr") # deadcode
  66. defineSymbol("nimNoNilSeqs") # deadcode
  67. defineSymbol("nimNoNilSeqs2") # deadcode
  68. defineSymbol("nimHasUserErrors") # deadcode
  69. defineSymbol("nimUncheckedArrayTyp") # deadcode
  70. defineSymbol("nimHasTypeof") # deadcode
  71. defineSymbol("nimErrorProcCanHaveBody") # deadcode
  72. defineSymbol("nimHasInstantiationOfInMacro") # deadcode
  73. defineSymbol("nimHasHotCodeReloading") # deadcode
  74. defineSymbol("nimHasNilSeqs") # deadcode
  75. defineSymbol("nimHasSignatureHashInMacro") # deadcode
  76. defineSymbol("nimHasDefault") # deadcode
  77. defineSymbol("nimMacrosSizealignof") # deadcode
  78. # > 0.20.0
  79. defineSymbol("nimNoZeroExtendMagic")
  80. defineSymbol("nimMacrosGetNodeId")
  81. for f in Feature:
  82. defineSymbol("nimHas" & $f)
  83. for s in warnMin..warnMax:
  84. defineSymbol("nimHasWarning" & $s)
  85. for s in hintMin..hintMax:
  86. defineSymbol("nimHasHint" & $s)
  87. defineSymbol("nimFixedOwned")
  88. defineSymbol("nimHasStyleChecks")
  89. defineSymbol("nimToOpenArrayCString")
  90. defineSymbol("nimHasUsed")
  91. defineSymbol("nimFixedForwardGeneric")
  92. defineSymbol("nimnomagic64")
  93. defineSymbol("nimNewShiftOps")
  94. defineSymbol("nimHasCursor")
  95. defineSymbol("nimAlignPragma")
  96. defineSymbol("nimHasExceptionsQuery")
  97. defineSymbol("nimHasIsNamedTuple")
  98. defineSymbol("nimHashOrdinalFixed")
  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")
  104. defineSymbol("nimHasSinkInference")
  105. defineSymbol("nimNewIntegerOps")
  106. defineSymbol("nimHasInvariant")
  107. defineSymbol("nimHasStacktraceMsgs")
  108. defineSymbol("nimDoesntTrackDefects")
  109. defineSymbol("nimHasLentIterators")
  110. defineSymbol("nimHasDeclaredMagic")
  111. defineSymbol("nimHasStacktracesModule")
  112. defineSymbol("nimHasEffectTraitsModule")
  113. defineSymbol("nimHasCastPragmaBlocks")
  114. defineSymbol("nimHasDeclaredLocs")
  115. defineSymbol("nimHasJsBigIntBackend")
  116. defineSymbol("nimHasWarningAsError")
  117. defineSymbol("nimHasHintAsError")
  118. defineSymbol("nimHasSpellSuggest")
  119. defineSymbol("nimHasCustomLiterals")
  120. defineSymbol("nimHasUnifiedTuple")
  121. defineSymbol("nimHasIterable")
  122. defineSymbol("nimHasTypeofVoid")
  123. defineSymbol("nimHasDragonBox")
  124. defineSymbol("nimHasHintAll")
  125. defineSymbol("nimHasTrace")
  126. defineSymbol("nimHasEffectsOf")
  127. defineSymbol("nimHasEnforceNoRaises")
  128. defineSymbol("nimHasTopDownInference")
  129. defineSymbol("nimHasTemplateRedefinitionPragma")
  130. defineSymbol("nimHasCstringCase")
  131. defineSymbol("nimHasCallsitePragma")
  132. defineSymbol("nimHasAmbiguousEnumHint")
  133. defineSymbol("nimHasOutParams")
  134. defineSymbol("nimHasSystemRaisesDefect")
  135. defineSymbol("nimHasWarnUnnamedBreak")