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 #ifndef V8_REGEXP_REGEXP_AST_H_ | 5 #ifndef V8_REGEXP_REGEXP_AST_H_ |
6 #define V8_REGEXP_REGEXP_AST_H_ | 6 #define V8_REGEXP_REGEXP_AST_H_ |
7 | 7 |
8 #include "src/objects.h" | 8 #include "src/objects.h" |
9 #include "src/utils.h" | 9 #include "src/utils.h" |
10 #include "src/zone.h" | 10 #include "src/zone.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 | 73 |
74 // Represents code units in the range from from_ to to_, both ends are | 74 // Represents code units in the range from from_ to to_, both ends are |
75 // inclusive. | 75 // inclusive. |
76 class CharacterRange { | 76 class CharacterRange { |
77 public: | 77 public: |
78 CharacterRange() : from_(0), to_(0) {} | 78 CharacterRange() : from_(0), to_(0) {} |
79 // For compatibility with the CHECK_OK macro | 79 // For compatibility with the CHECK_OK macro |
80 CharacterRange(void* null) { DCHECK_NULL(null); } // NOLINT | 80 CharacterRange(void* null) { DCHECK_NULL(null); } // NOLINT |
81 CharacterRange(uc32 from, uc32 to) : from_(from), to_(to) { | 81 CharacterRange(uc32 from, uc32 to) : from_(from), to_(to) { |
82 DCHECK(from <= to); | 82 DCHECK(0 <= from && to <= String::kMaxCodePoint); |
| 83 DCHECK(static_cast<uint32_t>(from) <= static_cast<uint32_t>(to)); |
83 } | 84 } |
84 static void AddClassEscape(uc16 type, ZoneList<CharacterRange>* ranges, | 85 static void AddClassEscape(uc16 type, ZoneList<CharacterRange>* ranges, |
85 Zone* zone); | 86 Zone* zone); |
86 static Vector<const int> GetWordBounds(); | 87 static Vector<const int> GetWordBounds(); |
87 static inline CharacterRange Singleton(uc32 value) { | 88 static inline CharacterRange Singleton(uc32 value) { |
88 return CharacterRange(value, value); | 89 return CharacterRange(value, value); |
89 } | 90 } |
90 static inline CharacterRange Range(uc32 from, uc32 to) { | 91 static inline CharacterRange Range(uc32 from, uc32 to) { |
91 DCHECK(0 <= from && to <= String::kMaxCodePoint); | |
92 DCHECK(static_cast<uint32_t>(from) <= static_cast<uint32_t>(to)); | |
93 return CharacterRange(from, to); | 92 return CharacterRange(from, to); |
94 } | 93 } |
95 static inline CharacterRange Everything() { | 94 static inline CharacterRange Everything() { |
96 return CharacterRange(0, String::kMaxCodePoint); | 95 return CharacterRange(0, String::kMaxCodePoint); |
97 } | 96 } |
98 static inline ZoneList<CharacterRange>* List(Zone* zone, | 97 static inline ZoneList<CharacterRange>* List(Zone* zone, |
99 CharacterRange range) { | 98 CharacterRange range) { |
100 ZoneList<CharacterRange>* list = | 99 ZoneList<CharacterRange>* list = |
101 new (zone) ZoneList<CharacterRange>(1, zone); | 100 new (zone) ZoneList<CharacterRange>(1, zone); |
102 list->Add(range, zone); | 101 list->Add(range, zone); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 RegExpEmpty* AsEmpty() override; | 511 RegExpEmpty* AsEmpty() override; |
513 bool IsEmpty() override; | 512 bool IsEmpty() override; |
514 int min_match() override { return 0; } | 513 int min_match() override { return 0; } |
515 int max_match() override { return 0; } | 514 int max_match() override { return 0; } |
516 }; | 515 }; |
517 | 516 |
518 } // namespace internal | 517 } // namespace internal |
519 } // namespace v8 | 518 } // namespace v8 |
520 | 519 |
521 #endif // V8_REGEXP_REGEXP_AST_H_ | 520 #endif // V8_REGEXP_REGEXP_AST_H_ |
OLD | NEW |