Mercurial > projects > dil
changeset 293:418c6548ce17
- Assigning to Node.children in several constructors that inherit from Node.
author | aziz |
---|---|
date | Thu, 09 Aug 2007 12:00:03 +0000 |
parents | 076152e945e0 |
children | 1ea6a6d97ec6 |
files | trunk/src/Expressions.d trunk/src/Parser.d |
diffstat | 2 files changed, 55 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/Expressions.d Thu Aug 09 11:13:04 2007 +0000 +++ b/trunk/src/Expressions.d Thu Aug 09 12:00:03 2007 +0000 @@ -31,6 +31,7 @@ Token* tok; this(Expression left, Expression right, Token* tok) { + this.children = [left, right]; this.left = left; this.right = right; this.tok = tok; @@ -40,10 +41,11 @@ class CondExpression : BinaryExpression { Expression condition; - this(Expression condition, Expression left, Expression right) + this(Expression condition, Expression left, Expression right, Token* tok) { - super(left, right, null); + super(left, right, tok); mixin(set_kind); + this.children ~= [condition]; this.condition = condition; } } @@ -337,6 +339,7 @@ Expression e; this(Expression e) { + this.children ~= e; this.e = e; } } @@ -452,6 +455,7 @@ { super(e); mixin(set_kind); + this.children ~= [dotList]; this.dotList = dotList; } } @@ -463,6 +467,7 @@ { super(e); mixin(set_kind); + this.children ~= args; this.args = args; } } @@ -476,6 +481,11 @@ { /*super(e);*/ mixin(set_kind); + if (newArgs.length) + this.children ~= newArgs; + this.children ~= type; + if (ctorArgs.length) + this.children ~= ctorArgs; this.newArgs = newArgs; this.type = type; this.ctorArgs = ctorArgs; @@ -492,6 +502,14 @@ { /*super(e);*/ mixin(set_kind); + if (newArgs.length) + this.children ~= newArgs; + if (bases.length) + this.children ~= bases; + if (ctorArgs.length) + this.children ~= ctorArgs; + if (decls.length) + this.children ~= decls; this.newArgs = newArgs; this.bases = bases; this.ctorArgs = ctorArgs; @@ -513,6 +531,7 @@ Type type; this(Expression e, Type type) { + this.children = [type]; super(e); mixin(set_kind); this.type = type; @@ -526,6 +545,7 @@ { super(e); mixin(set_kind); + this.children ~= args; this.args = args; } } @@ -537,6 +557,7 @@ { super(e); mixin(set_kind); + this.children ~= [left, right]; this.left = left; this.right = right; } @@ -574,6 +595,7 @@ this(Expression[] items) { mixin(set_kind); + this.children = items; this.items = items; } } @@ -585,6 +607,7 @@ this(Token* ident, TemplateArguments targs) { mixin(set_kind); + this.children = [targs]; this.ident = ident; this.targs = targs; } @@ -678,6 +701,7 @@ this(Expression[] values) { mixin(set_kind); + this.children = values; this.values = values; } } @@ -687,7 +711,10 @@ Expression[] keys, values; this(Expression[] keys, Expression[] values) { + assert(keys.length == values.length); mixin(set_kind); + foreach (i, key; keys) + this.children ~= [key, values[i]]; this.keys = keys; this.values = values; } @@ -699,6 +726,7 @@ this(Expression expr, Expression msg) { mixin(set_kind); + this.children = [expr, msg]; this.expr = expr; this.msg = msg; } @@ -710,6 +738,7 @@ this(Expression expr) { mixin(set_kind); + this.children = [expr]; this.expr = expr; } } @@ -720,6 +749,7 @@ this(Expression expr) { mixin(set_kind); + this.children = [expr]; this.expr = expr; } } @@ -730,6 +760,7 @@ this(Type type) { mixin(set_kind); + this.children = [type]; this.type = type; } } @@ -741,6 +772,7 @@ this(Type type, Token* ident) { mixin(set_kind); + this.children = [type]; this.type = type; this.ident = ident; } @@ -752,6 +784,7 @@ this(Type type) { mixin(set_kind); + this.children = [type]; this.type = type; } } @@ -765,6 +798,9 @@ this(Type type, Token* ident, Token* opTok, Token* specTok, Type specType) { mixin(set_kind); + this.children = [type]; + if (specType) + this.children ~= specType; this.type = type; this.ident = ident; this.opTok = opTok; @@ -782,20 +818,25 @@ this() { mixin(set_kind); + if (returnType) + this.children ~= returnType; + if (parameters) + this.children ~= parameters; + this.children ~= funcBody; } this(Type returnType, Parameters parameters, FunctionBody funcBody) { - this(); this.returnType = returnType; this.parameters = parameters; this.funcBody = funcBody; + this(); } this(FunctionBody funcBody) { + this.funcBody = funcBody; this(); - this.funcBody = funcBody; } } @@ -808,6 +849,7 @@ this(typeof(ident) ident, typeof(targs) targs) { mixin(set_kind); + this.children = [targs]; this.ident = ident; this.targs = targs; } @@ -828,7 +870,10 @@ Expression[] values; this(Expression[] keys, Expression[] values) { + assert(keys.length == values.length); mixin(set_kind); + foreach (i, key; keys) + this.children ~= [key, values[i]]; this.keys = keys; this.values = values; } @@ -841,6 +886,7 @@ this(Token*[] idents, Expression[] values) { mixin(set_kind); + this.children = values; this.idents = idents; this.values = values; } @@ -888,6 +934,7 @@ this(Expression e) { mixin(set_kind); + this.children = [e]; this.e = e; } }
--- a/trunk/src/Parser.d Thu Aug 09 11:13:04 2007 +0000 +++ b/trunk/src/Parser.d Thu Aug 09 12:00:03 2007 +0000 @@ -2496,11 +2496,12 @@ auto e = parseOrOrExpression(); if (token.type == T.Question) { + auto tok = token; nT(); auto iftrue = parseAsmExpression(); require(T.Colon); auto iffalse = parseAsmExpression(); - e = new CondExpression(e, iftrue, iffalse); + e = new CondExpression(e, iftrue, iffalse, tok); set(e, begin); } // TODO: create AsmExpression that contains e? @@ -2915,11 +2916,12 @@ auto e = parseOrOrExpression(); if (token.type == T.Question) { + auto tok = token; nT(); auto iftrue = parseExpression(); require(T.Colon); auto iffalse = parseCondExpression(); - e = new CondExpression(e, iftrue, iffalse); + e = new CondExpression(e, iftrue, iffalse, tok); set(e, begin); } return e;