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 20 matching lines...) Expand all Loading... |
31 | 31 |
32 void PreParserTraits::ReportMessageAt(int start_pos, int end_pos, | 32 void PreParserTraits::ReportMessageAt(int start_pos, int end_pos, |
33 MessageTemplate::Template message, | 33 MessageTemplate::Template message, |
34 const char* arg, | 34 const char* arg, |
35 ParseErrorType error_type) { | 35 ParseErrorType error_type) { |
36 pre_parser_->log_->LogMessage(start_pos, end_pos, message, arg, error_type); | 36 pre_parser_->log_->LogMessage(start_pos, end_pos, message, arg, error_type); |
37 } | 37 } |
38 | 38 |
39 | 39 |
40 PreParserIdentifier PreParserTraits::GetSymbol(Scanner* scanner) { | 40 PreParserIdentifier PreParserTraits::GetSymbol(Scanner* scanner) { |
41 if (scanner->current_token() == Token::FUTURE_RESERVED_WORD) { | 41 if (scanner->current_token() == Token::ENUM) { |
42 return PreParserIdentifier::FutureReserved(); | 42 return PreParserIdentifier::Enum(); |
| 43 } else if (scanner->current_token() == Token::AWAIT) { |
| 44 return PreParserIdentifier::Await(); |
43 } else if (scanner->current_token() == | 45 } else if (scanner->current_token() == |
44 Token::FUTURE_STRICT_RESERVED_WORD) { | 46 Token::FUTURE_STRICT_RESERVED_WORD) { |
45 return PreParserIdentifier::FutureStrictReserved(); | 47 return PreParserIdentifier::FutureStrictReserved(); |
46 } else if (scanner->current_token() == Token::LET) { | 48 } else if (scanner->current_token() == Token::LET) { |
47 return PreParserIdentifier::Let(); | 49 return PreParserIdentifier::Let(); |
48 } else if (scanner->current_token() == Token::STATIC) { | 50 } else if (scanner->current_token() == Token::STATIC) { |
49 return PreParserIdentifier::Static(); | 51 return PreParserIdentifier::Static(); |
50 } else if (scanner->current_token() == Token::YIELD) { | 52 } else if (scanner->current_token() == Token::YIELD) { |
51 return PreParserIdentifier::Yield(); | 53 return PreParserIdentifier::Yield(); |
52 } | 54 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 FunctionNameValidity function_name_validity, FunctionKind kind, | 95 FunctionNameValidity function_name_validity, FunctionKind kind, |
94 int function_token_position, FunctionLiteral::FunctionType type, | 96 int function_token_position, FunctionLiteral::FunctionType type, |
95 LanguageMode language_mode, bool* ok) { | 97 LanguageMode language_mode, bool* ok) { |
96 return pre_parser_->ParseFunctionLiteral( | 98 return pre_parser_->ParseFunctionLiteral( |
97 name, function_name_location, function_name_validity, kind, | 99 name, function_name_location, function_name_validity, kind, |
98 function_token_position, type, language_mode, ok); | 100 function_token_position, type, language_mode, ok); |
99 } | 101 } |
100 | 102 |
101 PreParser::PreParseResult PreParser::PreParseLazyFunction( | 103 PreParser::PreParseResult PreParser::PreParseLazyFunction( |
102 LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters, | 104 LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters, |
103 ParserRecorder* log, Scanner::BookmarkScope* bookmark, int* use_counts) { | 105 bool parsing_module, ParserRecorder* log, Scanner::BookmarkScope* bookmark, |
| 106 int* use_counts) { |
| 107 parsing_module_ = parsing_module; |
104 log_ = log; | 108 log_ = log; |
105 use_counts_ = use_counts; | 109 use_counts_ = use_counts; |
106 // Lazy functions always have trivial outer scopes (no with/catch scopes). | 110 // Lazy functions always have trivial outer scopes (no with/catch scopes). |
107 Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE); | 111 Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE); |
108 PreParserFactory top_factory(NULL); | 112 PreParserFactory top_factory(NULL); |
109 FunctionState top_state(&function_state_, &scope_, top_scope, kNormalFunction, | 113 FunctionState top_state(&function_state_, &scope_, top_scope, kNormalFunction, |
110 &top_factory); | 114 &top_factory); |
111 scope_->SetLanguageMode(language_mode); | 115 scope_->SetLanguageMode(language_mode); |
112 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind); | 116 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind); |
113 if (!has_simple_parameters) function_scope->SetHasNonSimpleParameters(); | 117 if (!has_simple_parameters) function_scope->SetHasNonSimpleParameters(); |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 ExpressionClassifier classifier(this); | 600 ExpressionClassifier classifier(this); |
597 Expression expr = ParseExpression(true, &classifier, CHECK_OK); | 601 Expression expr = ParseExpression(true, &classifier, CHECK_OK); |
598 ValidateExpression(&classifier, CHECK_OK); | 602 ValidateExpression(&classifier, CHECK_OK); |
599 | 603 |
600 // Even if the expression starts with an identifier, it is not necessarily an | 604 // Even if the expression starts with an identifier, it is not necessarily an |
601 // identifier. For example, "foo + bar" starts with an identifier but is not | 605 // identifier. For example, "foo + bar" starts with an identifier but is not |
602 // an identifier. | 606 // an identifier. |
603 if (starts_with_identifier && expr.IsIdentifier() && peek() == Token::COLON) { | 607 if (starts_with_identifier && expr.IsIdentifier() && peek() == Token::COLON) { |
604 // Expression is a single identifier, and not, e.g., a parenthesized | 608 // Expression is a single identifier, and not, e.g., a parenthesized |
605 // identifier. | 609 // identifier. |
606 DCHECK(!expr.AsIdentifier().IsFutureReserved()); | 610 DCHECK(!expr.AsIdentifier().IsEnum()); |
| 611 DCHECK(!parsing_module_ || !expr.AsIdentifier().IsAwait()); |
607 DCHECK(is_sloppy(language_mode()) || | 612 DCHECK(is_sloppy(language_mode()) || |
608 !IsFutureStrictReserved(expr.AsIdentifier())); | 613 !IsFutureStrictReserved(expr.AsIdentifier())); |
609 Consume(Token::COLON); | 614 Consume(Token::COLON); |
610 // ES#sec-labelled-function-declarations Labelled Function Declarations | 615 // ES#sec-labelled-function-declarations Labelled Function Declarations |
611 if (peek() == Token::FUNCTION && is_sloppy(language_mode())) { | 616 if (peek() == Token::FUNCTION && is_sloppy(language_mode())) { |
612 if (allow_function == kAllowLabelledFunctionStatement) { | 617 if (allow_function == kAllowLabelledFunctionStatement) { |
613 return ParseFunctionDeclaration(ok); | 618 return ParseFunctionDeclaration(ok); |
614 } else { | 619 } else { |
615 return ParseScopedStatement(true, ok); | 620 return ParseScopedStatement(true, ok); |
616 } | 621 } |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 } | 1223 } |
1219 Expect(Token::RBRACE, CHECK_OK); | 1224 Expect(Token::RBRACE, CHECK_OK); |
1220 return PreParserExpression::Default(); | 1225 return PreParserExpression::Default(); |
1221 } | 1226 } |
1222 | 1227 |
1223 #undef CHECK_OK | 1228 #undef CHECK_OK |
1224 | 1229 |
1225 | 1230 |
1226 } // namespace internal | 1231 } // namespace internal |
1227 } // namespace v8 | 1232 } // namespace v8 |
OLD | NEW |