changeset 780:edd217e14736

Using CompilationContext in command 'igraph'.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Wed, 20 Feb 2008 23:13:56 +0100
parents 8e6fed11bb68
children d887184efb3c
files trunk/src/cmd/ImportGraph.d trunk/src/dil/Compilation.d trunk/src/main.d
diffstat 3 files changed, 12 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/cmd/ImportGraph.d	Wed Feb 20 22:47:33 2008 +0100
+++ b/trunk/src/cmd/ImportGraph.d	Wed Feb 20 23:13:56 2008 +0100
@@ -9,6 +9,7 @@
 import dil.semantic.Module;
 import dil.parser.ImportParser;
 import dil.SourceText;
+import dil.Compilation;
 import Settings;
 import common;
 
@@ -227,7 +228,7 @@
   }
 }
 
-void execute(string filePathString, string[] importPaths, string[] strRegexps,
+void execute(string filePathString, CompilationContext context, string[] strRegexps,
              uint levels, string siStyle, string piStyle, IGraphOption options)
 {
   // Init regular expressions.
@@ -235,15 +236,14 @@
   foreach (strRegexp; strRegexps)
     regexps ~= new RegExp(strRegexp);
 
-  // Add directory of file and global directories to import paths.
+  // Add the directory of the file to the import paths.
   auto filePath = new FilePath(filePathString);
   auto fileDir = filePath.folder();
-  importPaths ~= fileDir;
-  importPaths ~= GlobalSettings.importPaths;
+  context.importPaths ~= fileDir;
 
   auto gbuilder = new GraphBuilder;
 
-  gbuilder.importPaths = importPaths;
+  gbuilder.importPaths = context.importPaths;
   gbuilder.options = options;
   gbuilder.filterPredicate = (string moduleFQNPath) {
     foreach (rx; regexps)
--- a/trunk/src/dil/Compilation.d	Wed Feb 20 22:47:33 2008 +0100
+++ b/trunk/src/dil/Compilation.d	Wed Feb 20 23:13:56 2008 +0100
@@ -24,7 +24,7 @@
     this.parent = parent;
     if (parent)
     {
-      this.importPaths = parent.importPaths;
+      this.importPaths = parent.importPaths.dup;
       this.debugLevel = parent.debugLevel;
       this.versionLevel = parent.versionLevel;
       this.releaseBuild = parent.releaseBuild;
--- a/trunk/src/main.d	Wed Feb 20 22:47:33 2008 +0100
+++ b/trunk/src/main.d	Wed Feb 20 23:13:56 2008 +0100
@@ -154,16 +154,18 @@
     break;
   case "importgraph", "igraph":
     string filePath;
-    string[] includePaths;
     string[] regexps;
     string siStyle = "dashed"; // static import style
     string piStyle = "bold";   // public import style
     uint levels;
     IGraphOption options;
+    auto context = newCompilationContext();
     foreach (arg; args[2..$])
     {
-      if (strbeg(arg, "-I"))
-        includePaths ~= arg[2..$];
+      if (parseDebugOrVersion(arg, context))
+      {}
+      else if (strbeg(arg, "-I"))
+        context.importPaths ~= arg[2..$];
       else if(strbeg(arg, "-r"))
         regexps ~= arg[2..$];
       else if(strbeg(arg, "-l"))
@@ -197,7 +199,7 @@
           filePath = arg;
         }
     }
-    cmd.ImportGraph.execute(filePath, includePaths, regexps, levels, siStyle, piStyle, options);
+    cmd.ImportGraph.execute(filePath, context, regexps, levels, siStyle, piStyle, options);
     break;
   case "stats", "statistics":
     char[][] filePaths;