Implement {.booldefine.} (#10533)

This commit is contained in:
Oscar Nihlgård 2019-02-03 09:06:00 +01:00 • committed by Andreas Rumpf
commit 0091f2ad3b
9 changed files with 71 additions and 17 deletions

View file

@ -15,26 +15,21 @@ import
from options import Feature
from lineinfos import HintsToStr, WarningsToStr
const
catNone = "false"
proc defineSymbol*(symbols: StringTableRef; symbol: string, value: string = "true") =
symbols[symbol] = value
proc undefSymbol*(symbols: StringTableRef; symbol: string) =
symbols[symbol] = catNone
symbols.del(symbol)
#proc lookupSymbol*(symbols: StringTableRef; symbol: string): string =
# result = if isDefined(symbol): gSymbols[symbol] else: nil
iterator definedSymbolNames*(symbols: StringTableRef): string =
for key, val in pairs(symbols):
if val != catNone: yield key
yield key
proc countDefinedSymbols*(symbols: StringTableRef): int =
result = 0
for key, val in pairs(symbols):
if val != catNone: inc(result)
symbols.len
proc initDefines*(symbols: StringTableRef) =
# for bootstrapping purposes and old code: