changeset 593:2848ce3becf5

Moved dil.Module to dil.semantic.Module.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 05 Jan 2008 23:58:42 +0100
parents b8dd677e0ace
children 7a9b5074a005
files trunk/src/cmd/ImportGraph.d trunk/src/dil/Module.d trunk/src/dil/SettingsLoader.d trunk/src/dil/semantic/Module.d trunk/src/main.d
diffstat 5 files changed, 143 insertions(+), 142 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/cmd/ImportGraph.d	Sat Jan 05 23:52:41 2008 +0100
+++ b/trunk/src/cmd/ImportGraph.d	Sat Jan 05 23:58:42 2008 +0100
@@ -6,9 +6,9 @@
 
 import dil.ast.Node;
 import dil.ast.Declarations;
+import dil.semantic.Module;
 import dil.Token;
 import dil.File;
-import dil.Module;
 import dil.Settings;
 import tango.text.Regex : RegExp = Regex;
 import tango.io.FilePath;
--- a/trunk/src/dil/Module.d	Sat Jan 05 23:52:41 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-/++
-  Author: Aziz Köksal
-  License: GPL3
-+/
-module dil.Module;
-
-import dil.ast.Node;
-import dil.ast.Declarations;
-import dil.parser.Parser;
-import dil.parser.ImportParser;
-import dil.lexer.Lexer;
-import dil.File;
-import dil.semantic.Scope;
-import dil.semantic.Symbol;
-import dil.semantic.Symbols;
-import dil.Information;
-import tango.io.FilePath;
-import tango.io.FileConst;
-import common;
-
-alias FileConst.PathSeparatorChar dirSep;
-
-class Module : ScopeSymbol
-{
-  bool isLightweight; /// If true an ImportParser is used instead of a full Parser.
-  string filePath; /// Path to the source file.
-  string moduleFQN; /// Fully qualified name of the module.
-  string packageName;
-  string moduleName;
-
-  Declarations root; /// The root of the AST.
-  ImportDeclaration[] imports;
-  ModuleDeclaration moduleDecl;
-  private Parser parser;
-
-  Module[] modules;
-
-  InfoManager infoMan;
-
-  this(string filePath, bool isLightweight = false)
-  {
-    this.sid = SYM.Module;
-
-    this.filePath = filePath;
-    this.isLightweight = isLightweight;
-  }
-
-  this(string filePath, InfoManager infoMan)
-  {
-    this(filePath, false);
-    this.infoMan = infoMan;
-  }
-
-  void parse()
-  {
-    auto sourceText = loadFile(filePath);
-    if (this.isLightweight)
-      this.parser = new ImportParser(sourceText, filePath);
-    else
-      this.parser = new Parser(sourceText, filePath, infoMan);
-
-    this.root = parser.start();
-
-    if (root.children.length)
-    {
-      // moduleDecl will be null if first node can't be cast to ModuleDeclaration.
-      this.moduleDecl = TryCast!(ModuleDeclaration)(root.children[0]);
-      if (moduleDecl)
-      {
-        this.setFQN(moduleDecl.getFQN());
-      }
-      else
-      {
-        // Take base name of file path as module name.
-        auto str = (new FilePath(filePath)).name();
-        if (!Lexer.isReservedIdentifier(str))
-        {
-          this.moduleFQN = moduleName = str;
-        }
-        // else
-        // TODO: error: file name has invalid identifier characters.
-      }
-
-      this.imports = parser.imports;
-    }
-  }
-
-  /// Starts the semantic analysis of this module.
-  void semantic()
-  {
-    if (this.hasErrors)
-      return;
-    // Create module scope.
-    auto scop = new Scope();
-    scop.symbol = this; // Set this module as the scope's symbol.
-    scop.infoMan = this.infoMan;
-    this.root.semantic(scop);
-  }
-
-  /// Returns true if there are errors in the source file.
-  bool hasErrors()
-  {
-    return parser.errors.length || parser.lx.errors.length;
-  }
-
-  string[] getImports()
-  {
-    string[] result;
-    foreach (import_; imports)
-      result ~= import_.getModuleFQNs(dirSep);
-    return result;
-  }
-
-  string getFQN()
-  {
-    return moduleFQN;
-  }
-
-  void setFQN(string moduleFQN)
-  {
-    uint i = moduleFQN.length;
-    if (i != 0) // Don't decrement if string has zero length.
-      i--;
-    // Find last dot.
-    for (; i != 0 && moduleFQN[i] != '.'; i--)
-    {}
-    this.moduleFQN = moduleFQN;
-    this.packageName = moduleFQN[0..i];
-    this.moduleName = moduleFQN[(i == 0 ? 0 : i+1) .. $];
-  }
-
-  string getFQNPath()
-  {
-    if (packageName.length)
-      return packageName ~ dirSep ~ moduleName;
-    else
-      return moduleName;
-  }
-}
--- a/trunk/src/dil/SettingsLoader.d	Sat Jan 05 23:52:41 2008 +0100
+++ b/trunk/src/dil/SettingsLoader.d	Sat Jan 05 23:58:42 2008 +0100
@@ -6,7 +6,8 @@
 
 import dil.Settings;
 import dil.Messages;
-import dil.Module, dil.ast.Node, dil.ast.Declarations, dil.ast.Expressions;
+import dil.ast.Node, dil.ast.Declarations, dil.ast.Expressions;
+import dil.semantic.Module;
 import dil.File;
 import tango.io.FilePath;
 import common;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trunk/src/dil/semantic/Module.d	Sat Jan 05 23:58:42 2008 +0100
@@ -0,0 +1,139 @@
+/++
+  Author: Aziz Köksal
+  License: GPL3
++/
+module dil.semantic.Module;
+
+import dil.ast.Node;
+import dil.ast.Declarations;
+import dil.parser.Parser;
+import dil.parser.ImportParser;
+import dil.lexer.Lexer;
+import dil.File;
+import dil.semantic.Scope;
+import dil.semantic.Symbol;
+import dil.semantic.Symbols;
+import dil.Information;
+import tango.io.FilePath;
+import tango.io.FileConst;
+import common;
+
+alias FileConst.PathSeparatorChar dirSep;
+
+class Module : ScopeSymbol
+{
+  bool isLightweight; /// If true an ImportParser is used instead of a full Parser.
+  string filePath; /// Path to the source file.
+  string moduleFQN; /// Fully qualified name of the module.
+  string packageName;
+  string moduleName;
+
+  Declarations root; /// The root of the AST.
+  ImportDeclaration[] imports;
+  ModuleDeclaration moduleDecl;
+  private Parser parser;
+
+  Module[] modules;
+
+  InfoManager infoMan;
+
+  this(string filePath, bool isLightweight = false)
+  {
+    this.sid = SYM.Module;
+
+    this.filePath = filePath;
+    this.isLightweight = isLightweight;
+  }
+
+  this(string filePath, InfoManager infoMan)
+  {
+    this(filePath, false);
+    this.infoMan = infoMan;
+  }
+
+  void parse()
+  {
+    auto sourceText = loadFile(filePath);
+    if (this.isLightweight)
+      this.parser = new ImportParser(sourceText, filePath);
+    else
+      this.parser = new Parser(sourceText, filePath, infoMan);
+
+    this.root = parser.start();
+
+    if (root.children.length)
+    {
+      // moduleDecl will be null if first node can't be cast to ModuleDeclaration.
+      this.moduleDecl = TryCast!(ModuleDeclaration)(root.children[0]);
+      if (moduleDecl)
+      {
+        this.setFQN(moduleDecl.getFQN());
+      }
+      else
+      {
+        // Take base name of file path as module name.
+        auto str = (new FilePath(filePath)).name();
+        if (!Lexer.isReservedIdentifier(str))
+        {
+          this.moduleFQN = moduleName = str;
+        }
+        // else
+        // TODO: error: file name has invalid identifier characters.
+      }
+
+      this.imports = parser.imports;
+    }
+  }
+
+  /// Starts the semantic analysis of this module.
+  void semantic()
+  {
+    if (this.hasErrors)
+      return;
+    // Create module scope.
+    auto scop = new Scope();
+    scop.symbol = this; // Set this module as the scope's symbol.
+    scop.infoMan = this.infoMan;
+    this.root.semantic(scop);
+  }
+
+  /// Returns true if there are errors in the source file.
+  bool hasErrors()
+  {
+    return parser.errors.length || parser.lx.errors.length;
+  }
+
+  string[] getImports()
+  {
+    string[] result;
+    foreach (import_; imports)
+      result ~= import_.getModuleFQNs(dirSep);
+    return result;
+  }
+
+  string getFQN()
+  {
+    return moduleFQN;
+  }
+
+  void setFQN(string moduleFQN)
+  {
+    uint i = moduleFQN.length;
+    if (i != 0) // Don't decrement if string has zero length.
+      i--;
+    // Find last dot.
+    for (; i != 0 && moduleFQN[i] != '.'; i--)
+    {}
+    this.moduleFQN = moduleFQN;
+    this.packageName = moduleFQN[0..i];
+    this.moduleName = moduleFQN[(i == 0 ? 0 : i+1) .. $];
+  }
+
+  string getFQNPath()
+  {
+    if (packageName.length)
+      return packageName ~ dirSep ~ moduleName;
+    else
+      return moduleName;
+  }
+}
--- a/trunk/src/main.d	Sat Jan 05 23:52:41 2008 +0100
+++ b/trunk/src/main.d	Sat Jan 05 23:58:42 2008 +0100
@@ -11,7 +11,7 @@
 import dil.Settings;
 import dil.SettingsLoader;
 import dil.CompilerInfo;
-import dil.Module;
+import dil.semantic.Module;
 import dil.ast.Declarations, dil.ast.Expressions, dil.ast.Node;
 import dil.Information;
 import dil.File;