changeset 394:6440da4adb07

Fixed forward references of enum MID complaints by compiler. Fix in cmd.Generate: token whitespace mustn't be printed in printToken().
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Wed, 19 Sep 2007 12:20:11 +0200
parents fce1e6133dac
children ac9cd48151b6
files trunk/src/cmd/Generate.d trunk/src/dil/Messages.d trunk/src/dil/Settings.d
diffstat 3 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/cmd/Generate.d	Mon Sep 17 21:57:11 2007 +0200
+++ b/trunk/src/cmd/Generate.d	Wed Sep 19 12:20:11 2007 +0200
@@ -333,6 +333,10 @@
   {
     token = token.next;
 
+    // Print whitespace.
+    if (token.ws)
+      print(token.ws[0..token.start - token.ws]);
+
     Node[]* nodes = token in beginNodes;
 
     if (nodes)
@@ -382,6 +386,9 @@
   while (token.type != TOK.EOF)
   {
     token = token.next;
+    // Print whitespace.
+    if (token.ws)
+      print(token.ws[0..token.start - token.ws]);
     printToken(token, tags, print);
   }
   print(\n~tags[DocPart.SrcEnd])(\n~tags[DocPart.Tail]);
@@ -392,10 +399,6 @@
   alias DocPart DP;
   string srcText = xml_escape(token.srcText);
 
-  // Print whitespace.
-  if (token.ws)
-    print(token.ws[0..token.start - token.ws]);
-
   switch(token.type)
   {
   case TOK.Identifier:
--- a/trunk/src/dil/Messages.d	Mon Sep 17 21:57:11 2007 +0200
+++ b/trunk/src/dil/Messages.d	Wed Sep 19 12:20:11 2007 +0200
@@ -3,7 +3,6 @@
   License: GPL3
 +/
 module dil.Messages;
-import dil.Settings;
 import common;
 
 /// Index into table of compiler messages.
@@ -70,10 +69,18 @@
   HelpImportGraph,
 }
 
+private string[] messages;
+
+package void SetMessages(string[] msgs)
+{
+  assert(MID.max+1 == msgs.length);
+  messages = msgs;
+}
+
 string GetMsg(MID mid)
 {
-  assert(mid < GlobalSettings.messages.length);
-  return GlobalSettings.messages[mid];
+  assert(mid < messages.length);
+  return messages[mid];
 }
 
 char[] FormatMsg(MID mid, ...)
--- a/trunk/src/dil/Settings.d	Mon Sep 17 21:57:11 2007 +0200
+++ b/trunk/src/dil/Settings.d	Wed Sep 19 12:20:11 2007 +0200
@@ -137,5 +137,6 @@
     if (messages.length != MID.max+1)
       throw new Exception(Format("messages table in {0} must exactly have {1} entries, but {2} were found.", fileName, MID.max+1, messages.length));
     GlobalSettings.messages = messages;
+    dil.Messages.SetMessages(messages);
   }
 }