Implement {.booldefine.} (#10533)
This commit is contained in:
parent
07553034de
commit
0091f2ad3b
9 changed files with 71 additions and 17 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue