diff 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
line wrap: on
line diff
--- a/trunk/src/dil/Compilation.d	Wed Feb 20 01:24:19 2008 +0100
+++ b/trunk/src/dil/Compilation.d	Wed Feb 20 22:09:29 2008 +0100
@@ -9,11 +9,61 @@
 /// A group of settings relevant to the compilation process.
 class CompilationContext
 {
+  alias typeof(this) CC;
+  CC parent;
   string[] importPaths;
   uint debugLevel;
   uint versionLevel;
   bool[string] debugIds;
   bool[string] versionIds;
   bool releaseBuild;
-  uint structAlign;
+  uint structAlign = 4;
+
+  this(CC parent = null)
+  {
+    this.parent = parent;
+    if (parent)
+    {
+      this.importPaths = parent.importPaths;
+      this.debugLevel = parent.debugLevel;
+      this.versionLevel = parent.versionLevel;
+      this.releaseBuild = parent.releaseBuild;
+      this.structAlign = parent.structAlign;
+    }
+  }
+
+  void addDebugId(string id)
+  {
+    debugIds[id] = true;
+  }
+
+  void addVersionId(string id)
+  {
+    versionIds[id] = true;
+  }
+
+  bool findDebugId(string id)
+  {
+    auto pId = id in debugIds;
+    if (pId)
+      return true;
+    if (!isRoot())
+      return parent.findDebugId(id);
+    return false;
+  }
+
+  bool findVersionId(string id)
+  {
+    auto pId = id in versionIds;
+    if (pId)
+      return true;
+    if (!isRoot())
+      return parent.findVersionId(id);
+    return false;
+  }
+
+  bool isRoot()
+  {
+    return parent is null;
+  }
 }