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/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/base/hashmap.h" | 10 #include "src/base/hashmap.h" |
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 // error that we might make in the future once we know the language mode. | 1360 // error that we might make in the future once we know the language mode. |
1361 if (this->IsEval(name)) { | 1361 if (this->IsEval(name)) { |
1362 classifier->RecordStrictModeFormalParameterError( | 1362 classifier->RecordStrictModeFormalParameterError( |
1363 scanner()->location(), MessageTemplate::kStrictEvalArguments); | 1363 scanner()->location(), MessageTemplate::kStrictEvalArguments); |
1364 if (is_strict(language_mode())) { | 1364 if (is_strict(language_mode())) { |
1365 classifier->RecordBindingPatternError( | 1365 classifier->RecordBindingPatternError( |
1366 scanner()->location(), MessageTemplate::kStrictEvalArguments); | 1366 scanner()->location(), MessageTemplate::kStrictEvalArguments); |
1367 } | 1367 } |
1368 } | 1368 } |
1369 if (this->IsArguments(name)) { | 1369 if (this->IsArguments(name)) { |
1370 scope()->RecordArgumentsUsage(); | |
1371 classifier->RecordStrictModeFormalParameterError( | 1370 classifier->RecordStrictModeFormalParameterError( |
1372 scanner()->location(), MessageTemplate::kStrictEvalArguments); | 1371 scanner()->location(), MessageTemplate::kStrictEvalArguments); |
1373 if (is_strict(language_mode())) { | 1372 if (is_strict(language_mode())) { |
1374 classifier->RecordBindingPatternError( | 1373 classifier->RecordBindingPatternError( |
1375 scanner()->location(), MessageTemplate::kStrictEvalArguments); | 1374 scanner()->location(), MessageTemplate::kStrictEvalArguments); |
1376 } | 1375 } |
1377 } | 1376 } |
1378 if (this->IsAwait(name)) { | 1377 if (this->IsAwait(name)) { |
1379 if (is_async_function()) { | 1378 if (is_async_function()) { |
1380 classifier->RecordPatternError( | 1379 classifier->RecordPatternError( |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1427 *is_strict_reserved = false; | 1426 *is_strict_reserved = false; |
1428 } else if (next == Token::FUTURE_STRICT_RESERVED_WORD || next == Token::LET || | 1427 } else if (next == Token::FUTURE_STRICT_RESERVED_WORD || next == Token::LET || |
1429 next == Token::STATIC || (next == Token::YIELD && !is_generator)) { | 1428 next == Token::STATIC || (next == Token::YIELD && !is_generator)) { |
1430 *is_strict_reserved = true; | 1429 *is_strict_reserved = true; |
1431 } else { | 1430 } else { |
1432 ReportUnexpectedToken(next); | 1431 ReportUnexpectedToken(next); |
1433 *ok = false; | 1432 *ok = false; |
1434 return Traits::EmptyIdentifier(); | 1433 return Traits::EmptyIdentifier(); |
1435 } | 1434 } |
1436 | 1435 |
1437 IdentifierT name = this->GetSymbol(scanner()); | 1436 return this->GetSymbol(scanner()); |
1438 if (this->IsArguments(name)) scope()->RecordArgumentsUsage(); | |
1439 return name; | |
1440 } | 1437 } |
1441 | 1438 |
1442 template <class Traits> | 1439 template <class Traits> |
1443 typename ParserBase<Traits>::IdentifierT | 1440 typename ParserBase<Traits>::IdentifierT |
1444 ParserBase<Traits>::ParseIdentifierName(bool* ok) { | 1441 ParserBase<Traits>::ParseIdentifierName(bool* ok) { |
1445 Token::Value next = Next(); | 1442 Token::Value next = Next(); |
1446 if (next != Token::IDENTIFIER && next != Token::ASYNC && | 1443 if (next != Token::IDENTIFIER && next != Token::ASYNC && |
1447 next != Token::ENUM && next != Token::AWAIT && next != Token::LET && | 1444 next != Token::ENUM && next != Token::AWAIT && next != Token::LET && |
1448 next != Token::STATIC && next != Token::YIELD && | 1445 next != Token::STATIC && next != Token::YIELD && |
1449 next != Token::FUTURE_STRICT_RESERVED_WORD && | 1446 next != Token::FUTURE_STRICT_RESERVED_WORD && |
1450 next != Token::ESCAPED_KEYWORD && | 1447 next != Token::ESCAPED_KEYWORD && |
1451 next != Token::ESCAPED_STRICT_RESERVED_WORD && !Token::IsKeyword(next)) { | 1448 next != Token::ESCAPED_STRICT_RESERVED_WORD && !Token::IsKeyword(next)) { |
1452 this->ReportUnexpectedToken(next); | 1449 this->ReportUnexpectedToken(next); |
1453 *ok = false; | 1450 *ok = false; |
1454 return Traits::EmptyIdentifier(); | 1451 return Traits::EmptyIdentifier(); |
1455 } | 1452 } |
1456 | 1453 |
1457 IdentifierT name = this->GetSymbol(scanner()); | 1454 return this->GetSymbol(scanner()); |
1458 if (this->IsArguments(name)) scope()->RecordArgumentsUsage(); | |
1459 return name; | |
1460 } | 1455 } |
1461 | 1456 |
1462 | 1457 |
1463 template <class Traits> | 1458 template <class Traits> |
1464 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseRegExpLiteral( | 1459 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseRegExpLiteral( |
1465 bool seen_equal, ExpressionClassifier* classifier, bool* ok) { | 1460 bool seen_equal, ExpressionClassifier* classifier, bool* ok) { |
1466 int pos = peek_position(); | 1461 int pos = peek_position(); |
1467 if (!scanner()->ScanRegExpPattern(seen_equal)) { | 1462 if (!scanner()->ScanRegExpPattern(seen_equal)) { |
1468 Next(); | 1463 Next(); |
1469 ReportMessage(MessageTemplate::kUnterminatedRegExp); | 1464 ReportMessage(MessageTemplate::kUnterminatedRegExp); |
(...skipping 2190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3660 has_seen_constructor_ = true; | 3655 has_seen_constructor_ = true; |
3661 return; | 3656 return; |
3662 } | 3657 } |
3663 } | 3658 } |
3664 | 3659 |
3665 | 3660 |
3666 } // namespace internal | 3661 } // namespace internal |
3667 } // namespace v8 | 3662 } // namespace v8 |
3668 | 3663 |
3669 #endif // V8_PARSING_PARSER_BASE_H | 3664 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |