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 3062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3073 } else { | 3073 } else { |
3074 // For other kinds of calls we record position of the parenthesis as | 3074 // For other kinds of calls we record position of the parenthesis as |
3075 // position of the call. Note that this is extremely important for | 3075 // position of the call. Note that this is extremely important for |
3076 // expressions of the form function(){...}() for which call position | 3076 // expressions of the form function(){...}() for which call position |
3077 // should not point to the closing brace otherwise it will intersect | 3077 // should not point to the closing brace otherwise it will intersect |
3078 // with positions recorded for function literal and confuse debugger. | 3078 // with positions recorded for function literal and confuse debugger. |
3079 pos = peek_position(); | 3079 pos = peek_position(); |
3080 // Also the trailing parenthesis are a hint that the function will | 3080 // Also the trailing parenthesis are a hint that the function will |
3081 // be called immediately. If we happen to have parsed a preceding | 3081 // be called immediately. If we happen to have parsed a preceding |
3082 // function literal eagerly, we can also compile it eagerly. | 3082 // function literal eagerly, we can also compile it eagerly. |
3083 if (result->IsFunctionLiteral() && mode() == PARSE_EAGERLY) { | 3083 if (result->IsFunctionLiteral()) { |
3084 result->AsFunctionLiteral()->SetShouldEagerCompile(); | 3084 result->AsFunctionLiteral()->SetShouldEagerCompile(); |
3085 } | 3085 } |
3086 } | 3086 } |
3087 Scanner::Location spread_pos; | 3087 Scanner::Location spread_pos; |
3088 ExpressionListT args; | 3088 ExpressionListT args; |
3089 if (V8_UNLIKELY(is_async && impl()->IsIdentifier(result))) { | 3089 if (V8_UNLIKELY(is_async && impl()->IsIdentifier(result))) { |
3090 ExpressionClassifier async_classifier(this); | 3090 ExpressionClassifier async_classifier(this); |
3091 args = ParseArguments(&spread_pos, true, CHECK_OK); | 3091 args = ParseArguments(&spread_pos, true, CHECK_OK); |
3092 if (peek() == Token::ARROW) { | 3092 if (peek() == Token::ARROW) { |
3093 if (fni_) { | 3093 if (fni_) { |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3403 case Token::TEMPLATE_TAIL: { | 3403 case Token::TEMPLATE_TAIL: { |
3404 *is_async = false; | 3404 *is_async = false; |
3405 impl()->RewriteNonPattern(CHECK_OK); | 3405 impl()->RewriteNonPattern(CHECK_OK); |
3406 BindingPatternUnexpectedToken(); | 3406 BindingPatternUnexpectedToken(); |
3407 ArrowFormalParametersUnexpectedToken(); | 3407 ArrowFormalParametersUnexpectedToken(); |
3408 int pos; | 3408 int pos; |
3409 if (scanner()->current_token() == Token::IDENTIFIER) { | 3409 if (scanner()->current_token() == Token::IDENTIFIER) { |
3410 pos = position(); | 3410 pos = position(); |
3411 } else { | 3411 } else { |
3412 pos = peek_position(); | 3412 pos = peek_position(); |
3413 if (expression->IsFunctionLiteral() && mode() == PARSE_EAGERLY) { | 3413 if (expression->IsFunctionLiteral()) { |
3414 // If the tag function looks like an IIFE, set_parenthesized() to | 3414 // If the tag function looks like an IIFE, set_parenthesized() to |
3415 // force eager compilation. | 3415 // force eager compilation. |
3416 expression->AsFunctionLiteral()->SetShouldEagerCompile(); | 3416 expression->AsFunctionLiteral()->SetShouldEagerCompile(); |
3417 } | 3417 } |
3418 } | 3418 } |
3419 expression = ParseTemplateLiteral(expression, pos, CHECK_OK); | 3419 expression = ParseTemplateLiteral(expression, pos, CHECK_OK); |
3420 break; | 3420 break; |
3421 } | 3421 } |
3422 case Token::ILLEGAL: { | 3422 case Token::ILLEGAL: { |
3423 ReportUnexpectedTokenAt(scanner()->peek_location(), Token::ILLEGAL); | 3423 ReportUnexpectedTokenAt(scanner()->peek_location(), Token::ILLEGAL); |
(...skipping 2022 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 |