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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 | 10 |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 break; | 726 break; |
727 } | 727 } |
728 case 'v': | 728 case 'v': |
729 c = '\v'; | 729 c = '\v'; |
730 break; | 730 break; |
731 case 'x': { | 731 case 'x': { |
732 c = ScanHexNumber<capture_raw>(2); | 732 c = ScanHexNumber<capture_raw>(2); |
733 if (c < 0) return false; | 733 if (c < 0) return false; |
734 break; | 734 break; |
735 } | 735 } |
736 case '0': | 736 case '0': // Fall through. |
737 if (in_template_literal) { | |
738 // \ 0 DecimalDigit is never allowed in templates. | |
739 if (IsDecimalDigit(c0_)) { | |
740 Advance<capture_raw>(); // Advance to include the problematic char. | |
741 return false; | |
742 } | |
743 | |
744 // The TV of TemplateCharacter :: \ EscapeSequence is the CV of | |
745 // EscapeSequence. | |
746 // The CV of EscapeSequence :: 0 is the code unit value 0. | |
747 c = 0; | |
748 break; | |
749 } | |
750 // Fall through. | |
751 case '1': // fall through | 737 case '1': // fall through |
752 case '2': // fall through | 738 case '2': // fall through |
753 case '3': // fall through | 739 case '3': // fall through |
754 case '4': // fall through | 740 case '4': // fall through |
755 case '5': // fall through | 741 case '5': // fall through |
756 case '6': // fall through | 742 case '6': // fall through |
757 case '7': | 743 case '7': |
758 if (!in_template_literal) { | 744 c = ScanOctalEscape<capture_raw>(c, 2); |
759 c = ScanOctalEscape<capture_raw>(c, 2); | 745 break; |
760 break; | |
761 } | |
762 // Fall through | |
763 case '8': | |
764 case '9': | |
765 if (in_template_literal) return false; | |
766 } | 746 } |
767 | 747 |
768 // According to ECMA-262, section 7.8.4, characters not covered by the | 748 // According to ECMA-262, section 7.8.4, characters not covered by the |
769 // above cases should be illegal, but they are commonly handled as | 749 // above cases should be illegal, but they are commonly handled as |
770 // non-escaped characters by JS VMs. | 750 // non-escaped characters by JS VMs. |
771 AddLiteralChar(c); | 751 AddLiteralChar(c); |
772 return true; | 752 return true; |
773 } | 753 } |
774 | 754 |
775 | 755 |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 } | 1478 } |
1499 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); | 1479 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); |
1500 } | 1480 } |
1501 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); | 1481 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); |
1502 | 1482 |
1503 backing_store_.AddBlock(bytes); | 1483 backing_store_.AddBlock(bytes); |
1504 return backing_store_.EndSequence().start(); | 1484 return backing_store_.EndSequence().start(); |
1505 } | 1485 } |
1506 | 1486 |
1507 } } // namespace v8::internal | 1487 } } // namespace v8::internal |
OLD | NEW |