comparison trunk/src/dil/Compilation.d @ 778:78be32e3e157

Implemented conditional compilation.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Wed, 20 Feb 2008 22:09:29 +0100
parents 9f61e8af55d5
children edd217e14736
comparison
equal deleted inserted replaced
777:9f61e8af55d5 778:78be32e3e157
7 import common; 7 import common;
8 8
9 /// A group of settings relevant to the compilation process. 9 /// A group of settings relevant to the compilation process.
10 class CompilationContext 10 class CompilationContext
11 { 11 {
12 alias typeof(this) CC;
13 CC parent;
12 string[] importPaths; 14 string[] importPaths;
13 uint debugLevel; 15 uint debugLevel;
14 uint versionLevel; 16 uint versionLevel;
15 bool[string] debugIds; 17 bool[string] debugIds;
16 bool[string] versionIds; 18 bool[string] versionIds;
17 bool releaseBuild; 19 bool releaseBuild;
18 uint structAlign; 20 uint structAlign = 4;
21
22 this(CC parent = null)
23 {
24 this.parent = parent;
25 if (parent)
26 {
27 this.importPaths = parent.importPaths;
28 this.debugLevel = parent.debugLevel;
29 this.versionLevel = parent.versionLevel;
30 this.releaseBuild = parent.releaseBuild;
31 this.structAlign = parent.structAlign;
32 }
33 }
34
35 void addDebugId(string id)
36 {
37 debugIds[id] = true;
38 }
39
40 void addVersionId(string id)
41 {
42 versionIds[id] = true;
43 }
44
45 bool findDebugId(string id)
46 {
47 auto pId = id in debugIds;
48 if (pId)
49 return true;
50 if (!isRoot())
51 return parent.findDebugId(id);
52 return false;
53 }
54
55 bool findVersionId(string id)
56 {
57 auto pId = id in versionIds;
58 if (pId)
59 return true;
60 if (!isRoot())
61 return parent.findVersionId(id);
62 return false;
63 }
64
65 bool isRoot()
66 {
67 return parent is null;
68 }
19 } 69 }