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...) 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, bool sloppy_let) { | |
1504 if (next_.token == Token::IDENTIFIER) { | |
1505 if (next_.literal_chars && next_.literal_chars->is_one_byte() && | |
adamk
2015/11/03 23:00:57
Please join this if() into the one on the line abo
caitp (gmail)
2015/11/04 04:49:24
Done.
| |
1506 next_literal_contains_escapes(next_)) { | |
adamk
2015/11/03 23:00:57
This won't compile, I'm guessing you can drop next
caitp (gmail)
2015/11/04 04:49:24
It was a last minute fixup, which failed because o
| |
1507 Vector<const uint8_t> chars = next_.literal_chars->one_byte_literal(); | |
caitp (gmail)
2015/11/03 17:19:13
I don't think this allocates a copy of the string,
adamk
2015/11/03 23:00:57
You're correct that there's no copy here.
caitp (gmail)
2015/11/04 04:49:24
Acknowledged.
| |
1508 switch (KeywordOrIdentifierToken(chars.start(), chars.length())) { | |
1509 case Token::IDENTIFIER: | |
1510 return false; | |
1511 case Token::FUTURE_STRICT_RESERVED_WORD: | |
1512 return is_strict(language_mode); | |
1513 case Token::YIELD: | |
1514 return is_generator; | |
1515 case Token::LET: | |
1516 return sloppy_let || is_strict(language_mode); | |
adamk
2015/11/03 23:00:57
My reading of the spec you pointed to is that LET
caitp (gmail)
2015/11/04 04:49:24
It was meant for the block underneath, but I guess
| |
1517 default: | |
1518 return true; | |
1519 } | |
1520 } | |
1521 } | |
1522 return false; | |
1523 } | |
1524 | |
1525 | |
1502 int DuplicateFinder::AddOneByteSymbol(Vector<const uint8_t> key, int value) { | 1526 int DuplicateFinder::AddOneByteSymbol(Vector<const uint8_t> key, int value) { |
1503 return AddSymbol(key, true, value); | 1527 return AddSymbol(key, true, value); |
1504 } | 1528 } |
1505 | 1529 |
1506 | 1530 |
1507 int DuplicateFinder::AddTwoByteSymbol(Vector<const uint16_t> key, int value) { | 1531 int DuplicateFinder::AddTwoByteSymbol(Vector<const uint16_t> key, int value) { |
1508 return AddSymbol(Vector<const uint8_t>::cast(key), false, value); | 1532 return AddSymbol(Vector<const uint8_t>::cast(key), false, value); |
1509 } | 1533 } |
1510 | 1534 |
1511 | 1535 |
(...skipping 121 matching lines...) Loading... | |
1633 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); | 1657 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); |
1634 } | 1658 } |
1635 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); | 1659 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); |
1636 | 1660 |
1637 backing_store_.AddBlock(bytes); | 1661 backing_store_.AddBlock(bytes); |
1638 return backing_store_.EndSequence().start(); | 1662 return backing_store_.EndSequence().start(); |
1639 } | 1663 } |
1640 | 1664 |
1641 } // namespace internal | 1665 } // namespace internal |
1642 } // namespace v8 | 1666 } // namespace v8 |
OLD | NEW |