changeset 159:5aa877506db0

- Added enum Linkage. - Changed type of linkage member in ExternDeclaration to Linkage. - Parsing LinkageType correctly now.
author aziz
date Fri, 13 Jul 2007 12:15:00 +0000
parents 759f437313f9
children c21192e8be2b
files trunk/src/Declarations.d trunk/src/Parser.d trunk/src/Types.d
diffstat 3 files changed, 38 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/Declarations.d	Fri Jul 13 11:42:04 2007 +0000
+++ b/trunk/src/Declarations.d	Fri Jul 13 12:15:00 2007 +0000
@@ -299,8 +299,8 @@
 
 class ExternDeclaration : AttributeDeclaration
 {
-  string linkage;
-  this(string linkage, Declaration[] decls)
+  Linkage linkage;
+  this(Linkage linkage, Declaration[] decls)
   {
     super(TOK.Extern, decls);
     this.linkage = linkage;
--- a/trunk/src/Parser.d	Fri Jul 13 11:42:04 2007 +0000
+++ b/trunk/src/Parser.d	Fri Jul 13 12:15:00 2007 +0000
@@ -240,11 +240,34 @@
     {
     case T.Extern:
       nT();
-      string linkage;
+      Linkage linkage;
       if (token.type == T.LParen)
       {
         nT();
-        linkage = requireIdentifier();
+        auto ident = requireIdentifier();
+        switch (ident)
+        {
+        case "C":
+          if (token.type == T.PlusPlus)
+          {
+            nT();
+            linkage = Linkage.Cpp;
+            break;
+          }
+          linkage = Linkage.C;
+          break;
+        case "D":
+          linkage = Linkage.D;
+          break;
+        case "Windows":
+          linkage = Linkage.Windows;
+          break;
+        case "Pascal":
+          linkage = Linkage.Pascal;
+          break;
+        default:
+          // TODO: issue error msg. Unrecognized LinkageType.
+        }
         require(T.RParen);
       }
       decl = new ExternDeclaration(linkage, parseDeclarationsBlock());
@@ -1050,6 +1073,7 @@
     Expression[] templateIdent;
     string mixinIdent;
 
+    // This code is similar to parseDotListType().
     if (token.type == T.Dot)
     {
       nT();
--- a/trunk/src/Types.d	Fri Jul 13 11:42:04 2007 +0000
+++ b/trunk/src/Types.d	Fri Jul 13 12:15:00 2007 +0000
@@ -6,6 +6,16 @@
 import Token;
 import Expressions;
 
+enum Linkage
+{
+  Invalid,
+  C,
+  Cpp,
+  D,
+  Windows,
+  Pascal
+}
+
 enum StorageClass
 {
   None         = 0,