OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 "src/regexp/regexp-parser.h" | 5 #include "src/regexp/regexp-parser.h" |
6 | 6 |
7 #include "src/char-predicates-inl.h" | 7 #include "src/char-predicates-inl.h" |
8 #include "src/factory.h" | 8 #include "src/factory.h" |
9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 *value = unibrow::Utf16::CombineSurrogatePair(static_cast<uc16>(*value), | 836 *value = unibrow::Utf16::CombineSurrogatePair(static_cast<uc16>(*value), |
837 static_cast<uc16>(trail)); | 837 static_cast<uc16>(trail)); |
838 return true; | 838 return true; |
839 } | 839 } |
840 } | 840 } |
841 Reset(start); | 841 Reset(start); |
842 } | 842 } |
843 return result; | 843 return result; |
844 } | 844 } |
845 | 845 |
| 846 #ifdef V8_I18N_SUPPORT |
846 bool LookupPropertyClass(UProperty property, const char* property_name, | 847 bool LookupPropertyClass(UProperty property, const char* property_name, |
847 ZoneList<CharacterRange>* result, Zone* zone) { | 848 ZoneList<CharacterRange>* result, Zone* zone) { |
848 int32_t property_value = u_getPropertyValueEnum(property, property_name); | 849 int32_t property_value = u_getPropertyValueEnum(property, property_name); |
849 if (property_value == UCHAR_INVALID_CODE) return false; | 850 if (property_value == UCHAR_INVALID_CODE) return false; |
850 | 851 |
851 USet* set = uset_openEmpty(); | 852 USet* set = uset_openEmpty(); |
852 UErrorCode ec = U_ZERO_ERROR; | 853 UErrorCode ec = U_ZERO_ERROR; |
853 uset_applyIntPropertyValue(set, property, property_value, &ec); | 854 uset_applyIntPropertyValue(set, property, property_value, &ec); |
854 bool success = ec == U_ZERO_ERROR && !uset_isEmpty(set); | 855 bool success = ec == U_ZERO_ERROR && !uset_isEmpty(set); |
855 | 856 |
856 if (success) { | 857 if (success) { |
857 uset_removeAllStrings(set); | 858 uset_removeAllStrings(set); |
858 int item_count = uset_getItemCount(set); | 859 int item_count = uset_getItemCount(set); |
859 int item_result = 0; | 860 int item_result = 0; |
860 for (int i = 0; i < item_count; i++) { | 861 for (int i = 0; i < item_count; i++) { |
861 uc32 start = 0; | 862 uc32 start = 0; |
862 uc32 end = 0; | 863 uc32 end = 0; |
863 item_result += uset_getItem(set, i, &start, &end, nullptr, 0, &ec); | 864 item_result += uset_getItem(set, i, &start, &end, nullptr, 0, &ec); |
864 result->Add(CharacterRange::Range(start, end), zone); | 865 result->Add(CharacterRange::Range(start, end), zone); |
865 } | 866 } |
866 DCHECK_EQ(U_ZERO_ERROR, ec); | 867 DCHECK_EQ(U_ZERO_ERROR, ec); |
867 DCHECK_EQ(0, item_result); | 868 DCHECK_EQ(0, item_result); |
868 } | 869 } |
869 uset_close(set); | 870 uset_close(set); |
870 return success; | 871 return success; |
871 } | 872 } |
| 873 #endif // V8_I18N_SUPPORT |
872 | 874 |
873 bool RegExpParser::ParsePropertyClass(ZoneList<CharacterRange>* result) { | 875 bool RegExpParser::ParsePropertyClass(ZoneList<CharacterRange>* result) { |
874 #ifdef V8_I18N_SUPPORT | 876 #ifdef V8_I18N_SUPPORT |
875 List<char> property_name_list; | 877 List<char> property_name_list; |
876 if (current() == '{') { | 878 if (current() == '{') { |
877 for (Advance(); current() != '}'; Advance()) { | 879 for (Advance(); current() != '}'; Advance()) { |
878 if (!has_next()) return false; | 880 if (!has_next()) return false; |
879 property_name_list.Add(static_cast<char>(current())); | 881 property_name_list.Add(static_cast<char>(current())); |
880 } | 882 } |
881 } else if (current() != kEndMarker) { | 883 } else if (current() != kEndMarker) { |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 return false; | 1500 return false; |
1499 } | 1501 } |
1500 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), | 1502 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), |
1501 zone()); | 1503 zone()); |
1502 LAST(ADD_TERM); | 1504 LAST(ADD_TERM); |
1503 return true; | 1505 return true; |
1504 } | 1506 } |
1505 | 1507 |
1506 } // namespace internal | 1508 } // namespace internal |
1507 } // namespace v8 | 1509 } // namespace v8 |
OLD | NEW |