Mercurial > projects > ddmd
view dmd/GotoCaseStatement.d @ 92:0c891ec48515
Fixed another bug related to copy ctor
author | korDen |
---|---|
date | Mon, 30 Aug 2010 23:43:38 +0400 |
parents | 2e2a5c3f943a |
children | e28b18c23469 |
line wrap: on
line source
module dmd.GotoCaseStatement; import dmd.Statement; import dmd.Expression; import dmd.CaseStatement; import dmd.IRState; import dmd.Scope; import dmd.Loc; import dmd.InterState; import dmd.OutBuffer; import dmd.HdrGenState; import dmd.BE; import dmd.WANT; class GotoCaseStatement : Statement { Expression exp; // NULL, or which case to goto CaseStatement cs; // case statement it resolves to this(Loc loc, Expression exp) { super(loc); cs = null; this.exp = exp; } override Statement syntaxCopy() { Expression e = exp ? exp.syntaxCopy() : null; GotoCaseStatement s = new GotoCaseStatement(loc, e); return s; } override Statement semantic(Scope sc) { if (exp) exp = exp.semantic(sc); if (!sc.sw) error("goto case not in switch statement"); else { sc.sw.gotoCases.push(cast(void*)this); if (exp) { exp = exp.implicitCastTo(sc, sc.sw.condition.type); exp = exp.optimize(WANTvalue); } } return this; } override Expression interpret(InterState istate) { assert(false); } override BE blockExit() { return BEgoto; } override void toCBuffer(OutBuffer buf, HdrGenState* hgs) { buf.writestring("goto case"); if (exp) { buf.writebyte(' '); exp.toCBuffer(buf, hgs); } buf.writebyte(';'); buf.writenl(); } override void toIR(IRState* irs) { assert(false); } }