Mercurial > projects > ddmd
view dmd/GotoDefaultStatement.d @ 68:ee3a9f34dc48
final bits of codegen implementation to compile Phobos
author | korDen |
---|---|
date | Tue, 24 Aug 2010 16:44:34 +0400 |
parents | 4290d870944a |
children | 2e2a5c3f943a |
line wrap: on
line source
module dmd.GotoDefaultStatement; import dmd.Statement; import dmd.SwitchStatement; import dmd.Loc; import dmd.Scope; import dmd.Expression; import dmd.InterState; import dmd.OutBuffer; import dmd.HdrGenState; import dmd.IRState; import dmd.BE; import dmd.backend.block; import dmd.backend.Blockx; import dmd.backend.Util; import dmd.backend.BC; class GotoDefaultStatement : Statement { SwitchStatement sw; this(Loc loc) { super(loc); sw = null; } Statement syntaxCopy() { GotoDefaultStatement s = new GotoDefaultStatement(loc); return s; } Statement semantic(Scope sc) { sw = sc.sw; if (!sw) error("goto default not in switch statement"); return this; } Expression interpret(InterState istate) { assert(false); } BE blockExit() { return BEgoto; } void toCBuffer(OutBuffer buf, HdrGenState* hgs) { buf.writestring("goto default;\n"); } void toIR(IRState *irs) { block *b; Blockx *blx = irs.blx; block *bdest = irs.getDefaultBlock(); b = blx.curblock; // The rest is equivalent to GotoStatement // Adjust exception handler scope index if in different try blocks if (b.Btry != bdest.Btry) { // Check that bdest is in an enclosing try block for (block* bt = b.Btry; bt != bdest.Btry; bt = bt.Btry) { if (!bt) { //printf("b.Btry = %p, bdest.Btry = %p\n", b.Btry, bdest.Btry); error("cannot goto into try block"); break; } } //setScopeIndex(blx, b, bdest.Btry ? bdest.Btry.Bscope_index : -1); } list_append(&b.Bsucc,bdest); incUsage(irs, loc); block_next(blx,BCgoto,null); } }