Mercurial > projects > ldc
diff dmd/statement.c @ 875:330f999ade44
Merged DMD 1.038
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 06 Jan 2009 16:33:51 +0100 |
parents | bc982f1ad106 |
children | d51551cb3a85 |
line wrap: on
line diff
--- a/dmd/statement.c Tue Jan 06 15:54:48 2009 +0100 +++ b/dmd/statement.c Tue Jan 06 16:33:51 2009 +0100 @@ -124,13 +124,6 @@ return BEany; } -// TRUE if statement may fall off the end without a throw or return - -int Statement::fallOffEnd() -{ - return TRUE; -} - // TRUE if statement 'comes from' somewhere else, like a goto int Statement::comeFrom() @@ -227,21 +220,6 @@ return result; } -int ExpStatement::fallOffEnd() -{ - if (exp) - { - if (exp->op == TOKassert) - { AssertExp *a = (AssertExp *)exp; - - if (a->e1->isBool(FALSE)) // if it's an assert(0) - return FALSE; - } - else if (exp->op == TOKhalt) - return FALSE; - } - return TRUE; -} /******************************** CompileStatement ***************************/ @@ -574,25 +552,6 @@ return result; } -int CompoundStatement::fallOffEnd() -{ int falloff = TRUE; - - //printf("CompoundStatement::fallOffEnd() %s\n", toChars()); - for (int i = 0; i < statements->dim; i++) - { Statement *s = (Statement *)statements->data[i]; - - if (!s) - continue; - - if (!falloff && global.params.warnings && !s->comeFrom()) - { - warning("%s: statement is not reachable", s->loc.toChars()); - } - falloff = s->fallOffEnd(); - } - return falloff; -} - int CompoundStatement::comeFrom() { int comefrom = FALSE; @@ -710,18 +669,6 @@ return result; } -int UnrolledLoopStatement::fallOffEnd() -{ - //printf("UnrolledLoopStatement::fallOffEnd()\n"); - for (size_t i = 0; i < statements->dim; i++) - { Statement *s = (Statement *)statements->data[i]; - - if (s) - s->fallOffEnd(); - } - return TRUE; -} - int UnrolledLoopStatement::comeFrom() { int comefrom = FALSE; @@ -815,11 +762,6 @@ return statement ? statement->blockExit() : BEfallthru; } -int ScopeStatement::fallOffEnd() -{ - return statement ? statement->fallOffEnd() : TRUE; -} - int ScopeStatement::comeFrom() { //printf("ScopeStatement::comeFrom()\n"); @@ -945,13 +887,6 @@ return result; } -int WhileStatement::fallOffEnd() -{ - if (body) - body->fallOffEnd(); - return TRUE; -} - int WhileStatement::comeFrom() { if (body) @@ -1040,13 +975,6 @@ return result; } -int DoStatement::fallOffEnd() -{ - if (body) - body->fallOffEnd(); - return TRUE; -} - int DoStatement::comeFrom() { if (body) @@ -1177,13 +1105,6 @@ return result; } -int ForStatement::fallOffEnd() -{ - if (body) - body->fallOffEnd(); - return TRUE; -} - int ForStatement::comeFrom() { //printf("ForStatement::comeFrom()\n"); @@ -1878,13 +1799,6 @@ return result; } -int ForeachStatement::fallOffEnd() -{ - if (body) - body->fallOffEnd(); - return TRUE; -} - int ForeachStatement::comeFrom() { if (body) @@ -2042,15 +1956,6 @@ return result; } -int IfStatement::fallOffEnd() -{ - if (!ifbody || ifbody->fallOffEnd() || - !elsebody || elsebody->fallOffEnd()) - return TRUE; - return FALSE; -} - - void IfStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { buf->writestring("if ("); @@ -2268,13 +2173,6 @@ return result; } -int PragmaStatement::fallOffEnd() -{ - if (body) - return body->fallOffEnd(); - return TRUE; -} - void PragmaStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { buf->writestring("pragma ("); @@ -2475,13 +2373,6 @@ return result; } -int SwitchStatement::fallOffEnd() -{ - if (body) - body->fallOffEnd(); - return TRUE; // need to do this better -} - void SwitchStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { buf->writestring("switch ("); @@ -2586,11 +2477,6 @@ return statement->blockExit(); } -int CaseStatement::fallOffEnd() -{ - return statement->fallOffEnd(); -} - int CaseStatement::comeFrom() { return TRUE; @@ -2650,11 +2536,6 @@ return statement->blockExit(); } -int DefaultStatement::fallOffEnd() -{ - return statement->fallOffEnd(); -} - int DefaultStatement::comeFrom() { return TRUE; @@ -2695,11 +2576,6 @@ return BEgoto; } -int GotoDefaultStatement::fallOffEnd() -{ - return FALSE; -} - void GotoDefaultStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { buf->writestring("goto default;\n"); @@ -2749,11 +2625,6 @@ return BEgoto; } -int GotoCaseStatement::fallOffEnd() -{ - return FALSE; -} - void GotoCaseStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { buf->writestring("goto case"); @@ -2777,11 +2648,6 @@ return BEthrow; } -int SwitchErrorStatement::fallOffEnd() -{ - return FALSE; -} - void SwitchErrorStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { buf->writestring("SwitchErrorStatement::toCBuffer()"); @@ -3056,11 +2922,6 @@ return result; } -int ReturnStatement::fallOffEnd() -{ - return FALSE; -} - void ReturnStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { buf->printf("return "); @@ -3155,11 +3016,6 @@ return ident ? BEgoto : BEbreak; } -int BreakStatement::fallOffEnd() -{ - return FALSE; -} - void BreakStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { buf->writestring("break"); @@ -3263,11 +3119,6 @@ return ident ? BEgoto : BEcontinue; } -int ContinueStatement::fallOffEnd() -{ - return FALSE; -} - void ContinueStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { buf->writestring("continue"); @@ -3358,11 +3209,6 @@ return body ? body->blockExit() : BEfallthru; } -int SynchronizedStatement::fallOffEnd() -{ - return body ? body->fallOffEnd() : TRUE; -} - void SynchronizedStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { buf->writestring("synchronized"); @@ -3480,11 +3326,6 @@ return result; } -int WithStatement::fallOffEnd() -{ - return body ? body->fallOffEnd() : TRUE; -} - /******************************** TryCatchStatement ***************************/ TryCatchStatement::TryCatchStatement(Loc loc, Statement *body, Array *catches) @@ -3556,22 +3397,6 @@ return result; } -int TryCatchStatement::fallOffEnd() -{ - int result = FALSE; - - if (body) - result = body->fallOffEnd(); - for (int i = 0; i < catches->dim; i++) - { Catch *c; - - c = (Catch *)catches->data[i]; - if (c->handler) - result |= c->handler->fallOffEnd(); - } - return result; -} - void TryCatchStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { buf->writestring("try"); @@ -3728,18 +3553,11 @@ int TryFinallyStatement::blockExit() { - int result = body->blockExit(); - return result; + if (body) + return body->blockExit(); + return BEfallthru; } -int TryFinallyStatement::fallOffEnd() -{ int result; - - result = body ? body->fallOffEnd() : TRUE; -// if (finalbody) -// result = finalbody->fallOffEnd(); - return result; -} /****************************** OnScopeStatement ***************************/ @@ -3861,11 +3679,6 @@ return BEthrow; // obviously } -int ThrowStatement::fallOffEnd() -{ - return FALSE; -} - void ThrowStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { buf->printf("throw "); @@ -3924,11 +3737,6 @@ return statement ? statement->blockExit() : BEfallthru; } -int VolatileStatement::fallOffEnd() -{ - return statement ? statement->fallOffEnd() : TRUE; -} - void VolatileStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { buf->writestring("volatile"); @@ -3993,11 +3801,6 @@ return BEgoto; } -int GotoStatement::fallOffEnd() -{ - return FALSE; -} - void GotoStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { buf->writestring("goto "); @@ -4087,11 +3890,6 @@ return statement ? statement->blockExit() : BEfallthru; } -int LabelStatement::fallOffEnd() -{ - return statement ? statement->fallOffEnd() : TRUE; -} - int LabelStatement::comeFrom() { //printf("LabelStatement::comeFrom()\n");