| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/ast/ast-expression-rewriter.h" | 10 #include "src/ast/ast-expression-rewriter.h" |
| (...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 kNoSourcePosition), | 1902 kNoSourcePosition), |
| 1903 scope()); | 1903 scope()); |
| 1904 auto block = factory()->NewBlock(nullptr, 2, false, kNoSourcePosition); | 1904 auto block = factory()->NewBlock(nullptr, 2, false, kNoSourcePosition); |
| 1905 block->statements()->Add( | 1905 block->statements()->Add( |
| 1906 factory()->NewExpressionStatement(assign_each, kNoSourcePosition), | 1906 factory()->NewExpressionStatement(assign_each, kNoSourcePosition), |
| 1907 zone()); | 1907 zone()); |
| 1908 block->statements()->Add(body, zone()); | 1908 block->statements()->Add(body, zone()); |
| 1909 body = block; | 1909 body = block; |
| 1910 each = factory()->NewVariableProxy(temp); | 1910 each = factory()->NewVariableProxy(temp); |
| 1911 } | 1911 } |
| 1912 MarkExpressionAsAssigned(each); |
| 1912 stmt->AsForInStatement()->Initialize(each, subject, body); | 1913 stmt->AsForInStatement()->Initialize(each, subject, body); |
| 1913 } | 1914 } |
| 1914 return stmt; | 1915 return stmt; |
| 1915 } | 1916 } |
| 1916 | 1917 |
| 1917 // Special case for legacy for | 1918 // Special case for legacy for |
| 1918 // | 1919 // |
| 1919 // for (var x = initializer in enumerable) body | 1920 // for (var x = initializer in enumerable) body |
| 1920 // | 1921 // |
| 1921 // An initialization block of the form | 1922 // An initialization block of the form |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2051 int next_result_pos) { | 2052 int next_result_pos) { |
| 2052 // Create the auxiliary expressions needed for iterating over the iterable, | 2053 // Create the auxiliary expressions needed for iterating over the iterable, |
| 2053 // and initialize the given ForOfStatement with them. | 2054 // and initialize the given ForOfStatement with them. |
| 2054 // If finalize is true, also instrument the loop with code that performs the | 2055 // If finalize is true, also instrument the loop with code that performs the |
| 2055 // proper ES6 iterator finalization. In that case, the result is not | 2056 // proper ES6 iterator finalization. In that case, the result is not |
| 2056 // immediately a ForOfStatement. | 2057 // immediately a ForOfStatement. |
| 2057 | 2058 |
| 2058 const int nopos = kNoSourcePosition; | 2059 const int nopos = kNoSourcePosition; |
| 2059 auto avfactory = ast_value_factory(); | 2060 auto avfactory = ast_value_factory(); |
| 2060 | 2061 |
| 2061 Variable* iterator = NewTemporary(ast_value_factory()->dot_iterator_string()); | 2062 Variable* iterator = NewTemporary(avfactory->dot_iterator_string()); |
| 2062 Variable* result = NewTemporary(ast_value_factory()->dot_result_string()); | 2063 Variable* result = NewTemporary(avfactory->dot_result_string()); |
| 2063 Variable* completion = NewTemporary(avfactory->empty_string()); | 2064 Variable* completion = NewTemporary(avfactory->empty_string()); |
| 2064 | 2065 |
| 2065 // iterator = GetIterator(iterable) | 2066 // iterator = GetIterator(iterable) |
| 2066 Expression* assign_iterator; | 2067 Expression* assign_iterator; |
| 2067 { | 2068 { |
| 2068 assign_iterator = factory()->NewAssignment( | 2069 assign_iterator = factory()->NewAssignment( |
| 2069 Token::ASSIGN, factory()->NewVariableProxy(iterator), | 2070 Token::ASSIGN, factory()->NewVariableProxy(iterator), |
| 2070 factory()->NewGetIterator(iterable, iterable->position()), | 2071 factory()->NewGetIterator(iterable, iterable->position()), |
| 2071 iterable->position()); | 2072 iterable->position()); |
| 2072 } | 2073 } |
| (...skipping 3369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5442 | 5443 |
| 5443 return final_loop; | 5444 return final_loop; |
| 5444 } | 5445 } |
| 5445 | 5446 |
| 5446 #undef CHECK_OK | 5447 #undef CHECK_OK |
| 5447 #undef CHECK_OK_VOID | 5448 #undef CHECK_OK_VOID |
| 5448 #undef CHECK_FAILED | 5449 #undef CHECK_FAILED |
| 5449 | 5450 |
| 5450 } // namespace internal | 5451 } // namespace internal |
| 5451 } // namespace v8 | 5452 } // namespace v8 |
| OLD | NEW |