diff trunk/src/dil/Settings.d @ 367:dda55fae37de

- ImportGraph.execute() can parse all modules depending on the imports of the root module. - Added function findModule(). - Renamed option includes to import_paths. - Fix in ctor of ModuleDeclaration: check for pname.length before removing last separator. - Fixed scanning binary numbers. - Added member modules and method getFQN() to class Module. - Fix in parseIfStatement(): AttributeStatement mustn't have a null parameter. - Parsing import_paths in GlobalSettings.load().
author aziz
date Fri, 31 Aug 2007 23:07:05 +0000
parents 0faf57d99c1c
children 2adf808343d6
line wrap: on
line diff
--- a/trunk/src/dil/Settings.d	Fri Aug 31 12:14:03 2007 +0000
+++ b/trunk/src/dil/Settings.d	Fri Aug 31 23:07:05 2007 +0000
@@ -47,6 +47,7 @@
 static:
   string language; /// Language of messages catalogue to load.
   string[] messages; /// Table of localized compiler messages.
+  string[] importPaths; /// Array of import paths to look for modules.
   void load()
   {
     auto fileName = "config.d"[];
@@ -63,18 +64,32 @@
     foreach (decl; root.children)
     {
       auto v = Cast!(VariableDeclaration)(decl);
-      if (v && v.idents[0].srcText == "langfile")
+      if (v is null)
+        continue;
+      auto vname = v.idents[0].srcText;
+      if (vname == "langfile")
       {
         auto e = v.values[0];
         if (!e)
           throw new Exception("langfile variable has no value set.");
         auto val = Cast!(StringLiteralsExpression)(e);
         if (val)
-        {
           // Set fileName to d-file with messages table.
           fileName = val.getString();
-          break;
+      }
+      else if (vname == "import_paths")
+      {
+        auto e = v.values[0];
+        if (e is null)
+          throw new Exception("import_paths variable has no variable set.");
+        if (auto array = Cast!(ArrayInitializer)(e))
+        {
+          foreach (value; array.values)
+            if (auto str = Cast!(StringLiteralsExpression)(value))
+              GlobalSettings.importPaths ~= str.getString();
         }
+        else
+          throw new Exception("import_paths variable is set to "~e.classinfo.name~" instead of an ArrayInitializer.");
       }
     }