Mercurial > projects > ddmd
view dmd/GotoCaseStatement.d @ 114:e28b18c23469
added a module dmd.common for commonly used stuff
it currently holds code for consistency checking of predefined versions
also added a VisualD project file
author | Trass3r |
---|---|
date | Wed, 01 Sep 2010 18:21:58 +0200 |
parents | 2e2a5c3f943a |
children | 9e39c7de8438 |
line wrap: on
line source
module dmd.GotoCaseStatement; import dmd.common; 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); } }