Mercurial > projects > ddmd
view dmd/GotoDefaultStatement.d @ 191:52188e7e3fb5
Fixed deprecated features, now compiles with DMD2.058
Also changed Array allocation policy:
Now doesn't reallocate but malloc's, followed by a memcpy (no free).
(this fixes a crash while compiling druntime. Same bug in dmd)
author | korDen@korDen-pc |
---|---|
date | Sun, 25 Mar 2012 03:11:12 +0400 |
parents | b0d41ff5e0df |
children |
line wrap: on
line source
module dmd.GotoDefaultStatement; import dmd.common; 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; import dmd.DDMDExtensions; class GotoDefaultStatement : Statement { mixin insertMemberExtension!(typeof(this)); SwitchStatement sw; this(Loc loc) { register(); super(loc); sw = null; } override Statement syntaxCopy() { GotoDefaultStatement s = new GotoDefaultStatement(loc); return s; } override Statement semantic(Scope sc) { sw = sc.sw; if (!sw) error("goto default not in switch statement"); return this; } override Expression interpret(InterState istate) { assert(false); } override BE blockExit() { return BEgoto; } override void toCBuffer(OutBuffer buf, HdrGenState* hgs) { buf.writestring("goto default;\n"); } override 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); } }