diff src/dil/semantic/Module.d @ 818:372fa4fbbb1d

Added error messages and applied fixes.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Thu, 13 Mar 2008 02:21:26 +0100
parents e6fb7ed87d3a
children 80eb3251e010
line wrap: on
line diff
--- a/src/dil/semantic/Module.d	Wed Mar 12 23:33:14 2008 +0100
+++ b/src/dil/semantic/Module.d	Thu Mar 13 02:21:26 2008 +0100
@@ -95,25 +95,28 @@
     this.root = parser.start();
     this.imports = parser.imports;
 
-    if (root.children.length)
+    // Set the fully qualified name of this module.
+    if (this.root.children.length)
     { // moduleDecl will be null if first node isn't a ModuleDeclaration.
-      this.moduleDecl = root.children[0].Is!(ModuleDeclaration);
+      this.moduleDecl = this.root.children[0].Is!(ModuleDeclaration);
       if (this.moduleDecl)
-        this.setFQN(moduleDecl.getFQN());
+        this.setFQN(moduleDecl.getFQN()); // E.g.: dil.ast.Node
     }
 
     if (!this.moduleFQN.length)
-    { // Take base name of file path as module name.
-      auto str = (new FilePath(filePath)).name();
+    { // Take the base name of the file as the module name.
+      auto str = (new FilePath(filePath)).name(); // E.g.: Node
       if (!Lexer.isValidUnreservedIdentifier(str))
       {
-        auto location = parser.lexer.firstToken().getErrorLocation();
+        auto location = this.firstToken().getErrorLocation();
         auto msg = Format(MSG.InvalidModuleName, str);
         infoMan ~= new LexerError(location, msg);
-        str = "__module_name";
+        str = IdTable.genModuleID().str;
       }
       this.moduleFQN = this.moduleName = str;
     }
+    assert(this.moduleFQN.length);
+
     // Set the symbol name.
     this.name = IdTable.lookup(this.moduleName);
   }