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 ExpressionClassifier classifier; | 959 Expression lhs = ParseExpression(false, CHECK_OK); |
960 Expression lhs = ParseExpression(false, &classifier, CHECK_OK); | |
961 int lhs_end_pos = scanner()->location().end_pos; | 960 int lhs_end_pos = scanner()->location().end_pos; |
962 is_let_identifier_expression = | 961 is_let_identifier_expression = |
963 lhs.IsIdentifier() && lhs.AsIdentifier().IsLet(); | 962 lhs.IsIdentifier() && lhs.AsIdentifier().IsLet(); |
964 if (CheckInOrOf(&mode, ok)) { | 963 if (CheckInOrOf(&mode, ok)) { |
965 if (!*ok) return Statement::Default(); | 964 if (!*ok) return Statement::Default(); |
966 bool is_destructuring = | 965 lhs = CheckAndRewriteReferenceExpression( |
967 allow_harmony_destructuring_assignment() && | 966 lhs, lhs_beg_pos, lhs_end_pos, MessageTemplate::kInvalidLhsInFor, |
968 (lhs->IsArrayLiteral() || lhs->IsObjectLiteral()); | 967 kSyntaxError, CHECK_OK); |
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 } | |
977 ParseExpression(true, CHECK_OK); | 968 ParseExpression(true, CHECK_OK); |
978 Expect(Token::RPAREN, CHECK_OK); | 969 Expect(Token::RPAREN, CHECK_OK); |
979 ParseSubStatement(CHECK_OK); | 970 ParseSubStatement(CHECK_OK); |
980 return Statement::Default(); | 971 return Statement::Default(); |
981 } | 972 } |
982 } | 973 } |
983 } | 974 } |
984 | 975 |
985 // Parsed initializer at this point. | 976 // Parsed initializer at this point. |
986 // Detect attempts at 'let' declarations in sloppy mode. | 977 // Detect attempts at 'let' declarations in sloppy mode. |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1276 Expect(Token::RBRACE, CHECK_OK); | 1267 Expect(Token::RBRACE, CHECK_OK); |
1277 return PreParserExpression::Default(); | 1268 return PreParserExpression::Default(); |
1278 } | 1269 } |
1279 } | 1270 } |
1280 | 1271 |
1281 #undef CHECK_OK | 1272 #undef CHECK_OK |
1282 | 1273 |
1283 | 1274 |
1284 } // namespace internal | 1275 } // namespace internal |
1285 } // namespace v8 | 1276 } // namespace v8 |
OLD | NEW |