diff trunk/src/dil/Declarations.d @ 570:3ebdc510a7fc

Added semantic() to InterfaceDeclaration.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 29 Dec 2007 23:02:46 +0100
parents 184a8d8bad2e
children 35a8926253c8
line wrap: on
line diff
--- a/trunk/src/dil/Declarations.d	Sat Dec 29 21:57:33 2007 +0100
+++ b/trunk/src/dil/Declarations.d	Sat Dec 29 23:02:46 2007 +0100
@@ -289,6 +289,22 @@
     this.bases = bases;
     this.decls = decls;
   }
+
+  alias dil.Symbols.Interface InterfaceSymbol;
+
+  InterfaceSymbol interface_; /// The interface symbol for this declaration.
+
+  override void semantic(Scope scop)
+  {
+    if (interface_)
+      return;
+    interface_ = new InterfaceSymbol(name, this);
+    // Create a new scope.
+    scop = scop.push(interface_);
+    // Continue semantic analysis.
+    decls.semantic(scop);
+    scop.pop();
+  }
 }
 
 class StructDeclaration : Declaration
@@ -320,7 +336,7 @@
   {
     if (struct_)
       return;
-    struct_ = new Struct(name);
+    struct_ = new Struct(name, this);
     // Create a new scope.
     scop = scop.push(struct_);
     // Continue semantic analysis.
@@ -477,6 +493,10 @@
     }
     assert(type !is null);
 
+    // Check for interface.
+    if (scop.isInterface)
+      return scop.error(begin, "an interface can't have member variables");
+
     // Iterate over variable identifiers in this declaration.
     foreach (i, ident; idents)
     {