# HG changeset patch # User Aziz K?ksal # Date 1198967185 -3600 # Node ID 35a8926253c87edca462cb78dbea2ea6f2b68442 # Parent 3ebdc510a7fcde21fe1e0ab94e4245bd366819d6 Added AggregateDeclaration. diff -r 3ebdc510a7fc -r 35a8926253c8 trunk/src/dil/Declarations.d --- 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; } }