view src/dil/Compilation.d @ 806:bcb74c9b895c

Moved out files in the trunk folder to the root.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sun, 09 Mar 2008 00:12:19 +0100
parents trunk/src/dil/Compilation.d@edd217e14736
children 525ee3f848d9
line wrap: on
line source

/++
  Author: Aziz Köksal
  License: GPL3
+/
module dil.Compilation;

import common;

/// 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 = 4;

  this(CC parent = null)
  {
    this.parent = parent;
    if (parent)
    {
      this.importPaths = parent.importPaths.dup;
      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;
  }
}