condsyms.nim 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 HintsToStr, WarningsToStr
  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")
  29. defineSymbol("niminheritable")
  30. defineSymbol("nimmixin")
  31. defineSymbol("nimeffects")
  32. defineSymbol("nimbabel")
  33. defineSymbol("nimcomputedgoto")
  34. defineSymbol("nimunion")
  35. defineSymbol("nimnewshared")
  36. defineSymbol("nimNewTypedesc")
  37. defineSymbol("nimrequiresnimframe")
  38. defineSymbol("nimparsebiggestfloatmagic")
  39. defineSymbol("nimalias")
  40. defineSymbol("nimlocks")
  41. defineSymbol("nimnode")
  42. defineSymbol("nimvarargstyped")
  43. defineSymbol("nimtypedescfixed")
  44. defineSymbol("nimKnowsNimvm")
  45. defineSymbol("nimArrIdx")
  46. defineSymbol("nimHasalignOf")
  47. defineSymbol("nimDistros")
  48. defineSymbol("nimHasCppDefine")
  49. defineSymbol("nimGenericInOutFlags")
  50. when false: defineSymbol("nimHasOpt")
  51. defineSymbol("nimNoArrayToCstringConversion")
  52. defineSymbol("nimNewRoof")
  53. defineSymbol("nimHasRunnableExamples")
  54. defineSymbol("nimNewDot")
  55. defineSymbol("nimHasNilChecks")
  56. defineSymbol("nimSymKind")
  57. defineSymbol("nimVmEqIdent")
  58. defineSymbol("nimNoNil")
  59. defineSymbol("nimNoZeroTerminator")
  60. defineSymbol("nimNotNil")
  61. defineSymbol("nimVmExportFixed")
  62. defineSymbol("nimHasSymOwnerInMacro")
  63. defineSymbol("nimNewRuntime")
  64. defineSymbol("nimIncrSeqV3")
  65. defineSymbol("nimAshr")
  66. defineSymbol("nimNoNilSeqs")
  67. defineSymbol("nimNoNilSeqs2")
  68. defineSymbol("nimHasUserErrors")
  69. defineSymbol("nimUncheckedArrayTyp")
  70. defineSymbol("nimHasTypeof")
  71. defineSymbol("nimErrorProcCanHaveBody")
  72. defineSymbol("nimHasInstantiationOfInMacro")
  73. defineSymbol("nimHasHotCodeReloading")
  74. defineSymbol("nimHasNilSeqs")
  75. defineSymbol("nimHasSignatureHashInMacro")
  76. defineSymbol("nimHasDefault")
  77. defineSymbol("nimMacrosSizealignof")
  78. defineSymbol("nimNoZeroExtendMagic")
  79. defineSymbol("nimMacrosGetNodeId")
  80. for f in low(Feature)..high(Feature):
  81. defineSymbol("nimHas" & $f)
  82. for s in WarningsToStr:
  83. defineSymbol("nimHasWarning" & s)
  84. for s in HintsToStr:
  85. defineSymbol("nimHasHint" & s)
  86. defineSymbol("nimFixedOwned")
  87. defineSymbol("nimHasStyleChecks")
  88. defineSymbol("nimToOpenArrayCString")
  89. defineSymbol("nimHasUsed")
  90. defineSymbol("nimFixedForwardGeneric")
  91. defineSymbol("nimnomagic64")
  92. defineSymbol("nimNewShiftOps")
  93. defineSymbol("nimHasCursor")
  94. defineSymbol("nimAlignPragma")
  95. defineSymbol("nimHasExceptionsQuery")
  96. defineSymbol("nimHasIsNamedTuple")
  97. defineSymbol("nimHashOrdinalFixed")
  98. when defined(nimHasLibFFI):
  99. # Renaming as we can't conflate input vs output define flags; e.g. this
  100. # will report the right thing regardless of whether user adds
  101. # `-d:nimHasLibFFI` in his user config.
  102. defineSymbol("nimHasLibFFIEnabled")
  103. defineSymbol("nimHasSinkInference")
  104. defineSymbol("nimNewIntegerOps")
  105. defineSymbol("nimHasInvariant")
  106. defineSymbol("nimHasStacktraceMsgs")
  107. defineSymbol("nimDoesntTrackDefects")
  108. defineSymbol("nimHasLentIterators")