diff options
author | Araq <rumpf_a@web.de> | 2011-04-12 01:13:42 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-04-12 01:13:42 +0200 |
commit | cd292568d775d55d9abb51e962882ecda12c03a9 (patch) | |
tree | 85451f0e1f17dc0463350915f12bdd0a82a73455 /nim/condsyms.pas | |
parent | 46c41e43690cba9bc1caff6a994bb6915df8a1b7 (diff) | |
download | Nim-cd292568d775d55d9abb51e962882ecda12c03a9.tar.gz |
big repo cleanup
Diffstat (limited to 'nim/condsyms.pas')
-rwxr-xr-x | nim/condsyms.pas | 152 |
1 files changed, 0 insertions, 152 deletions
diff --git a/nim/condsyms.pas b/nim/condsyms.pas deleted file mode 100755 index d22bc0e18..000000000 --- a/nim/condsyms.pas +++ /dev/null @@ -1,152 +0,0 @@ -// -// -// The Nimrod Compiler -// (c) Copyright 2008 Andreas Rumpf -// -// See the file "copying.txt", included in this -// distribution, for details about the copyright. -// -unit condsyms; - -// This module handles the conditional symbols. - -{$include 'config.inc'} - -interface - -uses - nsystem, ast, astalgo, msgs, nhashes, platform, strutils, idents; - -var - gSymbols: TStrTable; - -procedure InitDefines; -procedure DeinitDefines; - -procedure DefineSymbol(const symbol: string); -procedure UndefSymbol(const symbol: string); -function isDefined(symbol: PIdent): Boolean; -procedure ListSymbols; - -function countDefinedSymbols: int; - -implementation - -procedure DefineSymbol(const symbol: string); -var - sym: PSym; - i: PIdent; -begin - i := getIdent(symbol); - sym := StrTableGet(gSymbols, i); - if sym = nil then begin - new(sym); // circumvent the ID mechanism - {@ignore} - fillChar(sym^, sizeof(sym^), 0); - {@emit} - sym.kind := skConditional; - sym.name := i; - StrTableAdd(gSymbols, sym); - end; - sym.position := 1; -end; - -procedure UndefSymbol(const symbol: string); -var - sym: PSym; -begin - sym := StrTableGet(gSymbols, getIdent(symbol)); - if sym <> nil then sym.position := 0; -end; - -function isDefined(symbol: PIdent): Boolean; -var - sym: PSym; -begin - sym := StrTableGet(gSymbols, symbol); - result := (sym <> nil) and (sym.position = 1) -end; - -procedure ListSymbols; -var - it: TTabIter; - s: PSym; -begin - s := InitTabIter(it, gSymbols); - MessageOut('-- List of currently defined symbols --'); - while s <> nil do begin - if s.position = 1 then MessageOut(s.name.s); - s := nextIter(it, gSymbols); - end; - MessageOut('-- End of list --'); -end; - -function countDefinedSymbols: int; -var - it: TTabIter; - s: PSym; -begin - s := InitTabIter(it, gSymbols); - result := 0; - while s <> nil do begin - if s.position = 1 then inc(result); - s := nextIter(it, gSymbols); - end; -end; - -procedure InitDefines; -begin - initStrTable(gSymbols); - DefineSymbol('nimrod'); // 'nimrod' is always defined -{@ignore} - DefineSymbol('nim'); // Pascal version defines 'nim' in addition -{@emit} - // add platform specific symbols: - case targetCPU of - cpuI386: DefineSymbol('x86'); - cpuIa64: DefineSymbol('itanium'); - cpuAmd64: DefineSymbol('x8664'); - else begin end - end; - case targetOS of - osDOS: DefineSymbol('msdos'); - osWindows: begin - DefineSymbol('mswindows'); - DefineSymbol('win32'); - end; - osLinux, osMorphOS, osSkyOS, osIrix, osPalmOS, osQNX, osAtari, osAix: begin - // these are all 'unix-like' - DefineSymbol('unix'); - DefineSymbol('posix'); - end; - osSolaris: begin - DefineSymbol('sunos'); - DefineSymbol('unix'); - DefineSymbol('posix'); - end; - osNetBSD, osFreeBSD, osOpenBSD: begin - DefineSymbol('unix'); - DefineSymbol('bsd'); - DefineSymbol('posix'); - end; - osMacOS: begin - DefineSymbol('macintosh'); - end; - osMacOSX: begin - DefineSymbol('macintosh'); - DefineSymbol('unix'); - DefineSymbol('posix'); - end; - else begin end - end; - DefineSymbol('cpu' + ToString( cpu[targetCPU].bit )); - DefineSymbol(normalize(endianToStr[cpu[targetCPU].endian])); - DefineSymbol(cpu[targetCPU].name); - DefineSymbol(platform.os[targetOS].name); -end; - -procedure DeinitDefines; -begin -end; - -end. |