condsyms.nim 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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, platform, strutils, idents
  12. from options import Feature
  13. from lineinfos import HintsToStr, WarningsToStr
  14. const
  15. catNone = "false"
  16. proc defineSymbol*(symbols: StringTableRef; symbol: string, value: string = "true") =
  17. symbols[symbol] = value
  18. proc undefSymbol*(symbols: StringTableRef; symbol: string) =
  19. symbols[symbol] = catNone
  20. #proc lookupSymbol*(symbols: StringTableRef; symbol: string): string =
  21. # result = if isDefined(symbol): gSymbols[symbol] else: nil
  22. iterator definedSymbolNames*(symbols: StringTableRef): string =
  23. for key, val in pairs(symbols):
  24. if val != catNone: yield key
  25. proc countDefinedSymbols*(symbols: StringTableRef): int =
  26. result = 0
  27. for key, val in pairs(symbols):
  28. if val != catNone: inc(result)
  29. proc initDefines*(symbols: StringTableRef) =
  30. # for bootstrapping purposes and old code:
  31. template defineSymbol(s) = symbols.defineSymbol(s)
  32. defineSymbol("nimhygiene")
  33. defineSymbol("niminheritable")
  34. defineSymbol("nimmixin")
  35. defineSymbol("nimeffects")
  36. defineSymbol("nimbabel")
  37. defineSymbol("nimcomputedgoto")
  38. defineSymbol("nimunion")
  39. defineSymbol("nimnewshared")
  40. defineSymbol("nimNewTypedesc")
  41. defineSymbol("nimrequiresnimframe")
  42. defineSymbol("nimparsebiggestfloatmagic")
  43. defineSymbol("nimalias")
  44. defineSymbol("nimlocks")
  45. defineSymbol("nimnode")
  46. defineSymbol("nimnomagic64")
  47. defineSymbol("nimvarargstyped")
  48. defineSymbol("nimtypedescfixed")
  49. defineSymbol("nimKnowsNimvm")
  50. defineSymbol("nimArrIdx")
  51. defineSymbol("nimImmediateDeprecated")
  52. defineSymbol("nimNewShiftOps")
  53. defineSymbol("nimDistros")
  54. defineSymbol("nimHasCppDefine")
  55. defineSymbol("nimGenericInOutFlags")
  56. when false: defineSymbol("nimHasOpt")
  57. defineSymbol("nimNoArrayToCstringConversion")
  58. defineSymbol("nimNewRoof")
  59. defineSymbol("nimHasRunnableExamples")
  60. defineSymbol("nimNewDot")
  61. defineSymbol("nimHasNilChecks")
  62. defineSymbol("nimSymKind")
  63. defineSymbol("nimVmEqIdent")
  64. defineSymbol("nimNoNil")
  65. defineSymbol("nimNoZeroTerminator")
  66. defineSymbol("nimNotNil")
  67. defineSymbol("nimVmExportFixed")
  68. defineSymbol("nimHasSymOwnerInMacro")
  69. defineSymbol("nimNewRuntime")
  70. defineSymbol("nimIncrSeqV3")
  71. defineSymbol("nimAshr")
  72. defineSymbol("nimNoNilSeqs")
  73. defineSymbol("nimNoNilSeqs2")
  74. defineSymbol("nimHasNilSeqs")
  75. for f in low(Feature)..high(Feature):
  76. defineSymbol("nimHas" & $f)
  77. for s in WarningsToStr:
  78. defineSymbol("nimHasWarning" & s)
  79. for s in HintsToStr:
  80. defineSymbol("nimHasHint" & s)