| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 return NULL; | 311 return NULL; |
| 312 } | 312 } |
| 313 // The initialization statement has to be a simple assignment. | 313 // The initialization statement has to be a simple assignment. |
| 314 Assignment* init = stmt->init()->StatementAsSimpleAssignment(); | 314 Assignment* init = stmt->init()->StatementAsSimpleAssignment(); |
| 315 if (init == NULL) return NULL; | 315 if (init == NULL) return NULL; |
| 316 | 316 |
| 317 // We only deal with local variables. | 317 // We only deal with local variables. |
| 318 Variable* loop_var = init->target()->AsVariableProxy()->AsVariable(); | 318 Variable* loop_var = init->target()->AsVariableProxy()->AsVariable(); |
| 319 if (loop_var == NULL || !loop_var->IsStackAllocated()) return NULL; | 319 if (loop_var == NULL || !loop_var->IsStackAllocated()) return NULL; |
| 320 | 320 |
| 321 // Don't try to get clever with const or dynamic variables. |
| 322 if (loop_var->mode() != Variable::VAR) return NULL; |
| 323 |
| 321 // The initial value has to be a smi. | 324 // The initial value has to be a smi. |
| 322 Literal* init_lit = init->value()->AsLiteral(); | 325 Literal* init_lit = init->value()->AsLiteral(); |
| 323 if (init_lit == NULL || !init_lit->handle()->IsSmi()) return NULL; | 326 if (init_lit == NULL || !init_lit->handle()->IsSmi()) return NULL; |
| 324 int init_value = Smi::cast(*init_lit->handle())->value(); | 327 int init_value = Smi::cast(*init_lit->handle())->value(); |
| 325 | 328 |
| 326 // The condition must be a compare of variable with <, <=, >, or >=. | 329 // The condition must be a compare of variable with <, <=, >, or >=. |
| 327 CompareOperation* cond = stmt->cond()->AsCompareOperation(); | 330 CompareOperation* cond = stmt->cond()->AsCompareOperation(); |
| 328 if (cond == NULL) return NULL; | 331 if (cond == NULL) return NULL; |
| 329 if (cond->op() != Token::LT | 332 if (cond->op() != Token::LT |
| 330 && cond->op() != Token::LTE | 333 && cond->op() != Token::LTE |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 ASSERT(av_.IsEmpty()); | 749 ASSERT(av_.IsEmpty()); |
| 747 } | 750 } |
| 748 | 751 |
| 749 | 752 |
| 750 void AssignedVariablesAnalyzer::VisitDeclaration(Declaration* decl) { | 753 void AssignedVariablesAnalyzer::VisitDeclaration(Declaration* decl) { |
| 751 UNREACHABLE(); | 754 UNREACHABLE(); |
| 752 } | 755 } |
| 753 | 756 |
| 754 | 757 |
| 755 } } // namespace v8::internal | 758 } } // namespace v8::internal |
| OLD | NEW |