Mercurial > projects > ddmd
view dmd/DefaultStatement.d @ 53:a8b50ff7f201
ForeachStatement.syntaxCopy
SliceExp.syntaxCopy
AnonDeclaration.syntaxCopy
SwitchStatement.syntaxCopy
CaseStatement.syntaxCopy
BreakStatement.syntaxCopy
ThrowStatement.syntaxCopy
NewExp.syntaxCopy
DefaultStatement.syntaxCopy
AssertExp.syntaxCopy
ClassDeclaration.syntaxCopy
TypeTypedef.constConv
eval_builtin
ComplexExp.isConst
DVCondition.syntaxCopy
OrExp.getIntRange
AndExp.getIntRange
getMask
IntegerExp.getIntRange
Type.sizemask
CastExp.getIntRange
Expression.getIntRange
author | korDen |
---|---|
date | Sat, 21 Aug 2010 12:15:47 +0400 |
parents | 10317f0c89a5 |
children | cab4c37afb89 |
line wrap: on
line source
module dmd.DefaultStatement; import dmd.Statement; import dmd.Loc; import dmd.Scope; import dmd.Expression; import dmd.InterState; import dmd.OutBuffer; import dmd.HdrGenState; import dmd.InlineScanState; import dmd.IRState; import dmd.BE; import dmd.backend.Util; import dmd.backend.OPER; import dmd.backend.Blockx; import dmd.backend.block; import dmd.backend.BC; class DefaultStatement : Statement { Statement statement; version (IN_GCC) { block* cblock = null; // back end: label for the block } this(Loc loc, Statement s) { super(loc); this.statement = s; } Statement syntaxCopy() { DefaultStatement s = new DefaultStatement(loc, statement.syntaxCopy()); return s; } Statement semantic(Scope sc) { //printf("DefaultStatement.semantic()\n"); if (sc.sw) { if (sc.sw.sdefault) { error("switch statement already has a default"); } sc.sw.sdefault = this; if (sc.sw.tf !is sc.tf) error("switch and default are in different finally blocks"); if (sc.sw.isFinal) error("default statement not allowed in final switch statement"); } else error("default not in switch statement"); statement = statement.semantic(sc); return this; } bool usesEH() { assert(false); } BE blockExit() { return statement.blockExit(); } bool comeFrom() { return true; } Expression interpret(InterState* istate) { assert(false); } void toCBuffer(OutBuffer buf, HdrGenState* hgs) { assert(false); } Statement inlineScan(InlineScanState* iss) { if (statement) statement = statement.inlineScan(iss); return this; } void toIR(IRState* irs) { Blockx* blx = irs.blx; block* bcase = blx.curblock; block* bdefault = irs.getDefaultBlock(); block_next(blx,BCgoto,bdefault); list_append(&bcase.Bsucc,blx.curblock); if (blx.tryblock != irs.getSwitchBlock().Btry) error("default cannot be in different try block level from switch"); incUsage(irs, loc); if (statement) statement.toIR(irs); } }