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 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 // The loop must have all necessary parts. | 1051 // The loop must have all necessary parts. |
1052 if (stmt->init() == NULL || stmt->cond() == NULL || stmt->next() == NULL) { | 1052 if (stmt->init() == NULL || stmt->cond() == NULL || stmt->next() == NULL) { |
1053 return NULL; | 1053 return NULL; |
1054 } | 1054 } |
1055 // The initialization statement has to be a simple assignment. | 1055 // The initialization statement has to be a simple assignment. |
1056 Assignment* init = stmt->init()->StatementAsSimpleAssignment(); | 1056 Assignment* init = stmt->init()->StatementAsSimpleAssignment(); |
1057 if (init == NULL) return NULL; | 1057 if (init == NULL) return NULL; |
1058 | 1058 |
1059 // We only deal with local variables. | 1059 // We only deal with local variables. |
1060 Variable* loop_var = init->target()->AsVariableProxy()->AsVariable(); | 1060 Variable* loop_var = init->target()->AsVariableProxy()->AsVariable(); |
1061 if (!loop_var->IsStackAllocated()) return NULL; | 1061 if (loop_var == NULL || !loop_var->IsStackAllocated()) return NULL; |
1062 | 1062 |
1063 // The initial value has to be a smi. | 1063 // The initial value has to be a smi. |
1064 Literal* init_lit = init->value()->AsLiteral(); | 1064 Literal* init_lit = init->value()->AsLiteral(); |
1065 if (init_lit == NULL || !init_lit->handle()->IsSmi()) return NULL; | 1065 if (init_lit == NULL || !init_lit->handle()->IsSmi()) return NULL; |
1066 int init_value = Smi::cast(*init_lit->handle())->value(); | 1066 int init_value = Smi::cast(*init_lit->handle())->value(); |
1067 | 1067 |
1068 // The condition must be a compare of variable with <, <=, >, or >=. | 1068 // The condition must be a compare of variable with <, <=, >, or >=. |
1069 CompareOperation* cond = stmt->cond()->AsCompareOperation(); | 1069 CompareOperation* cond = stmt->cond()->AsCompareOperation(); |
1070 if (cond == NULL) return NULL; | 1070 if (cond == NULL) return NULL; |
1071 if (cond->op() != Token::LT | 1071 if (cond->op() != Token::LT |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1831 for (int i = postorder->length() - 1; i >= 0; i--) { | 1831 for (int i = postorder->length() - 1; i >= 0; i--) { |
1832 postorder->at(i)->PrintText(); | 1832 postorder->at(i)->PrintText(); |
1833 } | 1833 } |
1834 } | 1834 } |
1835 | 1835 |
1836 | 1836 |
1837 #endif // defined(DEBUG) | 1837 #endif // defined(DEBUG) |
1838 | 1838 |
1839 | 1839 |
1840 } } // namespace v8::internal | 1840 } } // namespace v8::internal |
OLD | NEW |