Changeset 209
- Timestamp:
- 10/13/09 22:11:20 (2 years ago)
- Files:
-
- branches/dmd-1.x/src/statement.c (modified) (6 diffs)
- branches/dmd-1.x/src/statement.h (modified) (4 diffs)
- trunk/src/statement.c (modified) (3 diffs)
- trunk/src/statement.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/statement.c
r202 r209 148 148 } 149 149 150 // Return TRUE if statement has no code in it 151 int Statement::isEmpty() 152 { 153 //printf("Statement::isEmpty()\n"); 154 return FALSE; 155 } 156 150 157 /**************************************** 151 158 * If this statement has code that needs to run in a finally clause … … 254 261 } 255 262 return result; 263 } 264 265 int ExpStatement::isEmpty() 266 { 267 return exp == NULL; 256 268 } 257 269 … … 575 587 if (!(result & BEfallthru) && !s->comeFrom()) 576 588 { 577 if (s->blockExit() != BEhalt )589 if (s->blockExit() != BEhalt && !s->isEmpty()) 578 590 s->warning("statement is not reachable"); 579 591 } 580 581 result &= ~BEfallthru; 582 result |= s->blockExit(); 592 else 593 { 594 result &= ~BEfallthru; 595 result |= s->blockExit(); 596 } 583 597 } 584 598 } … … 599 613 } 600 614 return comefrom; 615 } 616 617 int CompoundStatement::isEmpty() 618 { 619 for (int i = 0; i < statements->dim; i++) 620 { Statement *s = (Statement *) statements->data[i]; 621 if (s && !s->isEmpty()) 622 return FALSE; 623 } 624 return TRUE; 601 625 } 602 626 … … 869 893 } 870 894 895 871 896 int ScopeStatement::comeFrom() 872 897 { 873 898 //printf("ScopeStatement::comeFrom()\n"); 874 899 return statement ? statement->comeFrom() : FALSE; 900 } 901 902 int ScopeStatement::isEmpty() 903 { 904 //printf("ScopeStatement::isEmpty() %d\n", statement ? statement->isEmpty() : TRUE); 905 return statement ? statement->isEmpty() : TRUE; 875 906 } 876 907 … … 3837 3868 } 3838 3869 } 3870 3871 if (!body || body->isEmpty()) 3872 { 3873 return NULL; 3874 } 3839 3875 return this; 3840 3876 } branches/dmd-1.x/src/statement.h
r202 r209 105 105 virtual int blockExit(); 106 106 virtual int comeFrom(); 107 virtual int isEmpty(); 107 108 virtual void scopeCode(Scope *sc, Statement **sentry, Statement **sexit, Statement **sfinally); 108 109 virtual Statements *flatten(Scope *sc); … … 141 142 Expression *interpret(InterState *istate); 142 143 int blockExit(); 144 int isEmpty(); 143 145 144 146 int inlineCost(InlineCostState *ics); … … 186 188 int blockExit(); 187 189 int comeFrom(); 190 int isEmpty(); 188 191 Statements *flatten(Scope *sc); 189 192 ReturnStatement *isReturnStatement(); … … 245 248 int blockExit(); 246 249 int comeFrom(); 250 int isEmpty(); 247 251 Expression *interpret(InterState *istate); 248 252 trunk/src/statement.c
r202 r209 261 261 } 262 262 return result; 263 } 264 265 int ExpStatement::isEmpty() 266 { 267 return exp == NULL; 263 268 } 264 269 … … 606 611 if (!(result & BEfallthru) && !s->comeFrom()) 607 612 { 608 if (s->blockExit() != BEhalt )613 if (s->blockExit() != BEhalt && !s->isEmpty()) 609 614 s->warning("statement is not reachable"); 610 615 } 611 612 result &= ~BEfallthru; 613 result |= s->blockExit(); 616 else 617 { 618 result &= ~BEfallthru; 619 result |= s->blockExit(); 620 } 614 621 } 615 622 } … … 1086 1093 result = BEfallthru; 1087 1094 if (result & BEfallthru) 1088 { if (condition->canThrow()) 1095 { 1096 if (condition->canThrow()) 1089 1097 result |= BEthrow; 1090 1098 if (!(result & BEbreak) && condition->isBool(TRUE)) trunk/src/statement.h
r202 r209 142 142 Expression *interpret(InterState *istate); 143 143 int blockExit(); 144 int isEmpty(); 144 145 145 146 int inlineCost(InlineCostState *ics);
