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 <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/api.h" | 10 #include "src/api.h" |
(...skipping 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1892 Expression* Parser::BuildIteratorNextResult(Expression* iterator, | 1892 Expression* Parser::BuildIteratorNextResult(Expression* iterator, |
1893 Variable* result, IteratorType type, | 1893 Variable* result, IteratorType type, |
1894 int pos) { | 1894 int pos) { |
1895 Expression* next_literal = factory()->NewStringLiteral( | 1895 Expression* next_literal = factory()->NewStringLiteral( |
1896 ast_value_factory()->next_string(), kNoSourcePosition); | 1896 ast_value_factory()->next_string(), kNoSourcePosition); |
1897 Expression* next_property = | 1897 Expression* next_property = |
1898 factory()->NewProperty(iterator, next_literal, kNoSourcePosition); | 1898 factory()->NewProperty(iterator, next_literal, kNoSourcePosition); |
1899 ZoneList<Expression*>* next_arguments = | 1899 ZoneList<Expression*>* next_arguments = |
1900 new (zone()) ZoneList<Expression*>(0, zone()); | 1900 new (zone()) ZoneList<Expression*>(0, zone()); |
1901 Expression* next_call = | 1901 Expression* next_call = |
1902 factory()->NewCall(next_property, next_arguments, pos); | 1902 factory()->NewCall(next_property, next_arguments, kNoSourcePosition); |
1903 if (type == IteratorType::kAsync) { | 1903 if (type == IteratorType::kAsync) { |
1904 next_call = RewriteAwaitExpression(next_call, pos); | 1904 next_call = RewriteAwaitExpression(next_call, pos); |
1905 } | 1905 } |
1906 Expression* result_proxy = factory()->NewVariableProxy(result); | 1906 Expression* result_proxy = factory()->NewVariableProxy(result); |
1907 Expression* left = | 1907 Expression* left = |
1908 factory()->NewAssignment(Token::ASSIGN, result_proxy, next_call, pos); | 1908 factory()->NewAssignment(Token::ASSIGN, result_proxy, next_call, pos); |
1909 | 1909 |
1910 // %_IsJSReceiver(...) | 1910 // %_IsJSReceiver(...) |
1911 ZoneList<Expression*>* is_spec_object_args = | 1911 ZoneList<Expression*>* is_spec_object_args = |
1912 new (zone()) ZoneList<Expression*>(1, zone()); | 1912 new (zone()) ZoneList<Expression*>(1, zone()); |
(...skipping 11 matching lines...) Expand all Loading... |
1924 | 1924 |
1925 return factory()->NewBinaryOperation( | 1925 return factory()->NewBinaryOperation( |
1926 Token::AND, | 1926 Token::AND, |
1927 factory()->NewUnaryOperation(Token::NOT, is_spec_object_call, pos), | 1927 factory()->NewUnaryOperation(Token::NOT, is_spec_object_call, pos), |
1928 throw_call, pos); | 1928 throw_call, pos); |
1929 } | 1929 } |
1930 | 1930 |
1931 Statement* Parser::InitializeForEachStatement(ForEachStatement* stmt, | 1931 Statement* Parser::InitializeForEachStatement(ForEachStatement* stmt, |
1932 Expression* each, | 1932 Expression* each, |
1933 Expression* subject, | 1933 Expression* subject, |
1934 Statement* body, | 1934 Statement* body) { |
1935 int each_keyword_pos) { | |
1936 ForOfStatement* for_of = stmt->AsForOfStatement(); | 1935 ForOfStatement* for_of = stmt->AsForOfStatement(); |
1937 if (for_of != NULL) { | 1936 if (for_of != NULL) { |
1938 const bool finalize = true; | 1937 const bool finalize = true; |
1939 return InitializeForOfStatement(for_of, each, subject, body, finalize, | 1938 return InitializeForOfStatement(for_of, each, subject, body, finalize, |
1940 IteratorType::kNormal, each_keyword_pos); | 1939 IteratorType::kNormal, each->position()); |
1941 } else { | 1940 } else { |
1942 if (each->IsArrayLiteral() || each->IsObjectLiteral()) { | 1941 if (each->IsArrayLiteral() || each->IsObjectLiteral()) { |
1943 Variable* temp = NewTemporary(ast_value_factory()->empty_string()); | 1942 Variable* temp = NewTemporary(ast_value_factory()->empty_string()); |
1944 VariableProxy* temp_proxy = factory()->NewVariableProxy(temp); | 1943 VariableProxy* temp_proxy = factory()->NewVariableProxy(temp); |
1945 Expression* assign_each = PatternRewriter::RewriteDestructuringAssignment( | 1944 Expression* assign_each = PatternRewriter::RewriteDestructuringAssignment( |
1946 this, factory()->NewAssignment(Token::ASSIGN, each, temp_proxy, | 1945 this, factory()->NewAssignment(Token::ASSIGN, each, temp_proxy, |
1947 kNoSourcePosition), | 1946 kNoSourcePosition), |
1948 scope()); | 1947 scope()); |
1949 auto block = factory()->NewBlock(nullptr, 2, false, kNoSourcePosition); | 1948 auto block = factory()->NewBlock(nullptr, 2, false, kNoSourcePosition); |
1950 block->statements()->Add( | 1949 block->statements()->Add( |
(...skipping 3193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5144 literal->SetShouldEagerCompile(); | 5143 literal->SetShouldEagerCompile(); |
5145 } | 5144 } |
5146 } | 5145 } |
5147 | 5146 |
5148 #undef CHECK_OK | 5147 #undef CHECK_OK |
5149 #undef CHECK_OK_VOID | 5148 #undef CHECK_OK_VOID |
5150 #undef CHECK_FAILED | 5149 #undef CHECK_FAILED |
5151 | 5150 |
5152 } // namespace internal | 5151 } // namespace internal |
5153 } // namespace v8 | 5152 } // namespace v8 |
OLD | NEW |