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 #ifndef V8_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
7 | 7 |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 2711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2722 } | 2722 } |
2723 | 2723 |
2724 if (is_destructuring_assignment) { | 2724 if (is_destructuring_assignment) { |
2725 ValidateAssignmentPattern(CHECK_OK); | 2725 ValidateAssignmentPattern(CHECK_OK); |
2726 } else { | 2726 } else { |
2727 expression = CheckAndRewriteReferenceExpression( | 2727 expression = CheckAndRewriteReferenceExpression( |
2728 expression, lhs_beg_pos, scanner()->location().end_pos, | 2728 expression, lhs_beg_pos, scanner()->location().end_pos, |
2729 MessageTemplate::kInvalidLhsInAssignment, CHECK_OK); | 2729 MessageTemplate::kInvalidLhsInAssignment, CHECK_OK); |
2730 } | 2730 } |
2731 | 2731 |
2732 expression = impl()->MarkExpressionAsAssigned(expression); | 2732 impl()->MarkExpressionAsAssigned(expression); |
2733 | 2733 |
2734 Token::Value op = Next(); // Get assignment operator. | 2734 Token::Value op = Next(); // Get assignment operator. |
2735 if (op != Token::ASSIGN) { | 2735 if (op != Token::ASSIGN) { |
2736 classifier()->RecordPatternError(scanner()->location(), | 2736 classifier()->RecordPatternError(scanner()->location(), |
2737 MessageTemplate::kUnexpectedToken, | 2737 MessageTemplate::kUnexpectedToken, |
2738 Token::String(op)); | 2738 Token::String(op)); |
2739 } | 2739 } |
2740 int pos = position(); | 2740 int pos = position(); |
2741 | 2741 |
2742 ExpressionClassifier rhs_classifier(this); | 2742 ExpressionClassifier rhs_classifier(this); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2963 return impl()->BuildUnaryExpression(expression, op, pos); | 2963 return impl()->BuildUnaryExpression(expression, op, pos); |
2964 } else if (Token::IsCountOp(op)) { | 2964 } else if (Token::IsCountOp(op)) { |
2965 BindingPatternUnexpectedToken(); | 2965 BindingPatternUnexpectedToken(); |
2966 ArrowFormalParametersUnexpectedToken(); | 2966 ArrowFormalParametersUnexpectedToken(); |
2967 op = Next(); | 2967 op = Next(); |
2968 int beg_pos = peek_position(); | 2968 int beg_pos = peek_position(); |
2969 ExpressionT expression = ParseUnaryExpression(CHECK_OK); | 2969 ExpressionT expression = ParseUnaryExpression(CHECK_OK); |
2970 expression = CheckAndRewriteReferenceExpression( | 2970 expression = CheckAndRewriteReferenceExpression( |
2971 expression, beg_pos, scanner()->location().end_pos, | 2971 expression, beg_pos, scanner()->location().end_pos, |
2972 MessageTemplate::kInvalidLhsInPrefixOp, CHECK_OK); | 2972 MessageTemplate::kInvalidLhsInPrefixOp, CHECK_OK); |
2973 expression = impl()->MarkExpressionAsAssigned(expression); | 2973 impl()->MarkExpressionAsAssigned(expression); |
2974 impl()->RewriteNonPattern(CHECK_OK); | 2974 impl()->RewriteNonPattern(CHECK_OK); |
2975 | 2975 |
2976 return factory()->NewCountOperation(op, | 2976 return factory()->NewCountOperation(op, |
2977 true /* prefix */, | 2977 true /* prefix */, |
2978 expression, | 2978 expression, |
2979 position()); | 2979 position()); |
2980 | 2980 |
2981 } else if (is_async_function() && peek() == Token::AWAIT) { | 2981 } else if (is_async_function() && peek() == Token::AWAIT) { |
2982 classifier()->RecordFormalParameterInitializerError( | 2982 classifier()->RecordFormalParameterInitializerError( |
2983 scanner()->peek_location(), | 2983 scanner()->peek_location(), |
(...skipping 19 matching lines...) Expand all Loading... |
3003 int lhs_beg_pos = peek_position(); | 3003 int lhs_beg_pos = peek_position(); |
3004 ExpressionT expression = ParseLeftHandSideExpression(CHECK_OK); | 3004 ExpressionT expression = ParseLeftHandSideExpression(CHECK_OK); |
3005 if (!scanner()->HasAnyLineTerminatorBeforeNext() && | 3005 if (!scanner()->HasAnyLineTerminatorBeforeNext() && |
3006 Token::IsCountOp(peek())) { | 3006 Token::IsCountOp(peek())) { |
3007 BindingPatternUnexpectedToken(); | 3007 BindingPatternUnexpectedToken(); |
3008 ArrowFormalParametersUnexpectedToken(); | 3008 ArrowFormalParametersUnexpectedToken(); |
3009 | 3009 |
3010 expression = CheckAndRewriteReferenceExpression( | 3010 expression = CheckAndRewriteReferenceExpression( |
3011 expression, lhs_beg_pos, scanner()->location().end_pos, | 3011 expression, lhs_beg_pos, scanner()->location().end_pos, |
3012 MessageTemplate::kInvalidLhsInPostfixOp, CHECK_OK); | 3012 MessageTemplate::kInvalidLhsInPostfixOp, CHECK_OK); |
3013 expression = impl()->MarkExpressionAsAssigned(expression); | 3013 impl()->MarkExpressionAsAssigned(expression); |
3014 impl()->RewriteNonPattern(CHECK_OK); | 3014 impl()->RewriteNonPattern(CHECK_OK); |
3015 | 3015 |
3016 Token::Value next = Next(); | 3016 Token::Value next = Next(); |
3017 expression = | 3017 expression = |
3018 factory()->NewCountOperation(next, | 3018 factory()->NewCountOperation(next, |
3019 false /* postfix */, | 3019 false /* postfix */, |
3020 expression, | 3020 expression, |
3021 position()); | 3021 position()); |
3022 } | 3022 } |
3023 return expression; | 3023 return expression; |
(...skipping 2422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5446 has_seen_constructor_ = true; | 5446 has_seen_constructor_ = true; |
5447 return; | 5447 return; |
5448 } | 5448 } |
5449 } | 5449 } |
5450 | 5450 |
5451 | 5451 |
5452 } // namespace internal | 5452 } // namespace internal |
5453 } // namespace v8 | 5453 } // namespace v8 |
5454 | 5454 |
5455 #endif // V8_PARSING_PARSER_BASE_H | 5455 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |