changeset 571:35a8926253c8

Added AggregateDeclaration.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 29 Dec 2007 23:26:25 +0100
parents 3ebdc510a7fc
children 751d84733e07
files trunk/src/dil/Declarations.d
diffstat 1 files changed, 22 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/dil/Declarations.d	Sat Dec 29 23:02:46 2007 +0100
+++ b/trunk/src/dil/Declarations.d	Sat Dec 29 23:26:25 2007 +0100
@@ -249,45 +249,47 @@
   }
 }
 
-class ClassDeclaration : Declaration
+abstract class AggregateDeclaration : Declaration
 {
   Identifier* name;
   TemplateParameters tparams;
+  Declarations decls;
+  this(Identifier* name, TemplateParameters tparams, Declarations decls)
+  {
+    super.hasBody = decls !is null;
+    this.name = name;
+    this.tparams = tparams;
+    this.decls = decls;
+  }
+}
+
+class ClassDeclaration : AggregateDeclaration
+{
   BaseClass[] bases;
-  Declarations decls;
   this(Identifier* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls)
   {
-    super.hasBody = decls !is null;
+    super(name, tparams, decls);
     mixin(set_kind);
     addOptChild(tparams);
     addOptChildren(bases);
     addOptChild(decls);
 
-    this.name = name;
-    this.tparams = tparams;
     this.bases = bases;
-    this.decls = decls;
   }
 }
 
-class InterfaceDeclaration : Declaration
+class InterfaceDeclaration : AggregateDeclaration
 {
-  Identifier* name;
-  TemplateParameters tparams;
   BaseClass[] bases;
-  Declarations decls;
   this(Identifier* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls)
   {
-    super.hasBody = decls !is null;
+    super(name, tparams, decls);
     mixin(set_kind);
     addOptChild(tparams);
     addOptChildren(bases);
     addOptChild(decls);
 
-    this.name = name;
-    this.tparams = tparams;
     this.bases = bases;
-    this.decls = decls;
   }
 
   alias dil.Symbols.Interface InterfaceSymbol;
@@ -302,27 +304,20 @@
     // Create a new scope.
     scop = scop.push(interface_);
     // Continue semantic analysis.
-    decls.semantic(scop);
+    decls && decls.semantic(scop);
     scop.pop();
   }
 }
 
-class StructDeclaration : Declaration
+class StructDeclaration : AggregateDeclaration
 {
-  Identifier* name;
-  TemplateParameters tparams;
-  Declarations decls;
   uint alignSize;
   this(Identifier* name, TemplateParameters tparams, Declarations decls)
   {
-    super.hasBody = decls !is null;
+    super(name, tparams, decls);
     mixin(set_kind);
     addOptChild(tparams);
     addOptChild(decls);
-
-    this.name = name;
-    this.tparams = tparams;
-    this.decls = decls;
   }
 
   void setAlignSize(uint alignSize)
@@ -340,26 +335,19 @@
     // Create a new scope.
     scop = scop.push(struct_);
     // Continue semantic analysis.
-    decls.semantic(scop);
+    decls && decls.semantic(scop);
     scop.pop();
   }
 }
 
-class UnionDeclaration : Declaration
+class UnionDeclaration : AggregateDeclaration
 {
-  Identifier* name;
-  TemplateParameters tparams;
-  Declarations decls;
   this(Identifier* name, TemplateParameters tparams, Declarations decls)
   {
-    super.hasBody = decls !is null;
+    super(name, tparams, decls);
     mixin(set_kind);
     addOptChild(tparams);
     addOptChild(decls);
-
-    this.name = name;
-    this.tparams = tparams;
-    this.decls = decls;
   }
 }