OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <cmath> | 5 #include <cmath> |
6 | 6 |
7 #include "src/allocation.h" | 7 #include "src/allocation.h" |
8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 *ok = false; | 949 *ok = false; |
950 return Statement::Default(); | 950 return Statement::Default(); |
951 } | 951 } |
952 ParseExpression(true, CHECK_OK); | 952 ParseExpression(true, CHECK_OK); |
953 Expect(Token::RPAREN, CHECK_OK); | 953 Expect(Token::RPAREN, CHECK_OK); |
954 ParseSubStatement(CHECK_OK); | 954 ParseSubStatement(CHECK_OK); |
955 return Statement::Default(); | 955 return Statement::Default(); |
956 } | 956 } |
957 } else { | 957 } else { |
958 int lhs_beg_pos = peek_position(); | 958 int lhs_beg_pos = peek_position(); |
959 Expression lhs = ParseExpression(false, CHECK_OK); | 959 ExpressionClassifier classifier; |
| 960 Expression lhs = ParseExpression(false, &classifier, CHECK_OK); |
960 int lhs_end_pos = scanner()->location().end_pos; | 961 int lhs_end_pos = scanner()->location().end_pos; |
961 is_let_identifier_expression = | 962 is_let_identifier_expression = |
962 lhs.IsIdentifier() && lhs.AsIdentifier().IsLet(); | 963 lhs.IsIdentifier() && lhs.AsIdentifier().IsLet(); |
963 if (CheckInOrOf(&mode, ok)) { | 964 if (CheckInOrOf(&mode, ok)) { |
964 if (!*ok) return Statement::Default(); | 965 if (!*ok) return Statement::Default(); |
965 lhs = CheckAndRewriteReferenceExpression( | 966 bool is_destructuring = |
966 lhs, lhs_beg_pos, lhs_end_pos, MessageTemplate::kInvalidLhsInFor, | 967 allow_harmony_destructuring_assignment() && |
967 kSyntaxError, CHECK_OK); | 968 (lhs->IsArrayLiteral() || lhs->IsObjectLiteral()); |
| 969 if (is_destructuring) { |
| 970 ValidateAssignmentPattern(&classifier, CHECK_OK); |
| 971 } else { |
| 972 ValidateExpression(&classifier, CHECK_OK); |
| 973 lhs = CheckAndRewriteReferenceExpression( |
| 974 lhs, lhs_beg_pos, lhs_end_pos, MessageTemplate::kInvalidLhsInFor, |
| 975 kSyntaxError, CHECK_OK); |
| 976 } |
968 ParseExpression(true, CHECK_OK); | 977 ParseExpression(true, CHECK_OK); |
969 Expect(Token::RPAREN, CHECK_OK); | 978 Expect(Token::RPAREN, CHECK_OK); |
970 ParseSubStatement(CHECK_OK); | 979 ParseSubStatement(CHECK_OK); |
971 return Statement::Default(); | 980 return Statement::Default(); |
972 } | 981 } |
973 } | 982 } |
974 } | 983 } |
975 | 984 |
976 // Parsed initializer at this point. | 985 // Parsed initializer at this point. |
977 // Detect attempts at 'let' declarations in sloppy mode. | 986 // Detect attempts at 'let' declarations in sloppy mode. |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 Expect(Token::RBRACE, CHECK_OK); | 1276 Expect(Token::RBRACE, CHECK_OK); |
1268 return PreParserExpression::Default(); | 1277 return PreParserExpression::Default(); |
1269 } | 1278 } |
1270 } | 1279 } |
1271 | 1280 |
1272 #undef CHECK_OK | 1281 #undef CHECK_OK |
1273 | 1282 |
1274 | 1283 |
1275 } // namespace internal | 1284 } // namespace internal |
1276 } // namespace v8 | 1285 } // namespace v8 |
OLD | NEW |