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 // Features shared by parsing and pre-parsing scanners. | 5 // Features shared by parsing and pre-parsing scanners. |
6 | 6 |
7 #include "src/scanner.h" | 7 #include "src/scanner.h" |
8 | 8 |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1492 void Scanner::CopyTokenDesc(TokenDesc* to, TokenDesc* from) { | 1492 void Scanner::CopyTokenDesc(TokenDesc* to, TokenDesc* from) { |
1493 DCHECK_NOT_NULL(to); | 1493 DCHECK_NOT_NULL(to); |
1494 DCHECK_NOT_NULL(from); | 1494 DCHECK_NOT_NULL(from); |
1495 to->token = from->token; | 1495 to->token = from->token; |
1496 to->location = from->location; | 1496 to->location = from->location; |
1497 to->literal_chars->CopyFrom(from->literal_chars); | 1497 to->literal_chars->CopyFrom(from->literal_chars); |
1498 to->raw_literal_chars->CopyFrom(from->raw_literal_chars); | 1498 to->raw_literal_chars->CopyFrom(from->raw_literal_chars); |
1499 } | 1499 } |
1500 | 1500 |
1501 | 1501 |
1502 bool Scanner::IsNextEscapedReservedWord(LanguageMode language_mode, | |
1503 bool is_generator) { | |
1504 if (next_.token == Token::IDENTIFIER && next_.literal_chars->is_one_byte() && | |
1505 next_literal_contains_escapes()) { | |
1506 Vector<const uint8_t> chars = next_.literal_chars->one_byte_literal(); | |
1507 switch (KeywordOrIdentifierToken(chars.start(), chars.length())) { | |
1508 case Token::IDENTIFIER: | |
1509 return false; | |
1510 case Token::LET: | |
1511 case Token::FUTURE_STRICT_RESERVED_WORD: | |
1512 return is_strict(language_mode); | |
1513 case Token::YIELD: | |
1514 return is_generator || is_strict(language_mode); | |
caitp (gmail)
2015/11/04 05:03:37
yield is reserved in strict mode, so the change wa
| |
1515 default: | |
1516 return true; | |
1517 } | |
1518 } | |
1519 return false; | |
1520 } | |
1521 | |
1522 | |
1502 int DuplicateFinder::AddOneByteSymbol(Vector<const uint8_t> key, int value) { | 1523 int DuplicateFinder::AddOneByteSymbol(Vector<const uint8_t> key, int value) { |
1503 return AddSymbol(key, true, value); | 1524 return AddSymbol(key, true, value); |
1504 } | 1525 } |
1505 | 1526 |
1506 | 1527 |
1507 int DuplicateFinder::AddTwoByteSymbol(Vector<const uint16_t> key, int value) { | 1528 int DuplicateFinder::AddTwoByteSymbol(Vector<const uint16_t> key, int value) { |
1508 return AddSymbol(Vector<const uint8_t>::cast(key), false, value); | 1529 return AddSymbol(Vector<const uint8_t>::cast(key), false, value); |
1509 } | 1530 } |
1510 | 1531 |
1511 | 1532 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1633 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); | 1654 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); |
1634 } | 1655 } |
1635 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); | 1656 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); |
1636 | 1657 |
1637 backing_store_.AddBlock(bytes); | 1658 backing_store_.AddBlock(bytes); |
1638 return backing_store_.EndSequence().start(); | 1659 return backing_store_.EndSequence().start(); |
1639 } | 1660 } |
1640 | 1661 |
1641 } // namespace internal | 1662 } // namespace internal |
1642 } // namespace v8 | 1663 } // namespace v8 |
OLD | NEW |