# HG changeset patch # User aziz # Date 1186677005 0 # Node ID 75b47c71a34c60871a666a65401c37bc76fccbf2 # Parent 1ea6a6d97ec6abdcd6576f80a7d3a35bfd54a95e - Assigning to Node.children in several constructors that inherit from Node. diff -r 1ea6a6d97ec6 -r 75b47c71a34c trunk/src/Parser.d --- a/trunk/src/Parser.d Thu Aug 09 12:53:04 2007 +0000 +++ b/trunk/src/Parser.d Thu Aug 09 16:30:05 2007 +0000 @@ -4009,11 +4009,12 @@ TemplateParameters parseTemplateParameterList() { auto begin = token; + auto tparams = new TemplateParameters; + require(T.LParen); if (token.type == T.RParen) - return null; - - auto tparams = new TemplateParameters; + return tparams; + while (1) { auto paramBegin = token; diff -r 1ea6a6d97ec6 -r 75b47c71a34c trunk/src/Types.d --- a/trunk/src/Types.d Thu Aug 09 12:53:04 2007 +0000 +++ b/trunk/src/Types.d Thu Aug 09 16:30:05 2007 +0000 @@ -51,6 +51,9 @@ { super(NodeCategory.Other); mixin(set_kind); + this.children = [type]; + if (assignExpr) + this.children ~= assignExpr; StorageClass stc; if (stcTok !is null) @@ -90,8 +93,6 @@ class Parameters : Node { - Parameter[] items; - this() { super(NodeCategory.Other); @@ -100,16 +101,19 @@ bool hasVariadic() { - if (items.length != 0) + if (children.length != 0) return items[$-1].isVariadic(); return false; } void opCatAssign(Parameter param) - { items ~= param; } + { children ~= param; } + + Parameter[] items() + { return cast(Parameter[])children; } size_t length() - { return items.length; } + { return children.length; } } @@ -131,6 +135,7 @@ { super(NodeCategory.Other); mixin(set_kind); + this.children = [type]; this.prot = prot; this.type = type; } @@ -155,6 +160,16 @@ { super(NodeCategory.Other); mixin(set_kind); + if (valueType) + this.children ~= valueType; + if (specType) + this.children ~= specType; + if (defType) + this.children ~= defType; + if (specValue) + this.children ~= specValue; + if (defValue) + this.children ~= defValue; this.tp = tp; this.valueType = valueType; this.ident = ident; @@ -167,8 +182,6 @@ class TemplateParameters : Node { - TemplateParameter[] params; - this() { super(NodeCategory.Other); @@ -177,14 +190,17 @@ void opCatAssign(TemplateParameter parameter) { - params ~= parameter; + this.children ~= parameter; + } + + TemplateParameter[] items() + { + return cast(TemplateParameter[])children; } } class TemplateArguments : Node { - Node[] args; - this() { super(NodeCategory.Other); @@ -193,7 +209,7 @@ void opCatAssign(Node argument) { - args ~= argument; + this.children ~= argument; } } @@ -248,6 +264,8 @@ this(TID tid, Type next) { super(NodeCategory.Type); + if (next) + this.children ~= next; this.tid = tid; this.next = next; } @@ -278,6 +296,7 @@ { super(TID.DotList); mixin(set_kind); + this.children ~= dotList; this.dotList = dotList; } } @@ -300,6 +319,7 @@ { super(TID.Typeof); mixin(set_kind); + this.children ~= e; this.e = e; } } @@ -312,6 +332,7 @@ { super(TID.TemplateInstance); mixin(set_kind); + this.children ~= targs; this.ident = ident; this.targs = targs; } @@ -337,14 +358,16 @@ } this(Type t, Expression e, Expression e2) { - this(t); + this.children = [e, e2]; this.e = e; this.e2 = e2; + this(t); } this(Type t, Type assocType) { + this.children = [assocType]; + this.assocType = assocType; this(t); - this.assocType = assocType; } } @@ -356,6 +379,7 @@ { super(TID.Function); mixin(set_kind); + this.children = [cast(Node)returnType, parameters]; this.returnType = returnType; this.parameters = parameters; } @@ -369,6 +393,7 @@ { super(TID.Delegate); mixin(set_kind); + this.children = [cast(Node)returnType, parameters]; this.returnType = returnType; this.parameters = parameters; }