# HG changeset patch # User aziz # Date 1186663984 0 # Node ID 1ea6a6d97ec6abdcd6576f80a7d3a35bfd54a95e # Parent 418c6548ce17f996b29b9cb1cd12198ee19b4f9c - Assigning to Node.children in several constructors that inherit from Node. diff -r 418c6548ce17 -r 1ea6a6d97ec6 trunk/src/Statements.d --- a/trunk/src/Statements.d Thu Aug 09 12:00:03 2007 +0000 +++ b/trunk/src/Statements.d Thu Aug 09 12:53:04 2007 +0000 @@ -19,11 +19,13 @@ class Statements : Statement { - Statement[] ss; + this() + { + mixin(set_kind); + } void opCatAssign(Statement s) { - mixin(set_kind); - this.ss ~= s; + this.children ~= s; } } @@ -52,6 +54,11 @@ this() { super(NodeCategory.Other); + this.children = [funcBody]; + if (inBody) + this.children ~= inBody; + if (outBody) + this.children ~= outBody; mixin(set_kind); } } @@ -62,6 +69,7 @@ this(Statement s) { mixin(set_kind); + this.children = [s]; this.s = s; } } @@ -73,6 +81,7 @@ this(Token* label, Statement s) { mixin(set_kind); + this.children = [s]; this.label = label; this.s = s; } @@ -84,6 +93,7 @@ this(Expression expression) { mixin(set_kind); + this.children = [expression]; this.expression = expression; } } @@ -94,6 +104,7 @@ this(Declaration declaration) { mixin(set_kind); + this.children = [declaration]; this.declaration = declaration; } } @@ -107,18 +118,20 @@ this(Statement variable, Expression condition, Statement ifBody, Statement elseBody) { mixin(set_kind); + if (variable) + this.children ~= variable; + else + this.children ~= condition; + this.children ~= ifBody; + if (elseBody) + this.children ~= elseBody; this.variable = variable; this.condition = condition; this.ifBody = ifBody; this.elseBody = elseBody; } } -/+ -class ConditionalStatement : Statement -{ -} -+/ class WhileStatement : Statement { Expression condition; @@ -126,6 +139,7 @@ this(Expression condition, Statement whileBody) { mixin(set_kind); + this.children = [cast(Node)condition, whileBody]; this.condition = condition; this.whileBody = whileBody; } @@ -138,6 +152,7 @@ this(Expression condition, Statement doBody) { mixin(set_kind); + this.children = [cast(Node)condition, doBody]; this.condition = condition; this.doBody = doBody; } @@ -152,6 +167,13 @@ this(Statement init, Expression condition, Expression increment, Statement forBody) { mixin(set_kind); + if (init) + this.children ~= init; + if (condition) + this.children ~= condition; + if (increment) + this.children ~= increment; + this.children ~= forBody; this.init = init; this.condition = condition; this.increment = increment; @@ -169,6 +191,7 @@ this(TOK tok, Parameters params, Expression aggregate, Statement forBody) { mixin(set_kind); + this.children = [cast(Node)params, aggregate, forBody]; this.tok = tok; this.params = params; this.aggregate = aggregate; @@ -188,6 +211,7 @@ this(TOK tok, Parameters params, Expression lower, Expression upper, Statement forBody) { mixin(set_kind); + this.children = [cast(Node)params, lower, upper, forBody]; this.tok = tok; this.params = params; this.lower = lower; @@ -205,6 +229,7 @@ this(Expression condition, Statement switchBody) { mixin(set_kind); + this.children = [cast(Node)condition, switchBody]; this.condition = condition; this.switchBody = switchBody; } @@ -218,6 +243,7 @@ this(Expression[] values, Statement caseBody) { mixin(set_kind); + this.children = cast(Node[])values ~ [caseBody]; this.values = values; this.caseBody = caseBody; } @@ -229,6 +255,7 @@ this(Statement defaultBody) { mixin(set_kind); + this.children = [defaultBody]; this.defaultBody = defaultBody; } } @@ -259,6 +286,7 @@ this(Expression expr) { mixin(set_kind); + this.children = [expr]; this.expr = expr; } } @@ -270,6 +298,7 @@ this(Token* ident, Expression caseExpr) { mixin(set_kind); + this.children = [caseExpr]; this.ident = ident; this.caseExpr = caseExpr; } @@ -282,6 +311,7 @@ this(Expression expr, Statement withBody) { mixin(set_kind); + this.children = [cast(Node)expr, withBody]; this.expr = expr; this.withBody = withBody; } @@ -294,6 +324,7 @@ this(Expression expr, Statement withBody) { mixin(set_kind); + this.children = [cast(Node)expr, syncBody]; this.expr = expr; this.syncBody = syncBody; } @@ -307,6 +338,11 @@ this(Statement tryBody, CatchBody[] catchBodies, FinallyBody finallyBody) { mixin(set_kind); + this.children = [tryBody]; + if (catchBodies.length) + this.children ~= catchBodies; + if (finallyBody) + this.children ~= finallyBody; this.tryBody = tryBody; this.catchBodies = catchBodies; this.finallyBody = finallyBody; @@ -320,6 +356,7 @@ this(Parameter param, Statement catchBody) { mixin(set_kind); + this.children = [cast(Node)param, catchBody]; this.param = param; this.catchBody = catchBody; } @@ -331,6 +368,7 @@ this(Statement finallyBody) { mixin(set_kind); + this.children = [finallyBody]; this.finallyBody = finallyBody; } } @@ -342,6 +380,7 @@ this(Token* condition, Statement scopeBody) { mixin(set_kind); + this.children = [scopeBody]; this.condition = condition; this.scopeBody = scopeBody; } @@ -353,6 +392,7 @@ this(Expression expr) { mixin(set_kind); + this.children = [expr]; this.expr = expr; } } @@ -363,6 +403,8 @@ this(Statement volatileBody) { mixin(set_kind); + if (volatileBody) + this.children = [volatileBody]; this.volatileBody = volatileBody; } } @@ -373,6 +415,7 @@ this(Statements statements) { mixin(set_kind); + this.children = [statements]; this.statements = statements; } } @@ -384,6 +427,7 @@ this(Token* ident, Expression[] operands) { mixin(set_kind); + this.children = operands; this.ident = ident; this.operands = operands; } @@ -406,6 +450,9 @@ this(Token* ident, Expression[] args, Statement pragmaBody) { mixin(set_kind); + if (args.length) + this.children = args; + this.children ~= pragmaBody; this.ident = ident; this.args = args; this.pragmaBody = pragmaBody; @@ -414,12 +461,13 @@ class MixinStatement : Statement { - Expression[] templateIdent; + Expression[] templateIdents; Token* mixinIdent; - this(Expression[] templateIdent, Token* mixinIdent) + this(Expression[] templateIdents, Token* mixinIdent) { mixin(set_kind); - this.templateIdent = templateIdent; + this.children = templateIdents; + this.templateIdents = templateIdents; this.mixinIdent = mixinIdent; } } @@ -431,6 +479,9 @@ this(Expression condition, Statement ifBody, Statement elseBody) { mixin(set_kind); + this.children = [cast(Node)condition, ifBody]; + if (elseBody) + this.children ~= elseBody; this.condition = condition; this.ifBody = ifBody; this.elseBody = elseBody; @@ -443,6 +494,9 @@ this(Expression condition, Expression message) { mixin(set_kind); + this.children = [condition]; + if (message) + this.children ~= message; this.condition = condition; this.message = message; } @@ -455,6 +509,9 @@ this(Token* cond, Statement debugBody, Statement elseBody) { mixin(set_kind); + this.children = [debugBody]; + if (elseBody) + this.children ~= elseBody; this.cond = cond; this.debugBody = debugBody; this.elseBody = elseBody; @@ -468,6 +525,9 @@ this(Token* cond, Statement versionBody, Statement elseBody) { mixin(set_kind); + this.children = [versionBody]; + if (elseBody) + this.children ~= [elseBody]; this.cond = cond; this.versionBody = versionBody; this.elseBody = elseBody; @@ -481,6 +541,7 @@ this(TOK tok, Statement statement) { mixin(set_kind); + this.children = [statement]; this.tok = tok; this.statement = statement; } @@ -491,8 +552,8 @@ Linkage linkage; this(Linkage linkage, Statement statement) { + super(TOK.Extern, statement); mixin(set_kind); - super(TOK.Extern, statement); this.linkage = linkage; } }