diff trunk/src/dil/lexer/Token.d @ 675:e7811328e6c7

Made Token.getLocation() a template function and added two aliases.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Fri, 18 Jan 2008 18:18:14 +0100
parents c65b11c2074c
children ff6971637f88
line wrap: on
line diff
--- a/trunk/src/dil/lexer/Token.d	Fri Jan 18 17:25:37 2008 +0100
+++ b/trunk/src/dil/lexer/Token.d	Fri Jan 18 18:18:14 2008 +0100
@@ -193,14 +193,22 @@
   }
 
   /// Returns the Location of this token.
-  Location getLocation()
+  Location getLocation(bool realLocation)()
   {
     auto search_t = this.prev;
     // Find previous newline token.
     while (search_t.type != TOK.Newline)
       search_t = search_t.prev;
-    auto filePath  = search_t.newline.filePaths.setPath;
-    auto lineNum   = search_t.newline.oriLineNum - search_t.newline.setLineNum;
+    static if (realLocation)
+    {
+      auto filePath  = search_t.newline.filePaths.oriPath;
+      auto lineNum   = search_t.newline.oriLineNum;
+    }
+    else
+    {
+      auto filePath  = search_t.newline.filePaths.setPath;
+      auto lineNum   = search_t.newline.oriLineNum - search_t.newline.setLineNum;
+    }
     auto lineBegin = search_t.end;
     // Determine actual line begin and line number.
     while (1)
@@ -227,6 +235,9 @@
     return new Location(filePath, lineNum, lineBegin, this.start);
   }
 
+  alias getLocation!(true) getRealLocation;
+  alias getLocation!(false) getErrorLocation;
+
   uint lineCount()
   {
     uint count = 1;