view src/dil/Compilation.d @ 810:525ee3f848d9

Added modules cmd.Compile and dil.ModuleManager. Added options -I, -release and -unittest to the compile command. Tidied main.d up a bit. Renamed start() methods of SemanticPass1 and 2 to run(). Moved function findModuleFilePath() to class ModuleManager. Added msg CouldntLoadModule. Corrected two others. Added member semanticPass to class Module. Implemented visit(ImportDeclaration) in SemanticPass1.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Tue, 11 Mar 2008 02:48:01 +0100
parents bcb74c9b895c
children 438ed3a72c9d
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;
  bool unittestBuild;
  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;
  }
}